fix: remove ConsumedMP- and ConsumedAPEvents before TurnEvent for standard compatibility

This commit is contained in:
punchready 2021-06-03 04:14:33 +02:00
parent bc6846b5b1
commit 5a90056cd8
1 changed files with 20 additions and 36 deletions

View File

@ -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<Event> handleGoose(GameState state) {
ArrayList<Event> 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<StoneType> 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<Event> handleStan(GameState state, HashSet<EntityID> revived) {
ArrayList<Event> 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<Character> characters = new ArrayList<>();
ArrayList<IntVector2> 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)