develop #1
@@ -58,8 +58,14 @@ public abstract class Player implements Entity, combatOptions {
|
||||
@Override
|
||||
public void takeDamage(int damage) {
|
||||
|
||||
int finalDamage = damage - armor.getDefense();
|
||||
setHP(getHP() - finalDamage);
|
||||
int finalDamage = armor.getDefense() - damage;
|
||||
if (finalDamage < 0) {
|
||||
setHP(getHP() + finalDamage);
|
||||
armor.setDefense(0);
|
||||
}
|
||||
else {
|
||||
armor.setDefense(finalDamage);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,29 +1,29 @@
|
||||
package org.project.item.armors;
|
||||
|
||||
// TODO: UPDATE IMPLEMENTATION
|
||||
public abstract class Armor {
|
||||
import org.project.item.Item;
|
||||
|
||||
public abstract class Armor implements Item {
|
||||
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.maxDefense = defense;
|
||||
this.durability = durability;
|
||||
this.maxDurability = 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;
|
||||
}
|
||||
@@ -32,11 +32,12 @@ public abstract class Armor {
|
||||
return defense;
|
||||
}
|
||||
|
||||
public void setDefense(int defense) {
|
||||
this.defense = defense;
|
||||
}
|
||||
|
||||
public int getDurability() {
|
||||
return durability;
|
||||
}
|
||||
|
||||
public boolean isBroke() {
|
||||
return isBroke;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package org.project.item.armors;
|
||||
|
||||
// TODO: UPDATE IMPLEMENTATION
|
||||
public class KnightArmor {
|
||||
public class KnightArmor extends Armor{
|
||||
// TODO: DESIGN ARMOR'S ATTRIBUTES IMPLEMENT THE CONSTRUCTOR
|
||||
public KnightArmor(int defense, int durability) {
|
||||
super(defense, durability);
|
||||
}
|
||||
}
|
||||
@@ -5,15 +5,16 @@ import org.project.entity.Entity;
|
||||
import java.util.ArrayList;
|
||||
|
||||
// TODO: UPDATE IMPLEMENTATION
|
||||
public class Sword {
|
||||
public class Sword extends Weapon{
|
||||
/*
|
||||
THIS IS AN EXAMPLE OF A WEAPON DESIGN.
|
||||
*/
|
||||
|
||||
int abilityCharge;
|
||||
|
||||
public Sword() {
|
||||
public Sword(int damage, int manacost ) {
|
||||
// TODO: DESIGN SWORD'S ATTRIBUTES IMPLEMENT THE CONSTRUCTOR
|
||||
super(damage, manacost);
|
||||
}
|
||||
|
||||
// TODO: (BONUS) UPDATE THE UNIQUE ABILITY
|
||||
|
||||
Reference in New Issue
Block a user