Skip to content

Package: VierGewinntBoard

VierGewinntBoard

Coverage

1: /*
2: * Copyright © 2021 Fachhochschule für die Wirtschaft (FHDW) Hannover
3: *
4: * This file is part of ipspiel21-tictactoe-core.
5: *
6: * ipspiel21-tictactoe-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: * ipspiel21-tictactoe-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: * ipspiel21-tictactoe-core. If not, see <http://www.gnu.org/licenses/>.
18: */
19: package de.fhdw.gaming.ipspiel21.viergewinnt.core.domain;
20:
21:
22: import java.util.List;
23: import java.util.Map;
24: import java.util.Set;
25:
26: import de.fhdw.gaming.core.domain.Stateful;
27:
28: /**
29: * Represents the VierGewinnt board.
30: * <p>
31: * A VierGewinnt board is a square and hence possesses an identical non-zero
32: * positive number of rows and columns. Each combination of a row and a column
33: * is described by a {@link VierGewinntPosition position}. At each position,
34: * there is a {@link VierGewinntField field} which describes whether the field
35: * is empty or marked by a cross or nought.
36: */
37: public interface VierGewinntBoard extends Stateful {
38:
39: /**
40: * Returns the number of fields of this board.
41: */
42: int getSize();
43:
44: /**
45: * Returns the number of rows of this board.
46: */
47: int getRowSize();
48:
49: /**
50: * Returns the number of columns of this board.
51: */
52: int getColumnSize();
53:
54: /**
55: * Returns a list of all rows on this board.
56: */
57: List<VierGewinntRow> getRows();
58:
59: /**
60: * Checks whether this board contains a field at the position passed.
61: *
62: * @param position The position.
63: * @return {@code true} if this board contains a field at the position passed,
64: * else {@code false}.
65: */
66: boolean hasFieldAt(VierGewinntPosition position);
67:
68: /**
69: * Returns the field at the given position.
70: *
71: * @param position The position of the field to return.
72: * @return The field.
73: * @throws IllegalArgumentException if the position is out of range, i.e. if it
74: * does not denote a field.
75: */
76: VierGewinntField getFieldAt(VierGewinntPosition position);
77:
78: /**
79: * Returns all fields of this board line by line.
80: * <p>
81: * The set returned are possibly immutable, so do not modify them.
82: */
83: List<VierGewinntField> getFields();
84:
85: /**
86: * Returns all fields of a given state.
87: * <p>
88: * The map returned returned is possibly immutable, so do not modify it.
89: *
90: * @param fieldState The state of the fields to return.
91: * @return The fields.
92: */
93: Map<VierGewinntPosition, ? extends VierGewinntField> getFieldsBeing(VierGewinntFieldState fieldState);
94:
95: /**
96: * All playable fields.
97: *
98: * @return a Set of {@link VierGewinntField}
99: */
100: Set<VierGewinntField> getAllPlayableFields();
101:
102: @Override
103: VierGewinntBoard deepCopy();
104:
105: }