MatchPlayers

data class MatchPlayers(val player1: Player? = null, val player2: Player? = null) : Iterable<Player>

Represents the players in a Reversi match, supporting zero to two players.

Constructors

Link copied to clipboard
constructor(player1: Player? = null, player2: Player? = null)

Properties

Link copied to clipboard

The first player, or null if not yet assigned.

Link copied to clipboard

The second player, or null if not yet assigned.

Functions

Link copied to clipboard
fun addPlayerOrNull(newPlayerName: Player): MatchPlayers?

Adds a new player to the match if there is space available and the player type is not already taken.

Link copied to clipboard
operator fun get(index: Int): Player?

Gets a player by index (0 for player1, 1 for player2).

Link copied to clipboard

Returns a list of available piece types that can be assigned to new players. If both players are already assigned, the list will be empty.

Link copied to clipboard

Gets the next available piece type that has not yet been assigned.

Link copied to clipboard

Gets a player by their piece type.

Link copied to clipboard

Checks if exactly one player has been assigned.

Link copied to clipboard

Checks if no players have been assigned.

Link copied to clipboard

Checks if both player slots are filled.

Link copied to clipboard

Checks if at least one player has been assigned.

Link copied to clipboard
open operator override fun iterator(): Iterator<Player>
Link copied to clipboard

Refreshes both players' point counts based on the current board state.