diff --git a/src/game/gameFlow.ts b/src/game/gameFlow.ts index f3fbfb2..809b1c6 100644 --- a/src/game/gameFlow.ts +++ b/src/game/gameFlow.ts @@ -33,7 +33,7 @@ class GameFlow { break; case PHASE_ENUM.HUNT: // Handle hunting logic - await this.handleHunt(); + await this.handleHunt(userInput); break; case PHASE_ENUM.EATING: break; @@ -392,9 +392,21 @@ class GameFlow { console.log("userInput", userInput); switch (userInput) { case "1": // Hunt - this.gameState.phase = PHASE_ENUM.HUNT; - await this.gameState.save() - this.executeCurrentPhase() + if (this.gameState.amountSpentOnAmmunition < 40) { + responseMessage = `You do not have enough ammunition to hunt. Purchase more ammunition first.\n\n`; + if (this.gameState.fortOptionFlag) { + responseMessage += `Do you want to:\n2. Continue\n3. Stop at the Next Fort\n\n` + } else { + responseMessage += `Do you want to:\n2. Continue\n\n` + } + await this.statusUpdate(responseMessage) + } else { + this.gameState.phase = PHASE_ENUM.HUNT; + this.gameState.totalMileageWholeTrip -= 45; + await this.gameState.save() + this.executeCurrentPhase() + } + return; break; case "2": // Continue @@ -461,8 +473,28 @@ class GameFlow { // Logic for interacting at the fort, such as purchasing supplies } - private async handleHunt(): Promise { - // Logic for the hunt phase, possibly determining success based on gameState attributes + private async handleHunt(userInput?: string | number): Promise { + // Logic for the hunt phase, determining success based on gameState attributes + let responseMessage = ""; + if (!userInput) { + responseMessage += this.handleShooting() + await this.statusUpdate(responseMessage) + } else { + responseMessage += this.handleShooting(userInput.toString()); + if (this.gameState.actualResponseTimeForBang <= 1) { + responseMessage += `RIGHT BETWEEN THE EYES---YOU GOT A BIG ONE!!!!\n\n` + responseMessage += `FULL BELLIES TONIGHT!\n\n` + this.gameState.amountSpentOnFood += 52 + (Math.random() * 6) + this.gameState.amountSpentOnAmmunition -= 10 - (Math.random() * 4) + await this.statusUpdate(responseMessage) + } else if (100 * Math.random() > (13 * this.gameState.actualResponseTimeForBang)) { + responseMessage += `NICE SHOT--RIGHT ON TARGET--GOOD EATIN' TONIGHT!!\n\n` + this.gameState.amountSpentOnFood += 48 - (2 * this.gameState.actualResponseTimeForBang) + this.gameState.amountSpentOnAmmunition -= 10 - (3 * this.gameState.actualResponseTimeForBang) + } + } + + } private async handleEncounter(): Promise { @@ -484,7 +516,7 @@ class GameFlow { ]; // Simulating the shooting subroutine - private async handleShootingSubRoutine(userInput?: string): Promise { + private handleShooting(userInput?: string): string { let responseMessage = '' @@ -494,8 +526,8 @@ class GameFlow { 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); + responseMessage += `\nQuick! TYPE !!Oregon ${this.gameState.shootingWordSelector} within the next few minutes. Hurry, time is ticking!\n\n`; + return responseMessage; } else { // Check user input against shooting word if (userInput.toUpperCase() === this.gameState.shootingWordSelector) { @@ -508,8 +540,10 @@ class GameFlow { // Update the game state with the actual response time this.gameState.actualResponseTimeForBang = actualResponseTimeForBang; } else { + responseMessage += `Your Word was ${this.gameState.shootingWordSelector}. Better luck next time!\n\n` this.gameState.actualResponseTimeForBang = 9; // Set a high time to indicate a miss } + return responseMessage; } }