rstt.game package

Submodules

rstt.game.match module

class rstt.game.match.Duel(player1: SPlayer, player2: SPlayer, tracking: bool | None = None)[source]

Bases: Match

Duel class

Duel is a special type of rstt.game.match.Match with only two teams each consisiting of one player. In other words, two players facing each others.

Parameters

player1SPlayer

A player considered at ‘home’.

player2SPlayer

A player considered as ‘visitor’

trackingbool, optional

If true, the duel will try to add itself (once it has been assigned a score) to the both player’s game history, by default None.

isdraw() bool[source]

Getter method indicating a draw

A draw is a match where both player have the same scores, ranks.

Returns

bool

True if both player have the same score, in that case the rstt.game.match.Duel.winner() and rstt.game.match.Match.loser() return None. False if the duel has a winner and a loser.

loser() SPlayer[source]

Getter method for the loser of the duel

The loser is the player with the lowest score value, highest rank.

Returns

SPlayer

The loser of the duel. Can be None if the duel has not yet been played or in the case of a draw.

opponent(player: SPlayer) SPlayer[source]

Getter method for the opponent of a player in a duel

Suger method that returns the same value has rstt.game.match.Match.opponents(), but grammatically more correct has there is only one opponent in a duel.

Parameters

playerSPlayer

A player to get the opponent.

Returns

Splayer

The opponent of the parameter player.

Raises:

KeyError

When the parameter player is not a participant of the duel.

player1() SPlayer[source]

Getter method for player 1

Player1 can also be refer has the one playing at ‘home’.

Returns

SPlayer

the first player of the duel.

player2() SPlayer[source]

Getter method for palyer 2

Player2 - the opponent of player1 - can also be refered as ‘visitor’ or playing ‘away’.

Returns

SPlayer

the 2nd player of the duel.

winner() SPlayer[source]

Getter method for the winner of the duel

In a direct confrontation between two competitors, there is usually a winner (the one with the highest score, lowest rank) and a loser.

Returns

SPlayer

The winner of the duel. Can be None if the duel has not yet been played or in the case of a draw.

class rstt.game.match.Match(teams: list[list[SPlayer]], tracking: bool | None = None)[source]

Bases: object

Match base Class

General purpose match class. It can be used to create arbitrary game mode such as Many-versus-Many or Free-For-All games.

Parameters

teamsList[List[SPlayer]]

Participants of the match organized in a list of list. Players in the same sublist are part of the same team.

trackingbool, optional

If true, the match will try to add itself to the participants game history, by default None.

Raises

ValueError:

A Splayer can not be an element of two distinct sublist in the parameter teams.

live() bool[source]

Getter method for the match status

A live match is a match that has not yet been assigned an outcome/result.

Returns

bool

True if the match has yet to be played. False if the match has a scores assigned.

opponents(player: SPlayer) list[SPlayer][source]

Getter method for opponents

Opponents are participants of the match that or not in the same team as the given player.

Parameters

playerSPlayer

A player to get the opponents

Returns

List[SPlayer]

A list of opponents playing against the player, in a single list, not grouped by teams

players() list[SPlayer][source]

Getter method for player

Unlike rstt.game.match.Match.teams(), it returns a simple list of SPlayer, without grouping them by teams.

Returns

List[SPlayer]

All the participants of the match.

ranks() list[int][source]

Getter method for the team ranks

The ranks method is an alternative to the scores method. For a Match between n teams, the return list contains the values 1,…,n. The higher the score of a team, the lower the value in the return list.

Returns

List[int]

The rank of each team.

Raises

RuntimeError

This method can only be called when the match has been played and assigned a score.

score(player: SPlayer) float[source]

Getter method for the score of a given player.

Unlike the rstt.game.match.Match.scores(), this function return a single float value representing the success the parameter player had.

Parameters

playerSPlayer

A player to get the score.

Returns

float

A value representing the score, result of the player.

Raises

RuntimeError

This method can only be called when the match has been played and assigned a score.

scores() list[float][source]

Getter method for the match outcome

The result/outcome of the match. A rstt.stypes.Score is a list of float. The length of the Score is equal to the number of teams (i.e the length of the return value of :func: rstt.game.match.Match.teams).

Returns

Score

The outcom of the match. None if the match has not been played yet. Ordering of the float value matches the ordering of the teams as return by rstt.game.match.Match.teams()

teammates(player: SPlayer) list[SPlayer][source]

Getter method for teammates

Teammates of a player are other players in the same teams

Parameters

playerSPlayer

A player to get teammates

Returns

List[SPlayer]

All the player’s teammates

teams() list[list[SPlayer]][source]

Getter method for teams

Returns

List[List[SPlayer]]

All the players participating in the match grouped by teams.

Module contents

Modues defining SMatch

