This mini project is a simple text-based RPG battle simulator built using Python.
It was created as part of my learning journey after completing the SoloLearn Python course, with lots of help and code review from ChatGPT.
I'm excited to announce that version 1.0 is complete!
โ Features Implemented in v1.0
- Battle Mode Selection: Easy (vs. Fox) / Hard (vs. Dragon)
- Character Selection: Knight / Wizard
- Each character and enemy has unique stats (
str
,int
,HP
,MP
) - In-battle actions:
- Attack: based on strength, no MP cost
- Spell: based on intelligence, costs 10 MP
- MP check before casting spells
- End of battle is determined by HP reaching 0
- If the enemy is defeated by your attack, it won't counterattack
๐ Feature Planned: Smarter Dragon AI (Hard Mode)
In the next update, I plan to improve the Dragonโs behavior:
- Each turn, the Dragon will randomly choose to either:
- Perform an
attack
or - Cast a
spell
(only if it has enough MP)
- Perform an
I'll use
random.choice()
and basic conditionals to implement this logic.
๐ง Refactoring Plan (Next Steps)
-
Encapsulate Battle Logic in a Function
- Currently, the combat code for each character is repeated
- Planning to extract it into a function like
battle(player, enemy)
-
Unified Data Structures
- Merge individual variables like HP and MP into a single dictionary per character
- Include calculated values like
attack
andspell
damage
-
Clean End-of-Battle Logic
- Refactor win/lose/draw messages for better readability
- Handle draw cases more explicitly
๐ฌ Reflections
Even though this project is small, I learned a lotโfrom managing loops and conditionals to designing a basic game flow.
More importantly, I'm now thinking not just about what works, but how to structure code better.
Itโs super rewarding to see how even text-based games can grow step by step!
Stay tuned for version 1.1, where the Dragon gets... smarter ๐
๐ GitHub Repo: ๐ sankworks/rpg-simulator
Top comments (0)