Skip to content

Package: GameBuilder

GameBuilder

Coverage

1: /*
2: * Copyright © 2020-2023 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: import java.util.List;
22:
23: /**
24: * A builder which allows to create a game.
25: */
26: public interface GameBuilder {
27:
28: /**
29: * The default maximum computation time per move in seconds.
30: */
31: int DEFAULT_MAX_COMPUTATION_TIME_PER_MOVE = 5;
32:
33: /**
34: * Changes the maximum computation time per move in seconds.
35: * <p>
36: * If this operation is called multiple times, only the last value will be retained. If not called, the default size
37: * of {@link #DEFAULT_MAX_COMPUTATION_TIME_PER_MOVE} seconds is used.
38: *
39: * @param newMaxComputationTimePerMove The new maximum computation time per move in seconds.
40: * @return {@code this}
41: */
42: GameBuilder changeMaximumComputationTimePerMove(int newMaxComputationTimePerMove);
43:
44: /**
45: * Adds {@link Observer}s to be attached to the game.
46: *
47: * @param newObservers The list of {@link Observer}s to be attached to the game.
48: * @return {@code this}
49: */
50: GameBuilder addObservers(List<Observer> newObservers);
51:
52: /**
53: * Builds the game. Can be called as many times as desired, each time returning a new game.
54: *
55: * @param id The ID of the game.
56: * @throws GameException if creating the game is not allowed by the rules of the game.
57: * @throws InterruptedException if creating the game has been interrupted.
58: */
59: Game<?, ?, ?, ?> build(int id) throws GameException, InterruptedException;
60: }