Module server.rating_service.typedefs

Classes

class GameRatingResult (game_id: int,
rating_type: str,
old_ratings: dict[int, Rating],
new_ratings: dict[int, Rating],
outcome_map: dict[int, GameOutcome])
Expand source code
class GameRatingResult(NamedTuple):
    game_id: int
    rating_type: str
    old_ratings: RatingDict
    new_ratings: RatingDict
    outcome_map: dict[PlayerID, GameOutcome]

GameRatingResult(game_id, rating_type, old_ratings, new_ratings, outcome_map)

Ancestors

  • builtins.tuple

Instance variables

var game_id : int
Expand source code
class GameRatingResult(NamedTuple):
    game_id: int
    rating_type: str
    old_ratings: RatingDict
    new_ratings: RatingDict
    outcome_map: dict[PlayerID, GameOutcome]

Alias for field number 0

var new_ratings : dict[int, Rating]
Expand source code
class GameRatingResult(NamedTuple):
    game_id: int
    rating_type: str
    old_ratings: RatingDict
    new_ratings: RatingDict
    outcome_map: dict[PlayerID, GameOutcome]

Alias for field number 3

var old_ratings : dict[int, Rating]
Expand source code
class GameRatingResult(NamedTuple):
    game_id: int
    rating_type: str
    old_ratings: RatingDict
    new_ratings: RatingDict
    outcome_map: dict[PlayerID, GameOutcome]

Alias for field number 2

var outcome_map : dict[int, GameOutcome]
Expand source code
class GameRatingResult(NamedTuple):
    game_id: int
    rating_type: str
    old_ratings: RatingDict
    new_ratings: RatingDict
    outcome_map: dict[PlayerID, GameOutcome]

Alias for field number 4

var rating_type : str
Expand source code
class GameRatingResult(NamedTuple):
    game_id: int
    rating_type: str
    old_ratings: RatingDict
    new_ratings: RatingDict
    outcome_map: dict[PlayerID, GameOutcome]

Alias for field number 1

class GameRatingSummary (game_id: int,
rating_type: str,
teams: list[TeamRatingSummary])
Expand source code
class GameRatingSummary(NamedTuple):
    """
    Holds minimal information needed to rate a game.
    Fields:
     - game_id: id of the game to rate
     - rating_type: str (e.g. "ladder1v1")
     - teams: a list of two TeamRatingSummaries
    """

    game_id: int
    rating_type: str
    teams: list[TeamRatingSummary]

    @classmethod
    def from_game_info_dict(cls, game_info: dict[str]) -> "GameRatingSummary":
        if len(game_info["teams"]) != 2:
            raise ValueError("Detected other than two teams.")

        return cls(
            game_info["game_id"],
            game_info["rating_type"],
            [
                TeamRatingSummary(
                    GameOutcome(summary["outcome"]),
                    set(summary["player_ids"]),
                    summary["army_results"],
                )
                for summary in game_info["teams"]
            ],
        )

Holds minimal information needed to rate a game. Fields: - game_id: id of the game to rate - rating_type: str (e.g. "ladder1v1") - teams: a list of two TeamRatingSummaries

Ancestors

  • builtins.tuple

Static methods

def from_game_info_dict(game_info: dict[str]) ‑> GameRatingSummary

Instance variables

var game_id : int
Expand source code
class GameRatingSummary(NamedTuple):
    """
    Holds minimal information needed to rate a game.
    Fields:
     - game_id: id of the game to rate
     - rating_type: str (e.g. "ladder1v1")
     - teams: a list of two TeamRatingSummaries
    """

    game_id: int
    rating_type: str
    teams: list[TeamRatingSummary]

    @classmethod
    def from_game_info_dict(cls, game_info: dict[str]) -> "GameRatingSummary":
        if len(game_info["teams"]) != 2:
            raise ValueError("Detected other than two teams.")

        return cls(
            game_info["game_id"],
            game_info["rating_type"],
            [
                TeamRatingSummary(
                    GameOutcome(summary["outcome"]),
                    set(summary["player_ids"]),
                    summary["army_results"],
                )
                for summary in game_info["teams"]
            ],
        )

Alias for field number 0

var rating_type : str
Expand source code
class GameRatingSummary(NamedTuple):
    """
    Holds minimal information needed to rate a game.
    Fields:
     - game_id: id of the game to rate
     - rating_type: str (e.g. "ladder1v1")
     - teams: a list of two TeamRatingSummaries
    """

    game_id: int
    rating_type: str
    teams: list[TeamRatingSummary]

    @classmethod
    def from_game_info_dict(cls, game_info: dict[str]) -> "GameRatingSummary":
        if len(game_info["teams"]) != 2:
            raise ValueError("Detected other than two teams.")

        return cls(
            game_info["game_id"],
            game_info["rating_type"],
            [
                TeamRatingSummary(
                    GameOutcome(summary["outcome"]),
                    set(summary["player_ids"]),
                    summary["army_results"],
                )
                for summary in game_info["teams"]
            ],
        )

Alias for field number 1

var teams : list[TeamRatingSummary]
Expand source code
class GameRatingSummary(NamedTuple):
    """
    Holds minimal information needed to rate a game.
    Fields:
     - game_id: id of the game to rate
     - rating_type: str (e.g. "ladder1v1")
     - teams: a list of two TeamRatingSummaries
    """

    game_id: int
    rating_type: str
    teams: list[TeamRatingSummary]

    @classmethod
    def from_game_info_dict(cls, game_info: dict[str]) -> "GameRatingSummary":
        if len(game_info["teams"]) != 2:
            raise ValueError("Detected other than two teams.")

        return cls(
            game_info["game_id"],
            game_info["rating_type"],
            [
                TeamRatingSummary(
                    GameOutcome(summary["outcome"]),
                    set(summary["player_ids"]),
                    summary["army_results"],
                )
                for summary in game_info["teams"]
            ],
        )

Alias for field number 2

class RatingServiceError (*args, **kwargs)
Expand source code
class RatingServiceError(Exception):
    pass

Common base class for all non-exit exceptions.

Ancestors

  • builtins.Exception
  • builtins.BaseException

Subclasses

class ServiceNotReadyError (*args, **kwargs)
Expand source code
class ServiceNotReadyError(RatingServiceError):
    pass

Common base class for all non-exit exceptions.

Ancestors