Module server.games.typedefs

Classes

class BasicGameInfo (game_id: int, rating_type: Optional[str], map_id: int, game_mode: str, mods: list[int], teams: list[set[Player]])

Holds basic information about a game that does not change after launch. Fields: - game_id: id of the game - rating_type: str (e.g. "ladder1v1") - map_id: id of the map used - game_mode: name of the featured mod

Expand source code
class BasicGameInfo(NamedTuple):
    """
    Holds basic information about a game that does not change after launch.
    Fields:
     - game_id: id of the game
     - rating_type: str (e.g. "ladder1v1")
     - map_id: id of the map used
     - game_mode: name of the featured mod
    """

    game_id: int
    rating_type: Optional[str]
    map_id: int
    game_mode: str
    mods: list[int]
    teams: list[set[Player]]

Ancestors

  • builtins.tuple

Instance variables

var game_id : int

Alias for field number 0

var game_mode : str

Alias for field number 3

var map_id : int

Alias for field number 2

var mods : list[int]

Alias for field number 4

var rating_type : Optional[str]

Alias for field number 1

var teams : list[set[Player]]

Alias for field number 5

class EndedGameInfo (game_id: int, rating_type: Optional[str], map_id: int, game_mode: str, mods: list[int], commander_kills: dict[str, int], validity: ValidityState, team_summaries: list[TeamRatingSummary])

Holds the outcome of an ended game. Fields: - game_id: id of the game - rating_type: str (e.g. "ladder1v1") - map_id: id of the map used - game_mode: name of the featured mod - validity: ValidityState (e.g. VALID or TOO_SHORT) - team_summaries: a list of TeamRatingSummaries containing IDs of players on the team and the team's outcome

Expand source code
class EndedGameInfo(NamedTuple):
    """
    Holds the outcome of an ended game.
    Fields:
     - game_id: id of the game
     - rating_type: str (e.g. "ladder1v1")
     - map_id: id of the map used
     - game_mode: name of the featured mod
     - validity: ValidityState (e.g. VALID or TOO_SHORT)
     - team_summaries: a list of TeamRatingSummaries containing IDs of players
       on the team and the team's outcome
    """

    game_id: int
    rating_type: Optional[str]
    map_id: int
    game_mode: str
    mods: list[int]
    commander_kills: dict[str, int]
    validity: ValidityState
    team_summaries: list[TeamRatingSummary]

    @classmethod
    def from_basic(
        cls,
        basic_info: BasicGameInfo,
        validity: ValidityState,
        team_outcomes: list[GameOutcome],
        commander_kills: dict[str, int],
        team_army_results: list[list[ArmyResult]],
    ) -> "EndedGameInfo":
        if len(basic_info.teams) != len(team_outcomes):
            raise ValueError(
                "Team sets of basic_info and team outcomes must refer to the "
                "same number of teams in the same order."
            )

        return cls(
            basic_info.game_id,
            basic_info.rating_type,
            basic_info.map_id,
            basic_info.game_mode,
            basic_info.mods,
            commander_kills,
            validity,
            [
                TeamRatingSummary(outcome, set(player.id for player in team), army_results)
                for outcome, team, army_results
                in zip(team_outcomes, basic_info.teams, team_army_results)
            ],
        )

    def to_dict(self):
        return {
            "game_id": self.game_id,
            "rating_type": self.rating_type
            if self.rating_type is not None
            else "None",
            "map_id": self.map_id,
            "featured_mod": self.game_mode,
            "sim_mod_ids": self.mods,
            "commander_kills": self.commander_kills,
            "validity": self.validity.name,
            "teams": [
                {
                    "outcome": team_summary.outcome.name,
                    "player_ids": list(team_summary.player_ids),
                    "army_results": [
                        result._asdict()
                        for result in sorted(
                            team_summary.army_results,
                            key=lambda x: x.player_id
                        )
                    ],
                }
                for team_summary in self.team_summaries
            ],
        }

Ancestors

  • builtins.tuple

Static methods

def from_basic(basic_info: BasicGameInfo, validity: ValidityState, team_outcomes: list[GameOutcome], commander_kills: dict[str, int], team_army_results: list[list[ArmyResult]]) ‑> EndedGameInfo

Instance variables

var commander_kills : dict[str, int]

Alias for field number 5

var game_id : int

Alias for field number 0

var game_mode : str

Alias for field number 3

var map_id : int

Alias for field number 2

var mods : list[int]

Alias for field number 4

var rating_type : Optional[str]

Alias for field number 1

var team_summaries : list[TeamRatingSummary]

Alias for field number 7

var validityValidityState

Alias for field number 6

Methods

def to_dict(self)
class FA
Expand source code
class FA(object):
    __slots__ = ()

    ENABLED = _FAEnabled()
    DISABLED = _FADisabled()

Class variables

var DISABLED
var ENABLED
class FeaturedModType

String constants for featured mod technical_name

Expand source code
class FeaturedModType():
    """
    String constants for featured mod technical_name
    """

    COOP = "coop"
    FAF = "faf"
    FAFBETA = "fafbeta"
    LADDER_1V1 = "ladder1v1"

