A lightweight, single-file Java console RPG inspired by the epic Mahabharata. You travel abstract zones, battle spirits and shades of past warriors, gain power, and ultimately confront the Vengeful Spirit of Duryodhana.
I wanted a small, contained project where I could actively use my Java knowledge in a fun way instead of only reading or practicing isolated snippets. This game let me:
- Practice basic Java syntax and control flow in a real loop-driven program.
- Apply abstraction with a Player base class and concrete hero subclasses.
- Use inheritance / polymorphism for enemies, bosses, and the final boss.
- Experiment with randomness, scaling, and simple balance adjustments.
- Work with serialization (saving/loading state) and file I/O logging.
- Turn simple mechanics (attacks, events, progression) into something playable.
So I built a lightweight text RPG—simple enough to finish, but big enough to reinforce core Java concepts while keeping it fun.
- Three playable heroes with distinct stat profiles and growth rates:
- Arjuna: High dexterity, crit-focused, fast leveling.
- Bhima: Durable powerhouse with strong single-target hits.
- Yudhishthira: Tactical, wisdom-focused, fastest leveling & supportive scaling.
- Progressive zones with evolving descriptions and enemy pools.
- Random encounters: battles, item finds, peaceful rests, minor mixed (trap/boon) events.
- Mid-game dynamic mini-bosses and a final boss triggered at level 7.
- Permanent stat find items (HP, Strength, Dexterity, Wisdom) plus temporary crit buffs.
- Temporary critical bonuses that reset after each combat for clearer pacing.
- Scaled enemy generation with smooth difficulty curve.
- Save/Load system (savegame.dat) + session log (mahabharata_log.txt).
- Java 8+ (any modern JDK should work)
# From the CLIRPG folder
javac MahabharataRPG.java
java MahabharataRPGIf you see a prompt about an existing save, choose 1 to resume or 2 to start fresh.
- Choose your hero.
- Move across abstract map coordinates (N/S/E/W).
- Random events trigger after each move:
- Battle (common)
- Item discovery (boosts or heals)
- Minor event (trap/heal/temporary buff)
- Peaceful event (rest, blessing, or lore XP)
- Gain XP, level up, and improve stats until you reach Level 7 to trigger the final confrontation.
- Defeat the final boss to win (the save file is deleted on victory or death).
During combat you choose:
- Light Attack: Single target, accurate.
- Heavy Attack: Area-of-effect, lower accuracy per target.
- Heal: Scales with wisdom & level.
- Escape: 50% + Dexterity chance (disabled vs bosses).
Temporary crit bonuses from events only last for the current/next battle and are auto-cleared afterward.
- XP curve now ramps smoothly: quicker early levels, steadier mid-game, modest late growth.
- Enemy stats scale with your level and zone multiplier with light randomness for variation.
- Permanent stat items provide incremental power so runs feel distinct.
The game auto-saves only when you choose option 5 (Save and Quit). Files created:
- savegame.dat – serialized player & world state
- mahabharata_log.txt – chronological log of your journey
Delete
savegame.datmanually if you want to force a new run.
- Arjuna snowballs with crit buffs; stack dexterity finds.
- Bhima benefits most from permanent HP and strength gains for boss stability.
- Yudhishthira levels fastest—use the extra levels to heal efficiently and scale stats.
- Use heavy attacks when facing multiple low-HP enemies to reduce incoming damage.
- Consider retreating from rough random packs (non-boss) if HP is dangerously low.
Enjoy your journey, warrior.