From 95c9181cf3589bcaaf00586bd69d9163a7d5ca08 Mon Sep 17 00:00:00 2001 From: Fateme Azizi Date: Tue, 5 May 2026 14:40:32 +0330 Subject: [PATCH 01/21] add Assassin.java and Wizard.java --- .../src/main/java/org/project/entity/players/Assassin.java | 4 ++++ .../src/main/java/org/project/entity/players/Wizard.java | 4 ++++ 2 files changed, 8 insertions(+) create mode 100644 Java-Knight/src/main/java/org/project/entity/players/Assassin.java create mode 100644 Java-Knight/src/main/java/org/project/entity/players/Wizard.java diff --git a/Java-Knight/src/main/java/org/project/entity/players/Assassin.java b/Java-Knight/src/main/java/org/project/entity/players/Assassin.java new file mode 100644 index 0000000..2fb2ede --- /dev/null +++ b/Java-Knight/src/main/java/org/project/entity/players/Assassin.java @@ -0,0 +1,4 @@ +package org.project.entity.players; + +public class Assassin { +} diff --git a/Java-Knight/src/main/java/org/project/entity/players/Wizard.java b/Java-Knight/src/main/java/org/project/entity/players/Wizard.java new file mode 100644 index 0000000..db87a41 --- /dev/null +++ b/Java-Knight/src/main/java/org/project/entity/players/Wizard.java @@ -0,0 +1,4 @@ +package org.project.entity.players; + +public class Wizard { +} -- 2.54.0 From 8894866b6838944bf9066ada097e238ff87d7a21 Mon Sep 17 00:00:00 2001 From: Fateme Azizi Date: Tue, 5 May 2026 14:52:15 +0330 Subject: [PATCH 02/21] add AssassinWeapon and KnightWeapon and WizardWeapon --- .../main/java/org/project/item/weapons/AssassinWeapon.java | 4 ++++ .../src/main/java/org/project/item/weapons/KnightWeapon.java | 4 ++++ .../src/main/java/org/project/item/weapons/WizardWeapon.java | 4 ++++ 3 files changed, 12 insertions(+) create mode 100644 Java-Knight/src/main/java/org/project/item/weapons/AssassinWeapon.java create mode 100644 Java-Knight/src/main/java/org/project/item/weapons/KnightWeapon.java create mode 100644 Java-Knight/src/main/java/org/project/item/weapons/WizardWeapon.java diff --git a/Java-Knight/src/main/java/org/project/item/weapons/AssassinWeapon.java b/Java-Knight/src/main/java/org/project/item/weapons/AssassinWeapon.java new file mode 100644 index 0000000..798ef18 --- /dev/null +++ b/Java-Knight/src/main/java/org/project/item/weapons/AssassinWeapon.java @@ -0,0 +1,4 @@ +package org.project.item.weapons; + +public class AssassinWeapon { +} diff --git a/Java-Knight/src/main/java/org/project/item/weapons/KnightWeapon.java b/Java-Knight/src/main/java/org/project/item/weapons/KnightWeapon.java new file mode 100644 index 0000000..20e9263 --- /dev/null +++ b/Java-Knight/src/main/java/org/project/item/weapons/KnightWeapon.java @@ -0,0 +1,4 @@ +package org.project.item.weapons; + +public class KnightWeapon { +} diff --git a/Java-Knight/src/main/java/org/project/item/weapons/WizardWeapon.java b/Java-Knight/src/main/java/org/project/item/weapons/WizardWeapon.java new file mode 100644 index 0000000..f1bbdda --- /dev/null +++ b/Java-Knight/src/main/java/org/project/item/weapons/WizardWeapon.java @@ -0,0 +1,4 @@ +package org.project.item.weapons; + +public class WizardWeapon { +} -- 2.54.0 From 494f97935e4fb9c17f715cabed0298568c2b15b2 Mon Sep 17 00:00:00 2001 From: Fateme Azizi Date: Sun, 10 May 2026 01:12:52 +0330 Subject: [PATCH 03/21] add Dragon and Goblin and Vampire --- .../src/main/java/org/project/entity/enemies/Dragon.java | 4 ++++ .../src/main/java/org/project/entity/enemies/Goblin.java | 4 ++++ .../src/main/java/org/project/entity/enemies/Vampire.java | 4 ++++ 3 files changed, 12 insertions(+) create mode 100644 Java-Knight/src/main/java/org/project/entity/enemies/Dragon.java create mode 100644 Java-Knight/src/main/java/org/project/entity/enemies/Goblin.java create mode 100644 Java-Knight/src/main/java/org/project/entity/enemies/Vampire.java diff --git a/Java-Knight/src/main/java/org/project/entity/enemies/Dragon.java b/Java-Knight/src/main/java/org/project/entity/enemies/Dragon.java new file mode 100644 index 0000000..a4ca0b9 --- /dev/null +++ b/Java-Knight/src/main/java/org/project/entity/enemies/Dragon.java @@ -0,0 +1,4 @@ +package org.project.entity.enemies; + +public class Dragon { +} diff --git a/Java-Knight/src/main/java/org/project/entity/enemies/Goblin.java b/Java-Knight/src/main/java/org/project/entity/enemies/Goblin.java new file mode 100644 index 0000000..a11e517 --- /dev/null +++ b/Java-Knight/src/main/java/org/project/entity/enemies/Goblin.java @@ -0,0 +1,4 @@ +package org.project.entity.enemies; + +public class Goblin { +} diff --git a/Java-Knight/src/main/java/org/project/entity/enemies/Vampire.java b/Java-Knight/src/main/java/org/project/entity/enemies/Vampire.java new file mode 100644 index 0000000..966c4b5 --- /dev/null +++ b/Java-Knight/src/main/java/org/project/entity/enemies/Vampire.java @@ -0,0 +1,4 @@ +package org.project.entity.enemies; + +public class Vampire { +} -- 2.54.0 From e14965a64924d1bbeba58d35cb7e834651f42976 Mon Sep 17 00:00:00 2001 From: Fateme Azizi Date: Sun, 10 May 2026 16:15:54 +0330 Subject: [PATCH 04/21] implement Entity class --- .../main/java/org/project/entity/Entity.java | 38 +++++++++++++++---- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/Java-Knight/src/main/java/org/project/entity/Entity.java b/Java-Knight/src/main/java/org/project/entity/Entity.java index 2a060f9..44db1f8 100644 --- a/Java-Knight/src/main/java/org/project/entity/Entity.java +++ b/Java-Knight/src/main/java/org/project/entity/Entity.java @@ -1,19 +1,41 @@ package org.project.entity; -public interface Entity { - void attack(Entity target); +import org.project.item.weapons.Weapon; - void defend(); +public abstract class Entity { - void heal(int health); + private Weapon weapon; + private int hp; + private int maxHP; - void fillMana(int mana); - void takeDamage(int damage); + public Entity(Weapon weapon, int hp, int maxHP) { + this.weapon = weapon; + this.hp = hp; + this.maxHP = maxHP; + } - int getMaxHP(); + public boolean isAlive() { + if(hp>0) + return true; - int getMaxMP(); + return false; + } + + public abstract void attack(Entity target); + + public void heal(int health) { + hp += health; + if (hp > maxHP) { + hp = maxHP; + } + } + + public void takeDamage(int damage) {hp -= weapon.getDamage();} + + public int getMaxHP() {return maxHP;} + public int getHP() {return hp;} + public Weapon getWeapon() {return weapon;} /* TODO: ADD OTHER REQUIRED AND BONUS METHODS -- 2.54.0 From 8decc4d7d838648496abb97959d56b22bf16c1ea Mon Sep 17 00:00:00 2001 From: Fateme Azizi Date: Sun, 10 May 2026 16:17:04 +0330 Subject: [PATCH 05/21] implement Player class --- .../org/project/entity/players/Player.java | 76 ++++++------------- 1 file changed, 25 insertions(+), 51 deletions(-) diff --git a/Java-Knight/src/main/java/org/project/entity/players/Player.java b/Java-Knight/src/main/java/org/project/entity/players/Player.java index ff5385c..64da735 100644 --- a/Java-Knight/src/main/java/org/project/entity/players/Player.java +++ b/Java-Knight/src/main/java/org/project/entity/players/Player.java @@ -4,50 +4,35 @@ import org.project.entity.Entity; import org.project.item.armors.Armor; import org.project.item.weapons.Weapon; -// TODO: UPDATE IMPLEMENTATION -public abstract class Player { + +public abstract class Player extends Entity{ protected String name; - Weapon weapon; - Armor armor; - private int hp; - private int maxHP; + private Armor armor; private int mp; private int maxMP; + private boolean defensing; - public Player(String name, int hp, int mp, Weapon weapon, Armor armor) { + public Player(String name, int hp, int maxHP, int mp, int maxMP, Weapon weapon, Armor armor) { + super(weapon, hp, maxHP); this.name = name; - this.hp = hp; this.mp = mp; - - this.weapon = weapon; + this.maxMP = maxMP; this.armor = armor; + + defensing = false; } - @Override - public void attack(Entity target) { - target.takeDamage(weapon.getDamage()); + public void lightAttack(Entity target) { + target.takeDamage(super.getWeapon().getDamage()); } - @Override - public void defend() { - // TODO - } - - @Override public void takeDamage(int damage) { - hp -= damage - armor.getDefense(); - } - - @Override - public void heal(int health) { - hp += health; - if (hp > maxHP) { - hp = maxHP; + if(!isDefensing()){ + super.takeDamage(damage); } } - @Override public void fillMana(int mana) { mp += mana; if (mp > maxMP) { @@ -55,35 +40,24 @@ public abstract class Player { } } - - public String getName() { - return name; + public boolean reduceMana(int amount) { + if(mp - amount >= 0) { + mp -= amount; + return true; + } + return false; } - public int getHp() { - return hp; - } - @Override - public int getMaxHP() { - return maxHP; - } - public int getMp() { - return mp; - } + public String getName() { return name; } - @Override - public int getMaxMP() { - return maxMP; - } + public int getMp() { return mp; } - public Weapon getWeapon() { - return weapon; - } + public int getMaxMP() { return maxMP; } - public Armor getArmor() { - return armor; - } + public Armor getArmor() { return armor; } + public boolean isDefensing() { return defensing; } + public void setDefensing(boolean defensing) {this.defensing = defensing; } } -- 2.54.0 From 021a147dcf756be76d546d62e0f86cb935fc27c2 Mon Sep 17 00:00:00 2001 From: Fateme Azizi Date: Sun, 10 May 2026 16:19:45 +0330 Subject: [PATCH 06/21] implement Knight and Wizard and Assassin classes --- .../org/project/entity/players/Assassin.java | 25 ++++++++++++- .../org/project/entity/players/Knight.java | 35 ++++++++++++++++--- .../org/project/entity/players/Wizard.java | 28 ++++++++++++++- 3 files changed, 82 insertions(+), 6 deletions(-) diff --git a/Java-Knight/src/main/java/org/project/entity/players/Assassin.java b/Java-Knight/src/main/java/org/project/entity/players/Assassin.java index 2fb2ede..a1241ad 100644 --- a/Java-Knight/src/main/java/org/project/entity/players/Assassin.java +++ b/Java-Knight/src/main/java/org/project/entity/players/Assassin.java @@ -1,4 +1,27 @@ package org.project.entity.players; -public class Assassin { +import org.project.entity.Entity; +import org.project.item.armors.Armor; +import org.project.item.weapons.Weapon; + +public class Assassin extends Player{ + + public Assassin(String name, int hp, int maxHP, int mp, int maxMP, Weapon weapon, Armor armor) { + super(name, hp, maxHP, mp, maxMP, weapon, armor); + } + + @Override + public void attack(Entity target) { + + if(reduceMana(getWeapon().getManaCost())){ //checking if the player has enough Mana + + setDefensing(true); //dodging the next incoming attack + target.takeDamage(getWeapon().getDamage() * 2); // causing more damage than normal + System.out.println(getName() + " (Assassin \uD83D\uDDE1\uFE0F) turned invisible."); + } + else{ + System.out.println(getName() + " (Assassin \uD83D\uDDE1\uFE0F) dose not have enough Mana\n" + + "Choose another action..."); + } + } } diff --git a/Java-Knight/src/main/java/org/project/entity/players/Knight.java b/Java-Knight/src/main/java/org/project/entity/players/Knight.java index 14d8fa2..da70737 100644 --- a/Java-Knight/src/main/java/org/project/entity/players/Knight.java +++ b/Java-Knight/src/main/java/org/project/entity/players/Knight.java @@ -1,6 +1,33 @@ package org.project.entity.players; -// TODO: UPDATE IMPLEMENTATION -public class Knight { - // TODO: DESIGN KNIGHT'S WEAPON AND ARMOR AND IMPLEMENT THE CONSTRUCTOR -} +import org.project.entity.Entity; +import org.project.entity.enemies.Enemy; +import org.project.item.armors.Armor; +import org.project.item.weapons.Weapon; + + +public class Knight extends Player { + + public Knight(String name, int hp, int maxHP, int mp, int maxMP, Weapon weapon, Armor armor) { + super(name, hp, maxHP, mp, maxMP, weapon, armor); + } + + @Override + public void attack(Entity target) {//heavy attack + + if(reduceMana(getWeapon().getManaCost())) { //checking if the player has enough Mana + target.takeDamage(getWeapon().getDamage()); //causing damage + + if (target instanceof Enemy) { + Enemy enemy = (Enemy) target; + enemy.setStunned(true); //stun the enemy + } + + System.out.println(getName() + " (Knight ⚔️) performed a shield bash that stunned the enemy."); + } + else{ + System.out.println(getName() + " (Knight ⚔️) dose not have enough Mana\n" + + "Choose another action..."); + } + } +} \ No newline at end of file diff --git a/Java-Knight/src/main/java/org/project/entity/players/Wizard.java b/Java-Knight/src/main/java/org/project/entity/players/Wizard.java index db87a41..3c11100 100644 --- a/Java-Knight/src/main/java/org/project/entity/players/Wizard.java +++ b/Java-Knight/src/main/java/org/project/entity/players/Wizard.java @@ -1,4 +1,30 @@ package org.project.entity.players; -public class Wizard { +import org.project.entity.Entity; +import org.project.item.armors.Armor; +import org.project.item.weapons.Weapon; + +public class Wizard extends Player{ + + public Wizard(String name, int hp, int maxHP, int mp, int maxMP, Weapon weapon, Armor armor) { + super(name, hp, maxHP, mp, maxMP, weapon, armor); + } + + + @Override + public void attack(Entity target) { //heavy attack + + Weapon weapon = super.getWeapon(); + + if(reduceMana(weapon.getManaCost())){ //checking if the player has enough Mana + + target.takeDamage(weapon.getDamage()); //causing damage + heal(20); //replenishing HP + System.out.println(getName() + " (Wizard \uD83E\uDDD9\u200D♂\uFE0F) cast a devastating spell"); + } + else{ + System.out.println(getName() + " (Wizard \uD83E\uDDD9\u200D♂\uFE0F) dose not have enough Mana\n" + + "Choose another action..."); + } + } } -- 2.54.0 From c315d5f9ed5f191740328acf7f6d9519e98f5784 Mon Sep 17 00:00:00 2001 From: Fateme Azizi Date: Mon, 11 May 2026 17:04:05 +0330 Subject: [PATCH 07/21] add PlayStats --- .../src/main/java/org/project/entity/players/PlayerStats.java | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 Java-Knight/src/main/java/org/project/entity/players/PlayerStats.java diff --git a/Java-Knight/src/main/java/org/project/entity/players/PlayerStats.java b/Java-Knight/src/main/java/org/project/entity/players/PlayerStats.java new file mode 100644 index 0000000..f66c795 --- /dev/null +++ b/Java-Knight/src/main/java/org/project/entity/players/PlayerStats.java @@ -0,0 +1,4 @@ +package org.project.entity.players; + +public class PlayerStats { +} -- 2.54.0 From adaaf565b8f21d5b09b87089d5f12ec885cf6a0f Mon Sep 17 00:00:00 2001 From: Fateme Azizi Date: Mon, 11 May 2026 20:49:53 +0330 Subject: [PATCH 08/21] add EnemyStats --- .../src/main/java/org/project/entity/enemies/EnemyStats.java | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 Java-Knight/src/main/java/org/project/entity/enemies/EnemyStats.java diff --git a/Java-Knight/src/main/java/org/project/entity/enemies/EnemyStats.java b/Java-Knight/src/main/java/org/project/entity/enemies/EnemyStats.java new file mode 100644 index 0000000..399b1da --- /dev/null +++ b/Java-Knight/src/main/java/org/project/entity/enemies/EnemyStats.java @@ -0,0 +1,4 @@ +package org.project.entity.enemies; + +public class EnemyStats { +} -- 2.54.0 From 74d11ad284cf791b4b242c881c6c35560186c157 Mon Sep 17 00:00:00 2001 From: Fateme Azizi Date: Fri, 15 May 2026 04:00:27 +0330 Subject: [PATCH 09/21] delete armor and weapon --- .../org/project/entity/enemies/Enemy.java | 45 +++++++++++-------- .../src/main/java/org/project/item/Item.java | 11 ----- .../java/org/project/item/armors/Armor.java | 42 ----------------- .../org/project/item/armors/KnightArmor.java | 6 --- .../project/item/consumables/Consumable.java | 8 ---- .../org/project/item/consumables/Flask.java | 16 ------- .../project/item/weapons/AssassinWeapon.java | 4 -- .../project/item/weapons/KnightWeapon.java | 4 -- .../java/org/project/item/weapons/Sword.java | 26 ----------- .../java/org/project/item/weapons/Weapon.java | 35 --------------- .../project/item/weapons/WizardWeapon.java | 4 -- 11 files changed, 26 insertions(+), 175 deletions(-) delete mode 100644 Java-Knight/src/main/java/org/project/item/Item.java delete mode 100644 Java-Knight/src/main/java/org/project/item/armors/Armor.java delete mode 100644 Java-Knight/src/main/java/org/project/item/armors/KnightArmor.java delete mode 100644 Java-Knight/src/main/java/org/project/item/consumables/Consumable.java delete mode 100644 Java-Knight/src/main/java/org/project/item/consumables/Flask.java delete mode 100644 Java-Knight/src/main/java/org/project/item/weapons/AssassinWeapon.java delete mode 100644 Java-Knight/src/main/java/org/project/item/weapons/KnightWeapon.java delete mode 100644 Java-Knight/src/main/java/org/project/item/weapons/Sword.java delete mode 100644 Java-Knight/src/main/java/org/project/item/weapons/Weapon.java delete mode 100644 Java-Knight/src/main/java/org/project/item/weapons/WizardWeapon.java diff --git a/Java-Knight/src/main/java/org/project/entity/enemies/Enemy.java b/Java-Knight/src/main/java/org/project/entity/enemies/Enemy.java index e019acb..aa31f17 100644 --- a/Java-Knight/src/main/java/org/project/entity/enemies/Enemy.java +++ b/Java-Knight/src/main/java/org/project/entity/enemies/Enemy.java @@ -1,34 +1,41 @@ package org.project.entity.enemies; -import org.project.item.weapons.Weapon; +import org.project.entity.Entity; +import org.project.entity.players.Player; -// TODO: UPDATE IMPLEMENTATION -public abstract class Enemy { - Weapon weapon; - private int hp; - private int mp; - public Enemy(int hp, int mp, Weapon weapon) { - this.hp = hp; - this.mp = mp; +public abstract class Enemy extends Entity { - this.weapon = weapon; + protected final EnemyStats stats; + private boolean stunned; + + public Enemy(EnemyStats stats) { + super(stats.maxHP); + this.stats = stats; + stunned = false; } @Override public void takeDamage(int damage) { - hp -= damage; + super.takeDamage(damage); + System.out.println("Your attack dealt " + damage + " damage to the enemy!"); } - public int getHp() { - return hp; + public void attack(Player target) { + if(!stunned) { + System.out.println(getType() + " attacked you!"); + target.takeDamage(stats.damage); + } + + else { + System.out.println("The enemy was stunned and missed its turn!"); + stunned = false; + } } - public int getMp() { - return mp; - } + public abstract String getType(); - public Weapon getWeapon() { - return weapon; - } + public int getXpReward() {return stats.xpReward;} + public boolean isStunned() { return stunned; } + public void setStunned(boolean stunned) {this.stunned = stunned; } } diff --git a/Java-Knight/src/main/java/org/project/item/Item.java b/Java-Knight/src/main/java/org/project/item/Item.java deleted file mode 100644 index 6d6b5ad..0000000 --- a/Java-Knight/src/main/java/org/project/item/Item.java +++ /dev/null @@ -1,11 +0,0 @@ -package org.project.item; - -import org.project.entity.Entity; - -public interface Item { - void use(Entity target); - - /* - TODO: ADD OTHER REQUIRED AND BONUS METHODS - */ -} diff --git a/Java-Knight/src/main/java/org/project/item/armors/Armor.java b/Java-Knight/src/main/java/org/project/item/armors/Armor.java deleted file mode 100644 index 7ca8774..0000000 --- a/Java-Knight/src/main/java/org/project/item/armors/Armor.java +++ /dev/null @@ -1,42 +0,0 @@ -package org.project.item.armors; - -// TODO: UPDATE IMPLEMENTATION -public abstract class Armor { - private int defense; - private int maxDefense; - private int durability; - private int maxDurability; - - private boolean isBroke; - - public Armor(int defense, int durability) { - this.defense = defense; - this.durability = durability; - } - - public void checkBreak() { - if (durability <= 0) { - isBroke = true; - defense = 0; - } - } - - // TODO: (BONUS) UPDATE THE REPAIR METHOD - public void repair() { - isBroke = false; - defense = maxDefense; - durability = maxDurability; - } - - public int getDefense() { - return defense; - } - - public int getDurability() { - return durability; - } - - public boolean isBroke() { - return isBroke; - } -} diff --git a/Java-Knight/src/main/java/org/project/item/armors/KnightArmor.java b/Java-Knight/src/main/java/org/project/item/armors/KnightArmor.java deleted file mode 100644 index eb59a46..0000000 --- a/Java-Knight/src/main/java/org/project/item/armors/KnightArmor.java +++ /dev/null @@ -1,6 +0,0 @@ -package org.project.item.armors; - -// TODO: UPDATE IMPLEMENTATION -public class KnightArmor { - // TODO: DESIGN ARMOR'S ATTRIBUTES IMPLEMENT THE CONSTRUCTOR -} \ No newline at end of file diff --git a/Java-Knight/src/main/java/org/project/item/consumables/Consumable.java b/Java-Knight/src/main/java/org/project/item/consumables/Consumable.java deleted file mode 100644 index 028e13d..0000000 --- a/Java-Knight/src/main/java/org/project/item/consumables/Consumable.java +++ /dev/null @@ -1,8 +0,0 @@ -package org.project.item.consumables; - -// TODO: UPDATE IMPLEMENTATION -public abstract class Consumable { - /* - TODO: ADD OTHER REQUIRED AND BONUS METHODS - */ -} diff --git a/Java-Knight/src/main/java/org/project/item/consumables/Flask.java b/Java-Knight/src/main/java/org/project/item/consumables/Flask.java deleted file mode 100644 index c0e7a6d..0000000 --- a/Java-Knight/src/main/java/org/project/item/consumables/Flask.java +++ /dev/null @@ -1,16 +0,0 @@ -package org.project.item.consumables; - -import org.project.entity.Entity; - -// TODO: UPDATE IMPLEMENTATION -public class Flask { - /* - THIS IS AN EXAMPLE OF A CONSUMABLE DESIGN. - */ - - // TODO: UPDATE USE METHOD - @Override - public void use(Entity target) { - target.heal(target.getMaxHP() / 10); - } -} diff --git a/Java-Knight/src/main/java/org/project/item/weapons/AssassinWeapon.java b/Java-Knight/src/main/java/org/project/item/weapons/AssassinWeapon.java deleted file mode 100644 index 798ef18..0000000 --- a/Java-Knight/src/main/java/org/project/item/weapons/AssassinWeapon.java +++ /dev/null @@ -1,4 +0,0 @@ -package org.project.item.weapons; - -public class AssassinWeapon { -} diff --git a/Java-Knight/src/main/java/org/project/item/weapons/KnightWeapon.java b/Java-Knight/src/main/java/org/project/item/weapons/KnightWeapon.java deleted file mode 100644 index 20e9263..0000000 --- a/Java-Knight/src/main/java/org/project/item/weapons/KnightWeapon.java +++ /dev/null @@ -1,4 +0,0 @@ -package org.project.item.weapons; - -public class KnightWeapon { -} diff --git a/Java-Knight/src/main/java/org/project/item/weapons/Sword.java b/Java-Knight/src/main/java/org/project/item/weapons/Sword.java deleted file mode 100644 index 96226ee..0000000 --- a/Java-Knight/src/main/java/org/project/item/weapons/Sword.java +++ /dev/null @@ -1,26 +0,0 @@ -package org.project.item.weapons; - -import org.project.entity.Entity; - -import java.util.ArrayList; - -// TODO: UPDATE IMPLEMENTATION -public class Sword { - /* - THIS IS AN EXAMPLE OF A WEAPON DESIGN. - */ - - int abilityCharge; - - public Sword() { - // TODO: DESIGN SWORD'S ATTRIBUTES IMPLEMENT THE CONSTRUCTOR - } - - // TODO: (BONUS) UPDATE THE UNIQUE ABILITY - public void uniqueAbility(ArrayList targets) { - abilityCharge += 2; - for (Entity target : targets) { - target.takeDamage(getDamage()); - } - } -} diff --git a/Java-Knight/src/main/java/org/project/item/weapons/Weapon.java b/Java-Knight/src/main/java/org/project/item/weapons/Weapon.java deleted file mode 100644 index cb9fcf2..0000000 --- a/Java-Knight/src/main/java/org/project/item/weapons/Weapon.java +++ /dev/null @@ -1,35 +0,0 @@ -package org.project.item.weapons; - -import org.project.entity.Entity; - -// TODO: UPDATE IMPLEMENTATION -public abstract class Weapon { - private int damage; - private int manaCost; - - /* - TODO: ADD OTHER REQUIRED AND BONUS ATTRIBUTES - */ - - public Weapon(int damage, int manaCost) { - this.damage = damage; - this.manaCost = manaCost; - } - - @Override - public void use(Entity target) { - target.takeDamage(damage); - } - - public int getDamage() { - return damage; - } - - public int getManaCost() { - return manaCost; - } - - /* - TODO: ADD OTHER REQUIRED AND BONUS METHODS - */ -} diff --git a/Java-Knight/src/main/java/org/project/item/weapons/WizardWeapon.java b/Java-Knight/src/main/java/org/project/item/weapons/WizardWeapon.java deleted file mode 100644 index f1bbdda..0000000 --- a/Java-Knight/src/main/java/org/project/item/weapons/WizardWeapon.java +++ /dev/null @@ -1,4 +0,0 @@ -package org.project.item.weapons; - -public class WizardWeapon { -} -- 2.54.0 From afc563822e193e81ba336aadfce661e385169116 Mon Sep 17 00:00:00 2001 From: Fateme Azizi Date: Fri, 15 May 2026 04:01:13 +0330 Subject: [PATCH 10/21] edit Entity --- .../main/java/org/project/entity/Entity.java | 29 ++++++------------- 1 file changed, 9 insertions(+), 20 deletions(-) diff --git a/Java-Knight/src/main/java/org/project/entity/Entity.java b/Java-Knight/src/main/java/org/project/entity/Entity.java index 44db1f8..24a1494 100644 --- a/Java-Knight/src/main/java/org/project/entity/Entity.java +++ b/Java-Knight/src/main/java/org/project/entity/Entity.java @@ -1,43 +1,32 @@ package org.project.entity; -import org.project.item.weapons.Weapon; - public abstract class Entity { - private Weapon weapon; private int hp; - private int maxHP; + private final int maxHP; - public Entity(Weapon weapon, int hp, int maxHP) { - this.weapon = weapon; - this.hp = hp; + public Entity(int maxHP) { + this.hp = maxHP; this.maxHP = maxHP; } public boolean isAlive() { - if(hp>0) - return true; - - return false; + return hp > 0; } - public abstract void attack(Entity target); - public void heal(int health) { hp += health; - if (hp > maxHP) { + if (hp > maxHP) hp = maxHP; - } } - public void takeDamage(int damage) {hp -= weapon.getDamage();} + public void takeDamage(int damage) { + hp -= damage; + if(hp<0) hp = 0; + } public int getMaxHP() {return maxHP;} public int getHP() {return hp;} - public Weapon getWeapon() {return weapon;} - /* - TODO: ADD OTHER REQUIRED AND BONUS METHODS - */ } -- 2.54.0 From 858649285d6b2358b0b283df1763c0f78519c6f0 Mon Sep 17 00:00:00 2001 From: Fateme Azizi Date: Fri, 15 May 2026 04:01:56 +0330 Subject: [PATCH 11/21] edit Player --- .../org/project/entity/players/Player.java | 58 ++++++++++++++----- 1 file changed, 42 insertions(+), 16 deletions(-) diff --git a/Java-Knight/src/main/java/org/project/entity/players/Player.java b/Java-Knight/src/main/java/org/project/entity/players/Player.java index 64da735..8afb7f0 100644 --- a/Java-Knight/src/main/java/org/project/entity/players/Player.java +++ b/Java-Knight/src/main/java/org/project/entity/players/Player.java @@ -1,42 +1,58 @@ package org.project.entity.players; import org.project.entity.Entity; -import org.project.item.armors.Armor; -import org.project.item.weapons.Weapon; +import org.project.entity.enemies.Enemy; +import org.project.entity.enemies.Vampire; public abstract class Player extends Entity{ + + protected final PlayerStats stats; protected String name; - private Armor armor; private int mp; - private int maxMP; private boolean defensing; + private int XP; + private boolean skeletonKey; + private boolean goblinKey; + private boolean vampireKey; - public Player(String name, int hp, int maxHP, int mp, int maxMP, Weapon weapon, Armor armor) { - super(weapon, hp, maxHP); + + public Player(String name, PlayerStats stats) { + super(stats.maxHP); this.name = name; - this.mp = mp; - this.maxMP = maxMP; - this.armor = armor; + this.mp = stats.maxMP; + this.stats = stats; + XP = 0; defensing = false; + goblinKey = false; + skeletonKey = false; + vampireKey = false; } - public void lightAttack(Entity target) { - target.takeDamage(super.getWeapon().getDamage()); - } + public void lightAttack(Enemy target) {target.takeDamage(stats.lightAttackDamage);} + + public abstract void specialAbility(Enemy target); + public abstract void heavyAttack(Enemy target); @Override public void takeDamage(int damage) { if(!isDefensing()){ super.takeDamage(damage); + System.out.println("Enemy's attack dealt " + damage + " damage to you!"); + } + else { + System.out.println("You blocked the attack!"); + defensing = false; } } + public void defend() { setDefensing(true); } + public void fillMana(int mana) { mp += mana; - if (mp > maxMP) { - mp = maxMP; + if (mp > stats.maxMP) { + mp = stats.maxMP; } } @@ -49,15 +65,25 @@ public abstract class Player extends Entity{ } + public PlayerStats getStats() {return stats;} public String getName() { return name; } public int getMp() { return mp; } - public int getMaxMP() { return maxMP; } + public int getMaxMP() { return stats.maxMP; } - public Armor getArmor() { return armor; } + public boolean hasGoblinKey() {return goblinKey;} + public boolean hasSkeletonKey() {return skeletonKey;} + public boolean hasVampireKey() {return vampireKey;} + + public void giveGoblinKey() { goblinKey = true; } + public void giveSkeletonKey() { skeletonKey = true; } + public void giveVampireKey() { vampireKey = true; } public boolean isDefensing() { return defensing; } public void setDefensing(boolean defensing) {this.defensing = defensing; } + + public int getXP() { return XP;} + public void addXP(int amount) { XP += amount; } } -- 2.54.0 From 5c066131d78424b76df5a9ae05e72ba12ea2b5e1 Mon Sep 17 00:00:00 2001 From: Fateme Azizi Date: Fri, 15 May 2026 04:03:28 +0330 Subject: [PATCH 12/21] edit Knight and Wizard and Assassin --- .../org/project/entity/players/Assassin.java | 30 ++++++++--------- .../org/project/entity/players/Knight.java | 33 ++++++++----------- .../org/project/entity/players/Wizard.java | 31 +++++++---------- 3 files changed, 39 insertions(+), 55 deletions(-) diff --git a/Java-Knight/src/main/java/org/project/entity/players/Assassin.java b/Java-Knight/src/main/java/org/project/entity/players/Assassin.java index a1241ad..2d3af03 100644 --- a/Java-Knight/src/main/java/org/project/entity/players/Assassin.java +++ b/Java-Knight/src/main/java/org/project/entity/players/Assassin.java @@ -1,27 +1,25 @@ package org.project.entity.players; -import org.project.entity.Entity; -import org.project.item.armors.Armor; -import org.project.item.weapons.Weapon; +import org.project.entity.enemies.Enemy; public class Assassin extends Player{ - public Assassin(String name, int hp, int maxHP, int mp, int maxMP, Weapon weapon, Armor armor) { - super(name, hp, maxHP, mp, maxMP, weapon, armor); + private final static PlayerStats stats = new PlayerStats(9, 12, + 17, 20, + 12, 20, 24, + 210, 75); + + public Assassin(String name) { + super(name,stats); } @Override - public void attack(Entity target) { + public void heavyAttack(Enemy target) { target.takeDamage(stats.heavyAttackDamage);} - if(reduceMana(getWeapon().getManaCost())){ //checking if the player has enough Mana - - setDefensing(true); //dodging the next incoming attack - target.takeDamage(getWeapon().getDamage() * 2); // causing more damage than normal - System.out.println(getName() + " (Assassin \uD83D\uDDE1\uFE0F) turned invisible."); - } - else{ - System.out.println(getName() + " (Assassin \uD83D\uDDE1\uFE0F) dose not have enough Mana\n" + - "Choose another action..."); - } + @Override + public void specialAbility(Enemy target) { + System.out.println("You turned invisible"); + target.takeDamage(stats.specialAbilityDamage); // causing damage + setDefensing(true); //dodging the next incoming attack } } diff --git a/Java-Knight/src/main/java/org/project/entity/players/Knight.java b/Java-Knight/src/main/java/org/project/entity/players/Knight.java index da70737..7115fde 100644 --- a/Java-Knight/src/main/java/org/project/entity/players/Knight.java +++ b/Java-Knight/src/main/java/org/project/entity/players/Knight.java @@ -1,33 +1,26 @@ package org.project.entity.players; -import org.project.entity.Entity; import org.project.entity.enemies.Enemy; -import org.project.item.armors.Armor; -import org.project.item.weapons.Weapon; public class Knight extends Player { - public Knight(String name, int hp, int maxHP, int mp, int maxMP, Weapon weapon, Armor armor) { - super(name, hp, maxHP, mp, maxMP, weapon, armor); + private final static PlayerStats stats = new PlayerStats(10, 10, + 16, 22, + 18, 28, 34, + 180, 70); + + public Knight(String name) { + super(name, stats); } @Override - public void attack(Entity target) {//heavy attack + public void heavyAttack(Enemy target) { target.takeDamage(stats.heavyAttackDamage); } - if(reduceMana(getWeapon().getManaCost())) { //checking if the player has enough Mana - target.takeDamage(getWeapon().getDamage()); //causing damage - - if (target instanceof Enemy) { - Enemy enemy = (Enemy) target; - enemy.setStunned(true); //stun the enemy - } - - System.out.println(getName() + " (Knight ⚔️) performed a shield bash that stunned the enemy."); - } - else{ - System.out.println(getName() + " (Knight ⚔️) dose not have enough Mana\n" + - "Choose another action..."); - } + @Override + public void specialAbility(Enemy target) { + target.takeDamage(stats.specialAbilityDamage); //causing damage + target.setStunned(true); //stun the enemy + System.out.println(getName() + "You performed a shield bash that stunned the enemy."); } } \ No newline at end of file diff --git a/Java-Knight/src/main/java/org/project/entity/players/Wizard.java b/Java-Knight/src/main/java/org/project/entity/players/Wizard.java index 3c11100..cd6d8ec 100644 --- a/Java-Knight/src/main/java/org/project/entity/players/Wizard.java +++ b/Java-Knight/src/main/java/org/project/entity/players/Wizard.java @@ -1,30 +1,23 @@ package org.project.entity.players; -import org.project.entity.Entity; -import org.project.item.armors.Armor; -import org.project.item.weapons.Weapon; +import org.project.entity.enemies.Enemy; public class Wizard extends Player{ - public Wizard(String name, int hp, int maxHP, int mp, int maxMP, Weapon weapon, Armor armor) { - super(name, hp, maxHP, mp, maxMP, weapon, armor); - } + private final static PlayerStats stats = new PlayerStats(11, 9, + 18, 24, + 14, 22, 30, + 240, 55); + public Wizard(String name) { super(name, stats); } @Override - public void attack(Entity target) { //heavy attack + public void heavyAttack(Enemy target) { target.takeDamage(stats.heavyAttackDamage);} - Weapon weapon = super.getWeapon(); - - if(reduceMana(weapon.getManaCost())){ //checking if the player has enough Mana - - target.takeDamage(weapon.getDamage()); //causing damage - heal(20); //replenishing HP - System.out.println(getName() + " (Wizard \uD83E\uDDD9\u200D♂\uFE0F) cast a devastating spell"); - } - else{ - System.out.println(getName() + " (Wizard \uD83E\uDDD9\u200D♂\uFE0F) dose not have enough Mana\n" + - "Choose another action..."); - } + @Override + public void specialAbility(Enemy target) { + target.takeDamage(stats.specialAbilityDamage); //causing damage + heal(20); //replenishing HP + System.out.println("You cast a devastating spell"); } } -- 2.54.0 From 6ceff6068ae59155ce2b78a4803cfa36e8d799b0 Mon Sep 17 00:00:00 2001 From: Fateme Azizi Date: Fri, 15 May 2026 04:04:34 +0330 Subject: [PATCH 13/21] implement PlayerStats --- .../project/entity/players/PlayerStats.java | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/Java-Knight/src/main/java/org/project/entity/players/PlayerStats.java b/Java-Knight/src/main/java/org/project/entity/players/PlayerStats.java index f66c795..6a71d5e 100644 --- a/Java-Knight/src/main/java/org/project/entity/players/PlayerStats.java +++ b/Java-Knight/src/main/java/org/project/entity/players/PlayerStats.java @@ -1,4 +1,35 @@ package org.project.entity.players; public class PlayerStats { + + //Mana cost + public final int heavyAttackManaCost; + public final int defendManaCost; + public final int healManaCost; + public final int specialAbilityManaCost; + + //Damages + public final int lightAttackDamage; + public final int heavyAttackDamage; + public final int specialAbilityDamage; + + + public final int maxHP; + public final int maxMP; + + public PlayerStats(int heavyAttackManaCost, int defendManaCost, int healManaCost,int specialAbilityManaCost, + int lightAttackDamage, int heavyAttackDamage, int specialAbilityDamage, int maxHP, int maxMP) { + + this.heavyAttackManaCost = heavyAttackManaCost; + this.defendManaCost = defendManaCost; + this.healManaCost = healManaCost; + this.specialAbilityManaCost = specialAbilityManaCost; + this.lightAttackDamage = lightAttackDamage; + this.heavyAttackDamage = heavyAttackDamage; + this.specialAbilityDamage = specialAbilityDamage; + this.maxHP = maxHP; + this.maxMP = maxMP; + + } + } -- 2.54.0 From b5c3f6f3385290fc626e98552283109cd9df3928 Mon Sep 17 00:00:00 2001 From: Fateme Azizi Date: Fri, 15 May 2026 04:05:13 +0330 Subject: [PATCH 14/21] implement EnemyStats --- .../java/org/project/entity/enemies/EnemyStats.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Java-Knight/src/main/java/org/project/entity/enemies/EnemyStats.java b/Java-Knight/src/main/java/org/project/entity/enemies/EnemyStats.java index 399b1da..313010a 100644 --- a/Java-Knight/src/main/java/org/project/entity/enemies/EnemyStats.java +++ b/Java-Knight/src/main/java/org/project/entity/enemies/EnemyStats.java @@ -1,4 +1,14 @@ package org.project.entity.enemies; public class EnemyStats { + + public final int maxHP; + public final int damage; + public final int xpReward; + + public EnemyStats(int maxHP, int damage, int xpReward) { + this.maxHP = maxHP; + this.damage = damage; + this.xpReward = xpReward; + } } -- 2.54.0 From cc49f6bb27419c4c229a7bfd7e34cef2f805680e Mon Sep 17 00:00:00 2001 From: Fateme Azizi Date: Fri, 15 May 2026 04:07:01 +0330 Subject: [PATCH 15/21] implement Goblin and Skeleton and Vampire --- .../org/project/entity/enemies/Goblin.java | 31 ++++++++++++++++++- .../org/project/entity/enemies/Skeleton.java | 30 ++++++++++++++++-- .../org/project/entity/enemies/Vampire.java | 23 +++++++++++++- 3 files changed, 79 insertions(+), 5 deletions(-) diff --git a/Java-Knight/src/main/java/org/project/entity/enemies/Goblin.java b/Java-Knight/src/main/java/org/project/entity/enemies/Goblin.java index a11e517..18423c9 100644 --- a/Java-Knight/src/main/java/org/project/entity/enemies/Goblin.java +++ b/Java-Knight/src/main/java/org/project/entity/enemies/Goblin.java @@ -1,4 +1,33 @@ package org.project.entity.enemies; -public class Goblin { +import org.project.entity.players.Player; + +public class Goblin extends Enemy { + + private final static EnemyStats stats = new EnemyStats(60, 12, 20); + private final double critChance; + private final double critMultiplier; + + public Goblin() { + super(stats); + critChance = 0.25; + critMultiplier = 1.8; + } + + @Override + public void attack(Player target) { + + if(Math.random() Date: Fri, 15 May 2026 04:07:40 +0330 Subject: [PATCH 16/21] implement Location --- .../main/java/org/project/location/Location.java | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/Java-Knight/src/main/java/org/project/location/Location.java b/Java-Knight/src/main/java/org/project/location/Location.java index b0b4b98..d431687 100644 --- a/Java-Knight/src/main/java/org/project/location/Location.java +++ b/Java-Knight/src/main/java/org/project/location/Location.java @@ -5,12 +5,12 @@ import org.project.entity.enemies.Enemy; import java.util.ArrayList; public class Location { - private String name; + private String name; private ArrayList enemies; - public Location(ArrayList locations, ArrayList enemies) { - this.locations = locations; + public Location(String name, ArrayList enemies) { + this.name = name; this.enemies = enemies; } @@ -18,11 +18,7 @@ public class Location { return name; } - public ArrayList getLocations() { - return locations; - } + public ArrayList getEnemies() {return enemies;} - public ArrayList getEnemies() { - return enemies; - } + public Enemy getEnemy(int index) {return enemies.get(index); } } -- 2.54.0 From 0ed88943653e857509966b9dccccfbd83b9dd048 Mon Sep 17 00:00:00 2001 From: Fateme Azizi Date: Fri, 15 May 2026 04:08:10 +0330 Subject: [PATCH 17/21] implement Main --- .../src/main/java/org/project/Main.java | 279 +++++++++++++++++- 1 file changed, 275 insertions(+), 4 deletions(-) diff --git a/Java-Knight/src/main/java/org/project/Main.java b/Java-Knight/src/main/java/org/project/Main.java index 6bde20e..4241f87 100644 --- a/Java-Knight/src/main/java/org/project/Main.java +++ b/Java-Knight/src/main/java/org/project/Main.java @@ -1,15 +1,286 @@ package org.project; +import org.project.entity.enemies.*; +import org.project.entity.players.Assassin; +import org.project.entity.players.Knight; +import org.project.entity.players.Player; +import org.project.entity.players.Wizard; import org.project.location.Location; import java.util.ArrayList; import java.util.List; +import java.util.Random; +import java.util.Scanner; public class Main { - public static void main(String[] args) { - // TODO: ADD LOCATIONS TO YOUR GAME - List locations = new ArrayList<>(); - // TODO: IMPLEMENT GAMEPLAY + private static List locations = new ArrayList<>(); + public static Player player; + private static Enemy enemy; + private static int currentLocationIndex; + + public static void main(String[] args) { + createPlayer(); + setupLocations(); + chooseLocation(); + spawnRandomEnemy(); + handleLocation(); + } + + public static void handleLocation() { + + System.out.println("What next?"); + + Scanner in = new Scanner(System.in); + while (true) { + + System.out.println("1. Fight the " + enemy.getType() + + "\n2. Go to another location\n" + + "3. Go to the Castle to fight the Dragon"); + + int choice = in.nextInt(); + + switch (choice) { + case 1: + fight(); + return; + case 2: + chooseLocation(); + spawnRandomEnemy(); + handleLocation(); + fight(); + return; + case 3: + if(player.hasGoblinKey() && player.hasVampireKey() && player.hasSkeletonKey()) { + enemy = new Dragon(); + fight(); + } + return; + default: + System.out.println("Invalid choice❌\nChoose another option: "); + break; + } + } + } + public static void fight() { + + while (player.isAlive() && enemy.isAlive()) { + + System.out.println("\n" + player.getName() + " - " + + player.getMp() + "/" + player.getMaxMP() + " MP | " + + player.getHP() + "/" + player.getMaxHP() + " HP"); + + System.out.println(enemy.getType() + " - " + + enemy.getHP() + "/" + enemy.getMaxHP() + " HP"); + + playerTurn(); + + if(enemy.isAlive()) + enemyTurn(); + } + + if(!player.isAlive()) { + System.out.println("💀 You have been defeated..."); + System.exit(0); + } + + else if(!enemy.isAlive()) { + handleEnemyDeath(); + } + } + + public static void handleEnemyDeath() { + + if(enemy instanceof Skeleton && ((Skeleton) enemy).getReviveEnabled()) { + ((Skeleton) enemy).revive(); + fight(); + } + else if(enemy instanceof Dragon) { + System.out.println("Congratulations! You defeated the Dragon and won!"); + System.exit(0); + } + else{ + System.out.println("You won the battle!"); + player.addXP(enemy.getXpReward()); + player.fillMana(player.getMaxMP()); + player.heal(player.getMaxHP()); + tryDropKey(); + locations.get(currentLocationIndex).getEnemies().remove(enemy); + spawnRandomEnemy(); + handleLocation(); + } + + } + public static String getEnemyKeyName() { + return "player.has"+enemy.getType()+"Key"; + } + + public static void tryDropKey() { + + if(Math.random()<0.2) { + if(enemy instanceof Goblin && !player.hasGoblinKey()) player.giveGoblinKey(); + else if(enemy instanceof Skeleton && !player.hasSkeletonKey()) player.giveSkeletonKey(); + else if(enemy instanceof Vampire && !player.hasVampireKey()) player.giveVampireKey(); + } + } + + + + public static void enemyTurn() { + enemy.attack(player); + } + + public static void playerTurn() { + + System.out.println("Your turn: "); + Scanner in = new Scanner(System.in); + + while (true) { + + System.out.println("1.light attack\n2.heavy attack\n3.defend\n4.heal\n5.special move"); + int choice = in.nextInt(); + + int manaCost; + + switch (choice) { + case 1: + player.lightAttack(enemy); + return; + case 2: + manaCost = player.getStats().heavyAttackManaCost; + break; + case 3: + manaCost = player.getStats().defendManaCost; + break; + case 4: + manaCost = player.getStats().healManaCost; + break; + case 5: + manaCost = player.getStats().specialAbilityManaCost; + break; + default: + System.out.println("Invalid choice❌\nChoose another option: "); + continue; + } + + if(player.reduceMana(manaCost)) { + + if(choice == 2) player.heavyAttack(enemy); + else if (choice == 3 && !(enemy instanceof Dragon)) player.defend(); + else if (choice == 4) player.heal(20); + else if(choice == 5) player.specialAbility(enemy); + + return; + } + else + System.out.println("You don't have enough Mana\nChoose another..."); + + } + } + public static void chooseLocation() { + + System.out.println("Select your destination \uD83C\uDFAF"); + + Scanner in = new Scanner(System.in); + + while (true) { + + for(int i=0 ; i0 && choice<=locations.size()) { + currentLocationIndex = choice - 1; + System.out.println("You're in " + locations.get(currentLocationIndex).getName()); + return; + } + else + System.out.println("Invalid choice❌\nChoose another option: "); + } + } + + + public static void spawnRandomEnemy() { + + ArrayList enemies = locations.get(currentLocationIndex).getEnemies(); + Random random = new Random(); + int currentEnemyIndex = random.nextInt(enemies.size()); + enemy = locations.get(currentLocationIndex).getEnemy(currentEnemyIndex); + System.out.println("You're facing a " + enemy.getType()); + + } + + + public static void setupLocations() { + + ArrayList CryptEnemies = new ArrayList<>(); + CryptEnemies.add(new Skeleton()); + CryptEnemies.add(new Goblin()); + locations.add(new Location("Crypt", CryptEnemies)); + + + ArrayList WarrensEnemies = new ArrayList<>(); + WarrensEnemies.add(new Goblin()); + WarrensEnemies.add(new Goblin()); + WarrensEnemies.add(new Skeleton()); + locations.add(new Location("Warrens️", WarrensEnemies)); + + + ArrayList ManorEnemies = new ArrayList<>(); + ManorEnemies.add(new Vampire()); + ManorEnemies.add(new Skeleton()); + locations.add(new Location("Manor️", ManorEnemies)); + + + ArrayList CourtyardEnemies = new ArrayList<>(); + CourtyardEnemies.add(new Vampire()); + CourtyardEnemies.add(new Goblin()); + CourtyardEnemies.add(new Skeleton()); + locations.add(new Location("Courtyard", CourtyardEnemies)); + + + ArrayList CatacombsEnemies = new ArrayList<>(); + CatacombsEnemies.add(new Skeleton()); + CatacombsEnemies.add(new Goblin()); + CatacombsEnemies.add(new Vampire()); + CatacombsEnemies.add(new Goblin()); + locations.add(new Location("Catacombs", CatacombsEnemies)); + + } + + + public static void createPlayer() { + + Scanner in = new Scanner(System.in); + System.out.println("Enter your name: "); + String name = in.nextLine(); + + + while (true){ + + System.out.println("Choose your character: \n" + + "1. Knight⚔️\n" + + "2. Wizard\uD83E\uDDD9\u200D♂️\n" + + "3. Assassin\uD83D\uDDE1️"); + + + int choice = in.nextInt(); + switch (choice) { + + case 1: + player = new Knight(name); + return; + case 2: + player = new Wizard(name); + return; + case 3: + player = new Assassin(name); + return; + default: + System.out.println("Invalid choice❌"); + break; + } + } } } \ No newline at end of file -- 2.54.0 From 9c1ff5c518b1d85cd09eb0a1a7851c29b68ed3f7 Mon Sep 17 00:00:00 2001 From: Fateme Azizi Date: Fri, 15 May 2026 04:08:39 +0330 Subject: [PATCH 18/21] implement Dragon --- .../src/main/java/org/project/entity/enemies/Dragon.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Java-Knight/src/main/java/org/project/entity/enemies/Dragon.java b/Java-Knight/src/main/java/org/project/entity/enemies/Dragon.java index a4ca0b9..ef716e1 100644 --- a/Java-Knight/src/main/java/org/project/entity/enemies/Dragon.java +++ b/Java-Knight/src/main/java/org/project/entity/enemies/Dragon.java @@ -1,4 +1,11 @@ package org.project.entity.enemies; -public class Dragon { +public class Dragon extends Enemy{ + private final static EnemyStats stats = new EnemyStats(360, 22, 150); + public Dragon() { super(stats); } + + @Override + public String getType() { + return "Dragon"; + } } -- 2.54.0 From 2ccaa6a06fe18d8405ad7174b778ef08195d3bee Mon Sep 17 00:00:00 2001 From: Fateme Azizi Date: Fri, 15 May 2026 16:47:07 +0330 Subject: [PATCH 19/21] edit README --- README.md | 243 ++++++++++++++++++++++-------------------------------- 1 file changed, 98 insertions(+), 145 deletions(-) diff --git a/README.md b/README.md index 1e2c975..e204ea8 100644 --- a/README.md +++ b/README.md @@ -1,175 +1,128 @@ # Fourth Assignment - Java Knight ⚔️ A turn-based RPG with Roguelike elements which can be run in the terminal. -### **Prologue: The Legend of Javanest** -*For centuries, the land of Javanest lived in peace, until a magical Dragon attacked, plunging the realm into absolute darkness. With a wicked curse, the Dragon transformed the innocent people into horrific monsters: Goblins, Skeletons, and Vampires. Retreating to its impenetrable Castle, the Dragon divided the three keys to its lair and hid them among these cursed creatures. Now, it is your duty to step up and save the land. You must battle these monsters, recover the unique key from each monster type, and finally slay the Dragon to break the curse and restore peace to Javanest!* +--- -### **Introduction** -Welcome to **Java knight**, a turn-based RPG inspired by Roguelike games! In this assignment, you will develop a **text-based role-playing game (RPG)**. This project is designed to rigorously test your understanding of **Object-Oriented Programming (OOP) principles**. - -⚠️ **REQUIREMENT:** You **must** utilize all the OOP concepts you have learned so far—including *Inheritance, Interfaces, Abstract Classes, Encapsulation, Polymorphism, Overloading, and Overriding*. It is extremely important that you use everything in its right place. Your design and architecture will be graded based on how well you apply these principles to avoid code duplication and maintain a clean structure. - -🎯 **Your goal is not just to complete the assignment but to learn and apply OOP effectively!** - -### **What is a Turn-Based Game?** -In this combat system, two sides - which are usually the player's side and the enemy's side - attack each other in turns. The side which is not attacking can perform actions to avoid or deflect the enemy's attack. - -### **Core Mechanics:** -- **Turn-based combat** – Players and monsters take turns attacking each other. -- **Character classes with Unique Traits** – Players can choose from archetypes like **Knight, Assassin, or Wizard**, each starting with distinctly different base stats. -- **Unified Mana/Stamina System** – All player classes use a unified resource (Mana/Stamina) to perform actions. -- **Standardized Action Set** – Every player character has exactly 5 specific actions available during their turn. -- **Experience & Leveling System** – Earn XP based on enemy strength to automatically level up and increase your base stats. -- **Progression System** – You cannot fight the Dragon immediately. You must farm enemies for a chance to drop their specific key, collect all three, and grow stronger first. +## Introduction +Welcome to the epic world of our RPG! In this role-playing adventure, +you step into the shoes of a valiant hero tasked with battling various monsters! --- -## Tasks 📝 - -### 1️⃣ Step 1: Fork & Setup 🍴 +## Compile and run the project 1. **Fork** this repository and clone it to your local machine. ```bash -git clone https://git.meshcomp.ir/AdvancedProgramming1404/HW-04-JAVA-KNIGHT.git + git clone https://git.meshcomp.ir/Fateme_Azizi/HW-04-JAVA-KNIGHT.git ``` -2. Create a new branch named `develop` and switch to it. +2. **Navigate** to the project directory: ```bash -git checkout -b develop +cd HW-04-JAVA-KNIGHT ``` -### 2️⃣ Step 2: Implement the Class Hierarchy 🌲 - -A well-structured OOP hierarchy is crucial. Avoid duplicating code by placing shared logic in abstract classes. - -- **Entities & Locations:** You have `Entity`, `Item`(Bonus) , and `Location`. -- **Players:** `Player` is an abstract class implementing `Entity`. Subclasses: `Wizard`, `Knight`, `Assassin`. - - **Base Stat Differences:** Each class must have distinct starting stats. For example: - - **Knight:** Highest Base Damage. - - **Wizard:** Highest Max Health (HP). - - **Assassin:** Highest Max Stamina/Mana. -- **Enemies:** `Enemy` is an abstract class implementing `Entity`. Subclasses: `Skeleton`, `Goblin`, `Vampire`, and **`Dragon`**. - - **The Boss:** Even though `Dragon` is the final boss, it **must** be a subclass of `Enemy` to inherit common combat properties, while possessing extremely high stats and unique mechanics. -- **Item (Bonus):** `Consumable`, `Armor`, `Weapon` are abstract classes implementing `Item`. example : - - KnightArmor extends Armor - you can add more subclasses of Armor for extra score - - Sword extends Weapon - you can add more subclasses of Weapon for extra score - - Flask extends Consumable - you can add more subclasses of Consumable for extra score - -![structure](Readme_Pictures/structure.png) - -### 3️⃣ Step 3: Implement Player & Monster Methods 🏹 - -**Player Actions (The Rule of Five):** -Every player class **must** implement exactly the following 5 actions (You can use an interface like `ICombatActions`). Every action (except Light Attack) consumes a specific amount of Mana/Stamina. The **Special Ability** must consume the *highest* amount of Mana compared to the others. -1. **Light Attack:** Deals moderate damage and costs **NO Mana**. (Note: If the player runs out of Mana/Stamina, this is the ONLY action they can perform.) -2. **Heavy Attack:** Deals high damage, medium Mana cost. -3. **Defend:** Completely blocks or significantly reduces the damage of the enemy's *next* strike. Medium Mana cost. -4. **Heal:** Restores a portion of the player's HP. Medium-high Mana cost. -5. **Special Ability:** A unique class-based ultimate move (Highest Mana cost): - - **Wizard** 🧙‍♂️: Casts a devastating spell that damages the enemy while simultaneously replenishing some HP. - - **Assassin** 🗡️: Turns invisible, dodging the next incoming attack completely and guaranteeing a *Critical Hit* on their next turn. - - **Knight** ⚔️: Performs a shield bash that stuns the enemy, forcing them to skip their next turn while dealing heavy damage. - -**Monster Abilities:** -- **Goblin** 👹: High critical hit chance but low health. -- **Skeleton** ☠️: Can resurrect once per battle with 50% HP. -- **Vampire** 🦇: Lifesteal ability – a portion of the damage it deals to the player is added back to its own health. -- **Dragon (Final Boss)** 🐉: Immune to normal defense. Its fiery breath bypasses shields and deals massive damage. - -🔹 Make sure each entity **prints messages** when performing actions. example output (while in combat) : - +3. **Compile** the java files ```bash -You chose to FIGHT! - -[Ser Duncan - 45/45 HP | 40/40 Mana] -[Goblin - 30/30 HP] +javac Main.java +``` +4. **Run** the code +```bash +java Main +``` +This command will run the Main class, which serves as the entry point for the application, and start the game. --- -Your Turn: -1. Light Attack | 2. Heavy Attack (-8 Mana) | 3. Defend (-6 Mana) | 4. Heal (-12 Mana) | 5. Shield Bash (-15 Mana) -``` +## Classes and OOP Principles -```bash -→ Chose: Light Attack -⚔️ Ser Duncan (Knight) used Light Attack! (0 Mana) -Goblin took 10 damage! -Goblin has 20/30 HP remaining. -Ser Duncan Mana: 40/40 -``` -``` -Goblin's Turn : -👹 Goblin used Critical Strike! -💥 Critical hit! Ser Duncan took 20 damage! -Ser Duncan has 25/45 HP remaining. -``` -🔹 *Narrative Console:* Use ANSI escape codes to print colorful narrative logs (e.g., Red for damage, Blue for Mana usage, Green for healing). +This project has been developed adhering to Object-Oriented Programming (OOP) principles and +incorporates several key design patterns to ensure the code is clean, maintainable, and scalable. + +### Core classes + +* `Entity` (Abstract): The base class for all living entities in the game (both players and enemies). + It encapsulates common attributes such as name, health, and basic stats. -### 4️⃣ Step 4: Implement the Game Loop & Progression 🎮 - -1. **The Core Loop:** The game starts with the player entering a location. A random standard enemy (`Goblin`, `Skeleton`, or `Vampire`) spawns immediately. -2. **Player Choices:** Before engaging, the player is presented with the following options: - - **1. Fight the enemy:** Enter the turn-based combat sequence. - - **2. Move to another location:** Skip the current enemy and spawn a new random one. - - **3. Go to the Castle to fight the Dragon:** *(Note: This option must remain strictly hidden or locked until the player has successfully collected all 3 keys).* -3. **The Key Drop Logic (RNG Gatekeeping):** - - When the player defeats an enemy, there is a **specific percentage chance (e.g., 20%)** that it will drop the unique key associated with its species (Goblin Key, Skeleton Key, Vampire Key). - - **One Key Per Species:** Once a player obtains a specific key (e.g., Goblin Key), subsequent enemies of that same type (other Goblins) will **never** drop a key again. - - The player **must collect all 3 distinct keys** to unlock Option 3 and enter the Castle. -4. **Post-Combat Recovery:** After each successful battle, the player's HP and Mana bars must automatically replenish (either fully or partially) to their base amounts so they are ready for the next encounter. -5. **Experience & Leveling System:** - - Defeating an enemy grants **XP**. The amount of XP must scale proportionally to the enemy's power level. - - Upon reaching an XP threshold, the player levels up. **Leveling up must automatically increase the player's Max HP and Max Stamina/Mana**, making them strong enough to eventually face the Dragon. -6. **Final Boss Fight:** Once the 3 Keys are obtained and the player chooses to go to the Castle, they will face the Dragon. Defeating the Dragon breaks the curse, resulting in **Victory**. Dying at any point results in **Game Over**. - -🔹 Example game loop structure: - -```java -while (player.isAlive() && enemy.isAlive()) - player.attack(enemy); - if (enemy.isAlive()) { - enemy.attack(player); - } -} -``` +* `Player` (Abstract): The base class for player characters. It manages player-specific attributes like XP, mana, health, and core abilities. -### 5️⃣ Step 5: Extra Features & Bonus Tasks ⭐ -*(Optional for extra credit)* +* `Assassin`, `Knight`, `Wizard`: These are subclasses of `Player`, each with unique abilities, stats, and playstyles. -✅ **Dynamic Economy & Merchant System:** Implement coins that drop from enemies. Add a "Visit Merchant" option to the main loop where players can spend coins to buy specific weapons, armors, or consumables. -✅ **Multiple Weapons & Inventory:** Players can buy, store, and swap between multiple weapons or use consumables mid-combat. -✅ **Multiplayer/Party Mode:** Allow multiple players to team up and fight multiple enemies together. The Dragon's breath attack will damage the entire party simultaneously. -✅ **PvP Mode:** Implement a **Player vs. Player** combat system. -### 6️⃣ Step 6: Write a Comprehensive README 📄 -As the final mandatory step of your development, you must replace the default `README.md` with your own comprehensive documentation. Your README should include: -- A brief introduction to the game. -- How to compile and run your project from the terminal. -- An explanation of the classes, design patterns, and OOP principles you used. -- A brief guide on how to play (controls, stats, classes). +* `Enemy` (Abstract): The base class for all monsters. It contains the fundamental logic for combat, XP rewards, and aliveness status. + + +* `Dragon`, `Goblin`, `Skeleton`, `Vampire`: These are subclasses of `Enemy`, each possessing distinct behaviors, stats, and special abilities. + + +* `EnemyStats`, `PlayerStats`: Dedicated classes for managing and holding the data for players and enemies (e.g., attack power, defense). + This promotes separation of data from the core logic of the entity classes. + + +* `Location`: Represents different areas or zones within the game world. Each location contains a list of enemies. + + +* `Main`: The primary class of the application, acting as the program's entry point. It is responsible for the initial setup, managing the main game loop, and calls to location and combat logic. + + +### OOP Principles Employed: + +* **Encapsulation**: Data (variables) and behaviors (methods) are bundled within classes. + Access to data is controlled through getter and setter methods, ensuring data integrity. + + +* **Abstraction**: Abstract classes like `Entity`, `Player`, and `Enemy` define common interfaces and behaviors without implementing all details, + allowing subclasses to provide specific implementations. + + +* **Inheritance**: Concrete classes (`Dragon`, `Assassin`) inherit properties and methods from their base classes (`Enemy`, `Player`), + extending or modifying them as needed. + + +* **Polymorphism**: Objects of different classes can be treated through a common interface. For example, calling an `attack()` method on different `Player` or `Enemy` objects will result in distinct behaviors specific to each type. --- -## Evaluation Criteria ⚖ +## Gameplay Guide +This is your guide to navigating the world, battling monsters, and becoming a legend. -| **Criteria** | **Points** | -|-------------------------------------------------------------|------------| -| Proper use of OOP principles | **50** | -| Working combat mechanics, Leveling System & Enemy abilities | **20** | -| Clear and Comprehensive `README.md` | **20** | -| Code readability, documentation, and comments | **10** | -| Meaningful, interactive, & colored console outputs | **10** | -| Inventory (item) and Merchant System (bonus) | **20** | -| Other Extra features (bonus tasks) | **20** | -| **Total Score** | **150** | +### How to Play +The game is played through text commands in your computer’s terminal. When the game asks you to do something, just type your answer and press Enter. -## Tips 🚀 -- **Follow OOP principles**: Avoid redundant code by using inheritance properly. Think carefully about what belongs in an abstract class vs. a specific subclass. Make sure you use overriding and overloading correctly. -- **Test your code**: Run different scenarios (fighting, running out of mana, leveling up, dying) to ensure everything works as expected. -- **Ask for help**: If you're stuck, reach out to your classmates or mentors. +* **Exploration**: You’ll move between different places in the game world. Each place might have different monsters. +* **Combat**: When you meet a monster, a battle will begin. You’ll need to choose your actions wisely to win. -## Submission ⌛ -- **Deadline**: Submit your assignment before **21 Ordibehesht (May 11th, 2026)**. -- **Submission Format**: Push your code to your forked repository, create a PR, and ensure your comprehensive `README.md` is included in the root directory. +### Understanding your stats +Here’s what your hero’s (and the monsters’) numbers mean: + +* **Health Points (HP)**: This is your life bar. If your HP drops to 0, you lose the battle. Keep an eye on it! +* **Attack Power**: This number shows how much damage you deal with each normal hit or spell. Higher is better! +* **Defense**: This helps reduce the damage you take from enemy attacks. A good defense keeps you in the fight longer. +* **Mana Points (MP)**: heroes use MP to do actions (only light attack doesn't use MP). +* **Experience Points (XP)**: You earn XP by winning battles against monsters. + + +### Your Hero +You can choose to be one of three types of heroes. + +Each has a special ability: + +* `Knight⚔️`: Performs a shield bash that stuns the enemy, forcing them to skip their next turn while dealing heavy damage. + +* `Wizard🧙‍♂️`: Casts a devastating spell that damages the enemy while simultaneously replenishing some HP. + +* `Assassin🗡️`: Turns invisible, dodging the next incoming attack completely and guaranteeing a Critical Hit on their next turn. + + +### Monsters You’ll Face +The world is full of creatures you’ll need to defeat: + +* `Goblin👹`: Small, common enemies. Good for practicing your fighting skills and earning early XP. +* `Skeleton☠️`: These reanimated bones can be tricky. Some might even get back up after you defeat them! +* `Vampire🦇`: Dangerous creatures that can drain your health. Be careful when fighting them! +* `Dragon🐉`: One of the most powerful enemies in the game. You’ll need to be well-prepared and use all your skills to defeat a dragon. + + +### Winning the Game +To win, you’ll need to explore, get stronger by leveling up your chosen hero, +and use your skills effectively in combat to defeat all the challenging monsters, culminating in the defeat of the most powerful threats. +Good luck on your adventure! -![cover](Readme_Pictures/image.png) -###### - Born of God and Void. You shall seal the blinding light that plagues their dreams. You are the Vessel. You are the Java Knight. \ No newline at end of file -- 2.54.0 From 676db1a2258b99c951a75cc4a4b6f2283bea1aad Mon Sep 17 00:00:00 2001 From: Fateme Azizi Date: Fri, 15 May 2026 21:14:43 +0330 Subject: [PATCH 20/21] edit player and Main --- .idea/jarRepositories.xml | 5 + .../src/main/java/org/project/Main.java | 377 +++++++++--------- .../org/project/entity/enemies/Goblin.java | 2 +- .../org/project/entity/players/Assassin.java | 2 +- .../org/project/entity/players/Knight.java | 2 +- .../org/project/entity/players/Player.java | 23 +- .../target/classes/org/project/Main.class | Bin 0 -> 7837 bytes .../classes/org/project/entity/Entity.class | Bin 0 -> 893 bytes .../org/project/entity/enemies/Dragon.class | Bin 0 -> 663 bytes .../org/project/entity/enemies/Enemy.class | Bin 0 -> 2040 bytes .../project/entity/enemies/EnemyStats.class | Bin 0 -> 465 bytes .../org/project/entity/enemies/Goblin.class | Bin 0 -> 1408 bytes .../org/project/entity/enemies/Skeleton.class | Bin 0 -> 1190 bytes .../org/project/entity/enemies/Vampire.class | Bin 0 -> 961 bytes .../org/project/entity/players/Assassin.class | Bin 0 -> 1267 bytes .../org/project/entity/players/Knight.class | Bin 0 -> 1290 bytes .../org/project/entity/players/Player.class | Bin 0 -> 3847 bytes .../project/entity/players/PlayerStats.class | Bin 0 -> 832 bytes .../org/project/entity/players/Wizard.class | Bin 0 -> 1251 bytes .../org/project/location/Location.class | Bin 0 -> 1196 bytes 20 files changed, 215 insertions(+), 196 deletions(-) create mode 100644 Java-Knight/target/classes/org/project/Main.class create mode 100644 Java-Knight/target/classes/org/project/entity/Entity.class create mode 100644 Java-Knight/target/classes/org/project/entity/enemies/Dragon.class create mode 100644 Java-Knight/target/classes/org/project/entity/enemies/Enemy.class create mode 100644 Java-Knight/target/classes/org/project/entity/enemies/EnemyStats.class create mode 100644 Java-Knight/target/classes/org/project/entity/enemies/Goblin.class create mode 100644 Java-Knight/target/classes/org/project/entity/enemies/Skeleton.class create mode 100644 Java-Knight/target/classes/org/project/entity/enemies/Vampire.class create mode 100644 Java-Knight/target/classes/org/project/entity/players/Assassin.class create mode 100644 Java-Knight/target/classes/org/project/entity/players/Knight.class create mode 100644 Java-Knight/target/classes/org/project/entity/players/Player.class create mode 100644 Java-Knight/target/classes/org/project/entity/players/PlayerStats.class create mode 100644 Java-Knight/target/classes/org/project/entity/players/Wizard.class create mode 100644 Java-Knight/target/classes/org/project/location/Location.class diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml index 4158879..4e0bf3c 100644 --- a/.idea/jarRepositories.xml +++ b/.idea/jarRepositories.xml @@ -16,5 +16,10 @@