SMatch are the notion of game/match, competitive confrontation. It is more of a ponctual event with an outcome rather than a game with its own set of rules and mechanics. SMatch have participants, accessed by the method rstt.game.match.Match.players() and the result - a rstt.stypes.Score returned by the method rstt.game.match.Match.scores()

class rstt.game.Duel(player1: SPlayer, player2: SPlayer, tracking: bool | None = None)[source]

Bases: Match

Duel class

Duel is a special type of rstt.game.match.Match with only two teams each consisiting of one player. In other words, two players facing each others.

Parameters

player1SPlayer

A player considered at ‘home’.

player2SPlayer

A player considered as ‘visitor’

trackingbool, optional

If true, the duel will try to add itself (once it has been assigned a score) to the both player’s game history, by default None.

isdraw() bool[source]

Getter method indicating a draw

A draw is a match where both player have the same scores, ranks.

Returns

bool

True if both player have the same score, in that case the rstt.game.match.Duel.winner() and rstt.game.match.Match.loser() return None. False if the duel has a winner and a loser.

loser() SPlayer[source]

Getter method for the loser of the duel

The loser is the player with the lowest score value, highest rank.

Returns

SPlayer

The loser of the duel. Can be None if the duel has not yet been played or in the case of a draw.

opponent(player: SPlayer) SPlayer[source]

Getter method for the opponent of a player in a duel

Suger method that returns the same value has rstt.game.match.Match.opponents(), but grammatically more correct has there is only one opponent in a duel.

Parameters

playerSPlayer

A player to get the opponent.

Returns

Splayer

The opponent of the parameter player.

Raises:

KeyError

When the parameter player is not a participant of the duel.

player1() SPlayer[source]

Getter method for player 1

Player1 can also be refer has the one playing at ‘home’.

Returns

SPlayer

the first player of the duel.

player2() SPlayer[source]

Getter method for palyer 2

Player2 - the opponent of player1 - can also be refered as ‘visitor’ or playing ‘away’.

Returns

SPlayer

the 2nd player of the duel.

winner() SPlayer[source]

Getter method for the winner of the duel

In a direct confrontation between two competitors, there is usually a winner (the one with the highest score, lowest rank) and a loser.

Returns

SPlayer

The winner of the duel. Can be None if the duel has not yet been played or in the case of a draw.

class rstt.game.Match(teams: list[list[SPlayer]], tracking: bool | None = None)[source]

Bases: object

Match base Class

General purpose match class. It can be used to create arbitrary game mode such as Many-versus-Many or Free-For-All games.

Parameters

teamsList[List[SPlayer]]

Participants of the match organized in a list of list. Players in the same sublist are part of the same team.

trackingbool, optional

If true, the match will try to add itself to the participants game history, by default None.

Raises

ValueError:

A Splayer can not be an element of two distinct sublist in the parameter teams.

live() bool[source]

Getter method for the match status

A live match is a match that has not yet been assigned an outcome/result.

Returns

bool

True if the match has yet to be played. False if the match has a scores assigned.

opponents(player: SPlayer) list[SPlayer][source]

Getter method for opponents

Opponents are participants of the match that or not in the same team as the given player.

Parameters

playerSPlayer

A player to get the opponents

Returns

List[SPlayer]

A list of opponents playing against the player, in a single list, not grouped by teams

players() list[SPlayer][source]

Getter method for player

Unlike rstt.game.match.Match.teams(), it returns a simple list of SPlayer, without grouping them by teams.

Returns

List[SPlayer]

All the participants of the match.

ranks() list[int][source]

Getter method for the team ranks

The ranks method is an alternative to the scores method. For a Match between n teams, the return list contains the values 1,…,n. The higher the score of a team, the lower the value in the return list.

Returns

List[int]

The rank of each team.

Raises

RuntimeError

This method can only be called when the match has been played and assigned a score.

score(player: SPlayer) float[source]

Getter method for the score of a given player.

Unlike the rstt.game.match.Match.scores(), this function return a single float value representing the success the parameter player had.

Parameters

playerSPlayer

A player to get the score.

Returns

float

A value representing the score, result of the player.

Raises

RuntimeError

This method can only be called when the match has been played and assigned a score.

scores() list[float][source]

Getter method for the match outcome

The result/outcome of the match. A rstt.stypes.Score is a list of float. The length of the Score is equal to the number of teams (i.e the length of the return value of :func: rstt.game.match.Match.teams).

Returns

Score

The outcom of the match. None if the match has not been played yet. Ordering of the float value matches the ordering of the teams as return by rstt.game.match.Match.teams()

teammates(player: SPlayer) list[SPlayer][source]

Getter method for teammates

Teammates of a player are other players in the same teams

Parameters

playerSPlayer

A player to get teammates

Returns

List[SPlayer]

All the player’s teammates

teams() list[list[SPlayer]][source]

Getter method for teams

Returns

List[List[SPlayer]]

All the players participating in the match grouped by teams.