diff --git a/src/game/gameFlow.ts b/src/game/gameFlow.ts index 4650cc8..f3fbfb2 100644 --- a/src/game/gameFlow.ts +++ b/src/game/gameFlow.ts @@ -477,6 +477,42 @@ class GameFlow { // Logic for traversing the mountains, may affect gameState } + // Shooting word variations + private shootingWordVariations: string[] = [ + "BANG", "BLAM", "POW", "WHAM", "BOOM", "ZAP", "PEW", "BAM", "CRACK", "POP", + "BOFF", "SMACK", "KABOOM", "ZOOM", "WHOOSH", "BLOOP", "SPLAT", "SPLASH", "CRASH", "BANG!" + ]; + + // Simulating the shooting subroutine + private async handleShootingSubRoutine(userInput?: string): Promise { + + let responseMessage = '' + + if (!userInput) { + // Select a random shooting word + const shootingWordSelector = Math.floor(Math.random() * this.shootingWordVariations.length); + this.gameState.shootingWordSelector = this.shootingWordVariations[shootingWordSelector]; + this.gameState.clockTimeAtStartOfBang = Math.floor(new Date().getTime() / 1000); + //prompt the user to type !!Oregon shootingWord + responseMessage += `\nQuick! TYPE !!Oregon ${this.gameState.shootingWordSelector} within the next few minutes to hunt the animal. Hurry, time is ticking!\n`; + await this.statusUpdate(responseMessage); + } else { + // Check user input against shooting word + if (userInput.toUpperCase() === this.gameState.shootingWordSelector) { + const clockTimeAtEndOfBang = this.gameState.comment.created_utc; + let actualResponseTimeForBang = ((clockTimeAtEndOfBang - this.gameState.clockTimeAtStartOfBang) / 60000); + actualResponseTimeForBang += (this.gameState.shootingExpertiseLevelChoice - 1) + if (actualResponseTimeForBang < 0) { + actualResponseTimeForBang = 0; + } + // Update the game state with the actual response time + this.gameState.actualResponseTimeForBang = actualResponseTimeForBang; + } else { + this.gameState.actualResponseTimeForBang = 9; // Set a high time to indicate a miss + } + } + } + private handleDoctor(): string { let responseMessage: string = "" // Handle illness and injury diff --git a/src/game/gameState.ts b/src/game/gameState.ts index 18e682d..08c6132 100644 --- a/src/game/gameState.ts +++ b/src/game/gameState.ts @@ -13,7 +13,7 @@ class GameState { amountSpentOnAnimals: number = 0; amountSpentOnAmmunition: number = 0; actualResponseTimeForBang: number = 0; - clockTimeAtStartOfBang: Date = new Date(); + clockTimeAtStartOfBang: number = 0; amountSpentOnClothing: number = 0; insufficientClothingFlag: boolean = false; yesNoResponseToQuestions: string = '';