Inspiration

As a lifelong fan of RPGs like The Witcher, Skyrim, and Final Fantasy, I’ve always been fascinated by the storytelling, character progression, and immersive mechanics of role-playing games. I wanted to challenge myself to recreate a simplified but functional RPG system from scratch using TypeScript, not only to improve my skills with object-oriented programming but also to explore building a scalable game engine.

What it does

This RPG game simulates a turn-based fantasy world where characters can:

Explore a hexagonal world map made up of terrain-based locations

Acquire skills and items (weapons, potions, containers)

Interact with other characters through combat or trading

Gain temporary special effects by consuming potions

Traverse locations with health cost depending on terrain

Die and drop items when health reaches zero

Characters can either be controlled by the player or simulated via AI. The game also distinguishes between magical (e.g. Elves, Wizards) and non-magical (e.g. Humans, Dwarves) characters, affecting their available skills and item usage.

How I built it

Language & Framework: Developed using TypeScript, leveraging OOP principles for maintainable code.

Architecture: Designed using UML class diagrams before development to outline the entity relationships and game flow.

Game Engine: Built a modular structure with core classes like Character, Item, Skill, Location, and GameWorld.

Interaction Logic: Combat and trading mechanics implemented using polymorphism and interface-based design.

Testing: Wrote unit tests using Jest to validate core components like combat resolution, inventory handling, and location traversal.

Map System: Created a grid-based system representing hexagonal terrain with movement logic and health penalties.

Challenges I ran into

Designing the item system was tricky, especially implementing containers that could carry other items and still respect the two-item carry limit.

Managing character interactions (combat vs trading) with flexible logic for AI vs player decision-making required extra abstraction.

Ensuring scalability while keeping the code readable took careful thought in terms of class responsibilities and inheritance.

Creating and maintaining an effective game state across turns without bugs or state leakage.

Accomplishments that I'm proud of

Successfully modeled a complex RPG domain into well-structured, reusable TypeScript classes.

Built an extensible engine that can support new terrain types, character classes, or magic systems in future versions.

Achieved seamless gameplay logic between multiple characters, items, interactions, and map traversal.

Wrote clean, testable code that adheres to SOLID principles and could be extended into a GUI or browser-based game later.

What I learned

Deepened my understanding of TypeScript’s class system, interfaces, and strict typing in a real-world application.

Learned to translate UML diagrams into clean, maintainable code architecture.

Reinforced best practices in game state management, OOP design, and unit testing.

Appreciated the value of planning interactions on paper before jumping into code.

What's next for Rpg Game

Add a visual interface using React or Canvas API for better player interaction.

Implement save/load game states using localStorage or file-based persistence.

Expand combat with turn queues, mana, elemental resistances, and skill trees.

Include AI difficulty levels and scripted story events.

Turn it into a multiplayer experience using WebSockets for real-time interaction.

Built With

Share this project:

Updates