Merge 068df675691578d92d05f2ba8d8749ec9487e4bc into e2763faeee2b186e678a3f71410c3440c8e061fa

This commit is contained in:
djsheehy 2018-01-01 21:00:09 +00:00 committed by GitHub
commit 336edac556

View File

@ -8,12 +8,14 @@ import org.json.simple.JSONObject;
import java.util.ArrayList; import java.util.ArrayList;
public class Cubot extends GameObject implements Updatable, ControllableUnit, Programmable { public class Cubot extends GameObject implements Updatable, ControllableUnit, Programmable, Attackable {
private static final char MAP_INFO = 0x0080; private static final char MAP_INFO = 0x0080;
public static final int ID = 1; public static final int ID = 1;
public static int TYPE_ID = 2; public static int TYPE_ID = 2;
public static final int MAX_HEALTH = 100;
public static final int HEAL_RATE = 5;
private int hologram = 0; private int hologram = 0;
private String hologramString = ""; private String hologramString = "";
@ -26,6 +28,8 @@ public class Cubot extends GameObject implements Updatable, ControllableUnit, Pr
*/ */
private int hp; private int hp;
private int heldItem; private int heldItem;
private int healRate;
private int maxHp;
private Action currentAction = Action.IDLE; private Action currentAction = Action.IDLE;
private Action lastAction = Action.IDLE; private Action lastAction = Action.IDLE;
@ -278,4 +282,46 @@ public class Cubot extends GameObject implements Updatable, ControllableUnit, Pr
public void setHologramColor(int hologramColor) { public void setHologramColor(int hologramColor) {
this.hologramColor = hologramColor; this.hologramColor = hologramColor;
} }
@Override
public void setHealRate(int hp) {
healRate = hp;
}
@Override
public int getHp() {
return hp;
}
@Override
public void setHp(int hp) {
this.hp = hp;
}
@Override
public int getMaxHp() {
return maxHp;
}
@Override
public void setMaxHp(int hp) {
maxHp = hp;
}
@Override
public void heal(int amount) {
hp += amount;
if(hp > maxHp) {
hp = maxHp;
}
}
@Override
public void damage(int amount) {
hp -= amount;
if(hp <= 0) {
hp = 0;
// TODO: handle death here somehow.
}
}
} }