Skip to content

Commit

Permalink
Merge pull request #188 from marvin-wtt/fix/viewingRate-late-connection
Browse files Browse the repository at this point in the history
fix: Add error notification when controller tries to connect late.
  • Loading branch information
marvin-wtt authored Jul 14, 2024
2 parents 361c79f + 28fbeb2 commit 11e843c
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 4 deletions.
8 changes: 8 additions & 0 deletions src/i18n/de-DE/gameMode/viewingRate.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export default {
title: 'Einschaltquote',

controllersReady: '{count} Controller bereit!',
currentlyViewing: 'Aktuell eingeschaltet',
totalWatchRate: 'Totale Einschaltquote',

Expand All @@ -24,5 +25,12 @@ export default {
action: {
ok: 'Ok',
},

error: {
newController: {
message: 'Neue Controller sind vom diesem Spiel ausgeschlossen!.',
caption: 'Controller: ',
},
},
},
};
8 changes: 8 additions & 0 deletions src/i18n/en-US/gameMode/viewingRate.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export default {
title: 'Viewing Rate',

controllersReady: '{count} controllers ready!',
currentlyViewing: 'Currently viewing',
totalWatchRate: 'Total viewing rate',

Expand All @@ -25,4 +26,11 @@ export default {
ok: 'Ok',
},
},

error: {
newController: {
message: 'New controllers are excluded from this game.',
caption: 'Controller: ',
},
},
};
19 changes: 15 additions & 4 deletions src/pages/gameModes/ViewingRateGamePage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
>
<a class="text-h6">
{{
t('gameMode.stopwatch.controllersReady', {
t('gameMode.viewingRate.controllersReady', {
count: settings.readyCheck
? gameState.controllersReady.length
: controllers.length,
Expand Down Expand Up @@ -433,10 +433,21 @@ const runningListener = transition('running', (state, event: ButtonEvent) => {
}
const controllerId = event.controller.id;
const changes = { ...state.changeTimes };
if (!(controllerId in changes)) {
changes[controllerId] = [];
// Ignore controllers that connected after the start.
// This is to ensure correct calculation.
if (!(controllerId in state.changeTimes)) {
quasar.notify({
message: t('gameMode.viewingRate.error.newController.message'),
caption:
t('gameMode.viewingRate.error.newController.caption') +
event.controller.name,
color: 'negative',
});
return;
}
const changes = { ...state.changeTimes };
changes[controllerId].push(time.value);
event.controller.setLight(isControllerViewing(state, event.controller.id));
Expand Down

0 comments on commit 11e843c

Please sign in to comment.