fix: use correct variables and send only the complete gamestate event

This commit is contained in:
punchready 2021-07-29 01:19:12 +02:00
parent 0336e4769a
commit 3070b9864c
2 changed files with 5 additions and 10 deletions

View File

@ -768,13 +768,10 @@ public class GameLogic {
* @param state The game state to work on * @param state The game state to work on
* @param selectedCharacters1 The characters selected by player 1 * @param selectedCharacters1 The characters selected by player 1
* @param selectedCharacters2 The characters selected by player 2 * @param selectedCharacters2 The characters selected by player 2
* @return The list of resulting {@link Event Events}
*/ */
protected static ArrayList<Event> startGame(GameState state, List<Integer> selectedCharacters1, List<Integer> selectedCharacters2) { protected static void startGame(GameState state, List<Integer> selectedCharacters1, List<Integer> selectedCharacters2) {
Logger.trace("Starting game"); Logger.trace("Starting game");
ArrayList<Event> result = new ArrayList<>();
ArrayList<IntVector2> free = new ArrayList<>(); ArrayList<IntVector2> free = new ArrayList<>();
int rockIndex = 0; int rockIndex = 0;
@ -818,8 +815,6 @@ public class GameLogic {
state.turnOrder.add(id); state.turnOrder.add(id);
} }
return result;
} }
/** /**

View File

@ -115,16 +115,16 @@ class GameStateManager {
public List<Event> startGame(List<Integer> selectedCharacters1, List<Integer> selectedCharacters2) { public List<Event> startGame(List<Integer> selectedCharacters1, List<Integer> selectedCharacters2) {
GameState snapshot = state.snapshot(); GameState snapshot = state.snapshot();
ArrayList<Event> result = GameLogic.startGame(snapshot, selectedCharacters1, selectedCharacters2); GameLogic.startGame(snapshot, selectedCharacters1, selectedCharacters2);
result.add(GameLogic.buildGameStateEvent(state)); applyEvent(GameLogic.buildGameStateEvent(snapshot));
applyEvents(result);
snapshot = state.snapshot(); snapshot = state.snapshot();
ArrayList<Event> result2 = GameLogic.startRound(snapshot); ArrayList<Event> result2 = GameLogic.startRound(snapshot);
result.add(GameLogic.buildGameStateEvent(state));
applyEvents(result2); applyEvents(result2);
ArrayList<Event> result = new ArrayList<>();
result.add(GameLogic.buildGameStateEvent(snapshot));
result.addAll(result2); result.addAll(result2);
return result; return result;