A professional Java-based terminal RPG that demonstrates the practical use of Creational, Structural, and Behavioral design patterns.
- Endless Survival Mode: Enemies scale in HP and Damage as you progress through stages.
- Unique Class Abilities: Knight, Archer, and Tank each have specific strategies for combat and healing.
- Dynamic Buff System: Use of decorators to add equipment or cheats at runtime.
- Retro UI: Enhanced with ANSI colors and ASCII art for an immersive experience.
The character creation logic is encapsulated in playerFactory.java. This decouples the Main class from the specific subclasses, adhering to the Open/Closed Principle.
The PlayerDecorator system allows for dynamic stat modifications. Buffs like DMGBuff, HPBuff, and the secret CheatBuff wrap the player object, favoring Composition over Inheritance.
Combat behavior is decentralized. Each class implements its own attack(), heal(), and specialAbility() logic. The game engine follows the "Tell, Don't Ask" principle by commanding the player object without checking its specific type.
classDiagram
Player <|-- Knight
Player <|-- Archer
Player <|-- Tank
Player <|-- PlayerDecorator
PlayerDecorator o-- Player
PlayerDecorator <|-- DMGBuff
PlayerDecorator <|-- HPBuff
playerFactory ..> Player : Creates
- Navigate to the src directory.
- Compile the source code:
javac *.java
3.Launch the game:
java Main
⌨️ Cheat Codes
Enter HESOYAM as your nickname to activate God Mode via the CheatBuff decorator.