develop #1

Open
Z.Gharagozloo.M wants to merge 14 commits from develop into main
6 changed files with 72 additions and 22 deletions
Showing only changes of commit 3804297a29 - Show all commits
@@ -3,12 +3,14 @@ package org.project.entity.players;
import org.project.entity.Entity; import org.project.entity.Entity;
import org.project.entity.enemies.Enemy; import org.project.entity.enemies.Enemy;
import org.project.item.armors.Armor; import org.project.item.armors.Armor;
import org.project.item.weapons.Sword;
import org.project.item.weapons.Weapon; import org.project.item.weapons.Weapon;
import java.util.ArrayList; import java.util.ArrayList;
public class Knight extends Player { public class Knight extends Player {
Sword sword = new Sword()
public Knight(String name, Weapon weapon, Armor armor) { public Knight(String name, Weapon weapon, Armor armor) {
super(name, 45, 45, weapon, armor); super(name, 45, 45, weapon, armor);
} }
@@ -23,12 +25,11 @@ public class Knight extends Player {
} }
//Consuming mana //Consuming mana
super.setMp(super.getMp()-15); super.setMp(getMp()-15);
//Stunning the enemies //Stunning the enemies
target.takeDamage(25); if (getWeapon() instanceof Sword) {
if (target instanceof Enemy) { ((Sword) getWeapon()).uniqueAbility(target);
((Enemy) target).setStunned(true);
} }
System.out.println("💥 Shield Bash! Enemy is stunned!"); System.out.println("💥 Shield Bash! Enemy is stunned!");
@@ -1,31 +1,54 @@
package org.project.item.armors; package org.project.item.armors;
// TODO: UPDATE IMPLEMENTATION import org.project.entity.Entity;
public abstract class Armor { import org.project.item.Item;
public abstract class Armor implements Item {
private int defense; private int defense;
private int maxDefense; private int maxDefense;
private int durability; private int durability;
private int maxDurability; private int maxDurability;
private boolean isBroke; private boolean isBroke;
public Armor(int defense, int durability) { public Armor(int defense, int durability) {
this.defense = defense; this.defense = defense;
this.durability = durability; this.durability = durability;
this.maxDefense = defense;
this.maxDurability = durability;
this.isBroke = false;
} }
public void checkBreak() { public void checkBreak() {
if (durability <= 0) { if (durability <= 0) {
isBroke = true; isBroke = true;
defense = 0; defense = 0;
durability = 0;
System.out.println("Armor is broken!");
} }
} }
// TODO: (BONUS) UPDATE THE REPAIR METHOD
public void repair() { public void repair() {
if (isBroke) {
isBroke = false; isBroke = false;
defense = maxDefense; defense = maxDefense;
durability = maxDurability; durability = maxDurability;
System.out.println("🔧 Armor repaired! Defense: " + defense + ", Durability: " + durability);
}
else {
System.out.println("Armor is not broken. No need to repair.");
}
}
public void reduceDurability(int amount) {
if (!isBroke) {
durability -= amount;
checkBreak();
}
}
@Override
public void use(Entity target) {
System.out.println("🛡️ " + getClass().getSimpleName() + " equipped. Defense: " + defense);
} }
public int getDefense() { public int getDefense() {
@@ -0,0 +1,7 @@
package org.project.item.armors;
public class AssassinMask extends Armor {
public AssassinMask() {
super(4, 20);
}
}
@@ -1,6 +1,8 @@
package org.project.item.armors; package org.project.item.armors;
// TODO: UPDATE IMPLEMENTATION //The knight's armor
public class KnightArmor { public class KnightArmor extends Armor {
// TODO: DESIGN ARMOR'S ATTRIBUTES IMPLEMENT THE CONSTRUCTOR public KnightArmor() {
super(5, 25);
}
} }
@@ -0,0 +1,8 @@
package org.project.item.armors;
//The Wizard's armor
public class WizardRobe extends Armor {
public WizardRobe() {
super(3, 15);
}
}
@@ -1,23 +1,32 @@
package org.project.item.weapons; package org.project.item.weapons;
import org.project.entity.Entity; import org.project.entity.Entity;
import org.project.entity.enemies.Enemy;
import org.project.item.Item; import org.project.item.Item;
import java.util.ArrayList; import java.util.ArrayList;
//The knight's weapon //The knight's weapon
public class Sword extends Weapon implements Item { public class Sword extends Weapon {
int abilityCharge; private int abilityCharge;
public Sword(int damage, int manaCost) { public Sword() {
super(damage, manaCost); super(10, 8);
this.abilityCharge = 0; this.abilityCharge = 0;
} }
public void uniqueAbility(ArrayList<Entity> targets) { //Bonus method
public void uniqueAbility(Entity target) {
abilityCharge += 2; abilityCharge += 2;
for (Entity target : targets) { int totalDamage = getDamage() + (abilityCharge / 2);
target.takeDamage(getDamage());
target.takeDamage(totalDamage);
if (target instanceof Enemy) {
((Enemy) target).setStunned(true);
} }
} }
public int getAbilityCharge() {
return abilityCharge;
}
} }