add AssassinArmor.java DragonArmor.java GoblinArmor.java SkeletonArmor.java VampireArmor.java WizardArmor.java
This commit is contained in:
@@ -1,31 +1,77 @@
|
|||||||
package org.project.item.armors;
|
|
||||||
|
|
||||||
// TODO: UPDATE IMPLEMENTATION
|
package org.project.item.armors;
|
||||||
public abstract class Armor {
|
public class Armor {
|
||||||
|
|
||||||
|
public enum ArmorType {
|
||||||
|
LIGHT,
|
||||||
|
MEDIUM,
|
||||||
|
HEAVY
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
private ArmorType type;
|
||||||
|
|
||||||
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 isBroken;
|
||||||
|
|
||||||
public Armor(int defense, int durability) {
|
// Constructor
|
||||||
this.defense = defense;
|
public Armor(String name, ArmorType type, int maxDefense, int maxDurability) {
|
||||||
this.durability = durability;
|
this.name = name;
|
||||||
|
this.type = type;
|
||||||
|
this.maxDefense = maxDefense;
|
||||||
|
this.defense = maxDefense;
|
||||||
|
this.maxDurability = maxDurability;
|
||||||
|
this.durability = maxDurability;
|
||||||
|
this.isBroken = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void checkBreak() {
|
|
||||||
|
public int reduceDamage(int damage) {
|
||||||
|
|
||||||
|
if (isBroken) {
|
||||||
|
return damage;
|
||||||
|
}
|
||||||
|
|
||||||
|
int reducedDamage = damage - defense;
|
||||||
|
|
||||||
|
if (reducedDamage < 0) {
|
||||||
|
reducedDamage = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
reduceDurability(1);
|
||||||
|
|
||||||
|
return reducedDamage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void reduceDurability(int amount) {
|
||||||
|
durability -= amount;
|
||||||
|
|
||||||
if (durability <= 0) {
|
if (durability <= 0) {
|
||||||
isBroke = true;
|
durability = 0;
|
||||||
defense = 0;
|
breakArmor();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: (BONUS) UPDATE THE REPAIR METHOD
|
// شکستن زره
|
||||||
public void repair() {
|
private void breakArmor() {
|
||||||
isBroke = false;
|
isBroken = true;
|
||||||
defense = maxDefense;
|
defense = 0;
|
||||||
durability = maxDurability;
|
}
|
||||||
|
|
||||||
|
// ===== Getters =====
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArmorType getType() {
|
||||||
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getDefense() {
|
public int getDefense() {
|
||||||
@@ -36,7 +82,19 @@ public abstract class Armor {
|
|||||||
return durability;
|
return durability;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isBroke() {
|
public int getMaxDurability() {
|
||||||
return isBroke;
|
return maxDurability;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isBroken() {
|
||||||
|
return isBroken;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return name + " | Type: " + type +
|
||||||
|
" | Defense: " + defense +
|
||||||
|
" | Durability: " + durability + "/" + maxDurability +
|
||||||
|
(isBroken ? " (BROKEN)" : "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package org.project.item.armors;
|
||||||
|
|
||||||
|
public class AssassinArmor extends Armor {
|
||||||
|
|
||||||
|
private static final String NAME = "wizard Robe";
|
||||||
|
private static final ArmorType ARMOR_TYPE = ArmorType.HEAVY;
|
||||||
|
private static final int MAX_DEFENSE = 35;
|
||||||
|
private static final int MAX_DURABILITY = 60;
|
||||||
|
|
||||||
|
public AssassinArmor() {
|
||||||
|
super(NAME,
|
||||||
|
ARMOR_TYPE,
|
||||||
|
MAX_DEFENSE,
|
||||||
|
MAX_DURABILITY
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package org.project.item.armors;
|
||||||
|
|
||||||
|
public class DragonArmor extends Armor {
|
||||||
|
|
||||||
|
private static final String NAME = "Dragon scale armor";
|
||||||
|
private static final ArmorType ARMOR_TYPE = ArmorType.HEAVY;
|
||||||
|
private static final int MAX_DEFENSE = 40;
|
||||||
|
private static final int MAX_DURABILITY = 60;
|
||||||
|
|
||||||
|
public DragonArmor() {
|
||||||
|
super(NAME,
|
||||||
|
ARMOR_TYPE,
|
||||||
|
MAX_DEFENSE,
|
||||||
|
MAX_DURABILITY
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package org.project.item.armors;
|
||||||
|
|
||||||
|
public class GoblinArmor extends Armor {
|
||||||
|
|
||||||
|
private static final String NAME = "goblin Robe";
|
||||||
|
private static final ArmorType ARMOR_TYPE = ArmorType.LIGHT;
|
||||||
|
private static final int MAX_DEFENSE = 5;
|
||||||
|
private static final int MAX_DURABILITY = 15;
|
||||||
|
|
||||||
|
public GoblinArmor() {
|
||||||
|
super(NAME,
|
||||||
|
ARMOR_TYPE,
|
||||||
|
MAX_DEFENSE,
|
||||||
|
MAX_DURABILITY
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,17 @@
|
|||||||
package org.project.item.armors;
|
package org.project.item.armors;
|
||||||
|
|
||||||
// TODO: UPDATE IMPLEMENTATION
|
public class KnightArmor extends Armor {
|
||||||
public class KnightArmor {
|
|
||||||
// TODO: DESIGN ARMOR'S ATTRIBUTES IMPLEMENT THE CONSTRUCTOR
|
private static final String NAME = "knight armor";
|
||||||
}
|
private static final ArmorType ARMOR_TYPE = ArmorType.HEAVY;
|
||||||
|
private static final int MAX_DEFENSE = 35;
|
||||||
|
private static final int MAX_DURABILITY = 60;
|
||||||
|
|
||||||
|
public KnightArmor() {
|
||||||
|
super(NAME,
|
||||||
|
ARMOR_TYPE,
|
||||||
|
MAX_DEFENSE,
|
||||||
|
MAX_DURABILITY
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package org.project.item.armors;
|
||||||
|
|
||||||
|
public class SkeletonArmor extends Armor {
|
||||||
|
|
||||||
|
private static final String NAME = "skeleton armor";
|
||||||
|
private static final ArmorType ARMOR_TYPE = ArmorType.LIGHT;
|
||||||
|
private static final int MAX_DEFENSE = 15;
|
||||||
|
private static final int MAX_DURABILITY = 20;
|
||||||
|
|
||||||
|
public SkeletonArmor() {
|
||||||
|
super(NAME,
|
||||||
|
ARMOR_TYPE,
|
||||||
|
MAX_DEFENSE,
|
||||||
|
MAX_DURABILITY
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package org.project.item.armors;
|
||||||
|
|
||||||
|
public class VampireArmor extends Armor {
|
||||||
|
|
||||||
|
private static final String NAME = "vampire armor";
|
||||||
|
private static final ArmorType ARMOR_TYPE = ArmorType.MEDIUM;
|
||||||
|
private static final int MAX_DEFENSE = 16;
|
||||||
|
private static final int MAX_DURABILITY = 30;
|
||||||
|
|
||||||
|
public VampireArmor() {
|
||||||
|
super(NAME,
|
||||||
|
ARMOR_TYPE,
|
||||||
|
MAX_DEFENSE,
|
||||||
|
MAX_DURABILITY
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package org.project.item.armors;
|
||||||
|
|
||||||
|
public class WizardArmor extends Armor {
|
||||||
|
|
||||||
|
private static final String NAME = "wizard Robe";
|
||||||
|
private static final ArmorType ARMOR_TYPE = ArmorType.MEDIUM;
|
||||||
|
private static final int MAX_DEFENSE = 20;
|
||||||
|
private static final int MAX_DURABILITY = 20;
|
||||||
|
|
||||||
|
public WizardArmor() {
|
||||||
|
super(NAME,
|
||||||
|
ARMOR_TYPE,
|
||||||
|
MAX_DEFENSE,
|
||||||
|
MAX_DURABILITY
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user