Skip to content

Commit

Permalink
Merge pull request #33 from deanblackborough/main
Browse files Browse the repository at this point in the history
v1.02.0
  • Loading branch information
deanblackborough authored Aug 3, 2022
2 parents 721e348 + 9812443 commit 972b8d2
Show file tree
Hide file tree
Showing 14 changed files with 81 additions and 58 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

The complete changelog for the Costs to Expect REST API, our changelog follows the format defined at https://keepachangelog.com/en/1.0.0/

## [1.02.0] - [2022-08-04]
### Changed
- Removed the scratch chance option, not a relevant option.
- Minor change to the design of the bonus message container.
- Updated the bonus message text and added messages for additional combinations and scores.
- Fetch all players from the API rather than the latest ten.

## [1.01.0] - [2022-08-03]
### Added
- Added a landing page to highlight some of the features.
Expand Down
53 changes: 49 additions & 4 deletions app/Http/Controllers/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,18 @@ protected function playerBonusMessage(string $game_id, string $player_id, array
}
}

if ($total > 63 && (count($dice_scored) + count($dice_scratched)) < 6) {
$message = 'OK, OK, you have the bonus without even finishing!';
return $this->playerBonusView($game_id, $player_id, $message);
}

if ($total === 63 && count($dice_scored) === 6) {
$message = 'Damn, that was close, next time, give yourself some breathing room!';
$message = 'Damn, that was close, next time, give yourself a little breathing room!';
return $this->playerBonusView($game_id, $player_id, $message);
}

if ($total > 85 && count($dice_scored) === 6) {
$message = 'Umm!, I wasn\'t even sure you could score this much!';
return $this->playerBonusView($game_id, $player_id, $message);
}

Expand All @@ -201,18 +211,23 @@ protected function playerBonusMessage(string $game_id, string $player_id, array
return $this->playerBonusView($game_id, $player_id, $message);
}

