Skip to content

Commit

Permalink
FInal score
Browse files Browse the repository at this point in the history
- Added a modal showing your final score.
- Reduced the timer for player scores
  • Loading branch information
deanblackborough committed Aug 1, 2022
1 parent 8c6dead commit 5d89b41
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 4 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

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

## [0.17.0] - [2022-08-01]
### Added
- Added a modal that displays your final score.
### Changed
- Adjusted the timer for the player scores, down to ten seconds from thirty.

## [0.16.0] - [2022-08-01]
### Added
- Added ability to remove a player from an open game, deletes the score sheet, share token and assignment.
Expand Down
2 changes: 1 addition & 1 deletion 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' => '0.16.0',
'version' => '0.17.0',
'release_date' => '1st August 2022'
];
2 changes: 1 addition & 1 deletion public/js/player-scores.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@
});
}

poll(() => new Promise(() => fetchPlayerScores()), 1000 * 30)
poll(() => new Promise(() => fetchPlayerScores()), 1000 * 10)
})(axios);
2 changes: 1 addition & 1 deletion public/js/public-player-scores.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@
});
}

poll(() => new Promise(() => fetchPlayerScores()), 1000 * 30)
poll(() => new Promise(() => fetchPlayerScores()), 1000 * 10)
})(axios);
12 changes: 12 additions & 0 deletions public/js/public-score-sheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
let score_lower_upper = document.getElementById('lower-upper-total');
let score_lower = document.getElementById('lower-score');
let total_score = document.getElementById('total');
let player_final_score = document.getElementById('final-score');

