Skip to content

Commit ad8813d

Browse files
committed
docs(sdk): improve documentation for Games
1 parent 5f0f9f1 commit ad8813d

File tree

2 files changed

+23
-20
lines changed

2 files changed

+23
-20
lines changed

sdk/src/server-api/sc/api/plugins/TwoPlayerGameState.kt

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,34 +10,34 @@ abstract class TwoPlayerGameState<P : Player>(
1010
abstract val first: P
1111
abstract val second: P
1212
abstract val board: IBoard
13-
14-
/** List of all teams. */
13+
14+
/** Der Spieler, der das Spiel begonnen hat. */
15+
val startPlayer: P
16+
get() = getPlayer(startTeam)
17+
18+
/** Liste aller Spieler in Reihenfolge. */
1519
val players: List<P>
1620
get() = listOf(first, second)
1721

18-
/** Die Namen der beiden Spieler. */
22+
/** @returns die Namen aller Spieler in Reihenfolge. */
1923
val playerNames: Array<String>
2024
get() = arrayOf(first.displayName, second.displayName)
2125

22-
/** The Team active in the current turn. */
26+
/** @return das Team, das dran ist. */
2327
abstract val currentTeam: ITeam
24-
25-
/** The Player whose team's turn it is. */
28+
29+
/** @return das Team, das nicht dran ist. */
30+
val otherTeam: ITeam
31+
get() = currentTeam.opponent()
32+
33+
/** Der Spieler, der am Zug ist. */
2634
open val currentPlayer: P
2735
get() = getPlayer(currentTeam)
2836

29-
/** The player opposite to the currently active one. */
37+
/** Der Spieler, der nicht am Zug ist. */
3038
val otherPlayer: P
3139
get() = getPlayer(otherTeam)
3240

33-
/** The Team opposite to the currently active one. */
34-
val otherTeam: ITeam
35-
get() = currentTeam.opponent()
36-
37-
/** Der Spieler, der das Spiel begonnen hat. */
38-
val startPlayer: P
39-
get() = getPlayer(startTeam)
40-
4141
/** Letzter getaetigter Zug. */
4242
abstract val lastMove: IMove?
4343

sdk/src/server-api/sc/framework/plugins/AbstractGame.kt

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ abstract class AbstractGame<P : Player>(override val pluginUUID: String) : IGame
3737
* @param fromPlayer The player who invoked this action.
3838
* @param data The plugin-specific data.
3939
*
40-
* @throws GameLogicException if any invalid action is done, i.e. game rule violation
40+
* @throws GameLogicException if no move has been requested from the given [Player]
41+
* @throws InvalidMoveException when the given Move is not possible
4142
*/
4243
@Throws(GameLogicException::class, InvalidMoveException::class)
4344
override fun onAction(fromPlayer: Player, data: ProtocolMessage) {
@@ -61,11 +62,13 @@ abstract class AbstractGame<P : Player>(override val pluginUUID: String) : IGame
6162
abstract fun onRoundBasedAction(fromPlayer: Player, data: ProtocolMessage)
6263

6364
/**
64-
* Checks if a win condition in the current game state is met.
65-
* Checks round limit and end of round (and playerStats).
66-
* Checks if goal is reached.
65+
* Returns a WinCondition if the Game is over.
66+
* Checks:
67+
* - if a win condition in the current game state is met
68+
* - round limit and end of round (and playerStats)
69+
* - whether goal is reached
6770
*
68-
* @return WinCondition with winner and reason or null, if no win condition is yet met.
71+
* @return WinCondition, or null if no win condition is met yet.
6972
*/
7073
abstract fun checkWinCondition(): WinCondition?
7174

0 commit comments

Comments
 (0)