A complete implementation of the classic Battleship game built on the Calimero SDK, featuring a modern React frontend and a well-architected Rust backend with comprehensive documentation.
- Classic Battleship Gameplay: 10x10 grid with standard ship fleet (1x5, 1x4, 2x3, 1x2)
- Real-time Multiplayer: Turn-based gameplay with shot proposals and acknowledgments
- Private Ship Placement: Ships are stored privately until hit
- Modern UI: Clean, intuitive React interface with integrated shot selection
- Comprehensive Validation: Strategy pattern-based validation system
- Event-Driven Architecture: Complete audit trail of all game actions
- React + TypeScript: Modern frontend with hooks and functional components
- Calimero Integration: Seamless connection to the Calimero blockchain
- Responsive Design: Clean, intuitive user interface
- Real-time Updates: Live game state synchronization
- Rust + Calimero SDK: High-performance blockchain-based game logic
- Domain-Driven Design: Well-organized modules with clear separation of concerns
- Validation Strategy Pattern: Extensible validation system
- Comprehensive Documentation: Full Rust documentation with examples
battleship/
├── app/ # React frontend
│ ├── src/
│ │ ├── pages/ # Game pages (home, login, match, play)
│ │ ├── features/ # Feature modules
│ │ └── api/ # Calimero API client
│ └── package.json
├── logic/ # Rust backend
│ ├── src/
│ │ ├── board.rs # Board and coordinate types
│ │ ├── ships.rs # Ship and fleet management
│ │ ├── players.rs # Player management and private boards
│ │ ├── game.rs # Core game logic and match management
│ │ ├── events.rs # Domain events
│ │ ├── validation.rs # Validation strategy pattern
│ │ └── lib.rs # Main application logic
│ └── Cargo.toml
├── data/ # Calimero node data
└── scripts/ # Build and deployment scripts
- Node.js 16+ and npm/pnpm
- Rust 1.70+
- Calimero SDK
- Git
-
Clone the repository
git clone <repository-url> cd battleship
-
Install frontend dependencies (via root scripts)
pnpm run app:install
-
Build the backend (WASM)
pnpm run logic:build
-
Start the development servers (frontend + WASM watcher)
pnpm run app:dev
- Fleet Composition: 1x5 (carrier), 1x4 (battleship), 2x3 (cruiser, submarine), 1x2 (destroyer)
- Placement Rules: Ships must be straight, contiguous, and non-adjacent
- Coordinate Format: "x1,y1;x2,y2;..." for ship coordinates
- Turn-based: Players alternate taking shots
- Shot Process: Propose shot → Target acknowledges → Shot resolved
- Win Condition: First player to sink all opponent ships wins
The Rust backend follows Domain-Driven Design principles:
board: Board representation and coordinate managementships: Ship definitions and fleet validationplayers: Player management and private data storagegame: Core game logic and match managementevents: Domain events for decouplingvalidation: Strategy pattern-based validation system
# Build WASM (release profile used by the app)
pnpm run logic:build
# Optional: clean build artifacts
pnpm run logic:clean
# Optional: continuously watch and sync WASM into app on changes
pnpm run logic:watch
# Generate ABI client for the frontend from the latest ABI
pnpm run app:generate-client
# Low-level Rust workflows (if you need them)
cd logic
cargo check # Check for compilation errors
cargo test # Run tests
cargo doc --open # Generate and view documentationThe React frontend provides a modern, intuitive interface:
- Integrated Shot Selection: Click directly on the "Your Shots" board
- Real-time Updates: Live game state synchronization
- Responsive Design: Works on desktop and mobile devices
- Error Handling: Comprehensive error messages and validation
# Start the app + WASM res watcher together (recommended)
pnpm run app:dev
# Build production frontend
pnpm run app:build
# Preview the production build locally
pnpm run app:previewGenerate comprehensive API documentation:
cd logic
cargo doc --open- Rust Documentation: Complete API reference with examples
- TypeScript Types: Well-defined interfaces and types
- README Files: Module-specific documentation
cd logic
cargo testcd app
npm test-
Bootstrap local Calimero network with workflow
pnpm run network:bootstrap
-
Build the WASM
pnpm run logic:build
-
Sync the built WASM into the app
pnpm run logic:sync
-
Deploy to Calimero
- Follow Calimero deployment guidelines
- Upload the generated WASM file (
logic/target/wasm32-unknown-unknown/app-release/kv_store.wasm) - Configure the frontend to connect to your Calimero node
pnpm run app:build
# Deploy the app/dist (or app/build) directory to your hosting service- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Calimero SDK: For providing the blockchain infrastructure
- React Team: For the excellent frontend framework
- Rust Community: For the amazing language and ecosystem
If you have any questions or need help:
- Check the documentation
- Open an issue
- Join our community discussions
Happy Gaming! 🎮⚓