Compare commits
No commits in common. "6371945969b1d45b6ffb3590963599e68bbc7096" and "4cb45aa8b08e2e61fc777548542016dc8fe0581c" have entirely different histories.
6371945969
...
4cb45aa8b0
|
@ -715,7 +715,7 @@ class GameFlow {
|
||||||
];
|
];
|
||||||
|
|
||||||
// Simulating the shooting subroutine
|
// Simulating the shooting subroutine
|
||||||
handleShooting(userInput?: string): string {
|
private handleShooting(userInput?: string): string {
|
||||||
|
|
||||||
let responseMessage = ''
|
let responseMessage = ''
|
||||||
|
|
||||||
|
|
|
@ -11,57 +11,7 @@ export class RidersPhase {
|
||||||
case 1: // Choice Logic
|
case 1: // Choice Logic
|
||||||
await RidersPhase.choiceLogic(gameState, gameFlow, userInput);
|
await RidersPhase.choiceLogic(gameState, gameFlow, userInput);
|
||||||
break;
|
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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,17 +65,14 @@ export class RidersPhase {
|
||||||
if (Math.random() > 0.2) gameState.hostileRiders = !gameState.hostileRiders;
|
if (Math.random() > 0.2) gameState.hostileRiders = !gameState.hostileRiders;
|
||||||
|
|
||||||
if (gameState.hostileRiders) RidersPhase.hostileRidersLogic(gameState, gameFlow)
|
if (gameState.hostileRiders) RidersPhase.hostileRidersLogic(gameState, gameFlow)
|
||||||
else RidersPhase.friendlyRidersLogic(gameState, gameFlow);
|
|
||||||
|
|
||||||
}
|
// Handle tactics choice
|
||||||
|
|
||||||
static async hostileRidersLogic(gameState: GameState, gameFlow: GameFlow): Promise<void> {
|
|
||||||
switch (gameState.tacticsChoiceWhenAttacked) {
|
switch (gameState.tacticsChoiceWhenAttacked) {
|
||||||
case 1: // RUN
|
case 1: // RUN
|
||||||
gameState.totalMileageWholeTrip += 20
|
gameState.totalMileageWholeTrip += gameState.hostileRiders ? 20 : 15;
|
||||||
gameState.amountSpentOnAnimals -= 40
|
gameState.amountSpentOnAnimals -= gameState.hostileRiders ? 40 : 10;
|
||||||
gameState.amountSpentOnMiscellaneousSupplies -= 15
|
gameState.amountSpentOnMiscellaneousSupplies -= gameState.hostileRiders ? 15 : 0;
|
||||||
gameState.amountSpentOnAmmunition -= 150
|
gameState.amountSpentOnAmmunition -= gameState.hostileRiders ? 150 : 0;
|
||||||
|
|
||||||
gameState.phase = PHASE_ENUM.EVENT;
|
gameState.phase = PHASE_ENUM.EVENT;
|
||||||
gameState.subPhase = 0;
|
gameState.subPhase = 0;
|
||||||
|
@ -136,14 +83,30 @@ export class RidersPhase {
|
||||||
gameState.save()
|
gameState.save()
|
||||||
return gameFlow.executeCurrentPhase()
|
return gameFlow.executeCurrentPhase()
|
||||||
case 3: // CONTINUE
|
case 3: // CONTINUE
|
||||||
//Penalize lost initiative if riders are hostile
|
if (gameState.hostileRiders) {
|
||||||
gameState.lastPrompt = "You continue on cautiously, keeping your guard up. THE RIDERS ATTACK!\n\n";
|
//Penalize lost initiative if riders are hostile
|
||||||
gameState.totalMileageWholeTrip -= 5;
|
gameState.lastPrompt = "You continue on cautiously, keeping your guard up. THE RIDERS ATTACK!\n\n";
|
||||||
gameState.amountSpentOnAmmunition -= 100;
|
gameState.totalMileageWholeTrip -= 5;
|
||||||
gameState.subPhase = 2;
|
gameState.amountSpentOnAmmunition -= 100;
|
||||||
gameState.save()
|
gameState.subPhase = 2;
|
||||||
return gameFlow.executeCurrentPhase()
|
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();
|
||||||
case 4: // CIRCLE WAGONS
|
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.subPhase = 4;
|
||||||
gameState.lastPrompt = "You formed a defensive circle with your wagons.THE RIDERS ATTACK!\n\n"
|
gameState.lastPrompt = "You formed a defensive circle with your wagons.THE RIDERS ATTACK!\n\n"
|
||||||
gameState.save()
|
gameState.save()
|
||||||
|
@ -155,41 +118,70 @@ export class RidersPhase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static async friendlyRidersLogic(gameState: GameState, gameFlow: GameFlow): Promise<void> {
|
static async hostileRidersLogic(gameState: GameState, gameFlow: GameFlow): Promise<void> {
|
||||||
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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue