diff --git a/src/main/java/uulm/teamname/marvelous/gamelibrary/gamelogic/GameLogic.java b/src/main/java/uulm/teamname/marvelous/gamelibrary/gamelogic/GameLogic.java index 30dc511..aa6f3ec 100644 --- a/src/main/java/uulm/teamname/marvelous/gamelibrary/gamelogic/GameLogic.java +++ b/src/main/java/uulm/teamname/marvelous/gamelibrary/gamelogic/GameLogic.java @@ -508,6 +508,16 @@ public class GameLogic { case ConsumedMPEvent -> { ((NPC)state.entities.findEntity(((CharacterEvent)event).targetEntity)).mp.decreaseValue(((CharacterEvent)event).amount); } + case TurnEvent -> { + if(((GameEvent)event).nextCharacter.type != EntityType.NPC) { + Character target = (Character)state.entities.findEntity(((GameEvent)event).nextCharacter); + target.ap.setValue(target.ap.getMax()); + target.mp.setValue(target.mp.getMax()); + }else if(((GameEvent)event).nextCharacter.id == NPCType.Thanos.getID()) { + NPC target = (NPC)state.entities.findEntity(((GameEvent)event).nextCharacter); + target.mp.setValue(target.mp.getMax()); + } + } case SpawnEntityEvent -> { state.entities.addEntity(((EntityEvent)event).entity); } @@ -844,13 +854,6 @@ public class GameLogic { private static ArrayList handleGoose(GameState state) { ArrayList result = new ArrayList<>(); - EntityID goose = new EntityID(EntityType.NPC, NPCType.Goose.getID()); - - result.add(new EventBuilder(EventType.TurnEvent) - .withTurnCount(state.turnOrder.size()) - .withNextCharacter(goose) - .buildGameEvent()); - ArrayList inventory = new ArrayList<>(state.unvomitedStones); int picked = rand.nextInt(inventory.size()); StoneType stone = inventory.get(picked); @@ -868,9 +871,14 @@ public class GameLogic { } IntVector2 position = free.get(rand.nextInt(free.size())); + EntityID goose = new EntityID(EntityType.NPC, NPCType.Goose.getID()); result.add(new EventBuilder(EventType.SpawnEntityEvent) .withEntity(new NPC(goose, position, inventory)) .buildEntityEvent()); + result.add(new EventBuilder(EventType.TurnEvent) + .withTurnCount(state.turnOrder.size()) + .withNextCharacter(goose) + .buildGameEvent()); result.add(new EventBuilder(EventType.SpawnEntityEvent) .withEntity(new InfinityStone(new EntityID(EntityType.InfinityStones, stone.getID()), position, stone)) .buildEntityEvent()); @@ -890,13 +898,6 @@ public class GameLogic { private static ArrayList handleStan(GameState state, HashSet revived) { ArrayList result = new ArrayList<>(); - EntityID stan = new EntityID(EntityType.NPC, NPCType.Stan.getID()); - - result.add(new EventBuilder(EventType.TurnEvent) - .withTurnCount(state.turnOrder.size()) - .withNextCharacter(stan) - .buildGameEvent()); - ArrayList characters = new ArrayList<>(); ArrayList targetOptions = new ArrayList<>(); @@ -921,9 +922,14 @@ public class GameLogic { } IntVector2 spawnPosition = spawnOptions.get(rand.nextInt(spawnOptions.size())); + EntityID stan = new EntityID(EntityType.NPC, NPCType.Stan.getID()); result.add(new EventBuilder(EventType.SpawnEntityEvent) .withEntity(new NPC(stan, spawnPosition)) .buildEntityEvent()); + result.add(new EventBuilder(EventType.TurnEvent) + .withTurnCount(state.turnOrder.size()) + .withNextCharacter(stan) + .buildGameEvent()); for(Character character: characters) { if(checkLineOfSight(state, spawnPosition, character.getPosition())) { @@ -1115,14 +1121,6 @@ public class GameLogic { thanos.mp.setMax(thanos.mp.getMax() + 1);//TODO: use event for this... } - if(thanos.mp.getValue() != thanos.mp.getMax()) { - result.add(new EventBuilder(EventType.ConsumedMPEvent) - .withTargetEntity(state.activeCharacter) - .withTargetField(thanos.getPosition()) - .withAmount(thanos.mp.getValue() - thanos.mp.getMax()) - .buildGameEvent()); - thanos.mp.setValue(thanos.mp.getMax()); - } result.addAll(handleThanos(state, thanos)); return result; @@ -1130,20 +1128,6 @@ public class GameLogic { Character activeCharacter = (Character)state.entities.findEntity(state.activeCharacter); - if(activeCharacter.ap.getValue() != activeCharacter.ap.getMax()) { - result.add(new EventBuilder(EventType.ConsumedAPEvent) - .withTargetEntity(state.activeCharacter) - .withTargetField(activeCharacter.getPosition()) - .withAmount(activeCharacter.ap.getValue() - activeCharacter.ap.getMax()) - .buildGameEvent()); - } - if(activeCharacter.mp.getValue() != activeCharacter.mp.getMax()) { - result.add(new EventBuilder(EventType.ConsumedMPEvent) - .withTargetEntity(state.activeCharacter) - .withTargetField(activeCharacter.getPosition()) - .withAmount(activeCharacter.mp.getValue() - activeCharacter.mp.getMax()) - .buildGameEvent()); - } result.add(new EventBuilder(EventType.TurnEvent) .withTurnCount(state.turnOrder.size()) .withNextCharacter(state.activeCharacter)