Skip to content

Package: VierConnectsBoard

VierConnectsBoard

Coverage

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