|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +Dark Shuffle is a deck-building game built on Starknet. It uses: |
| 8 | +- **Frontend**: React 18 + Vite + Material-UI |
| 9 | +- **Smart Contracts**: Cairo 2.10.1 with Dojo Engine v1.5.0 |
| 10 | +- **Blockchain**: Starknet Layer 2 |
| 11 | + |
| 12 | +## Essential Commands |
| 13 | + |
| 14 | +### Local Development |
| 15 | + |
| 16 | +**Start the full development environment:** |
| 17 | +```bash |
| 18 | +# Terminal 1: Start local blockchain (Katana) |
| 19 | +./scripts/contracts.sh |
| 20 | + |
| 21 | +# Terminal 2: Start indexer (Torii) - wait for Katana to be ready |
| 22 | +./scripts/indexer.sh |
| 23 | + |
| 24 | +# Terminal 3: Start frontend |
| 25 | +./scripts/client.sh |
| 26 | +``` |
| 27 | + |
| 28 | +### Frontend Commands (run from `client/` directory) |
| 29 | +```bash |
| 30 | +pnpm install # Install dependencies |
| 31 | +pnpm dev # Start dev server (with --force flag) |
| 32 | +pnpm build # Production build |
| 33 | +pnpm lint # Run ESLint |
| 34 | +pnpm preview # Preview production build |
| 35 | +``` |
| 36 | + |
| 37 | +### Smart Contract Commands (run from `contracts/` directory) |
| 38 | +```bash |
| 39 | +sozo build # Build contracts |
| 40 | +sozo test # Run all tests |
| 41 | +sozo migrate # Deploy to local Katana |
| 42 | +scarb fmt # Format Cairo code |
| 43 | +scarb fmt --check # Check formatting (used in CI) |
| 44 | +``` |
| 45 | + |
| 46 | +### Testing |
| 47 | +```bash |
| 48 | +# Run a single contract test |
| 49 | +sozo test -f test_function_name |
| 50 | + |
| 51 | +# Frontend has no test command defined - check for test files before suggesting tests |
| 52 | +``` |
| 53 | + |
| 54 | +## Architecture |
| 55 | + |
| 56 | +### Directory Structure |
| 57 | +- `client/` - React frontend |
| 58 | + - `src/api/` - Blockchain integration (indexer, starknet) |
| 59 | + - `src/battle/` - Battle logic and utilities |
| 60 | + - `src/components/` - React components |
| 61 | + - `src/contexts/` - State management |
| 62 | +- `contracts/` - Cairo smart contracts |
| 63 | + - `src/models/` - Game data models (ECS entities) |
| 64 | + - `src/systems/` - Game logic (ECS systems) |
| 65 | + - `src/utils/` - Contract utilities |
| 66 | +- `scripts/` - Development and deployment scripts |
| 67 | + |
| 68 | +### Key Concepts |
| 69 | + |
| 70 | +**Dojo Engine**: The game uses Dojo's Entity Component System (ECS) pattern: |
| 71 | +- **Models** define game state (entities and components) |
| 72 | +- **Systems** implement game logic that modifies state |
| 73 | +- **World** is the deployed game instance containing all systems and models |
| 74 | + |
| 75 | +**Game Flow**: |
| 76 | +1. Players connect wallet via Cartridge Controller |
| 77 | +2. Draft phase: Select cards to build a deck |
| 78 | +3. Map navigation: Progress through game stages |
| 79 | +4. Battle phase: Turn-based card battles with on-chain logic |
| 80 | +5. Achievements: Track player accomplishments |
| 81 | + |
| 82 | +### Important Files |
| 83 | + |
| 84 | +**Entry Points**: |
| 85 | +- `client/src/main.jsx` - Frontend entry |
| 86 | +- `contracts/dojo_world_sepolia.toml` - Deployment config |
| 87 | +- `contracts/src/lib.cairo` - Contract entry |
| 88 | + |
| 89 | +**Game Logic**: |
| 90 | +- `contracts/src/systems/draft.cairo` - Card selection |
| 91 | +- `contracts/src/systems/battle.cairo` - Combat logic |
| 92 | +- `contracts/src/models/game.cairo` - Core game state |
| 93 | + |
| 94 | +**Monster Abilities**: Each creature has unique abilities in: |
| 95 | +- `contracts/src/systems/monster_abilities/` |
| 96 | +- `client/src/battle/creature/abilities/` |
| 97 | + |
| 98 | +### Development Workflow |
| 99 | + |
| 100 | +1. **Contract Changes**: |
| 101 | + - Modify Cairo files |
| 102 | + - Run `sozo build` to verify compilation |
| 103 | + - Run `sozo test` for affected systems |
| 104 | + - Run `scarb fmt` before committing |
| 105 | + |
| 106 | +2. **Frontend Changes**: |
| 107 | + - GraphQL queries are generated from `client/src/queries/` |
| 108 | + - Card assets are in `client/src/assets/cards/` |
| 109 | + - Battle animations use Lottie files in `client/src/assets/animations/` |
| 110 | + |
| 111 | +3. **Adding New Features**: |
| 112 | + - Define models in `contracts/src/models/` |
| 113 | + - Implement systems in `contracts/src/systems/` |
| 114 | + - Update frontend queries and components |
| 115 | + - Copy new manifest to client after migration |
| 116 | + |
| 117 | +### Deployment Environments |
| 118 | + |
| 119 | +- **Local**: Katana + Torii (development) |
| 120 | +- **Sepolia**: Testnet deployment |
| 121 | +- **Mainnet**: Production deployment |
| 122 | +- **Slot**: Cartridge infrastructure deployment |
| 123 | + |
| 124 | +Each environment has its own manifest file (`manifest_*.json`) generated after deployment. |
0 commit comments