Compare commits

..

No commits in common. "04335c5b4199e2640570e7a6a16b7aac7ca0f3ab" and "da9b7f9114a2a1166d7dc6d01218b6fc8de462ec" have entirely different histories.

5 changed files with 9 additions and 44 deletions

View File

@ -114,13 +114,12 @@ class GameFlow {
} }
private async handleSetupPhase(userInput?: string): Promise<void> { private async handleSetupPhase(userInput?: string): Promise<void> {
userInput = userInput?.toLowerCase()
let responseMessage = ""; let responseMessage = "";
// Logic to handle initial setup // Logic to handle initial setup
switch (this.gameState.subPhase) { switch (this.gameState.subPhase) {
case 0: case 0:
// Weapons Purchase Subphase // Weapons Purchase Subphase
if (!userInput || userInput === 'start') { if (!userInput) {
// Send instructions to the user for the current subphase // Send instructions to the user for the current subphase
responseMessage = `${MessageService.getRandomMessage( responseMessage = `${MessageService.getRandomMessage(
MessageFileName.Oregon_WeaponPurchase, MessageFileName.Oregon_WeaponPurchase,
@ -137,10 +136,6 @@ class GameFlow {
} else { } else {
// If there was an error, include the error message in responseMessage // If there was an error, include the error message in responseMessage
responseMessage = `${purchaseResult.errorMessage}`; responseMessage = `${purchaseResult.errorMessage}`;
responseMessage += `\n\n${MessageService.getRandomMessage(
MessageFileName.Oregon_WeaponPurchase,
{}
)}`
// Do not advance subphase; possibly prompt the same instructions with an error message // Do not advance subphase; possibly prompt the same instructions with an error message
} }
} }
@ -159,10 +154,6 @@ class GameFlow {
return this.handleSetupPhase(); // Call setup phase again for next subphase return this.handleSetupPhase(); // Call setup phase again for next subphase
} else { } else {
responseMessage = purchaseResult.errorMessage || ''; responseMessage = purchaseResult.errorMessage || '';
responseMessage += `\n\n${MessageService.getRandomMessage(
MessageFileName.Oregon_OxenPurchase,
{}
)}`
} }
} }
break; break;
@ -180,10 +171,6 @@ class GameFlow {
return this.handleSetupPhase(); // Call setup phase again for next subphase return this.handleSetupPhase(); // Call setup phase again for next subphase
} else { } else {
responseMessage = purchaseResult.errorMessage || ''; responseMessage = purchaseResult.errorMessage || '';
responseMessage += `\n\n${MessageService.getRandomMessage(
MessageFileName.Oregon_FoodPurchase,
{}
)}`
} }
} }
break; break;
@ -201,10 +188,6 @@ class GameFlow {
return this.handleSetupPhase(); // Call setup phase again for next subphase return this.handleSetupPhase(); // Call setup phase again for next subphase
} else { } else {
responseMessage = purchaseResult.errorMessage || ''; responseMessage = purchaseResult.errorMessage || '';
responseMessage += `\n\n${MessageService.getRandomMessage(
MessageFileName.Oregon_AmmoPurchase,
{}
)}`
} }
} }
break; break;
@ -222,10 +205,6 @@ class GameFlow {
return this.handleSetupPhase(); // Call setup phase again for next subphase return this.handleSetupPhase(); // Call setup phase again for next subphase
} else { } else {
responseMessage = purchaseResult.errorMessage || ''; responseMessage = purchaseResult.errorMessage || '';
responseMessage += `\n\n${MessageService.getRandomMessage(
MessageFileName.Oregon_ClothingPurchase,
{}
)}`
} }
} }
break; break;
@ -243,10 +222,6 @@ class GameFlow {
return this.handleSetupPhase(); // Call setup phase again for next subphase return this.handleSetupPhase(); // Call setup phase again for next subphase
} else { } else {
responseMessage = purchaseResult.errorMessage || ''; responseMessage = purchaseResult.errorMessage || '';
responseMessage += `\n\n${MessageService.getRandomMessage(
MessageFileName.Oregon_MiscSuppliesPurchase,
{}
)}`
} }
} }
break; break;

View File

@ -77,14 +77,6 @@ class GameState {
} }
} }
/**
* Resets the current game state by saving the current state and then resetting the game state in the database.
*/
public async reset() {
await DatabaseService.saveGameState(this.authorId, this);
await DatabaseService.resetGameState(this.authorId)
}
} }
export default GameState export default GameState

View File

@ -4,7 +4,7 @@
📅 **Date:** {date} 📅 **Date:** {date}
💰 **Available Funds:** ${money} 💰 **Available Funds:** ${money}
🧭 **Distance Travelled:** {totalMileage} 🧭 **Distance Travelled:** {totalMilage}
<details> <details>
<summary>🛒 Current Supplies</summary> <summary>🛒 Current Supplies</summary>

View File

@ -2,11 +2,11 @@
Please select from the following options by replying with **!!Oregon [choice]**: Please select from the following options by replying with **!!Oregon [choice]**:
- 1. **Frontiersman's Sharpshooter Rifle** - $200 (Best accuracy and range) 1. **Frontiersman's Sharpshooter Rifle** - $200 (Best accuracy and range)
- 2. **Pioneer's Long Rifle** - $150 (Improved accuracy and range) 2. **Pioneer's Long Rifle** - $150 (Improved accuracy and range)
- 3. **Settler's Carbine** - $100 (Good balance of cost and performance) 3. **Settler's Carbine** - $100 (Good balance of cost and performance)
- 4. **Homesteader's Musket** - $75 (Reliable but not as accurate) 4. **Homesteader's Musket** - $75 (Reliable but not as accurate)
- 5. **Grandpa's Rusty Shotgun** - Free (Least accurate but no cost) 5. **Grandpa's Rusty Shotgun** - Free (Least accurate but no cost)
**Note:** Your choice of weapon can greatly affect your hunting success and defense against threats on the trail. Choose wisely! **Note:** Your choice of weapon can greatly affect your hunting success and defense against threats on the trail. Choose wisely!

View File

@ -3,19 +3,17 @@ import { Comment } from '../models/Comment';
export class CommentParser { export class CommentParser {
/** /**
* Parses commands from the body of a single comment triggered by !!Oregon. * 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.
* @param comment A single Comment object to be processed. * @param comment A single Comment object to be processed.
* @returns An object containing the command and its arguments, if any. * @returns An object containing the command and its arguments, if any.
*/ */
public static parseCommand(comment: Comment): { command: string, args: string[] } { public static parseCommand(comment: Comment): { command: string, args: string[] } {
if (comment.is_bot) return { command: '', args: [] }; if (comment.is_bot) return { command: '', args: [] };
const commandTrigger: RegExp = /!!Oregon\s*(\w+)?(?:\s+(.*))?/i; const commandTrigger: RegExp = /!!Oregon\s+(\w+)(?:\s+(.*))?/i;
const match = comment.body.match(commandTrigger); const match = comment.body.match(commandTrigger);
if (match) { if (match) {
// If the command is exactly "!!Oregon" with no additional command word, set command to "start" const command = match[1].toLowerCase();
const command = match[1] ? match[1].toLowerCase() : "start";
const args = match[2] ? match[2].split(' ').map(arg => arg.trim()) : []; const args = match[2] ? match[2].split(' ').map(arg => arg.trim()) : [];
return { command, args }; return { command, args };
} }