DEV Community

San Kang
San Kang

Posted on

๐Ÿง™โ€โ™‚๏ธ Mini Project 2 - RPG Simulator v1.0 (with Python) ๐ŸŽฎ

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)

I'll use random.choice() and basic conditionals to implement this logic.


๐Ÿ”ง Refactoring Plan (Next Steps)

  1. 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)
  2. Unified Data Structures

    • Merge individual variables like HP and MP into a single dictionary per character
    • Include calculated values like attack and spell damage
  3. 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

Python #MiniProject #TextBasedGame #RPG #SoloLearn #ChatGPT

Top comments (0)