feat: add thanos' ai

This commit is contained in:
2021-06-01 19:14:44 +02:00
parent 2f45e2b772
commit 850c46c6e1
3 changed files with 98 additions and 6 deletions

View File

@ -80,7 +80,10 @@ public class Inventory implements Iterable<StoneType> {
content.remove(stone);
}
/** Returns the stones inside of the Inventory as Array of {@link StoneType StoneTypes} */
/**
* Returns the stones inside of the Inventory as Array of {@link StoneType StoneTypes}.
* @return The array of stones the inventory has
*/
public StoneType[] getStonesAsArray() {
var toReturn = new StoneType[content.size()];
var iterator = content.iterator();
@ -90,6 +93,17 @@ public class Inventory implements Iterable<StoneType> {
return toReturn;
}
/**
* Transfers the stones inside of the Inventory to a different Inventory.
* @param to The {@link Inventory} to transfer to
*/
public void transfer(Inventory to) {
for(StoneType stone: content) {
to.addStone(stone);
}
content.clear();
}
/** Iterates over the inventory. */
@Override
public Iterator<StoneType> iterator() {

View File

@ -20,7 +20,7 @@ public class NPC extends Entity {
*/
public NPC(EntityID id, IntVector2 position, int maxMP, ArrayList<StoneType> inventory) {
super(id, position);
solid = false;
solid = true;
opaque = true;
this.inventory = new Inventory(inventory);
this.mp = new Stat(StatType.MP, maxMP);