2021-04-29 14:45:18 +00:00
|
|
|
package uulm.teamname.marvelous.gamelibrary.entities;
|
2021-04-29 14:40:23 +00:00
|
|
|
|
2021-04-29 14:45:18 +00:00
|
|
|
import uulm.teamname.marvelous.gamelibrary.IntVector2;
|
2021-04-29 14:40:23 +00:00
|
|
|
|
2021-04-30 18:54:34 +00:00
|
|
|
/** Represents a playable character inside a match. */
|
2021-04-29 14:40:23 +00:00
|
|
|
public class Character extends Entity {
|
2021-04-30 18:54:34 +00:00
|
|
|
/** The name of the character */
|
2021-04-29 14:40:23 +00:00
|
|
|
public final String name;
|
|
|
|
|
2021-04-30 18:54:34 +00:00
|
|
|
/** The hp stat of the character */
|
2021-04-29 14:40:23 +00:00
|
|
|
public final Stat hp;
|
|
|
|
|
2021-04-30 18:54:34 +00:00
|
|
|
/** The mp stat of the character */
|
2021-04-29 14:40:23 +00:00
|
|
|
public final Stat mp;
|
|
|
|
|
2021-04-30 18:54:34 +00:00
|
|
|
/** The ap stat of the character */
|
2021-04-29 14:40:23 +00:00
|
|
|
public final Stat ap;
|
|
|
|
|
2021-04-30 18:54:34 +00:00
|
|
|
/** The ranged attack range of the character */
|
2021-04-29 14:40:23 +00:00
|
|
|
public final int attackRange;
|
|
|
|
|
2021-04-30 18:54:34 +00:00
|
|
|
/** The ranged attack damage of the character */
|
2021-04-29 14:40:23 +00:00
|
|
|
public final int rangedDamage;
|
|
|
|
|
2021-04-30 18:54:34 +00:00
|
|
|
/** The melee attack damage of the character */
|
2021-04-29 14:40:23 +00:00
|
|
|
public final int meleeDamage;
|
|
|
|
|
2021-04-30 18:54:34 +00:00
|
|
|
/** The {@link Inventory} of the character */
|
2021-04-29 14:40:23 +00:00
|
|
|
public final Inventory inventory = new Inventory();
|
|
|
|
|
2021-04-30 18:54:34 +00:00
|
|
|
/**
|
|
|
|
* 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 hp The maximum hp of the character
|
|
|
|
* @param mp The maximum mp of the character
|
|
|
|
* @param ap The maximum 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
|
2021-04-29 14:40:23 +00:00
|
|
|
*/
|
|
|
|
public Character(EntityID id, IntVector2 position, String name, int hp, int mp, int ap, int attackRange, int rangedDamage, int meleeDamage) {
|
|
|
|
super(id, position);
|
|
|
|
this.name = name;
|
|
|
|
this.hp = new Stat(StatType.HP, hp);
|
|
|
|
this.mp = new Stat(StatType.MP, mp);
|
|
|
|
this.ap = new Stat(StatType.AP, ap);
|
|
|
|
this.attackRange = attackRange;
|
|
|
|
this.rangedDamage = rangedDamage;
|
|
|
|
this.meleeDamage = meleeDamage;
|
|
|
|
}
|
|
|
|
|
2021-04-30 18:54:34 +00:00
|
|
|
/**
|
|
|
|
* Checks if the character is still alive.
|
|
|
|
* @return Whether or not the characters hp is greater than 0
|
2021-04-29 14:40:23 +00:00
|
|
|
*/
|
|
|
|
public boolean isAlive() {
|
|
|
|
return hp.getValue() > 0;
|
|
|
|
}
|
2021-04-30 19:48:28 +00:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public Character clone() {
|
|
|
|
Character clone = new Character(id, position, name, hp.max, mp.max, ap.max, attackRange, rangedDamage, meleeDamage);
|
|
|
|
for(StoneType stone: inventory) {
|
|
|
|
clone.inventory.addStone(stone);
|
|
|
|
}
|
|
|
|
clone.hp.setValue(hp.getValue());
|
|
|
|
clone.mp.setValue(mp.getValue());
|
|
|
|
clone.ap.setValue(ap.getValue());
|
|
|
|
return clone;
|
|
|
|
}
|
2021-04-29 14:40:23 +00:00
|
|
|
}
|