A turn-based RPG combat simulator built in C# (.NET), where heroes and enemies clash in tactical group encounters. Features a full class hierarchy with characters, items, spells, and an encounter engine that drives the entire battle logic.
The system simulates group battles between heroes and enemies. Each character has base stats (attack, defense, health) and can be equipped with items that modify those values. Battles play out round by round until one side is completely wiped out.
| Class | Attack | Defense | Health | Equipment |
|---|---|---|---|---|
Knight |
150 | 100 | 300 | Sword, Shield, Armor |
Wizard |
50 | 80 | 150 | Staff, SpellsBook |
Archer |
90 | 30 | 100 | Bow, Armor |
Dwarves |
70 | 50 | 400 | Axe, Helmet, Shield |
Elves |
50 | 20 | 300 | SpellsBook |
Giant |
100 | 0 | 500 | — |
| Class | Attack | Defense | Health | Victory Points |
|---|---|---|---|---|
Goblin |
30 | 10 | 50 | 10 |
Zombie |
20 | 5 | 80 | 15 |
Skeleton |
25 | 15 | 40 | 12 |
Devil |
60 | 40 | 150 | 50 |
The Encounter class drives the battle:
- Enemies attack first — each enemy targets a hero by rotation (enemy
iattacks heroi % N). - Surviving heroes counterattack — each hero attacks every living enemy.
- Victory points — when a hero kills an enemy, they earn that enemy's VP. Reaching 5+ accumulated VP triggers a full heal.
- Battle ends when all heroes or all enemies are dead.
Damage is calculated as: attacker's total attack − defender's total defense. If defense exceeds attack, no damage is dealt.
Items are split by function:
- Offensive (
IOffensiveItem): add to attack —Sword,Axe,Bow,Staff - Defensive (
IDefensiveItem): add to defense —Shield,Armor,Helmet - Mixed —
SpellsBookimplements both interfaces. Its attack and defense values are computed dynamically from theSpellobjects loaded into it.
The design is built around a clean inheritance and interface hierarchy:
ICharacter
└── Character (abstract)
├── Heroes (abstract)
│ ├── Knight
│ ├── Wizard
│ ├── Archer
│ ├── Dwarves
│ ├── Elves
│ └── Giant
└── Enemies (abstract)
├── Goblin
├── Zombie
├── Skeleton
└── Devil
IItem
├── IOffensiveItem → Sword, Axe, Bow, Staff, SpellsBook
└── IDefensiveItem → Shield, Armor, Helmet, SpellsBook
GetTotalAttack() and GetTotalDefense() live in Character and iterate over the equipment list — no need to override per subclass. SpellsBook is the interesting edge case: it recalculates its own attack/defense values from its spells each time those methods are called.
Program.cs sets up a sample encounter: a Giant and a fire Wizard (with a Fireball spell loaded) vs. a Goblin and a Zombie. Output logs each defeat as it happens.
- C# / .NET
- OOP: abstract classes, interfaces, inheritance, polymorphism
- Santiago Abella
- Rodrigo García
- Rodrigo Quincke
- Gerónimo Sosa