Skip to content

Package: Move

Move

Coverage

1: /*
2: * Copyright © 2020-2023 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: /**
22: * Represents a move.
23: * <p>
24: * Note that a move is not a subtype of {@link Stateful}, i.e. it is assumed that a move has no mutable state.
25: *
26: * @param <P> The type of allowed players.
27: * @param <S> The type of allowed states.
28: */
29: public interface Move<P extends Player<P>, S extends State<P, S>> {
30:
31: /**
32: * Applies this move to a state for some player.
33: *
34: * @param state The state to apply this move to.
35: * @param player The player making the move.
36: * @throws GameException if the rules of the game do not allow this move at this state. Note that this operation
37: * only performs local state changes. Global state changes are checked in
38: * {@link State#nextTurn()}. This allows a game move to consist of a sequence of smaller
39: * (sub-)moves where global consistency is reached only after the last (sub-)move. Of course,
40: * only the rules of the game eventually dictate which rule can be checked at which point.
41: */
42: void applyTo(S state, P player) throws GameException;
43: }