A Pokemon-like battle simulator written in Rust, demonstrating key Rust programming concepts.
Educational Project: This project follows the Rustmon case study from the Italian Rust documentation. It demonstrates Rust concepts through a familiar gaming domain with extensive documentation.
Disclaimer: Pokemon is a trademark of Nintendo/Game Freak/The Pokemon Company. This project is not affiliated with, endorsed by, or associated with Nintendo. This is a fan project for educational purposes only.
rustmon/
βββ src/
β βββ lib.rs # Library root and module organization
β βββ main.rs # Simple battle example (binary)
β βββ types.rs # 18 Pokemon types and effectiveness system
β βββ moves.rs # Move definitions and categories
β βββ traits.rs # Battler trait for polymorphic behavior
β βββ pokemon.rs # Pokemon data structures
β βββ battle.rs # Battle simulation with generic functions
βββ examples/
βββ bevy_simulation.rs # Optional Bevy ECS integration example
- Complete Type System: All 18 Pokemon types with accurate effectiveness
- Trait-Based Design: Battler trait enables polymorphic battle functions
- Generic Programming: Battle functions work with any type implementing Battler
- Ownership Patterns: Demonstrates immutable/mutable borrowing
- Pattern Matching: Exhaustive type effectiveness matching
- Optional Bevy Integration: ECS example (feature-gated)
cargo runcargo run --example bevy_simulation --features bevy_integrationcargo testcargo doc --openThis project demonstrates key Rust concepts:
// Immutable borrow for reading stats
fn print_stats<B: Battler>(battler: &B) { ... }
// Mutable borrow for modifying HP
fn simulate_attack<A: Battler, D: Battler>(
attacker: &A, // Read-only
defender: &mut D, // Can be modified
move_used: &Move
) { ... }match (attack_type, defender_type) {
(Fire, Grass | Ice | Bug | Steel) => 2.0, // Super effective
(Electric, Ground) => 0.0, // No effect
_ => 1.0, // Normal
}pub trait Battler {
fn name(&self) -> &str;
fn current_hp(&self) -> u32;
// ... required methods
// Default implementations
fn can_battle(&self) -> bool { self.current_hp() > 0 }
fn calculate_damage<D: Battler>(&self, defender: &D, move_used: &Move) -> u32 { ... }
}All modules include comprehensive documentation with examples. View with:
cargo doc --openMIT License - See LICENSE file for details.
This project is not affiliated with, endorsed by, or associated with Nintendo, Game Freak, or The Pokemon Company.