Compare commits

..

No commits in common. "398465db02509365d2acf1d40a6dd4138f600ce7" and "2ba372f6fd12e0ecffb2f52af68d6957f4070713" have entirely different histories.

3 changed files with 4 additions and 6 deletions

View File

@ -12,6 +12,8 @@ class GameFlow {
async executeCurrentPhase(userInput?: string) {
this.cleanupGameState();
if (userInput && userInput?.toLowerCase().indexOf('restart') >= 0) this.gameState = await this.gameState.reset();
switch (this.gameState.phase) {
case PHASE_ENUM.SETUP:
// Handle the setup phase, e.g., initial purchases
@ -127,7 +129,7 @@ class GameFlow {
switch (this.gameState.subPhase) {
case 0:
// Weapons Purchase Subphase
if (!userInput || userInput === 'start' || userInput === 'restart') {
if (!userInput || userInput === 'start') {
// Send instructions to the user for the current subphase
responseMessage = `${MessageService.getRandomMessage(
MessageFileName.Oregon_WeaponPurchase,

View File

@ -58,7 +58,6 @@ class GameState {
* Saves the current game state to the database.
*/
public async save() {
console.log(`Saving game state to database... Phase: ${this.phase} SubPhase: ${this.subPhase} Cash: ${this.cashLeftAfterInitialPurchases}`);
await DatabaseService.saveGameState(this.authorId, this);
}

View File

@ -14,10 +14,7 @@ class WorkflowOrchestrator {
try {
const parsedComment = CommentParser.parseCommand(comment)
if (parsedComment.command === "") return
let gameState = await GameState.load(comment)
if (parsedComment.command === 'restart') gameState = await gameState.reset();
const gameState = await GameState.load(comment)
const gameFlow = new GameFlow(gameState)
await gameFlow.executeCurrentPhase(parsedComment.command)
await gameState.save()