whist_core.session.matcher

Match making tool.

Attributes

subclass_registry

Classes

Matcher

Abstrakt class for player to teams matching.

RoundRobinMatcher

Distributes the players in the order of the user list.

RandomMatcher

Distributes the players randomly to teams.

Module Contents

whist_core.session.matcher.subclass_registry
class whist_core.session.matcher.Matcher

Bases: abc.ABC, pydantic.BaseModel

Abstrakt class for player to teams matching.

teams: list[whist_core.session.distribution.Distribution] = []
number_teams: int
classmethod __init_subclass__(**kwargs)

Initializes the subclass :param kwargs: field from above :return: None

Parameters:

kwargs (Any)

Return type:

None

abstractmethod distribute(users)

Distributes cards according to subclass implementation. :param users: the players to be distributed to teams :return: the list of teams with players distributed to them

Parameters:

users (whist_core.session.userlist.UserList)

Return type:

whist_core.session.distribution.Distribution

_apply_distribution(distribution)
class whist_core.session.matcher.RoundRobinMatcher(number_teams, **data)

Bases: Matcher

Distributes the players in the order of the user list.

Parameters:

number_teams (int)

iteration: int = 0
distributions: list[whist_core.session.distribution.Distribution] = []
distribute(users)

Distributes one player to each team each round in order of the user list. Repeats until the user list is empty. :param users: the players to be distributed to teams :return: the teams in round robin distribution

Parameters:

users (whist_core.session.userlist.UserList)

Return type:

whist_core.session.distribution.Distribution

_precalculate_distributions(number_players)
Parameters:

number_players (int)

class whist_core.session.matcher.RandomMatcher

Bases: Matcher

Distributes the players randomly to teams.

distribute(users)

For given parameter distributes the players to teams. :return: None :rtype: None

Parameters:

users (whist_core.session.userlist.UserList)

Return type:

whist_core.session.distribution.Distribution