feat: add thanos into the handling
This commit is contained in:
@ -46,6 +46,9 @@ public class Character extends Entity {
|
||||
super(id, position);
|
||||
solid = false;
|
||||
opaque = true;
|
||||
if(id.type == EntityType.NPC && id.id == 2) {
|
||||
solid = true; //characters cannot walk into thanos
|
||||
}
|
||||
this.name = name;
|
||||
this.hp = new Stat(StatType.HP, hp);
|
||||
this.mp = new Stat(StatType.MP, mp);
|
||||
@ -65,7 +68,7 @@ public class Character extends Entity {
|
||||
|
||||
@Override
|
||||
public Character clone() {
|
||||
Character clone = new Character(id, position, name, hp.max, mp.max, ap.max, attackRange, rangedDamage, meleeDamage);
|
||||
Character clone = new Character(id, position, name, hp.getMax(), mp.getMax(), ap.getMax(), attackRange, rangedDamage, meleeDamage);
|
||||
for(StoneType stone: inventory) {
|
||||
clone.inventory.addStone(stone);
|
||||
}
|
||||
|
@ -2,26 +2,8 @@ package uulm.teamname.marvelous.gamelibrary.entities;
|
||||
|
||||
import uulm.teamname.marvelous.gamelibrary.IntVector2;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/** Represents an NPC inside the game. */
|
||||
public class NPC extends Entity {
|
||||
/** The {@link Inventory} of the NPC */
|
||||
public final Inventory inventory;
|
||||
|
||||
/**
|
||||
* Constructs a new {@link NPC}.
|
||||
* @param id The {@link EntityID} of the NPC
|
||||
* @param position The position of the NPC
|
||||
* @param inventory The starting inventory the NPC should have
|
||||
*/
|
||||
public NPC(EntityID id, IntVector2 position, ArrayList<StoneType> inventory) {
|
||||
super(id, position);
|
||||
solid = false;
|
||||
opaque = true;
|
||||
this.inventory = new Inventory(inventory);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new {@link NPC} with an empty inventory.
|
||||
* @param id The {@link EntityID} of the NPC
|
||||
@ -29,15 +11,12 @@ public class NPC extends Entity {
|
||||
*/
|
||||
public NPC(EntityID id, IntVector2 position) {
|
||||
super(id, position);
|
||||
this.inventory = new Inventory();
|
||||
solid = false;
|
||||
opaque = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC clone() {
|
||||
NPC clone = new NPC(id, position);
|
||||
for(StoneType stone: inventory) {
|
||||
clone.inventory.addStone(stone);
|
||||
}
|
||||
return clone;
|
||||
return new NPC(id, position);
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ public class Stat {
|
||||
public final StatType type;
|
||||
|
||||
/** The maximum value of the stat */
|
||||
public final int max;
|
||||
private int max;
|
||||
|
||||
/** The current value of the stat */
|
||||
private int value;
|
||||
@ -40,25 +40,33 @@ public class Stat {
|
||||
this.value -= value;
|
||||
}
|
||||
|
||||
public int getMax() {
|
||||
return max;
|
||||
}
|
||||
|
||||
public void setMax(int max) {
|
||||
this.max = max;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
Stat stat = (Stat) o;
|
||||
return max == stat.max && value == stat.value && type == stat.type;
|
||||
return getMax() == stat.getMax() && value == stat.value && type == stat.type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(type, max, value);
|
||||
return Objects.hash(type, getMax(), value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Stat{" +
|
||||
"type=" + type +
|
||||
", max=" + max +
|
||||
", max=" + getMax() +
|
||||
", value=" + value +
|
||||
'}';
|
||||
}
|
||||
|
Reference in New Issue
Block a user