Based on the reference implementation, we'll create the following components:
#[component]
#[derive(Copy)]
pub struct PlayerComponent {
pub name: String,
pub cash: u64,
pub position: u8,
pub jail_turns: u8,
pub properties: Vec<u8>, // Indices of owned properties
}
#[component]
#[derive(Copy)]
pub struct PropertyComponent {
pub name: String,
pub color: u8, // Enum index
pub cost: u64,
pub rent: [u64; 6], // Base rent + 1-4 houses + hotel
pub house_cost: u64,
pub hotel_cost: u64,
pub owner: Option<u8>,
pub houses: u8,
}
#[component]
#[derive(Copy)]
pub struct GameStateComponent {
pub current_player: u8,
pub free_parking_pool: u64,
pub community_chest_index: u8,
pub chance_index: u8,
}
- Handles dice rolling and player movement
- Manages passing GO
- Triggers property landing events
- Handles jail entry/exit
- Handles property purchases
- Manages rent collection
- Implements house/hotel building
- Handles property trading (future enhancement)
- Implements Chance card effects
- Implements Community Chest card effects
- Manages card deck state
- Handles all monetary transactions
- Manages free parking pool
- Processes tax payments
// Create world instance
const worldPda = FindWorldPda(worldId);
const initWorldIx = createInitializeNewWorldInstruction({
world: worldPda,
registry: registryPda,
payer: provider.wallet.publicKey,
});
// Initialize board state
const boardEntity = FindEntityPda(worldId, new anchor.BN(0));
const propertyComponents = initializeProperties(boardEntity);
// Initialize players
const playerEntities = initializePlayers(worldId, playerCount);
- Player turns managed by GameState component
- Movement system processes dice rolls and movement
- Property/Card systems handle landing outcomes
- Bank system processes all financial transactions
- All game state stored in components as Solana accounts
- PDAs used for deterministic account derivation
- Component updates handled through system instructions
- Initialize project with bolt-cli
- Create basic components (Player, Property)
- Implement World Program structure
- Implement Movement System
- Add Property System for basic buying/rent
- Create Bank System for transactions
- Add Card System
- Implement house/hotel building
- Add jail mechanics
- Unit tests for all systems
- Integration tests for game flow
- Deployment to Solana testnet/mainnet
- Use PDAs for all game-related accounts
- Implement proper account validation
- Handle account size limits appropriately
- Batch operations where possible
- Implement proper error handling
- Consider transaction size limits
- Implement proper access controls
- Validate all state transitions
- Ensure atomic operations
- Test each system independently
- Verify component state changes
- Test edge cases and error conditions
- Test complete game flows
- Verify cross-system interactions
- Test concurrent operations
- Deploy to testnet
- Verify gas costs
- Test with multiple players