Skip to content

Package: OthelloBoard

OthelloBoard

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.othello.core.domain;
20:
21: import java.util.List;
22: import java.util.Map;
23:
24: import de.fhdw.gaming.core.domain.Stateful;
25:
26: /**
27: * Represents the Othello board.
28: * <p>
29: * An Othello board is a square and hence possesses an identical non-zero positive number of rows and columns. Each
30: * combination of a row and a column is described by a {@link OthelloPosition position}. At each position, there is a
31: * {@link OthelloField field} which describes whether the field is empty or occupied by a token.
32: */
33: public interface OthelloBoard extends Stateful {
34:
35: /**
36: * Returns the number of rows (or columns) of this board.
37: */
38: int getSize();
39:
40: /**
41: * Checks whether this board contains a field at the position passed.
42: *
43: * @param position The position.
44: * @return {@code true} if this board contains a field at the position passed, else {@code false}.
45: */
46: boolean hasFieldAt(OthelloPosition position);
47:
48: /**
49: * Returns the field at the given position.
50: *
51: * @param position The position of the field to return.
52: * @return The field.
53: * @throws IllegalArgumentException if the position is out of range, i.e. if it does not denote a field.
54: */
55: OthelloField getFieldAt(OthelloPosition position);
56:
57: /**
58: * Returns all fields of this board line by line.
59: * <p>
60: * The list(s) returned are possibly immutable, so do not modify them.
61: */
62: List<List<? extends OthelloField>> getFields();
63:
64: /**
65: * Returns all fields of a given state.
66: * <p>
67: * The map returned returned is possibly immutable, so do not modify it.
68: *
69: * @param fieldState The state of the fields to return.
70: * @return The fields.
71: */
72: Map<OthelloPosition, ? extends OthelloField> getFieldsBeing(OthelloFieldState fieldState);
73:
74: @Override
75: OthelloBoard deepCopy();
76: }