Skip to content

OptionManager

Classes

OptionManager

Bases: AoE2Object

Source code in AoE2ScenarioParser/objects/managers/option_manager.py
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
class OptionManager(AoE2Object):
    _link_list = [
        RetrieverObjectLinkGroup("GlobalVictory", group=[
            RetrieverObjectLink("victory_condition", link='mode'),
            RetrieverObjectLink("victory_score", link='required_score_for_score_victory'),
            RetrieverObjectLink("_victory_years_10ths", link='time_for_timed_game_in_10ths_of_a_year'),
            RetrieverObjectLink("victory_custom_conditions_required", link='all_custom_conditions_required'),
        ]),

        RetrieverObjectLinkGroup("Diplomacy", group=[
            RetrieverObjectLink("lock_teams"),
            RetrieverObjectLink("random_start_points"),
            RetrieverObjectLink("allow_players_choose_teams"),
        ]),

        RetrieverObjectLinkGroup("Map", group=[
            RetrieverObjectLink("collide_and_correct"),
            RetrieverObjectLink("villager_force_drop", support=Support(since=1.37)),
            RetrieverObjectLink("lock_coop_alliances", support=Support(since=1.42)),
            RetrieverObjectLink("secondary_game_modes", support=Support(since=1.42)),
        ]),
    ]

    def __init__(
            self,
            victory_condition: int,
            victory_score: int,
            _victory_years_10ths: int,
            victory_custom_conditions_required: bool,
            secondary_game_modes: int,
            lock_teams: bool,
            random_start_points: bool,
            allow_players_choose_teams: bool,
            collide_and_correct: bool,
            villager_force_drop: bool,
            lock_coop_alliances: bool,
            **kwargs
    ):
        super().__init__(**kwargs)

        if victory_condition in VictoryCondition:
            victory_condition = VictoryCondition(victory_condition)
        if secondary_game_modes in SecondaryGameMode:
            secondary_game_modes = SecondaryGameMode(secondary_game_modes)

        self.victory_condition: int | VictoryCondition = victory_condition
        self.victory_score: int = victory_score
        self._victory_years_10ths: int = _victory_years_10ths
        self.victory_custom_conditions_required: bool = bool(victory_custom_conditions_required)
        self.secondary_game_modes: int | SecondaryGameMode = secondary_game_modes

        self.lock_teams: bool = bool(lock_teams)
        self.random_start_points: bool = bool(random_start_points)
        self.allow_players_choose_teams: bool = bool(allow_players_choose_teams)
        self.collide_and_correct: bool = bool(collide_and_correct)
        self.villager_force_drop: bool = bool(villager_force_drop) if villager_force_drop is not None else None
        self.lock_coop_alliances: bool = bool(lock_coop_alliances) if lock_coop_alliances is not None else None

    @property
    def victory_years(self) -> float:
        return self._victory_years_10ths / 10

    @victory_years.setter
    def victory_years(self, value: float):
        self._victory_years_10ths = floor(value * 10)

Attributes

allow_players_choose_teams: bool = bool(allow_players_choose_teams) instance-attribute
Type: bool
Value: bool(allow_players_choose_teams)
collide_and_correct: bool = bool(collide_and_correct) instance-attribute
Type: bool
Value: bool(collide_and_correct)
lock_coop_alliances: bool = bool(lock_coop_alliances) if lock_coop_alliances is not None else None instance-attribute
Type: bool
Value: bool(lock_coop_alliances) if lock_coop_alliances is not None else None
lock_teams: bool = bool(lock_teams) instance-attribute
Type: bool
Value: bool(lock_teams)
random_start_points: bool = bool(random_start_points) instance-attribute
Type: bool
Value: bool(random_start_points)
secondary_game_modes: int | SecondaryGameMode = secondary_game_modes instance-attribute
Type: int | SecondaryGameMode
Value: secondary_game_modes
victory_condition: int | VictoryCondition = victory_condition instance-attribute
Type: int | VictoryCondition
Value: victory_condition
victory_custom_conditions_required: bool = bool(victory_custom_conditions_required) instance-attribute
Type: bool
Value: bool(victory_custom_conditions_required)
victory_score: int = victory_score instance-attribute
Type: int
Value: victory_score
victory_years: float property writable
Type: float
villager_force_drop: bool = bool(villager_force_drop) if villager_force_drop is not None else None instance-attribute
Type: bool
Value: bool(villager_force_drop) if villager_force_drop is not None else None

Functions


def __init__(...)

Parameters:

Name Type Description Default
victory_condition int - required
victory_score int - required
_victory_years_10ths int - required
victory_custom_conditions_required bool - required
secondary_game_modes int - required
lock_teams bool - required
random_start_points bool - required
allow_players_choose_teams bool - required
collide_and_correct bool - required
villager_force_drop bool - required
lock_coop_alliances bool - required
kwargs ? - {}
Source code in AoE2ScenarioParser/objects/managers/option_manager.py
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
def __init__(
        self,
        victory_condition: int,
        victory_score: int,
        _victory_years_10ths: int,
        victory_custom_conditions_required: bool,
        secondary_game_modes: int,
        lock_teams: bool,
        random_start_points: bool,
        allow_players_choose_teams: bool,
        collide_and_correct: bool,
        villager_force_drop: bool,
        lock_coop_alliances: bool,
        **kwargs
):
    super().__init__(**kwargs)

    if victory_condition in VictoryCondition:
        victory_condition = VictoryCondition(victory_condition)
    if secondary_game_modes in SecondaryGameMode:
        secondary_game_modes = SecondaryGameMode(secondary_game_modes)

    self.victory_condition: int | VictoryCondition = victory_condition
    self.victory_score: int = victory_score
    self._victory_years_10ths: int = _victory_years_10ths
    self.victory_custom_conditions_required: bool = bool(victory_custom_conditions_required)
    self.secondary_game_modes: int | SecondaryGameMode = secondary_game_modes

    self.lock_teams: bool = bool(lock_teams)
    self.random_start_points: bool = bool(random_start_points)
    self.allow_players_choose_teams: bool = bool(allow_players_choose_teams)
    self.collide_and_correct: bool = bool(collide_and_correct)
    self.villager_force_drop: bool = bool(villager_force_drop) if villager_force_drop is not None else None
    self.lock_coop_alliances: bool = bool(lock_coop_alliances) if lock_coop_alliances is not None else None