Skip to content

Commit

Permalink
feat(admin): add a button to remove comp messages
Browse files Browse the repository at this point in the history
  • Loading branch information
timotheeg committed Jan 31, 2024
1 parent 8585dca commit c57a65b
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 5 deletions.
3 changes: 2 additions & 1 deletion domains/MatchRoom.js
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,8 @@ class MatchRoom extends Room {
case 'cancelGameOver':
case 'focusPlayer':
case 'setHideProfileCardOnNextGame':
case 'startCountDown': {
case 'startCountDown':
case 'removeCompMessage': {
update_admin = false;
break; // simple passthrough
}
Expand Down
6 changes: 3 additions & 3 deletions public/views/Player.js
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,9 @@ export default class Player {
}

hideCompMessage() {
if (this.count_down_timer) {
this.count_down_timer = clearTimeout(this.count_down_timer);
}
this.comp_messages.style.display = 'none';
}

Expand Down Expand Up @@ -865,9 +868,6 @@ export default class Player {
}
this.hide_profile_card_on_next_game = false;

if (this.count_down_timer) {
this.count_down_timer = clearTimeout(this.count_down_timer);
}
this.hideCompMessage();
}

Expand Down
4 changes: 4 additions & 0 deletions public/views/competition.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,10 @@ class TetrisCompetitionAPI {
players.forEach(player => player.startCountDown(seconds));
}

removeCompMessage() {
players.forEach(player => player.hideCompMessage());
}

_repaintVictories(player_idx) {
const player = players[player_idx]; // direct access... not great
const victories = this.victories[player_idx];
Expand Down
8 changes: 8 additions & 0 deletions public/views/competition_admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const dom = {
'#setHideProfileCardOnNextGame'
),
count_down: document.querySelector('#count_down'),
remove_count_down: document.querySelector('#remove_count_down'),
clear_victories: document.querySelector('#clear_victories'),
show_runways: document.querySelector('#show_runways'),
hide_runways: document.querySelector('#hide_runways'),
Expand Down Expand Up @@ -104,6 +105,9 @@ const remoteAPI = {
startCountDown: function (seconds) {
connection.send(['startCountDown', seconds]);
},
removeCompMessage: function () {
connection.send(['removeCompMessage']);
},
};

const players = [];
Expand Down Expand Up @@ -407,6 +411,10 @@ function bootstrap() {
remoteAPI.startCountDown(5);
});

dom.remove_count_down.addEventListener('click', () => {
remoteAPI.removeCompMessage();
});

dom.clear_victories.addEventListener('click', () => {
remoteAPI.resetVictories();
});
Expand Down
3 changes: 2 additions & 1 deletion views/admin.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@
</div>
<div class="buttons">
<button id="count_down" title="Show a 5s timer for ALL players">Count Down 5s</button>
<button id="setHideProfileCardOnNextGame" title="Profile card will auto-hide when the next game starts">Hide profile card when next game starts</button>
<button id="remove_count_down" title="Hide overlay">Remove Ready / Count Down</button>
<button id="setHideProfileCardOnNextGame" style="display: none;" title="Profile card will auto-hide when the next game starts">Auto-Hide profile cards</button>
</div>
<div class="buttons">
<button id="clear_victories">Clear Victories</button>
Expand Down

0 comments on commit c57a65b

Please sign in to comment.