Compare commits

..

No commits in common. "20b7a883fa91305ee8d42a38e45b9d00fb09c8a8" and "46cfe43c75b41641e7f5993c4793a69898c8dbeb" have entirely different histories.

2 changed files with 9 additions and 70 deletions

View File

@ -330,20 +330,19 @@ class GameFlow {
// Update gameState based on itemType
switch (itemType) {
case PurchaseOption.OXEN:
//Round down after multiplication
this.gameState.amountSpentOnAnimals += Math.floor(totalCost * modifier);
this.gameState.amountSpentOnAnimals += totalCost * modifier;
break;
case PurchaseOption.FOOD:
this.gameState.amountSpentOnFood += Math.floor(totalCost * modifier);
this.gameState.amountSpentOnFood += totalCost * modifier;
break;
case PurchaseOption.AMMO:
this.gameState.amountSpentOnAmmunition += Math.floor(totalCost * 50 * modifier);
this.gameState.amountSpentOnAmmunition += totalCost * 50 * modifier;
break;
case PurchaseOption.CLOTHING:
this.gameState.amountSpentOnClothing += Math.floor(totalCost * modifier);
this.gameState.amountSpentOnClothing += totalCost * modifier;
break;
case PurchaseOption.MISC:
this.gameState.amountSpentOnMiscellaneousSupplies += Math.floor(totalCost * modifier);
this.gameState.amountSpentOnMiscellaneousSupplies += totalCost * modifier;
break;
// Add cases for other item types
}
@ -461,62 +460,10 @@ class GameFlow {
return;
}
private async handleTravel(userInput?: string | number): Promise<void> {
let responseMessage = "";
if (!userInput || userInput?.toString().toLowerCase() === "start") {
responseMessage = "DO YOU WANT TO EAT\n(1) POORLY\n(2) MODERATELY\n(3) WELL: ";
this.statusUpdate(responseMessage);
return;
}
// Check if userInput is a number or can be converted to a valid number
if (isNaN(Number(userInput))) {
responseMessage = "Invalid input. Please enter a number.\n\n"
responseMessage += "DO YOU WANT TO EAT\n(1) POORLY\n(2) MODERATELY\n(3) WELL: ";
await this.statusUpdate(responseMessage);
return; // Exit if input is not a valid number
}
let eatingChoice: number = parseInt(userInput.toString(), 10);
// Validate eating choice
if (eatingChoice < 1 || eatingChoice > 3) {
responseMessage = "Invalid choice.\n\n"
responseMessage += "DO YOU WANT TO EAT\n(1) POORLY\n(2) MODERATELY\n(3) WELL: ";
await this.statusUpdate(responseMessage);
return;
}
// Calculate potential food consumption without updating the game state yet
let potentialAmountSpentOnFood = this.gameState.amountSpentOnFood - (8 + 5 * eatingChoice);
// Check if the potential amount spent on food is negative
if (potentialAmountSpentOnFood < 0) {
// If it would result in a negative value, inform the user they can't eat that well
responseMessage = "YOU CAN'T EAT THAT WELL\n\n";
responseMessage += "DO YOU WANT TO EAT\n(1) POORLY\n(2) MODERATELY\n(3) WELL: ";
await this.statusUpdate(responseMessage);
return; // Exit the method to prevent further execution
} else {
// If the amount is sufficient, update the game state with the new amount
this.gameState.amountSpentOnFood = potentialAmountSpentOnFood;
}
// Calculate total mileage
this.gameState.totalMileageWholeTrip += 200 + (this.gameState.amountSpentOnAnimals - 220) / 5 + 10 * Math.random();
this.gameState.blizzardFlag = this.gameState.insufficientClothingFlag = false;
this.gameState.phase = PHASE_ENUM.RIDERS_ATTACK;
// Save the game state after making changes
await this.gameState.save();
// Continue with the game flow
this.executeCurrentPhase();
private async handleTravel(): Promise<void> {
// Logic for handling the travel phase
}
private async handleRidersAttack(userInput?: string | number): Promise<void> {
// Logic for handling a riders attack, may involve checking userInput for response to attack
}

View File

@ -4,7 +4,6 @@ export class CommentParser {
/**
* Parses commands from the body of a single comment triggered by !!Oregon.
* If the comment contains only "!!Oregon", it treats it as a "start" command.
* Additionally, if the command or any argument is a number, it is floored.
* @param comment A single Comment object to be processed.
* @returns An object containing the command and its arguments, if any.
*/
@ -16,15 +15,8 @@ export class CommentParser {
if (match) {
// If the command is exactly "!!Oregon" with no additional command word, set command to "start"
let command = match[1] ? match[1].toLowerCase() : "start";
const numCommand = Number(command);
if (!isNaN(numCommand) && isFinite(numCommand)) {
command = Math.floor(numCommand).toString();
}
const args = match[2] ? match[2].split(' ').map(arg => {
const numArg = Number(arg);
return !isNaN(numArg) && isFinite(numArg) ? Math.floor(numArg).toString() : arg;
}) : [];
const command = match[1] ? match[1].toLowerCase() : "start";
const args = match[2] ? match[2].split(' ').map(arg => arg.trim()) : [];
return { command, args };
}