document.querySelectorAll('div.upper-section-scratch input[type="checkbox"].active').forEach(upper_scratch => {
upper_scratch.addEventListener('change', function () {
Expand All @@ -39,6 +40,8 @@
upper.value = 0;
upper.disabled = true;

player_final_score.innerText = response.data.score.upper + response.data.score.bonus + response.data.score.lower;

disable_yahtzee_bonus(response.data.turns);

document.querySelectorAll('label[for="' + this.value + '"] svg').forEach(dice =>
Expand Down Expand Up @@ -96,6 +99,7 @@
score_upper_total.innerText = response.data.score.upper + response.data.score.bonus;
score_lower_upper.innerText = response.data.score.upper + response.data.score.bonus;
total_score.innerText = response.data.score.upper + response.data.score.bonus + response.data.score.lower;
player_final_score.innerText = response.data.score.upper + response.data.score.bonus + response.data.score.lower;

disable_yahtzee_bonus(response.data.turns);

Expand Down Expand Up @@ -247,6 +251,8 @@
yahtzee_bonus_one.disabled = true;
yahtzee_bonus_two.disabled = true;
yahtzee_bonus_three.disabled = true;

display_toast('done');
}
}

Expand Down Expand Up @@ -291,6 +297,7 @@

score_lower.innerText = response.data.score.lower;
total_score.innerText = response.data.score.upper + response.data.score.bonus + response.data.score.lower;
player_final_score.innerText = response.data.score.upper + response.data.score.bonus + response.data.score.lower;

disable_yahtzee_bonus(response.data.turns);

Expand Down Expand Up @@ -327,6 +334,7 @@

score_lower.innerText = response.data.score.lower;
total_score.innerText = response.data.score.upper + response.data.score.bonus + response.data.score.lower;
player_final_score.innerText = response.data.score.upper + response.data.score.bonus + response.data.score.lower;

disable_yahtzee_bonus(response.data.turns);

Expand Down Expand Up @@ -365,6 +373,8 @@
lower.disabled = true;
lower.value = 0;

player_final_score.innerText = response.data.score.upper + response.data.score.bonus + response.data.score.lower;

disable_yahtzee_bonus(response.data.turns);

display_toast(show_toast);
Expand Down Expand Up @@ -400,6 +410,8 @@
lower.classList.add('disabled');
lower.disabled = true;

player_final_score.innerText = response.data.score.upper + response.data.score.bonus + response.data.score.lower;

disable_yahtzee_bonus(response.data.turns);

document.querySelectorAll('p.' + element.id.toString().replace('scratch_', '') + '_dice svg').forEach(dice =>
Expand Down
13 changes: 13 additions & 0 deletions public/js/score-sheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
let player_score_lower_upper = document.getElementById('lower-upper-total');
let player_score_lower = document.getElementById('lower-score');
let player_total_score = document.getElementById('total');
let player_final_score = document.getElementById('final-score');

document.querySelectorAll('div.upper-section-scratch input[type="checkbox"].active').forEach(upper_scratch => {
upper_scratch.addEventListener('change', function () {
Expand Down Expand Up @@ -155,6 +156,8 @@
yahtzee_bonus_one.disabled = true;
yahtzee_bonus_two.disabled = true;
yahtzee_bonus_three.disabled = true;

display_selected_toast('done');
}
}

Expand Down Expand Up @@ -205,6 +208,7 @@

player_score_lower.innerText = response.data.score.lower;
player_total_score.innerText = response.data.score.upper + response.data.score.bonus + response.data.score.lower;
player_final_score.innerText = response.data.score.upper + response.data.score.bonus + response.data.score.lower;

disable_yahtzee_bonus_if_game_over(response.data.turns);

Expand Down Expand Up @@ -246,6 +250,7 @@

player_score_lower.innerText = response.data.score.lower;
player_total_score.innerText = response.data.score.upper + response.data.score.bonus + response.data.score.lower;
player_final_score.innerText = response.data.score.upper + response.data.score.bonus + response.data.score.lower;

disable_yahtzee_bonus_if_game_over(response.data.turns);

Expand Down Expand Up @@ -285,6 +290,8 @@
lower.disabled = true;
lower.value = 0;

player_final_score.innerText = response.data.score.upper + response.data.score.bonus + response.data.score.lower;

disable_yahtzee_bonus_if_game_over(response.data.turns);

display_selected_toast(show_toast);
Expand Down Expand Up @@ -322,6 +329,8 @@
lower.classList.add('disabled');
lower.disabled = true;

player_final_score.innerText = response.data.score.upper + response.data.score.bonus + response.data.score.lower;

display_selected_toast(show_toast);

disable_yahtzee_bonus_if_game_over(response.data.turns);
Expand Down Expand Up @@ -378,6 +387,7 @@
player_score_upper_total.innerText = response.data.score.upper + response.data.score.bonus;
player_score_lower_upper.innerText = response.data.score.upper + response.data.score.bonus;
player_total_score.innerText = response.data.score.upper + response.data.score.bonus + response.data.score.lower;
player_final_score.innerText = response.data.score.upper + response.data.score.bonus + response.data.score.lower;

display_selected_toast(show_toast);

Expand Down Expand Up @@ -420,6 +430,8 @@
upper.value = 0;
upper.disabled = true;

player_final_score.innerText = response.data.score.upper + response.data.score.bonus + response.data.score.lower;

display_selected_toast(show_toast);

disable_yahtzee_bonus_if_game_over(response.data.turns);
Expand Down Expand Up @@ -458,6 +470,7 @@

player_score_lower.innerText = response.data.score.lower;
player_total_score.innerText = response.data.score.upper + response.data.score.bonus + response.data.score.lower;
player_final_score.innerText = response.data.score.upper + response.data.score.bonus + response.data.score.lower;

disable_yahtzee_bonus_if_game_over(response.data.turns);

Expand Down
7 changes: 7 additions & 0 deletions resources/views/components/toast.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,11 @@
<p class="mb-0">{{ $toast_yahtzee_bonus_three['message'] }}</p>
</div>
</div>
<div id="toast_done" class="toast bg-primary" role="alert" aria-live="assertive" aria-atomic="true">
<div class="toast-body text-white">
<h2>Done!</h2>
<p class="mb-0">You scored <span id="final-score">0</span>, when everyone has finished
their final turn we will see how you did</p>
</div>
</div>
</div>
2 changes: 1 addition & 1 deletion resources/views/player-scores.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<h2 class="text-primary">Player Scores</h2>

<table class="table table-striped table-sm">
<caption>Player scores, delayed by thirty seconds.</caption>
<caption>Player scores, delayed by ten seconds.</caption>
<thead>
<tr>
<th scope="col">Name</th>
Expand Down

0 comments on commit 5d89b41

Please sign in to comment.