From 46abc5ba684018915d318abbca7284574acaedca Mon Sep 17 00:00:00 2001 From: j Date: Tue, 2 Apr 2024 22:56:16 -0400 Subject: [PATCH] cleanup --- src/game/gameSession.ts | 72 ----------------------------------------- 1 file changed, 72 deletions(-) delete mode 100644 src/game/gameSession.ts diff --git a/src/game/gameSession.ts b/src/game/gameSession.ts deleted file mode 100644 index 2aa2ceb..0000000 --- a/src/game/gameSession.ts +++ /dev/null @@ -1,72 +0,0 @@ -import GameState from './gameState'; -import GameFlow from './gameFlow'; -import { Comment } from '../rdrama/models/Comment'; -import { CommentParser } from '../rdrama/services/CommentParser'; - -class GameSession { - private gameState: GameState; - private gameFlow: GameFlow; - private authorId: number; - - private constructor(authorId: number, gameState: GameState) { - this.authorId = authorId; - this.gameState = gameState; - this.gameFlow = new GameFlow(gameState); - } - - /** - * Loads an existing game session for the given author or creates a new one if none exists. - * @param authorId The ID of the author for whom to load or create the game session. - * @returns A GameSession instance for the given author. - */ - public static async loadSession(authorId: number): Promise { - const gameState = await GameState.load(authorId); - return new GameSession(authorId, gameState); - } - - /** - * Handles user input by parsing the command and executing the corresponding action. - * @param comment The comment containing the user input. - */ - public async handleUserInput(comment: Comment): Promise { - const { command, args } = CommentParser.parseCommand(comment); - - // Process the command - switch (command) { - case 'startover': - // Example of resetting the game - this.gameState.reset(); - break; - case 'buysupplies': - // Example of handling a purchase command - // Logic to handle buying supplies - break; - // Add additional cases for other commands - default: - console.error('Unrecognized command:', command); - break; - } - - // After processing the command, save any changes to the game state - await this.gameState.save(); - } - - /** - * Generates a status update message based on the current state of the game. - * @returns A string representing the current game status, formatted for display. - */ - public getStatusUpdate(): string { - // Use the GameFlow instance to generate a status message - return this.gameFlow.generateStatusMessage(); - } - - /** - * Resets the game to its initial state and saves the updated state. - */ - private async reset(): Promise { - this.gameState.reset(); - await this.gameState.save(); - } -} - -export { GameSession }; \ No newline at end of file