Skip to content

Package: VGField

VGField

Coverage

1: /*
2: * Copyright © 2020 Fachhochschule für die Wirtschaft (FHDW) Hannover
3: *
4: * This file is part of othello-core.
5: *
6: * Othello-core is free software: you can redistribute it and/or modify
7: * it under the terms of the GNU General Public License as published by
8: * the Free Software Foundation, either version 3 of the License, or
9: * (at your option) any later version.
10: *
11: * Othello-core is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14: * GNU General Public License for more details.
15: *
16: * You should have received a copy of the GNU General Public License
17: * along with othello-core. If not, see <http://www.gnu.org/licenses/>.
18: */
19: package de.fhdw.gaming.ipspiel22.vierGewinnt.domain;
20:
21: import de.fhdw.gaming.core.domain.GameException;
22:
23: /**
24: * Represents a single field on a {@link VGBoard board}.
25: * <p>
26: * A field has a {@link VGPosition position}. This position is fixed and does not change.
27: * <p>
28: * The state of a field cannot be changed directly. Instead, a conforming move has to be submitted.
29: */
30: public interface VGField {
31:
32: /**
33: * Returns the board this field belongs to.
34: */
35: VGBoard getBoard();
36:
37: /**
38: * Returns the position of this field.
39: */
40: VGPosition getPosition();
41:
42: /**
43: * Returns the current state of this field.
44: */
45: VGFieldState getState();
46:
47: /**
48: * Sets the current state of this field.
49: * @param newState
50: */
51: void setState(VGFieldState newState) throws IllegalArgumentException;
52:
53: /**
54: * Places a token on this field. Requires this field to be active. Computes and changes the state of neighbour
55: * fields according to the rules of the game.
56: *
57: * @param redChip {@code true} if a black token is placed, and {@code false} if a white token is placed.
58: * @throws GameException if placing a token of the given colour is not allowed according to the rules of the game.
59: */
60: void placeToken(boolean redChip) throws GameException;
61: }