Compare commits

..

No commits in common. "648b8146baa03c276529b758c9e9f8b38a5a81e4" and "96ad73a3eb1539fd3c72f743153d29dcd90f8260" have entirely different histories.

4 changed files with 5 additions and 94 deletions

View File

@ -9,14 +9,13 @@ class GameFlow {
this.gameState = gameState;
}
async executeCurrentPhase(userInput?: string, previousTurnText: string = "") {
async executeCurrentPhase(userInput?: string) {
switch (this.gameState.phase) {
case PHASE_ENUM.SETUP:
// Handle the setup phase, e.g., initial purchases
await this.handleSetupPhase(userInput);
break;
case PHASE_ENUM.START_TURN:
await this.startTurn();
break;
case PHASE_ENUM.ACTION_CHOICE:
break;
@ -46,9 +45,9 @@ class GameFlow {
// Handle mountain traversal challenges
await this.handleMountain();
break;
case PHASE_ENUM.DEATH:
case PHASE_ENUM.DEATH_CHECK:
// Check if conditions leading to the player's death have been met
await this.handleDeath(previousTurnText);
await this.handleDeathCheck();
break;
default:
console.error("Unknown game phase:", this.gameState.phase);
@ -351,68 +350,6 @@ class GameFlow {
};
}
startTurn(): void {
let responseMessage = ""
// Ensure all expenditures are non-negative
this.gameState.amountSpentOnFood = Math.max(0, this.gameState.amountSpentOnFood);
this.gameState.amountSpentOnAmmunition = Math.max(0, this.gameState.amountSpentOnAmmunition);
this.gameState.amountSpentOnClothing = Math.max(0, this.gameState.amountSpentOnClothing);
this.gameState.amountSpentOnMiscellaneousSupplies = Math.max(0, this.gameState.amountSpentOnMiscellaneousSupplies);
// Round expenditures and cash to integers
this.gameState.amountSpentOnFood = Math.floor(this.gameState.amountSpentOnFood);
this.gameState.amountSpentOnAmmunition = Math.floor(this.gameState.amountSpentOnAmmunition);
this.gameState.amountSpentOnClothing = Math.floor(this.gameState.amountSpentOnClothing);
this.gameState.amountSpentOnMiscellaneousSupplies = Math.floor(this.gameState.amountSpentOnMiscellaneousSupplies);
this.gameState.cashLeftAfterInitialPurchases = Math.floor(this.gameState.cashLeftAfterInitialPurchases);
this.gameState.totalMileageWholeTrip = Math.floor(this.gameState.totalMileageWholeTrip);
// Update total mileage up through the previous turn
this.gameState.totalMileageUpThroughPreviousTurn = this.gameState.totalMileageWholeTrip;
// Handle illness and injury
if (this.gameState.illnessFlag || this.gameState.injuryFlag) {
if (this.gameState.illnessFlag && this.gameState.injuryFlag) {
responseMessage += `You were sick and and injured `
} else if (this.gameState.illnessFlag) {
responseMessage += `You were sick and `
} else {
responseMessage += `You were injured and `
}
this.gameState.cashLeftAfterInitialPurchases -= 20;
if (this.gameState.cashLeftAfterInitialPurchases < 0) {
responseMessage += `You've run out of money for the doctor\n\n`;
if (this.gameState.illnessFlag && this.gameState.injuryFlag) {
responseMessage += `You died of dysentery.\n\n`
} else {
responseMessage += `${MessageService.getRandomMessage(
MessageFileName.Oregon_SickInjuredDeath,
{}
)}`
}
this.gameState.phase = PHASE_ENUM.DEATH;
this.executeCurrentPhase(undefined, responseMessage)
return;
// Consider adding logic to handle game over state
} else {
responseMessage += `The Doctors bill was $20\n\n`
}
this.gameState.injuryFlag = false;
this.gameState.illnessFlag = false;
}
// Warn the player if food is low
if (this.gameState.amountSpentOnFood < 13) {
responseMessage = `YOU'D BETTER DO SOME HUNTING OR BUY FOOD AND SOON!!!!\n\n`;
}
// Toggle fort option flag
this.gameState.fortOptionFlag = !this.gameState.fortOptionFlag;
this.gameState.phase = PHASE_ENUM.ACTION_CHOICE;
this.executeCurrentPhase(undefined, responseMessage)
}
private async handleRidersAttack(userInput?: string | number): Promise<void> {
@ -443,8 +380,7 @@ class GameFlow {
// Logic for traversing the mountains, may affect gameState
}
private async handleDeath(previousTurnText: string): Promise<void> {
console.log(previousTurnText)
private async handleDeathCheck(): Promise<void> {
// Check gameState conditions and determine if the player has died
}

View File

@ -101,5 +101,5 @@ export enum PHASE_ENUM {
RIDERS_ATTACK = 'RIDERS_ATTACK',
EVENT = 'EVENT',
MOUNTAIN = 'MOUNTAIN',
DEATH = 'DEATH',
DEATH_CHECK = 'DEATH_CHECK',
}

View File

@ -1,24 +0,0 @@
You died of a snakebite.
---END---
You died of cholera.
---END---
You died of typhoid fever.
---END---
You died of pneumonia.
---END---
You died of scurvy.
---END---
You died of tuberculosis.
---END---
You died of starvation.
---END---
You died of smallpox.
---END---
You died of a broken leg that became infected.
---END---
You died of exposure to extreme cold.
---END---
You died of heatstroke.
---END---
You died of accidental poisoning from misidentified plants.
---END---

View File

@ -9,7 +9,6 @@ export enum MessageFileName {
Oregon_AmmoPurchase = 'oregon_AmmoPurchase.txt',
Oregon_ClothingPurchase = 'oregon_ClothingPurchase.txt',
Oregon_MiscSuppliesPurchase = 'oregon_MiscSuppliesPurchase.txt',
Oregon_SickInjuredDeath = 'oregon_SickInjuredDeath.txt',
Oregon_Template = 'oregon_Template.txt',
}