UNPKG

@hhoangphuoc/escape-room-cli

Version:

A CLI for playing AI-generated escape room games. Install globally with: npm install -g @hhoangphuoc/escape-room-cli

28 lines (27 loc) 804 B
// escape-room-cli/source/hooks/useGame.ts import { useState } from 'react'; const initialState = { gameId: null, roomName: 'Loading...', roomBackground: 'Please wait or type /help.', gameMode: 'unknown', unlockedObjects: [], currentRoomObjects: [], totalRooms: 1, }; export const useGame = () => { const [gameState, setGameState] = useState(initialState); const setGame = (data) => { setGameState(prev => ({ ...prev, ...data })); }; const resetGame = () => { setGameState(initialState); }; const unlockObject = (objectName) => { setGameState(prev => ({ ...prev, unlockedObjects: [...prev.unlockedObjects, objectName] })); }; return { ...gameState, setGame, resetGame, unlockObject }; };