whist_core.session.userlist

Handles users joining and leaving a table.

Classes

UserListEntry

Entry class containing the player object and its current status at the table.

UserList

User handler for tables.

Module Contents

class whist_core.session.userlist.UserListEntry

Bases: pydantic.BaseModel

Entry class containing the player object and its current status at the table.

player: whist_core.user.player.Player
status: whist_core.user.status.Status
class whist_core.session.userlist.UserList

Bases: pydantic.BaseModel

User handler for tables.

users: Dict[str, UserListEntry]
__len__()

Amount of players

property players: list[whist_core.user.player.Player]

Returns all players at the table. :return: players of the table :rtype: list[Player]

Return type:

list[whist_core.user.player.Player]

property ready: bool

Returns if all players are ready. :return: Ready or not :rtype: boolean

Return type:

bool

property teams: list[whist_core.scoring.team.Team]

Returns the teams. :return: list of teams

Return type:

list[whist_core.scoring.team.Team]

team(player)

Gets the id of the team for a player. :param player: for which the id should be retrieved :type player: Player :return: Integer if player joined a team or None if not. :rtype: int

Parameters:

player (whist_core.user.player.Player)

Return type:

Optional[int]

team_size(team)

Gets the size of the team. :param team: ID of the team :type team: int :return: Amount of members :rtype: int

Parameters:

team (int)

Return type:

int

is_joined(player)

Checks if the player is already at the table. :param player: to check :type player: Player :return: True if is member else false :rtype: bool

Parameters:

player (whist_core.user.player.Player)

Return type:

bool

append(player)

Adds a player to the list. :param player: player to join :type player: Player :return: None :rtype: None

Parameters:

player (whist_core.user.player.Player)

remove(player)

Removes the player from the list. :param player: player to leave :type player: Player :return: None :rtype: None

Parameters:

player (whist_core.user.player.Player)

apply_distribution(distribution)

Apply the changes of teams. :param distribution: matrix of player assignment to teams :return: None

Parameters:

distribution (whist_core.session.distribution.Distribution)

Return type:

None

change_team(player, team)

Player changes teams. :param player: to change teams :type player: Player :param team: id of the new team :type team: int :return: None :rtype: None

Parameters:
Return type:

None

player_ready(player)

Player says they is ready. :param player: player who is ready, must be joined :type player: Player :return: Raised PlayerNotJoinedError if the player has not yet joined. :rtype: None

Parameters:

player (whist_core.user.player.Player)

player_unready(player)

Player says they is not ready. :param player: player who is not ready :type player: Player :return: Raised PlayerNotJoinedError if the player has not yet joined. :rtype: None

Parameters:

player (whist_core.user.player.Player)

_get_status(player)
Return type:

whist_core.user.status.Status

_get_entry(player)
Return type:

UserListEntry