From ce7fbef913d1b3aded5312a5dab31dd94dbabc9e Mon Sep 17 00:00:00 2001 From: Baran-sys Date: Tue, 12 May 2026 01:01:30 +0300 Subject: [PATCH 1/2] input close --- src/Main.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Main.java b/src/Main.java index 84d495e..d295981 100644 --- a/src/Main.java +++ b/src/Main.java @@ -47,5 +47,6 @@ public static void main(String[] args) { } Game.play(p, input, rand); + input.close(); } } From 942869000b3286219b1c0960578cc44721d49276 Mon Sep 17 00:00:00 2001 From: Baran-sys Date: Tue, 12 May 2026 01:21:22 +0300 Subject: [PATCH 2/2] feat: add ASCII UI, ANSI colors, and HESOYAM cheat buff (closes #10) --- .github/workflows/build.yml | 26 +++++++++++++++++++++ README.md | 46 +++++++++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 .github/workflows/build.yml create mode 100644 README.md diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..b6de364 --- /dev/null +++ b/.github/workflows/build.yml @@ -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 \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..c35ac82 --- /dev/null +++ b/README.md @@ -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. \ No newline at end of file