Shooting Subroutine

master
j 2024-04-15 01:35:00 -04:00
parent 04f3f8a0a7
commit 1eb158ac10
2 changed files with 37 additions and 1 deletions

View File

@ -477,6 +477,42 @@ class GameFlow {
// Logic for traversing the mountains, may affect gameState // 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<void> {
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 { private handleDoctor(): string {
let responseMessage: string = "" let responseMessage: string = ""
// Handle illness and injury // Handle illness and injury

View File

@ -13,7 +13,7 @@ class GameState {
amountSpentOnAnimals: number = 0; amountSpentOnAnimals: number = 0;
amountSpentOnAmmunition: number = 0; amountSpentOnAmmunition: number = 0;
actualResponseTimeForBang: number = 0; actualResponseTimeForBang: number = 0;
clockTimeAtStartOfBang: Date = new Date(); clockTimeAtStartOfBang: number = 0;
amountSpentOnClothing: number = 0; amountSpentOnClothing: number = 0;
insufficientClothingFlag: boolean = false; insufficientClothingFlag: boolean = false;
yesNoResponseToQuestions: string = ''; yesNoResponseToQuestions: string = '';