fix: include NPCs in RoundSetupEvent and TurnEvent for standard compatibility

This commit is contained in:
punchready 2021-06-03 02:30:25 +02:00
parent dd3201dfd2
commit cc4c5ba8cb

View File

@ -751,16 +751,25 @@ public class GameLogic {
state.roundNumber++; state.roundNumber++;
state.turnNumber = 0; state.turnNumber = 0;
result.add(new EventBuilder(EventType.RoundSetupEvent)
.withRoundCount(state.roundNumber)
.buildGameEvent());
ArrayList<EntityID> turns = new ArrayList<>();
if(state.roundNumber >= 1 && state.roundNumber <= 6) { if(state.roundNumber >= 1 && state.roundNumber <= 6) {
turns.add(new EntityID(EntityType.NPC, NPCType.Goose.getID()));
result.addAll(handleGoose(state)); result.addAll(handleGoose(state));
} }
HashSet<EntityID> revived = new HashSet<>(); HashSet<EntityID> revived = new HashSet<>();
if(state.roundNumber == 7) { if(state.roundNumber == 7) {
turns.add(new EntityID(EntityType.NPC, NPCType.Stan.getID()));
result.addAll(handleStan(state, revived)); result.addAll(handleStan(state, revived));
} }
if(state.roundNumber == state.partyConfig.maxRounds + 1) { if(state.roundNumber == state.partyConfig.maxRounds + 1) {
turns.add(new EntityID(EntityType.NPC, NPCType.Thanos.getID()));
result.addAll(spawnThanos(state)); result.addAll(spawnThanos(state));
} }
@ -775,10 +784,10 @@ public class GameLogic {
state.stoneCooldown.update(); state.stoneCooldown.update();
result.add(new EventBuilder(EventType.RoundSetupEvent) turns.addAll(state.turnOrder);
.withRoundCount(state.roundNumber)
.withCharacterOrder(state.turnOrder.toArray(new EntityID[0])) // RoundSetupEvent has to be sent first, but the contents of it are determined later...
.buildGameEvent()); ((GameEvent)result.get(0)).characterOrder = turns.toArray(new EntityID[0]);
return result; return result;
} }
@ -791,6 +800,13 @@ public class GameLogic {
private static ArrayList<Event> handleGoose(GameState state) { private static ArrayList<Event> handleGoose(GameState state) {
ArrayList<Event> result = new ArrayList<>(); 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); ArrayList<StoneType> inventory = new ArrayList<>(state.unvomitedStones);
int picked = rand.nextInt(inventory.size()); int picked = rand.nextInt(inventory.size());
StoneType stone = inventory.get(picked); StoneType stone = inventory.get(picked);
@ -808,7 +824,6 @@ public class GameLogic {
} }
IntVector2 position = free.get(rand.nextInt(free.size())); IntVector2 position = free.get(rand.nextInt(free.size()));
EntityID goose = new EntityID(EntityType.NPC, NPCType.Goose.getID());
result.add(new EventBuilder(EventType.SpawnEntityEvent) result.add(new EventBuilder(EventType.SpawnEntityEvent)
.withEntity(new NPC(goose, position, inventory)) .withEntity(new NPC(goose, position, inventory))
.buildEntityEvent()); .buildEntityEvent());
@ -831,6 +846,13 @@ public class GameLogic {
private static ArrayList<Event> handleStan(GameState state, HashSet<EntityID> revived) { private static ArrayList<Event> handleStan(GameState state, HashSet<EntityID> revived) {
ArrayList<Event> result = new ArrayList<>(); 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<Character> characters = new ArrayList<>();
ArrayList<IntVector2> targetOptions = new ArrayList<>(); ArrayList<IntVector2> targetOptions = new ArrayList<>();
@ -855,7 +877,6 @@ public class GameLogic {
} }
IntVector2 spawnPosition = spawnOptions.get(rand.nextInt(spawnOptions.size())); IntVector2 spawnPosition = spawnOptions.get(rand.nextInt(spawnOptions.size()));
EntityID stan = new EntityID(EntityType.NPC, NPCType.Stan.getID());
result.add(new EventBuilder(EventType.SpawnEntityEvent) result.add(new EventBuilder(EventType.SpawnEntityEvent)
.withEntity(new NPC(stan, spawnPosition)) .withEntity(new NPC(stan, spawnPosition))
.buildEntityEvent()); .buildEntityEvent());
@ -921,6 +942,11 @@ public class GameLogic {
private static ArrayList<Event> handleThanos(GameState state, NPC thanos) { private static ArrayList<Event> handleThanos(GameState state, NPC thanos) {
ArrayList<Event> result = new ArrayList<>(); ArrayList<Event> result = new ArrayList<>();
result.add(new EventBuilder(EventType.TurnEvent)
.withTurnCount(state.turnOrder.size())
.withNextCharacter(thanos.id)
.buildGameEvent());
if(thanos.inventory.getFreeSlots() > 0) { if(thanos.inventory.getFreeSlots() > 0) {
IntVector2 picked = null; IntVector2 picked = null;
@ -1053,10 +1079,6 @@ public class GameLogic {
.buildGameEvent()); .buildGameEvent());
thanos.mp.setValue(thanos.mp.getMax()); thanos.mp.setValue(thanos.mp.getMax());
} }
result.add(new EventBuilder(EventType.TurnEvent)
.withTurnCount(state.turnOrder.size())
.withNextCharacter(state.activeCharacter)
.buildGameEvent());
result.addAll(handleThanos(state, thanos)); result.addAll(handleThanos(state, thanos));
return result; return result;