From 01a2825fc060253e158c43e49dc0b82384d1f86d Mon Sep 17 00:00:00 2001 From: j Date: Mon, 25 Mar 2024 23:59:01 -0400 Subject: [PATCH] potential input handling --- src/game/gameSession.ts | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/src/game/gameSession.ts b/src/game/gameSession.ts index e1d4f11..7e8bbdb 100644 --- a/src/game/gameSession.ts +++ b/src/game/gameSession.ts @@ -14,17 +14,30 @@ class GameSession { this.gameManager = new GameFlow(this.gameState); } - /** - * Processes player actions and updates the game state accordingly. - * @param action The player's action. - * @param params Optional parameters for the action. - */ - public async processAction(action: string, params?: any): Promise { - // Update the game state based on the action. - // This might include changing locations, spending money, hunting for food, etc. - await this.gameManager.handleAction(action, params); - // Save the current game state to allow resuming later. - this.saveGameState(); + async handleUserInput(userId: string, input: string): Promise { + const gameState = await this.loadGameState(userId); + + switch (input.split(' ')[0].toLowerCase()) { + case "!!oregon": + await this.processCommand(gameState, input); + break; + // Additional commands as necessary + } + + await this.saveGameState(gameState); + } + + private async processCommand(gameState: GameState, command: string): Promise { + const args = command.split(' '); + // Process different game setup commands (e.g., "start over", "buy supplies") + if (args[1].toLowerCase() === "startover") { + gameState.reset(); // Resets game state to initial values + } else if (args[1].toLowerCase() === "buysupplies") { + // Transition to handling purchases + // This would involve setting the next expected action in the game state + // And possibly sending a prompt for the first purchase + } + // Handle other commands and shopping logic } /**