Skip to content

Package: MoveChecker

MoveChecker

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: /**
22: * Checks if a move returned by a {@link Strategy} is a supported move, i.e. allowed by the underlying game engine. As
23: * the {@link Move} interface could be implemented freely, a {@link Strategy} could cheat by creating a custom move that
24: * manipulates the {@link State} of a game in an unexpected way. A {@link MoveChecker} is responsible for detecting and
25: * preventing such malicious behaviour.
26: *
27: * @param <P> The type of game players.
28: * @param <S> The type of game states.
29: * @param <M> The type of game moves.
30: */
31: @FunctionalInterface
32: public interface MoveChecker<P extends Player<P>, S extends State<P, S>, M extends Move<P, S>> {
33:
34: /**
35: * Checks if the move passed is one of the predefined moves offered by the game engine.
36: *
37: * @param move The move to check.
38: * @return {@code true} if the move is supported, else {@code false}.
39: */
40: boolean check(M move);
41: }