breaking: remove observable pattern, make methods return events directly
This commit is contained in:
@ -49,8 +49,8 @@ class GameStateManager {
|
||||
* Handles events that happen after a turn phase.
|
||||
* @return The optionally resulting {@link Event}s
|
||||
*/
|
||||
public Event[] checkPostPhase() {
|
||||
return (Event[])GameLogic.checkTurnEnd(state).toArray();
|
||||
public ArrayList<Event> checkPostPhase() {
|
||||
return GameLogic.checkTurnEnd(state);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -59,23 +59,23 @@ class GameStateManager {
|
||||
* @param selectedCharacters2 The characters selected by player 2
|
||||
* @return The resulting {@link Event}s
|
||||
*/
|
||||
public Event[] initGame(ArrayList<Integer> selectedCharacters1, ArrayList<Integer> selectedCharacters2) {
|
||||
return GameLogic.startGame(state, selectedCharacters1, selectedCharacters2).toArray(new Event[0]);
|
||||
public ArrayList<Event> initGame(ArrayList<Integer> selectedCharacters1, ArrayList<Integer> selectedCharacters2) {
|
||||
return GameLogic.startGame(state, selectedCharacters1, selectedCharacters2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts the game.
|
||||
* @return The resulting {@link Event}s
|
||||
*/
|
||||
public Event[] startGame() {
|
||||
return GameLogic.handleRoundStart(state).toArray(new Event[0]);
|
||||
public ArrayList<Event> startGame() {
|
||||
return GameLogic.handleRoundStart(state);
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies an array of {@link Event}s to the game state.
|
||||
* @param events The events to apply
|
||||
*/
|
||||
public void applyEvents(Event... events) {
|
||||
public void applyEvents(ArrayList<Event> events) {
|
||||
for(Event event: events) {
|
||||
GameLogic.applyEvent(state, event);
|
||||
}
|
||||
@ -85,13 +85,12 @@ class GameStateManager {
|
||||
* Applies the result of the last processRequests call.
|
||||
* @return A list of applied events
|
||||
*/
|
||||
public Event[] apply() {
|
||||
Event[] toReturn = new Event[queue.size()];
|
||||
public ArrayList<Event> apply() {
|
||||
ArrayList<Event> toReturn = new ArrayList<Event>(queue.size());
|
||||
Event current;
|
||||
int i = 0;
|
||||
while ((current = queue.poll()) != null) {
|
||||
GameLogic.applyEvent(state, current);
|
||||
toReturn[i++] = current;
|
||||
toReturn.add(current);
|
||||
}
|
||||
return toReturn;
|
||||
}
|
||||
|
Reference in New Issue
Block a user