Skip to content

Package: Player

Player

Coverage

1: /*
2: * Copyright © 2020 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.Optional;
22:
23: /**
24: * Represents a player, i.e.some participant of the game that acts for itself and aims at winning the game. It does not
25: * necessarily have to be a human.
26: * <p>
27: * Note that even if a player has a state, a {@link Player} is not a {@link Stateful} object as the player (and the
28: * player's state) is managed by the {@link State} class.
29: */
30: public interface Player {
31:
32: /**
33: * Returns the name of this player.
34: */
35: String getName();
36:
37: /**
38: * Returns the state of this player.
39: */
40: PlayerState getState();
41:
42: /**
43: * Returns the outcome of this player (if available). The outcome is unavailable if the player is in the state
44: * {@link PlayerState#PLAYING}. Otherwise, if no outcome has been set, the outcome is computed from the player's
45: * state:
46: * <ul>
47: * <li>1.0 if the state is {@link PlayerState#WON}</li>
48: * <li>0.0 if the state is {@link PlayerState#DRAW}</li>
49: * <li>-1.0 if the state is {@link PlayerState#LOST} or {@link PlayerState#RESIGNED}</li>
50: * </ul>
51: */
52: Optional<Double> getOutcome();
53: }