if ($total > 63 && count($dice_scored) === 6) {
if ($total > 68 && count($dice_scored) === 6) {
$message = 'Awesome, plenty of breathing room!';
return $this->playerBonusView($game_id, $player_id, $message);
}

if ($total > 63 && count($dice_scored) === 6) {
$message = 'Awesome, made it with a little breathing room!';
return $this->playerBonusView($game_id, $player_id, $message);
}

if ($total > 75 && count($dice_scratched) > 0) {
$message = 'Um! How exactly did you manage to get your bonus!';
return $this->playerBonusView($game_id, $player_id, $message);
}

if ($total > 63 && count($dice_scratched) > 0) {
$message = 'WOW, nothing like scoring the bonus whilst scratching!';
$message = 'WOW, nothing like scoring the bonus whilst also scratching!';
return $this->playerBonusView($game_id, $player_id, $message);
}

Expand All @@ -234,20 +249,50 @@ protected function playerBonusMessage(string $game_id, string $player_id, array
if (
$total < 63 && (count($dice_scored) + count($dice_scratched)) < 6
) {
$ones_total = $total;
$twos_total = $total;
$threes_total = $total;
$fours_total = $total;
foreach($dice_to_score as $dice) {
$ones_total += ($dice_values[$dice] * 1);
$twos_total += ($dice_values[$dice] * 2);
$threes_total += ($dice_values[$dice] * 3);
$fours_total += ($dice_values[$dice] * 4);
}

if ($ones_total === 63) {
$message = 'Easy, one of everything left will do!';
return $this->playerBonusView($game_id, $player_id, $message);
}
if ($ones_total >= 63) {
if ((count($dice_scored) + count($dice_scratched)) === 5) {
$message = 'Easy, one of the last dice please!';
return $this->playerBonusView($game_id, $player_id, $message);
}
$message = 'You should be able to get your bonus without even trying!';
return $this->playerBonusView($game_id, $player_id, $message);
}

if ($twos_total === 63) {
$message = 'Looking good, two of everything left will do!';
return $this->playerBonusView($game_id, $player_id, $message);
}
if ($twos_total >= 63) {
if ((count($dice_scored) + count($dice_scratched)) === 5) {
$message = 'You can still easily get the bonus, two of the last dice please!';
return $this->playerBonusView($game_id, $player_id, $message);
}
$message = 'You can still easily get the bonus';
return $this->playerBonusView($game_id, $player_id, $message);
}

if ($threes_total === 63) {
$message = 'Looking good, you haven\'t messed up yet, three of everything left will do!';
return $this->playerBonusView($game_id, $player_id, $message);
}
if ($threes_total > 63) {
if ((count($dice_scored) + count($dice_scratched)) === 5) {
$message = 'You can still easily get the bonus, three of the last dice please!';
$message = 'You can still get the bonus, three of the last dice please!';
return $this->playerBonusView($game_id, $player_id, $message);
}
$message = 'You can still easily get the bonus';
Expand Down
4 changes: 2 additions & 2 deletions app/Http/Controllers/Game.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public function newGame(Request $request)
{
$this->boostrap($request);

$players_response = $this->api->getPlayers($this->resource_type_id);
$players_response = $this->api->getPlayers($this->resource_type_id, ['collection' => true]);

$players = [];
if ($players_response['status'] === 200 && count($players_response['content']) > 0) {
Expand Down Expand Up @@ -169,7 +169,7 @@ public function addPlayersToGame(Request $request, string $game_id)
$game_players = [];


$all_players_response = $this->api->getPlayers($this->resource_type_id);
$all_players_response = $this->api->getPlayers($this->resource_type_id, ['collection' => true]);

$all_players = [];
if ($all_players_response['status'] === 200 && count($all_players_response['content']) > 0) {
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function home(Request $request)
$closed_games = $closed_games_response['content'];
}

$players_response = $this->api->getPlayers($this->resource_type_id, ['limit'=> 5]);
$players_response = $this->api->getPlayers($this->resource_type_id, ['collection'=> true]);

$players = [];
if ($players_response['status'] === 200 && count($players_response['content']) > 0) {
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/Player.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function index(Request $request)
{
$this->boostrap($request);

$players_response = $this->api->getPlayers($this->resource_type_id);
$players_response = $this->api->getPlayers($this->resource_type_id, ['collection' => true]);

$players = [];
if ($players_response['status'] === 200 && count($players_response['content']) > 0) {
Expand Down
11 changes: 0 additions & 11 deletions app/View/Components/Toast.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,6 @@ public function __construct()
'message' => 'Was this tactical, are you Psyching out your opponents.',
]
],
'toast_chance_scratch' => [
[
'heading' => 'Oh dear!',
'message' => 'Why are you scratching chance, what is going on?',
],
[
'heading' => 'Really!',
'message' => 'What is wrong with you, do you know how to play?',
]
],
'toast_yahtzee_bonus_one' => [
[
'heading' => 'Yahtzee X 2',
Expand Down Expand Up @@ -113,7 +103,6 @@ public function render()
[
'toast_yahtzee' => Arr::random($this->messages['toast_yahtzee']),
'toast_yahtzee_scratch' => Arr::random($this->messages['toast_yahtzee_scratch']),
'toast_chance_scratch' => Arr::random($this->messages['toast_chance_scratch']),
'toast_yahtzee_bonus_one' => Arr::random($this->messages['toast_yahtzee_bonus_one']),
'toast_yahtzee_bonus_two' => Arr::random($this->messages['toast_yahtzee_bonus_two']),
'toast_yahtzee_bonus_three' => Arr::random($this->messages['toast_yahtzee_bonus_three']),
Expand Down
4 changes: 2 additions & 2 deletions config/app/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
'item_subtype_id' => env('ITEM_SUBTYPE_ID'),
'cookie_user' => env('SESSION_NAME_USER'),
'cookie_bearer' => env('SESSION_NAME_BEARER'),
'version' => '1.01.0',
'release_date' => '3rd August 2022'
'version' => '1.02.0',
'release_date' => '4rd August 2022'
];
3 changes: 2 additions & 1 deletion public/css/theme.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion public/css/theme.css.map

Large diffs are not rendered by default.

15 changes: 5 additions & 10 deletions public/js/score-sheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,6 @@ import { display_selected_toast, disable_yahtzee_bonus_if_game_over } from './fu
});
}

let scratch_chance = document.querySelector('input[type="checkbox"]#scratch_chance.active');
if (scratch_chance !== null) {
scratch_chance.addEventListener('change', function () {
scratch_lower_combination(this, 'chance_scratch');
});
}

let yahtzee_bonus_one = document.querySelector('input[type="checkbox"]#yahtzee_bonus_one.active');
if (yahtzee_bonus_one !== null) {
yahtzee_bonus_one.addEventListener('change', function () {
Expand Down Expand Up @@ -185,9 +178,11 @@ import { display_selected_toast, disable_yahtzee_bonus_if_game_over } from './fu
element.disabled = true;

let scratch = document.getElementById('scratch_' + element.id);
scratch.classList.remove('active');
scratch.classList.add('disabled');
scratch.disabled = true;
if (scratch !== null) {
scratch.classList.remove('active');
scratch.classList.add('disabled');
scratch.disabled = true;
}

player_score_lower.innerText = response.data.score.lower;
player_total_score.innerText = response.data.score.upper + response.data.score.bonus + response.data.score.lower;
Expand Down
3 changes: 2 additions & 1 deletion resources/scss/theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ a.nav-link.active {

div.bonus-message p {
margin-top: 1rem;
border: 1px solid rgba(137, 43, 124, 1);
border-top: 1px solid rgba(137, 43, 124, 1);
border-right: 1px solid rgba(137, 43, 124, 0.40);
}

svg.scored {
Expand Down
6 changes: 0 additions & 6 deletions resources/views/components/toast.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,6 @@
<p class="mb-0">{{ $toast_yahtzee_scratch['message'] }}</p>
</div>
</div>
<div id="toast_chance_scratch" class="toast bg-primary" role="alert" aria-live="assertive" aria-atomic="true">
<div class="toast-body text-white">
<h2>{{ $toast_chance_scratch['heading'] }}</h2>
<p class="mb-0">{{ $toast_chance_scratch['message'] }}</p>
</div>
</div>
<div id="toast_yahtzee_bonus_one" class="toast bg-primary" role="alert" aria-live="assertive" aria-atomic="true">
<div class="toast-body text-white">
<h2>{{ $toast_yahtzee_bonus_one['heading'] }}</h2>
Expand Down
14 changes: 5 additions & 9 deletions resources/views/public-score-sheet.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,7 @@
</div>

<div class="row">
<div class="col-12">
<hr />
<div class="col-12 pt-3">
<h2 class="text-primary">Lower Section</h2>
</div>
</div>
Expand Down Expand Up @@ -429,7 +428,6 @@
<h6>Score</h6>
</div>
<div class="col-3 text-center">
<h6>Scratch</h6>
</div>
<div class="col-6">
<p class="mb-0 chance_dice">
Expand Down Expand Up @@ -463,9 +461,7 @@
<label for="chance" class="visually-hidden">Chance</label>
</div>
<div class="col-3">
<div class="text-center">
<input class="accessible form-check-input @if(array_key_exists('chance', $score_sheet['upper-section'])) disabled @else active @endif" type="checkbox" id="scratch_chance" value="chance" aria-label="Scratch chance" @if(array_key_exists('chance', $score_sheet['lower-section'])) disabled="disabled" @endif @if(array_key_exists('chance', $score_sheet['lower-section']) && $score_sheet['lower-section']['chance'] === 0) checked="checked" @endif>
</div>

</div>
</div>

Expand Down Expand Up @@ -541,8 +537,8 @@
<script src="{{ asset('node_modules/axios/dist/axios.min.js') }}" defer></script>
<script src="{{ asset('node_modules/bootstrap/dist/js/bootstrap.js') }}" defer></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/confetti.browser.min.js" defer></script>
<script type="module" src="{{ asset('js/score-sheet.js?v0.18.0') }}" defer></script>
<script src="{{ asset('js/player-scores.js?v0.18.0') }}" defer></script>
<script src="{{ asset('js/bonus-message.js?v0.18.0') }}" defer></script>
<script type="module" src="{{ asset('js/score-sheet.js?v1.02.0') }}" defer></script>
<script src="{{ asset('js/player-scores.js?v1.02.0') }}" defer></script>
<script src="{{ asset('js/bonus-message.js?v1.02.0') }}" defer></script>
</body>
</html>
13 changes: 4 additions & 9 deletions resources/views/score-sheet.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,7 @@
</div>

<div class="row">
<div class="col-12">
<hr />
<div class="col-12 pt-3">
<h2 class="text-primary">Lower Section</h2>
</div>
</div>
Expand Down Expand Up @@ -437,7 +436,6 @@
<h6>Score</h6>
</div>
<div class="col-3 text-center">
<h6>Scratch</h6>
</div>
<div class="col-6">
<p class="mb-0 chance_dice">
Expand Down Expand Up @@ -471,9 +469,6 @@
<label for="chance" class="visually-hidden">Chance</label>
</div>
<div class="col-3">
<div class="text-center">
<input class="accessible form-check-input @if(array_key_exists('chance', $score_sheet['upper-section'])) disabled @else active @endif" type="checkbox" id="scratch_chance" value="chance" aria-label="Scratch chance" @if(array_key_exists('chance', $score_sheet['lower-section'])) disabled="disabled" @endif @if(array_key_exists('chance', $score_sheet['lower-section']) && $score_sheet['lower-section']['chance'] === 0) checked="checked" @endif>
</div>
</div>
</div>

Expand Down Expand Up @@ -550,9 +545,9 @@
<script src="{{ asset('node_modules/axios/dist/axios.min.js') }}" defer></script>
<script src="{{ asset('node_modules/bootstrap/dist/js/bootstrap.js') }}" defer></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/confetti.browser.min.js" defer></script>
<script type="module" src="{{ asset('js/score-sheet.js?v0.18.0') }}" defer></script>
<script src="{{ asset('js/player-scores.js?v0.18.0') }}" defer></script>
<script src="{{ asset('js/bonus-message.js?v0.18.0') }}" defer></script>
<script type="module" src="{{ asset('js/score-sheet.js?v1.02.0') }}" defer></script>
<script src="{{ asset('js/player-scores.js?v1.02.0') }}" defer></script>
<script src="{{ asset('js/bonus-message.js?v1.02.0') }}" defer></script>
@endif
</body>
</html>

0 comments on commit 972b8d2

Please sign in to comment.