From c5667695b2de7207367b1b2429a1ebb6576f6aa5 Mon Sep 17 00:00:00 2001 From: Kevin Date: Sun, 18 Aug 2024 16:41:25 +1000 Subject: [PATCH 1/5] Added crit mission timer option partially --- assets/scripts/lobby/buttonEventListeners2.js | 11 ++++++++++- src/gameplay/game.ts | 6 ++++-- src/gameplay/gameTimer.ts | 2 ++ src/gameplay/room.ts | 3 +++ src/sockets/sockets.ts | 1 + src/views/lobby.ejs | 3 +++ 6 files changed, 23 insertions(+), 3 deletions(-) diff --git a/assets/scripts/lobby/buttonEventListeners2.js b/assets/scripts/lobby/buttonEventListeners2.js index 280ffafa1..da166c919 100644 --- a/assets/scripts/lobby/buttonEventListeners2.js +++ b/assets/scripts/lobby/buttonEventListeners2.js @@ -70,7 +70,8 @@ function greenButtonFunction() { gameMode: $($('.gameModeSelect')[1]).val(), timeouts: { default: ((parseInt($('#startGameOptionsDefaultPhaseTimeoutMin').val()) * 60 + parseInt($('#startGameOptionsDefaultPhaseTimeoutSec').val())) * 1000).toString(), - assassination: ((parseInt($('#startGameOptionsAssassinationPhaseTimeoutMin').val()) * 60 + parseInt($('#startGameOptionsAssassinationPhaseTimeoutSec').val())) * 1000).toString() + assassination: ((parseInt($('#startGameOptionsAssassinationPhaseTimeoutMin').val()) * 60 + parseInt($('#startGameOptionsAssassinationPhaseTimeoutSec').val())) * 1000).toString(), + critMission: ((parseInt($('#startGameOptionsCritMissionTimeoutMin').val()) * 60 + parseInt($('#startGameOptionsCritMissionTimeoutSec').val())) * 1000).toString() }, anonymousMode: $('#startGameOptionsAnonymousMode')[0].checked, }; @@ -244,6 +245,14 @@ $('#startGameOptionsAssassinationPhaseTimeoutSec').on('change', () => { handleTimeoutInput('#startGameOptionsAssassinationPhaseTimeoutSec'); }); +$('#startGameOptionsCritMissionTimeoutMin').on('change', () => { + handleTimeoutInput('#startGameOptionsCritMissionTimeoutMin'); +}); + +$('#startGameOptionsCritMissionTimeoutSec').on('change', () => { + handleTimeoutInput('#startGameOptionsCritMissionTimeoutSec'); +}); + function handleTimeoutInput(inputId) { let input = $(inputId)[0]; let val = parseInt(input.value, 10); diff --git a/src/gameplay/game.ts b/src/gameplay/game.ts index 65c42b9ee..e5a20362e 100644 --- a/src/gameplay/game.ts +++ b/src/gameplay/game.ts @@ -550,11 +550,13 @@ class Game extends Room { this.sendText(str, 'gameplay-text'); const timeouts = this.gameTimer.getTimeouts(); - if (timeouts.assassination || timeouts.default) { + if (timeouts.assassination || timeouts.default || timeouts.critMission) { this.sendText( `Timeouts: Default = ${millisToStr( timeouts.default, - )}, Assassination = ${millisToStr(timeouts.assassination)}`, + )}, Assassination = ${millisToStr( + timeouts.assassination, + )}, Critical Mission = ${millisToStr(timeouts.critMission)}`, 'gameplay-text', ); } diff --git a/src/gameplay/gameTimer.ts b/src/gameplay/gameTimer.ts index 06c466264..46526f946 100644 --- a/src/gameplay/gameTimer.ts +++ b/src/gameplay/gameTimer.ts @@ -11,6 +11,7 @@ export interface Timeouts { // All in milliseconds default: number; assassination: number; + critMission: number; } export class GameTimer { @@ -22,6 +23,7 @@ export class GameTimer { private timeoutSettings: Timeouts = { default: 0, assassination: 0, + critMission: 0, }; private playersVotedPause: Set = new Set(); diff --git a/src/gameplay/room.ts b/src/gameplay/room.ts index 542aea6a0..d6fda6129 100644 --- a/src/gameplay/room.ts +++ b/src/gameplay/room.ts @@ -643,6 +643,9 @@ class Room { rolesInStr += `
Assassination timeout: ${millisToStr( timeouts.assassination, )}`; + rolesInStr += `
Critical Mission timeout: ${millisToStr( + timeouts.critMission, + )}`; rolesInStr += `
Anonymous mode: ${anonymousMode}`; this.sendText('The game is starting!', 'gameplay-text'); diff --git a/src/sockets/sockets.ts b/src/sockets/sockets.ts index a90074661..9e6a3e1d4 100644 --- a/src/sockets/sockets.ts +++ b/src/sockets/sockets.ts @@ -1597,6 +1597,7 @@ function startGame(data) { const timeouts = { default: processTimeout(timeoutsStr.default), assassination: processTimeout(timeoutsStr.assassination), + critMission: processTimeout(timeoutsStr.critMission), }; if ( diff --git a/src/views/lobby.ejs b/src/views/lobby.ejs index 6d0c19085..bf7f93d0f 100644 --- a/src/views/lobby.ejs +++ b/src/views/lobby.ejs @@ -969,6 +969,9 @@
+ + +
From cc24e51dc758b71f7f5621d1f673b1f304902537 Mon Sep 17 00:00:00 2001 From: Kevin Date: Sun, 18 Aug 2024 17:09:03 +1000 Subject: [PATCH 2/5] Crit mission timeout now starts when 2 fails --- src/gameplay/game.ts | 1 + src/gameplay/gameTimer.ts | 14 ++++++++++---- src/gameplay/phases/common/votingMission.ts | 5 +++++ 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/gameplay/game.ts b/src/gameplay/game.ts index e5a20362e..e15afc094 100644 --- a/src/gameplay/game.ts +++ b/src/gameplay/game.ts @@ -97,6 +97,7 @@ class Game extends Room { // Game misc variables winner: Alliance = ''; requireSave = false; + critMission = false; // TODO This shouldn't be here! Should be in Assassin file. startAssassinationTime: Date; diff --git a/src/gameplay/gameTimer.ts b/src/gameplay/gameTimer.ts index 46526f946..d6f850861 100644 --- a/src/gameplay/gameTimer.ts +++ b/src/gameplay/gameTimer.ts @@ -113,10 +113,16 @@ export class GameTimer { // Kinda sad to have direct knowledge of the phase here // but not much we can do. We don't want the timeout settings // in game.ts - let timerDuration = - this.game.phase === Phase.Assassination - ? this.timeoutSettings.assassination - : this.timeoutSettings.default; + let timerDuration; + + if (this.game.phase === Phase.Assassination) { + timerDuration = this.timeoutSettings.assassination; + } else if (this.game.critMission) { + timerDuration = this.timeoutSettings.critMission; + console.log('THIS HIT'); + } else { + timerDuration = this.timeoutSettings.default; + } // Timeout not enabled if (timerDuration === 0) { diff --git a/src/gameplay/phases/common/votingMission.ts b/src/gameplay/phases/common/votingMission.ts index ee3e491fe..91bd606b3 100644 --- a/src/gameplay/phases/common/votingMission.ts +++ b/src/gameplay/phases/common/votingMission.ts @@ -127,6 +127,11 @@ class VotingMission implements IPhase { } } + // Critical mission if 2 fails + if (numOfFails == 2) { + this.thisRoom.critMission = true; + } + // game over if more than 3 fails or successes if (numOfFails >= 3) { this.thisRoom.winner = Alliance.Spy; From 24c404446215bb38aff83889549a4b7497e48cc2 Mon Sep 17 00:00:00 2001 From: Kevin Date: Sun, 18 Aug 2024 17:16:14 +1000 Subject: [PATCH 3/5] Remove console log --- src/gameplay/gameTimer.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/gameplay/gameTimer.ts b/src/gameplay/gameTimer.ts index d6f850861..bbc79b259 100644 --- a/src/gameplay/gameTimer.ts +++ b/src/gameplay/gameTimer.ts @@ -119,7 +119,6 @@ export class GameTimer { timerDuration = this.timeoutSettings.assassination; } else if (this.game.critMission) { timerDuration = this.timeoutSettings.critMission; - console.log('THIS HIT'); } else { timerDuration = this.timeoutSettings.default; } From 5f2cf4037895c464097fb9a4c17a18505abd20b2 Mon Sep 17 00:00:00 2001 From: Kevin Date: Thu, 22 Aug 2024 17:24:36 +1000 Subject: [PATCH 4/5] Crit mission timer resets to default if unset --- src/gameplay/gameTimer.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/gameplay/gameTimer.ts b/src/gameplay/gameTimer.ts index bbc79b259..de9f4a987 100644 --- a/src/gameplay/gameTimer.ts +++ b/src/gameplay/gameTimer.ts @@ -38,6 +38,11 @@ export class GameTimer { } configureTimeouts(timeouts: Timeouts): void { + // Set crit mission timer to default if unset. + if (timeouts.critMission == 0) { + timeouts.critMission = timeouts.default; + } + this.timeoutSettings = timeouts; } From 54c02de13b5628f1ea0ebb307b5c72e9f28b0103 Mon Sep 17 00:00:00 2001 From: Kevin Date: Thu, 22 Aug 2024 17:30:46 +1000 Subject: [PATCH 5/5] Reordered Crit Mission to be before Assasination timeout --- assets/scripts/lobby/buttonEventListeners2.js | 18 +++++++++--------- src/gameplay/game.ts | 6 +++--- src/gameplay/room.ts | 6 +++--- src/views/lobby.ejs | 6 +++--- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/assets/scripts/lobby/buttonEventListeners2.js b/assets/scripts/lobby/buttonEventListeners2.js index da166c919..a0cbee7d4 100644 --- a/assets/scripts/lobby/buttonEventListeners2.js +++ b/assets/scripts/lobby/buttonEventListeners2.js @@ -70,8 +70,8 @@ function greenButtonFunction() { gameMode: $($('.gameModeSelect')[1]).val(), timeouts: { default: ((parseInt($('#startGameOptionsDefaultPhaseTimeoutMin').val()) * 60 + parseInt($('#startGameOptionsDefaultPhaseTimeoutSec').val())) * 1000).toString(), + critMission: ((parseInt($('#startGameOptionsCritMissionTimeoutMin').val()) * 60 + parseInt($('#startGameOptionsCritMissionTimeoutSec').val())) * 1000).toString(), assassination: ((parseInt($('#startGameOptionsAssassinationPhaseTimeoutMin').val()) * 60 + parseInt($('#startGameOptionsAssassinationPhaseTimeoutSec').val())) * 1000).toString(), - critMission: ((parseInt($('#startGameOptionsCritMissionTimeoutMin').val()) * 60 + parseInt($('#startGameOptionsCritMissionTimeoutSec').val())) * 1000).toString() }, anonymousMode: $('#startGameOptionsAnonymousMode')[0].checked, }; @@ -237,14 +237,6 @@ $('#startGameOptionsDefaultPhaseTimeoutSec').on('change', () => { handleTimeoutInput('#startGameOptionsDefaultPhaseTimeoutSec'); }); -$('#startGameOptionsAssassinationPhaseTimeoutMin').on('change', () => { - handleTimeoutInput('#startGameOptionsAssassinationPhaseTimeoutMin'); -}); - -$('#startGameOptionsAssassinationPhaseTimeoutSec').on('change', () => { - handleTimeoutInput('#startGameOptionsAssassinationPhaseTimeoutSec'); -}); - $('#startGameOptionsCritMissionTimeoutMin').on('change', () => { handleTimeoutInput('#startGameOptionsCritMissionTimeoutMin'); }); @@ -253,6 +245,14 @@ $('#startGameOptionsCritMissionTimeoutSec').on('change', () => { handleTimeoutInput('#startGameOptionsCritMissionTimeoutSec'); }); +$('#startGameOptionsAssassinationPhaseTimeoutMin').on('change', () => { + handleTimeoutInput('#startGameOptionsAssassinationPhaseTimeoutMin'); +}); + +$('#startGameOptionsAssassinationPhaseTimeoutSec').on('change', () => { + handleTimeoutInput('#startGameOptionsAssassinationPhaseTimeoutSec'); +}); + function handleTimeoutInput(inputId) { let input = $(inputId)[0]; let val = parseInt(input.value, 10); diff --git a/src/gameplay/game.ts b/src/gameplay/game.ts index e15afc094..317b879ba 100644 --- a/src/gameplay/game.ts +++ b/src/gameplay/game.ts @@ -555,9 +555,9 @@ class Game extends Room { this.sendText( `Timeouts: Default = ${millisToStr( timeouts.default, - )}, Assassination = ${millisToStr( - timeouts.assassination, - )}, Critical Mission = ${millisToStr(timeouts.critMission)}`, + )}, Critical Mission = ${millisToStr( + timeouts.critMission, + )}, Assassination = ${millisToStr(timeouts.assassination)}`, 'gameplay-text', ); } diff --git a/src/gameplay/room.ts b/src/gameplay/room.ts index d6fda6129..669f2edc5 100644 --- a/src/gameplay/room.ts +++ b/src/gameplay/room.ts @@ -640,12 +640,12 @@ class Room { rolesInStr += `
Ranked: ${this.ranked}`; rolesInStr += `
Mute Spectators: ${this.muteSpectators}`; rolesInStr += `
Default timeout: ${millisToStr(timeouts.default)}`; - rolesInStr += `
Assassination timeout: ${millisToStr( - timeouts.assassination, - )}`; rolesInStr += `
Critical Mission timeout: ${millisToStr( timeouts.critMission, )}`; + rolesInStr += `
Assassination timeout: ${millisToStr( + timeouts.assassination, + )}`; rolesInStr += `
Anonymous mode: ${anonymousMode}`; this.sendText('The game is starting!', 'gameplay-text'); diff --git a/src/views/lobby.ejs b/src/views/lobby.ejs index bf7f93d0f..b2e5fd1a1 100644 --- a/src/views/lobby.ejs +++ b/src/views/lobby.ejs @@ -966,12 +966,12 @@
- - -

+ + +