fix: correctly set maximum values when parsing entities
This commit is contained in:
parent
a28741ac3d
commit
cf035dedac
@ -58,6 +58,37 @@ public class Character extends Entity {
|
|||||||
this.meleeDamage = meleeDamage;
|
this.meleeDamage = meleeDamage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a new {@link Character} with an empty inventory.
|
||||||
|
* @param id The {@link EntityID} of the character
|
||||||
|
* @param position The position of the character
|
||||||
|
* @param name The name of the character
|
||||||
|
* @param maxHp The maximum hp of the character
|
||||||
|
* @param maxMp The maximum mp of the character
|
||||||
|
* @param maxAp The maximum ap of the character
|
||||||
|
* @param hp The current hp of the character
|
||||||
|
* @param mp The current mp of the character
|
||||||
|
* @param ap The current ap of the character
|
||||||
|
* @param attackRange The ranged attack range of the character
|
||||||
|
* @param rangedDamage The ranged damage of the character
|
||||||
|
* @param meleeDamage The melee damage of the character
|
||||||
|
*/
|
||||||
|
public Character(EntityID id, IntVector2 position, String name, int maxHp, int maxMp, int maxAp, int hp, int mp, int ap, int attackRange, int rangedDamage, int meleeDamage) {
|
||||||
|
super(id, position);
|
||||||
|
solid = false;
|
||||||
|
opaque = true;
|
||||||
|
if(id.type == EntityType.NPC && id.id == NPCType.Thanos.getID()) {
|
||||||
|
solid = true; //characters cannot walk into thanos
|
||||||
|
}
|
||||||
|
this.name = name;
|
||||||
|
this.hp = new Stat(StatType.HP, hp, maxHp);
|
||||||
|
this.mp = new Stat(StatType.MP, mp, maxMp);
|
||||||
|
this.ap = new Stat(StatType.AP, ap, maxAp);
|
||||||
|
this.attackRange = attackRange;
|
||||||
|
this.rangedDamage = rangedDamage;
|
||||||
|
this.meleeDamage = meleeDamage;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the character is still alive.
|
* Checks if the character is still alive.
|
||||||
* @return Whether or not the characters hp is greater than 0
|
* @return Whether or not the characters hp is greater than 0
|
||||||
|
@ -43,6 +43,9 @@ public class EntityDeserializer extends JsonDeserializer<Entity> {
|
|||||||
id,
|
id,
|
||||||
codec.treeToValue(node.get("position"), IntVector2.class),
|
codec.treeToValue(node.get("position"), IntVector2.class),
|
||||||
characterName,
|
characterName,
|
||||||
|
properties.HP,
|
||||||
|
properties.MP,
|
||||||
|
properties.AP,
|
||||||
node.get("HP").asInt(),
|
node.get("HP").asInt(),
|
||||||
node.get("MP").asInt(),
|
node.get("MP").asInt(),
|
||||||
node.get("AP").asInt(),
|
node.get("AP").asInt(),
|
||||||
|
Loading…
Reference in New Issue
Block a user