Skip to contentPackage: Observer
Observer
Coverage
1: /*
2: * Copyright © 2020 Fachhochschule für die Wirtschaft (FHDW) Hannover
3: *
4: * This file is part of gaming-core.
5: *
6: * Gaming-core is free software: you can redistribute it and/or modify it under
7: * the terms of the GNU General Public License as published by the Free Software
8: * Foundation, either version 3 of the License, or (at your option) any later
9: * version.
10: *
11: * Gaming-core is distributed in the hope that it will be useful, but WITHOUT
12: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13: * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14: * details.
15: *
16: * You should have received a copy of the GNU General Public License along with
17: * gaming-core. If not, see <http://www.gnu.org/licenses/>.
18: */
19: package de.fhdw.gaming.core.domain;
20:
21: import java.util.Optional;
22: import java.util.Set;
23:
24: /**
25: * Receives events about the game.
26: */
27: public interface Observer {
28:
29: /**
30: * Indicates that the game has been started.
31: *
32: * @param game The game.
33: * @param state A copy of the game state.
34: * @throws InterruptedException if the game has been interrupted while processing this event.
35: */
36: void started(Game<?, ?, ?, ?> game, State<?, ?> state) throws InterruptedException;
37:
38: /**
39: * Indicates that a new set of players being able to make a move has been computed.
40: *
41: * @param game The game.
42: * @param state A copy of the game state.
43: * @param players The set of players. May be empty if no players have been chosen.
44: * @throws InterruptedException if the game has been interrupted while processing this event.
45: */
46: void nextPlayersComputed(Game<?, ?, ?, ?> game, State<?, ?> state, Set<? extends Player> players)
47: throws InterruptedException;
48:
49: /**
50: * Indicates that an illegal player has been rejected by the game.
51: *
52: * @param game The game.
53: * @param state A copy of the game state.
54: * @param player The player.
55: * @throws InterruptedException if the game has been interrupted while processing this event.
56: */
57: void illegalPlayerRejected(Game<?, ?, ?, ?> game, State<?, ?> state, Player player) throws InterruptedException;
58:
59: /**
60: * Indicates that a legal move has been applied to the game state.
61: *
62: * @param game The game.
63: * @param state A copy of the game state.
64: * @param player The player.
65: * @param move The move.
66: * @throws InterruptedException if the game has been interrupted while processing this event.
67: */
68: void legalMoveApplied(Game<?, ?, ?, ?> game, State<?, ?> state, Player player, Move<?, ?> move)
69: throws InterruptedException;
70:
71: /**
72: * Indicates that an illegal move has been rejected by the game.
73: *
74: * @param game The game.
75: * @param state A copy of the game state.
76: * @param player The player.
77: * @param move The move. Can be empty if no move at all has been selected by the strategy.
78: * @param reason The reason why the move is illegal.
79: * @throws InterruptedException if the game has been interrupted while processing this event.
80: */
81: void illegalMoveRejected(Game<?, ?, ?, ?> game, State<?, ?> state, Player player, Optional<Move<?, ?>> move,
82: String reason) throws InterruptedException;
83:
84: /**
85: * Indicates that a move is overdue, i.e. it has exceeded its time window.
86: *
87: * @param game The game.
88: * @param state A copy of the game state.
89: * @param player The player.
90: * @param chosenMove The move that has been chosen. Can be empty if no move is available (e.g. because a player has
91: * already won the game).
92: * @throws InterruptedException if the game has been interrupted while processing this event.
93: */
94: void overdueMoveRejected(Game<?, ?, ?, ?> game, State<?, ?> state, Player player, Optional<Move<?, ?>> chosenMove)
95: throws InterruptedException;
96:
97: /**
98: * Indicates that a player has resigned.
99: *
100: * @param game The game.
101: * @param state A copy of the game state.
102: * @param player The player that has resigned.
103: * @throws InterruptedException if the game has been interrupted while processing this event.
104: */
105: void playerResigned(Game<?, ?, ?, ?> game, State<?, ?> state, Player player) throws InterruptedException;
106:
107: /**
108: * Indicates that a player has been overtaken by some other player.
109: *
110: * @param game The game.
111: * @param state A copy of the game state.
112: * @param overtakenPlayer The overtaken player.
113: * @param overtakingPlayer The overtaking player.
114: * @throws InterruptedException if the game has been interrupted while processing this event.
115: */
116: void playerOvertaken(Game<?, ?, ?, ?> game, State<?, ?> state, Player overtakenPlayer, Player overtakingPlayer)
117: throws InterruptedException;
118:
119: /**
120: * Indicates that the game has been finished.
121: *
122: * @param game The game.
123: * @param state A copy of the game state.
124: * @throws InterruptedException if the game has been interrupted while processing this event.
125: */
126: void finished(Game<?, ?, ?, ?> game, State<?, ?> state) throws InterruptedException;
127: }