-
Notifications
You must be signed in to change notification settings - Fork 6
Description
📚 Overview
Implement the core game state management structures and logic for the Monopoly game, including tracking game status, player turns, dice rolls, game items, and game lifecycle (new, restart, terminate). This enables the contract to manage ongoing games with multiple players, their actions, and game conditions on Starknet.
🛠️ Tasks
Define GameCounter struct to keep track of unique game IDs and current count.
Define GameBalance struct for player balances within games.
Define Game struct with fields for:
Game ID, creator, initialization status, status (Pending/Ongoing/Ended)
Game mode (SinglePlayer/MultiPlayer)
Player turn info (next_player, player_chance, has_thrown_dice)
Dice roll info (rolls_count, rolls_times, dice_face)
Number of players, winner info, and game condition array
Board items and corresponding player assignments (hat, car, dog, etc.)
Implement GameTrait with methods:
new() to create a new game with initialized state
restart() to reset a game’s dynamic state for replay
terminate_game() to mark a game as ended
Define enums for GameStatus and GameMode to represent game phases and play styles
Use zero address constant for resetting player addresses
Ensure all game state fields are properly initialized and updated
✅ Definition of Done
New games can be created with full initial state setup
Games can be restarted resetting dynamic game state variables
Games can be terminated changing their status to Ended
Enums properly represent game status and mode with clear transitions
Game state reflects player turns, dice rolls, and board item ownerships
The game struct and trait methods conform to Starknet contract standards
🔧 Technical Considerations
Use contract_address_const::<0x0>() as the zero address for resetting addresses
Implement careful state mutation inside restart() and terminate_game() methods
Ensure serialization and storage compatibility with Dojo’s model and Starknet
Handle concurrency or reentrancy concerns when updating game states
Design for extensibility (e.g., adding more game modes or items)
Validate all inputs during game creation to avoid invalid game states