Class variables

var COOP
var FAF
var FAFBETA
var LADDER_1V1
class GameConnectionState (value, names=None, *, module=None, qualname=None, type=None, start=1)

An enumeration.

Expand source code
@unique
class GameConnectionState(Enum):
    INITIALIZING = 0
    INITIALIZED = 1
    CONNECTED_TO_HOST = 2
    ENDED = 3

Ancestors

  • enum.Enum

Class variables

var CONNECTED_TO_HOST
var ENDED
var INITIALIZED
var INITIALIZING
class GameState (value, names=None, *, module=None, qualname=None, type=None, start=1)

An enumeration.

Expand source code
@unique
class GameState(Enum):
    INITIALIZING = 0
    LOBBY = 1
    LIVE = 2
    ENDED = 3

Ancestors

  • enum.Enum

Class variables

var ENDED
var INITIALIZING
var LIVE
var LOBBY
class GameType (value, names=None, *, module=None, qualname=None, type=None, start=1)

An enumeration.

Expand source code
@unique
class GameType(Enum):
    COOP = "coop"
    CUSTOM = "custom"
    MATCHMAKER = "matchmaker"

Ancestors

  • enum.Enum

Class variables

var COOP
var CUSTOM
var MATCHMAKER
class InitMode (value, names=None, *, module=None, qualname=None, type=None, start=1)

An enumeration.

Expand source code
@unique
class InitMode(Enum):
    NORMAL_LOBBY = 0
    AUTO_LOBBY = 1

Ancestors

  • enum.Enum

Class variables

var AUTO_LOBBY
var NORMAL_LOBBY
class TeamRatingSummary (outcome: GameOutcome, player_ids: set[int], army_results: list[ArmyResult])

TeamRatingSummary(outcome, player_ids, army_results)

Expand source code
class TeamRatingSummary(NamedTuple):
    outcome: GameOutcome
    player_ids: set[int]
    army_results: list[ArmyResult]

Ancestors

  • builtins.tuple

Instance variables

var army_results : list[ArmyResult]

Alias for field number 2

var outcomeGameOutcome

Alias for field number 0

var player_ids : set[int]

Alias for field number 1

class ValidityState (value, names=None, *, module=None, qualname=None, type=None, start=1)

An enumeration.

Expand source code
@unique
class ValidityState(Enum):
    VALID = 0
    TOO_MANY_DESYNCS = 1
    WRONG_VICTORY_CONDITION = 2
    NO_FOG_OF_WAR = 3
    CHEATS_ENABLED = 4
    PREBUILT_ENABLED = 5
    NORUSH_ENABLED = 6
    BAD_UNIT_RESTRICTIONS = 7
    BAD_MAP = 8
    TOO_SHORT = 9
    BAD_MOD = 10
    COOP_NOT_RANKED = 11
    MUTUAL_DRAW = 12
    SINGLE_PLAYER = 13
    FFA_NOT_RANKED = 14
    UNEVEN_TEAMS_NOT_RANKED = 15
    UNKNOWN_RESULT = 16
    UNLOCKED_TEAMS = 17
    MULTI_TEAM = 18
    HAS_AI_PLAYERS = 19
    CIVILIANS_REVEALED = 20
    WRONG_DIFFICULTY = 21
    EXPANSION_DISABLED = 22
    SPAWN_NOT_FIXED = 23
    OTHER_UNRANK = 24
    HOST_SET_UNRANKED = 25

Ancestors

  • enum.Enum

Class variables

var BAD_MAP
var BAD_MOD
var BAD_UNIT_RESTRICTIONS
var CHEATS_ENABLED
var CIVILIANS_REVEALED
var COOP_NOT_RANKED
var EXPANSION_DISABLED
var FFA_NOT_RANKED
var HAS_AI_PLAYERS
var HOST_SET_UNRANKED
var MULTI_TEAM
var MUTUAL_DRAW
var NORUSH_ENABLED
var NO_FOG_OF_WAR
var OTHER_UNRANK
var PREBUILT_ENABLED
var SINGLE_PLAYER
var SPAWN_NOT_FIXED
var TOO_MANY_DESYNCS
var TOO_SHORT
var UNEVEN_TEAMS_NOT_RANKED
var UNKNOWN_RESULT
var UNLOCKED_TEAMS
var VALID
var WRONG_DIFFICULTY
var WRONG_VICTORY_CONDITION
class Victory (value, names=None, *, module=None, qualname=None, type=None, start=1)

An enumeration.

Expand source code
@unique
class Victory(Enum):
    DEMORALIZATION = 0
    DOMINATION = 1
    ERADICATION = 2
    SANDBOX = 3

Ancestors

  • enum.Enum

Class variables

var DEMORALIZATION
var DOMINATION
var ERADICATION
var SANDBOX
class VisibilityState (value, names=None, *, module=None, qualname=None, type=None, start=1)

An enumeration.

Expand source code
@unique
class VisibilityState(Enum):
    PUBLIC = "public"
    FRIENDS = "friends"

Ancestors

  • enum.Enum

Class variables

var FRIENDS
var PUBLIC