Skip to content

ColorId

Bases: IntEnum

This enum represents the actual colors in the dropdown menu for players. Do not confuse with the PlayerColorId which is used to reference a player number by it's color.

Source code in AoE2ScenarioParser/datasets/players.py
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
class ColorId(IntEnum):
    """
    This enum represents the actual colors in the dropdown menu for players.
    Do not confuse with the PlayerColorId which is used to reference a player number by it's color.
    """
    BLUE = 0
    RED = 1
    GREEN = 2
    YELLOW = 3
    AQUA = 4
    PURPLE = 5
    GRAY = 6
    ORANGE = 7
    INVALID_8 = 8
    INVALID_9 = 9
    INVALID_10 = 10
    INVALID_11 = 11
    INVALID_12 = 12
    INVALID_13 = 13
    INVALID_14 = 14
    INVALID_15 = 15

    @staticmethod
    def from_player_id(player_id: PlayerId | int):
        if not 0 <= player_id <= 8:
            raise ValueError(f"Invalid player ID. Should be between 0 and 8 (both incl), but got: {player_id}")
        if player_id == 0:
            return ColorId.GRAY
        return ColorId(player_id - 1)

Attributes

BLUE = 0 class-attribute instance-attribute

Value: 0

RED = 1 class-attribute instance-attribute

Value: 1

GREEN = 2 class-attribute instance-attribute

Value: 2

YELLOW = 3 class-attribute instance-attribute

Value: 3

AQUA = 4 class-attribute instance-attribute

Value: 4

PURPLE = 5 class-attribute instance-attribute

Value: 5

GRAY = 6 class-attribute instance-attribute

Value: 6

ORANGE = 7 class-attribute instance-attribute

Value: 7

INVALID_8 = 8 class-attribute instance-attribute

Value: 8

INVALID_9 = 9 class-attribute instance-attribute

Value: 9

INVALID_10 = 10 class-attribute instance-attribute

Value: 10

INVALID_11 = 11 class-attribute instance-attribute

Value: 11

INVALID_12 = 12 class-attribute instance-attribute

Value: 12

INVALID_13 = 13 class-attribute instance-attribute

Value: 13

INVALID_14 = 14 class-attribute instance-attribute

Value: 14

INVALID_15 = 15 class-attribute instance-attribute

Value: 15

Functions


def from_player_id(...) staticmethod

Parameters:

Name Type Description Default
player_id PlayerId | int - required
Source code in AoE2ScenarioParser/datasets/players.py
77
78
79
80
81
82
83
@staticmethod
def from_player_id(player_id: PlayerId | int):
    if not 0 <= player_id <= 8:
        raise ValueError(f"Invalid player ID. Should be between 0 and 8 (both incl), but got: {player_id}")
    if player_id == 0:
        return ColorId.GRAY
    return ColorId(player_id - 1)