diff --git a/src/game/phases/riders.ts b/src/game/phases/riders.ts index ce91d2b..a904308 100644 --- a/src/game/phases/riders.ts +++ b/src/game/phases/riders.ts @@ -11,7 +11,57 @@ export class RidersPhase { case 1: // Choice Logic await RidersPhase.choiceLogic(gameState, gameFlow, userInput); break; - + case 2: //Fight Logic + responseMessage = gameState.lastPrompt + responseMessage += gameFlow.handleShooting() + gameState.lastPrompt = responseMessage + gameState.subPhase = 3 + await gameFlow.statusUpdate(responseMessage) + await gameState.save() + break; + case 3: //Fight Outcome + if (!userInput) { + responseMessage = "Invalid input.\n\n" + responseMessage += gameState.lastPrompt + await gameFlow.statusUpdate(responseMessage) + return; + } + responseMessage += gameFlow.handleShooting(userInput.toString()); + if (gameState.shootResponseTime <= 1) { + responseMessage += `NICE SHOOTING---YOU DROVE THEM OFF!!!\n\n` + await gameFlow.statusUpdate(responseMessage) + } else if (gameState.shootResponseTime <= 4) { + responseMessage += `KINDA SLOW WITH YOUR GUN\n\n` + } else { + responseMessage += `LOUSY SHOT---YOU GOT KNIFED\nYOU HAVE TO SEE OL' DOC GARY CHESS\n\n` + gameState.injuryFlag = true + } + gameState.phase = PHASE_ENUM.EVENT; + await gameState.save(); + await gameFlow.executeCurrentPhase(); + return; + case 4: // wagon fight logic + responseMessage = gameState.lastPrompt + responseMessage += gameFlow.handleShooting() + gameState.lastPrompt = responseMessage + gameState.subPhase = 5 + await gameFlow.statusUpdate(responseMessage) + await gameState.save() + break; + case 5: // wagon fight outcome logic + if (!userInput) { + responseMessage = "Invalid input.\n\n" + responseMessage += gameState.lastPrompt + await gameFlow.statusUpdate(responseMessage) + return; + } + responseMessage += gameFlow.handleShooting(userInput.toString()); + gameState.amountSpentOnAmmunition -= gameState.shootResponseTime * 30 - 80 + gameState.totalMileageWholeTrip -= 25 + gameState.phase = PHASE_ENUM.EVENT; + await gameState.save(); + await gameFlow.executeCurrentPhase(); + return; } } @@ -65,14 +115,17 @@ export class RidersPhase { if (Math.random() > 0.2) gameState.hostileRiders = !gameState.hostileRiders; if (gameState.hostileRiders) RidersPhase.hostileRidersLogic(gameState, gameFlow) + else RidersPhase.friendlyRidersLogic(gameState, gameFlow); - // Handle tactics choice + } + + static async hostileRidersLogic(gameState: GameState, gameFlow: GameFlow): Promise { switch (gameState.tacticsChoiceWhenAttacked) { case 1: // RUN - gameState.totalMileageWholeTrip += gameState.hostileRiders ? 20 : 15; - gameState.amountSpentOnAnimals -= gameState.hostileRiders ? 40 : 10; - gameState.amountSpentOnMiscellaneousSupplies -= gameState.hostileRiders ? 15 : 0; - gameState.amountSpentOnAmmunition -= gameState.hostileRiders ? 150 : 0; + gameState.totalMileageWholeTrip += 20 + gameState.amountSpentOnAnimals -= 40 + gameState.amountSpentOnMiscellaneousSupplies -= 15 + gameState.amountSpentOnAmmunition -= 150 gameState.phase = PHASE_ENUM.EVENT; gameState.subPhase = 0; @@ -83,30 +136,14 @@ export class RidersPhase { gameState.save() return gameFlow.executeCurrentPhase() case 3: // CONTINUE - if (gameState.hostileRiders) { - //Penalize lost initiative if riders are hostile - gameState.lastPrompt = "You continue on cautiously, keeping your guard up. THE RIDERS ATTACK!\n\n"; - gameState.totalMileageWholeTrip -= 5; - gameState.amountSpentOnAmmunition -= 100; - gameState.subPhase = 2; - gameState.save() - return gameFlow.executeCurrentPhase() - } - // No additional action if riders are friendly - gameState.lastPrompt = "The riders continue on their way without incident.\n\n"; - gameState.phase = PHASE_ENUM.EVENT; - gameState.subPhase = 0; - gameState.save(); - return gameFlow.executeCurrentPhase(); + //Penalize lost initiative if riders are hostile + gameState.lastPrompt = "You continue on cautiously, keeping your guard up. THE RIDERS ATTACK!\n\n"; + gameState.totalMileageWholeTrip -= 5; + gameState.amountSpentOnAmmunition -= 100; + gameState.subPhase = 2; + gameState.save() + return gameFlow.executeCurrentPhase() case 4: // CIRCLE WAGONS - if (!gameState.hostileRiders) { - gameState.totalMileageWholeTrip -= 20; - gameState.lastPrompt = "You formed a defensive circle with your wagons. The riders continue on their way without incident.\n\n"; - gameState.phase = PHASE_ENUM.EVENT; - gameState.subPhase = 0; - gameState.save(); - return gameFlow.executeCurrentPhase() - } gameState.subPhase = 4; gameState.lastPrompt = "You formed a defensive circle with your wagons.THE RIDERS ATTACK!\n\n" gameState.save() @@ -118,70 +155,41 @@ export class RidersPhase { } } - static async hostileRidersLogic(gameState: GameState, gameFlow: GameFlow): Promise { + static async friendlyRidersLogic(gameState: GameState, gameFlow: GameFlow): Promise { + switch (gameState.tacticsChoiceWhenAttacked) { + case 1: // RUN + gameState.totalMileageWholeTrip += 15; + gameState.amountSpentOnAnimals -= 10; + gameState.amountSpentOnMiscellaneousSupplies -= 0; + gameState.amountSpentOnAmmunition -= 0; + gameState.phase = PHASE_ENUM.EVENT; + gameState.subPhase = 0; + gameState.save(); + return gameFlow.executeCurrentPhase(); + case 2: // ATTACK + gameState.subPhase = 2; + gameState.save() + return gameFlow.executeCurrentPhase() + case 3: // CONTINUE + + gameState.lastPrompt = "The riders continue on their way without incident.\n\n"; + gameState.phase = PHASE_ENUM.EVENT; + gameState.subPhase = 0; + gameState.save(); + return gameFlow.executeCurrentPhase(); + case 4: // CIRCLE WAGONS + gameState.totalMileageWholeTrip -= 20; + gameState.lastPrompt = "You formed a defensive circle with your wagons. The riders continue on their way without incident.\n\n"; + gameState.phase = PHASE_ENUM.EVENT; + gameState.subPhase = 0; + gameState.save(); + return gameFlow.executeCurrentPhase() + + default: + // Handle unexpected input (should be unreachable due to prior validation) + console.log("Unexpected tactics choice."); + break; + } } - -} - - - - - - - - - -private async handleRidersAttack(userInput ?: string | number): Promise < void> { - // Logic for handling a riders attack - let responseMessage = '' - this.gameState.lastPrompt = responseMessage; - - switch(this.gameState.subPhase) { - - - case 1: // Choice - - break; - case 2: // Resolve fight logic - responseMessage = this.gameState.lastPrompt - responseMessage += this.handleShooting() - this.gameState.lastPrompt = responseMessage - this.gameState.subPhase = 3 - await this.statusUpdate(responseMessage) - await this.gameState.save() - break; - case 3: // Resolve fight outcome - if (!userInput) { - responseMessage = "Invalid input.\n\n" - responseMessage += this.gameState.lastPrompt - await this.statusUpdate(responseMessage) - return; - } - responseMessage += this.handleShooting(userInput.toString()); - if (this.gameState.shootResponseTime <= 1) { - responseMessage += `NICE SHOOTING---YOU DROVE THEM OFF!!!\n\n` - await this.statusUpdate(responseMessage) - } else if (this.gameState.shootResponseTime <= 4) { - responseMessage += `KINDA SLOW WITH YOUR GUN\n\n` - } else { - responseMessage += `LOUSY SHOT---YOU GOT KNIFED\nYOU HAVE TO SEE OL' DOC GARY CHESS\n\n` - this.gameState.injuryFlag = true - } - this.gameState.phase = PHASE_ENUM.ACTION_CHOICE; - await this.gameState.save(); - await this.executeCurrentPhase(); - return; - case 4: // Resolve wagon logic - responseMessage = this.gameState.lastPrompt - responseMessage += this.handleShooting() - this.gameState.lastPrompt = responseMessage - this.gameState.subPhase = 5 - await this.statusUpdate(responseMessage) - await this.gameState.save() - break; - case 5: // Resolve wagon outcome - break; -} - }