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