Compare commits
2 Commits
2ba372f6fd
...
398465db02
Author | SHA1 | Date |
---|---|---|
|
398465db02 | |
|
51a9aa3ee6 |
|
@ -12,8 +12,6 @@ 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
|
||||
|
@ -129,7 +127,7 @@ class GameFlow {
|
|||
switch (this.gameState.subPhase) {
|
||||
case 0:
|
||||
// Weapons Purchase Subphase
|
||||
if (!userInput || userInput === 'start') {
|
||||
if (!userInput || userInput === 'start' || userInput === 'restart') {
|
||||
// Send instructions to the user for the current subphase
|
||||
responseMessage = `${MessageService.getRandomMessage(
|
||||
MessageFileName.Oregon_WeaponPurchase,
|
||||
|
|
|
@ -58,6 +58,7 @@ 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);
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,10 @@ class WorkflowOrchestrator {
|
|||
try {
|
||||
const parsedComment = CommentParser.parseCommand(comment)
|
||||
if (parsedComment.command === "") return
|
||||
const gameState = await GameState.load(comment)
|
||||
|
||||
let gameState = await GameState.load(comment)
|
||||
if (parsedComment.command === 'restart') gameState = await gameState.reset();
|
||||
|
||||
const gameFlow = new GameFlow(gameState)
|
||||
await gameFlow.executeCurrentPhase(parsedComment.command)
|
||||
await gameState.save()
|
||||
|
|
Loading…
Reference in New Issue