Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Java CI Build

on:
push:
branches: [ main, master ]
pull_request:
branches: [ main, master ]

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout Code
uses: actions/checkout@v3

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'

- name: Compile Java Files
run: |
cd src
javac *.java
46 changes: 46 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Terminal RPG: Design Patterns Implementation

A professional Java-based terminal RPG that demonstrates the practical use of **Creational, Structural, and Behavioral design patterns**.

## 🛡️ Core Features
- **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.

## 🏗️ Architectural Design Patterns

### 1. Factory Method (Creational)
The character creation logic is encapsulated in `playerFactory.java`. This decouples the `Main` class from the specific subclasses, adhering to the **Open/Closed Principle**.

### 2. Decorator (Structural)
The `PlayerDecorator` system allows for dynamic stat modifications. Buffs like `DMGBuff`, `HPBuff`, and the secret `CheatBuff` wrap the player object, favoring **Composition over Inheritance**.

### 3. Strategy / Polymorphism (Behavioral)
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.

## 📊 Class Diagram (Mermaid)
```mermaid
classDiagram
Player <|-- Knight
Player <|-- Archer
Player <|-- Tank
Player <|-- PlayerDecorator
PlayerDecorator o-- Player
PlayerDecorator <|-- DMGBuff
PlayerDecorator <|-- HPBuff
playerFactory ..> Player : Creates
```
## 🚀 How to Run
1. Navigate to the src directory.
2. 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.
1 change: 1 addition & 0 deletions src/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,6 @@ public static void main(String[] args) {
}

Game.play(p, input, rand);
input.close();
}
}
Loading