SYSTEMS / 2026

Mini RPG Battle

A terminal RPG with combat, loot, bosses, and save files.

MY ROLE
Solo project
KEY RESULT
JSON save and load, 3 passing pytest tests
TEAM
Built on my own.

How a request flows

  1. Menu loopTerminal input
  2. BattleTurn-based rules
  3. Player stateInventory, pity counters
  4. JSON fileSave and load

Why

Games are a compact way to practise state: health, inventory, levels, and saves all have to stay consistent.

What I built

  1. 01

    Separated combat, progression, inventory, and terminal output into their own classes and functions.

  2. 02

    Built turn-based combat, boss encounters with a pity counter, weighted loot, and player progression.

  3. 03

    Added JSON save and load for player state, with pytest tests.

See it run

python main.py
==========================================
          ⚔   WARRIOR'S PATH   ⚔
==========================================
  Name:    Hero
  Level:   0    XP: 0
  HP:      [**********----------] 100/200
  ATK:     15    DEF: 5
------------------------------------------
  [1]  Fight      [2]  Inventory (0 items)
  [3]  Equip      [4]  Use Item
  [5]  Exit       [6]  Save     [7]  Load
==========================================
  Choose: 1
==========================================
  Battle: Hero vs Enemy
==========================================
  You deal 10 damage.   Enemy HP: 90
  Enemy deals 10 damage.  Your HP: 190
  ...
  You deal 10 damage.   Enemy HP: 0
  Stats upgraded! ATK: 25 | DEF: 10
  Level: 0 | XP: 50
  Loot: Rusty Dagger
  *** Victory! Survived 10 rounds. ***
  Choose: 6
Saving Players data...
Writing File...
Player data saved sucessfully.

$ cat playerSave.json
{"KeyXP": 50, "KeyInv": [{"name": "Rusty Dagger", "type": "weapon"}],
 "KeyLvl": 0, "KeyHp": 110, "KeyMaxHp": 200, "KeyAtk": 25, "KeyDef": 10, ...}
Recorded from the real program. Input typed at each prompt is shown after it.

Outcome

A playable game whose progress survives between sessions. The session on this page was recorded from the real program.

The trade-off

Saves are plain JSON rather than pickle. JSON is readable and safe to load, but every field has to be mapped by hand in both directions.

What I learned

Keeping game rules separate from printing made the rules testable without running the game.

What I'd fix next

The save menu prints “saved successfully” before the file is written, so a failed write still reports success. I’d move the message after the write and add a test for a failed save.

Built with

  • Python
  • Object-oriented design
  • pytest
  • JSON