A dark fantasy turn-based RPG built with Rust, demonstrating advanced trait systems, resource management, and interactive combat mechanics.
- Resource Management: Each class has unique resources (Mana, Rage, Energy)
- Special Abilities: Powerful skills with resource costs and strategic timing
- Dynamic Combat Menu: Real-time display of available abilities and costs
- Interactive Inventory: Use items during combat or from the inventory menu
- Resource: Rage (50 + 5/level)
- Special: Shield Bash - Deals 2x attack damage (Costs 20 Rage)
- High HP and armor for survivability
- Resource: Mana (80 + 10/level)
- Special: Fireball - Deals 3x intelligence damage (Costs 30 Mana)
- Powerful spells but lower health
- Resource: Energy (100 + 10/level)
- Special: Backstab - Critical strike for 3x damage (Costs 40 Energy)
- Balanced stats with high burst damage
# Clone the repository
git clone https://github.com/yourusername/emberlight.git
cd emberlight
# Build and run
cargo run --releaseCharacter Selection
- Choose your class: Warrior, Mage, or Rogue
- Enter your character name
Combat
[1]Attack - Basic attack with no resource cost[2]Special - Use your class's special ability (if you have enough resources)[3]Potion - Quick-use a Health Potion[4]Inventory - Open interactive inventory to use items
Main Menu (Between Battles)
[1]Continue Quest - Face the next enemy[2]Stats - View your character statistics[3]Inventory - View your items and gold[4]Rest & Quit - End your adventure
pub trait Character { /* Health, Level, Name */ }
pub trait ResourcePool { /* Mana/Rage/Energy management */ }
pub trait Combat { /* Attack, Special abilities */ }
pub trait Fighter: Character + Combat + ResourcePool {}src/
โโโ main.rs # Game loop and core logic
โโโ character/ # Character traits and classes
โ โโโ mod.rs
โ โโโ traits.rs # Trait definitions
โ โโโ warrior.rs
โ โโโ mage.rs
โ โโโ rogue.rs
โโโ enemy.rs # Enemy types and AI
โโโ inventory/ # Items and inventory system
โ โโโ mod.rs
โ โโโ item.rs
โโโ ui.rs # Display and UI utilities
- Resources are consumed when using special abilities
- Strategic decision: Save resources for powerful attacks or use basic attacks?
- Different resource pools encourage unique playstyles
- Player chooses action (Attack, Special, Potion, Inventory)
- Damage is calculated and applied
- Check for enemy defeat
- Enemy counterattacks
- Check for player defeat
- Repeat
- Defeat enemies to earn gold
- Find Health Potions after even-numbered encounters
- Face increasingly difficult enemies (Goblins โ Orcs โ Dragons)
- Survive as many encounters as possible
- โ
Proper error handling with
Resulttypes - โ Trait objects for polymorphism
- โ Private fields with accessor methods
- โ Const values for magic numbers
- โ Derive macros (Debug, Clone, PartialEq)
- โ Zero clippy warnings
- โ Formatted with rustfmt
- Clean separation of concerns (UI, Combat, Character, Inventory)
- Type-safe resource management
- Extensible item system
- Well-documented code structure
This project is licensed under the MIT License - see the LICENSE file for details.
Contributions are welcome! Feel free to:
- Report bugs
- Suggest new features
- Add new character classes
- Implement new items and abilities
- Improve the UI/UX
- More character classes (Paladin, Ranger, etc.)
- Equipment system (Weapons, Armor)
- Skill trees and leveling
- Save/Load game functionality
- Multiple enemy types per encounter
- Boss battles with special mechanics
- Story mode with narrative elements
- Multiplayer arena mode
This project demonstrates:
- Trait-based polymorphism in Rust
- Resource management patterns
- Interactive CLI application design
- Modular code organization
- State management in game loops
Perfect for learning Rust through game development!
Built with โค๏ธ using Rust