Skip to content

Method: toString()

1: package de.fhdw.gaming.ipspiel22.kopfundzahl.domain.impl;
2:
3: import java.util.Map;
4: import java.util.Optional;
5:
6: import de.fhdw.gaming.core.domain.DefaultGame;
7: import de.fhdw.gaming.core.domain.ObserverFactoryProvider;
8: import de.fhdw.gaming.ipspiel22.kopfundzahl.domain.KopfundZahlGame;
9: import de.fhdw.gaming.ipspiel22.kopfundzahl.domain.KopfundZahlMoveChecker;
10: import de.fhdw.gaming.ipspiel22.kopfundzahl.domain.KopfundZahlPlayer;
11: import de.fhdw.gaming.ipspiel22.kopfundzahl.domain.KopfundZahlState;
12: import de.fhdw.gaming.ipspiel22.kopfundzahl.domain.KopfundZahlStrategy;
13: import de.fhdw.gaming.ipspiel22.kopfundzahl.moves.KopfundZahlMove;
14: import de.fhdw.gaming.ipspiel22.kopfundzahl.moves.factory.KopfundZahlMoveFactory;
15: import de.fhdw.gaming.ipspiel22.kopfundzahl.moves.impl.DefaultKopfundZahlMoveFactory;
16:
17: /**
18: * Implements a KopfundZahl game.
19: */
20: public final class KopfundZahlGameImpl extends DefaultGame<KopfundZahlPlayer, KopfundZahlState, KopfundZahlMove,
21: KopfundZahlStrategy> implements KopfundZahlGame {
22:
23: /**
24: * The move Factory.
25: */
26: private final KopfundZahlMoveFactory moveFactory;
27:
28: /**
29: * Creates a KopfundZahl game.
30: *
31: * @param id The ID of this game.
32: * @param initialState The initial state of the game.
33: * @param strategies The players' strategies.
34: * @param maxComputationTimePerMove The maximum computation time per move in seconds.
35: * @param moveChecker The move checker.
36: * @param observerFactoryProvider The maximum computation time per move in seconds.
37: * @throws IllegalArgumentException if the player sets do not match.
38: * @throws InterruptedException if creating the game has been interrupted.
39: */
40: KopfundZahlGameImpl(final int id, final KopfundZahlState initialState, final Map<String,
41: KopfundZahlStrategy> strategies,
42: final long maxComputationTimePerMove, final KopfundZahlMoveChecker moveChecker,
43: final ObserverFactoryProvider observerFactoryProvider)
44: throws IllegalArgumentException, InterruptedException {
45: super(id, initialState, strategies, maxComputationTimePerMove, moveChecker, observerFactoryProvider);
46: this.moveFactory = new DefaultKopfundZahlMoveFactory();
47: }
48:
49: @Override
50: public Optional<KopfundZahlMove> chooseRandomMove(final KopfundZahlPlayer player, final KopfundZahlState state) {
51: return Optional.of(this.moveFactory.createTailMove());
52: }
53:
54: @Override
55: public String toString() {
56: return String.format("KopfundZahlGame[id=%d, %s]", this.getId(), this.gameToString());
57: }
58:
59: }