1
2
3
4
5
6
7
8
9
10
11
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
use lazy_static::lazy_static;
use linked_hash_map::LinkedHashMap;

#[derive(Clone)]
pub struct ConditionConfig {
    pub name: &'static str,
    pub attrs: Vec<&'static str>,
}

impl ConditionConfig {
    fn new(name: &'static str, attrs: Vec<&'static str>) -> Self {
        ConditionConfig { name, attrs }
    }
}

lazy_static! {
    pub static ref CONDITION_SCHEME: LinkedHashMap<i32, ConditionConfig> = {
        let mut mapping = LinkedHashMap::new();

        mapping.insert(0, ConditionConfig::new("None", vec![]));
        mapping.insert(
            1,
            ConditionConfig::new(
                "BRING_OBJECT_TO_AREA",
                vec![
                    "unit_object",
                    "area_x1",
                    "area_y1",
                    "area_x2",
                    "area_y2",
                    "inverted",
                ],
            ),
        );
        mapping.insert(
            2,
            ConditionConfig::new(
                "BRING_OBJECT_TO_OBJECT",
                vec!["unit_object", "next_object", "inverted"],
            ),
        );
        mapping.insert(
            3,
            ConditionConfig::new(
                "OWN_OBJECTS",
                vec![
                    "quantity",
                    "object_list",
                    "source_player",
                    "object_group",
                    "object_type",
                    "include_changeable_weapon_objects",
                ],
            ),
        );
        mapping.insert(
            4,
            ConditionConfig::new(
                "OWN_FEWER_OBJECTS",
                vec![
                    "quantity",
                    "object_list",
                    "source_player",
                    "area_x1",
                    "area_y1",
                    "area_x2",
                    "area_y2",
                    "object_group",
                    "object_type",
                    "include_changeable_weapon_objects",
                ],
            ),
        );
        mapping.insert(
            5,
            ConditionConfig::new(
                "OBJECTS_IN_AREA",
                vec![
                    "quantity",
                    "object_list",
                    "source_player",
                    "area_x1",
                    "area_y1",
                    "area_x2",
                    "area_y2",
                    "object_group",
                    "object_type",
                    "object_state",
                    "inverted",
                    "include_changeable_weapon_objects",
                ],
            ),
        );
        mapping.insert(
            6,
            ConditionConfig::new("DESTROY_OBJECT", vec!["unit_object", "inverted"]),
        );
        mapping.insert(
            7,
            ConditionConfig::new(
                "CAPTURE_OBJECT",
                vec!["unit_object", "source_player", "inverted"],
            ),
        );
        mapping.insert(
            8,
            ConditionConfig::new(
                "ACCUMULATE_ATTRIBUTE",
                vec!["quantity", "attribute", "source_player", "inverted"],
            ),
        );
        mapping.insert(
            9,
            ConditionConfig::new(
                "RESEARCH_TECHNOLOGY",
                vec!["source_player", "technology", "inverted"],
            ),
        );

        mapping.insert(10, ConditionConfig::new("TIMER", vec!["timer", "inverted"]));
        mapping.insert(
            11,
            ConditionConfig::new("OBJECT_SELECTED", vec!["unit_object", "inverted"]),
        );
        mapping.insert(
            12,
            ConditionConfig::new("AI_SIGNAL", vec!["ai_signal", "inverted"]),
        );
        mapping.insert(
            13,
            ConditionConfig::new("PLAYER_DEFEATED", vec!["source_player", "inverted"]),
        );
        mapping.insert(
            14,
            ConditionConfig::new(
                "OBJECT_HAS_TARGET",
                vec![
                    "unit_object",
                    "next_object",
                    "object_list",
                    "object_group",
                    "object_type",
                    "inverted",
                ],
            ),
        );
        mapping.insert(
            15,
            ConditionConfig::new("OBJECT_VISIBLE", vec!["unit_object"]),
        );
        mapping.insert(
            16,
            ConditionConfig::new("OBJECT_NOT_VISIBLE", vec!["unit_object"]),
        );
        mapping.insert(
            17,
            ConditionConfig::new(
                "RESEARCHING_TECH",
                vec!["source_player", "technology", "inverted"],
            ),
        );
        mapping.insert(
            18,
            ConditionConfig::new(
                "UNITS_GARRISONED",
                vec!["quantity", "unit_object", "inverted"],
            ),
        );
        mapping.insert(
            19,
            ConditionConfig::new(
                "DIFFICULTY_LEVEL",
                vec!["condition_type", "quantity", "inverted"],
            ),
        );

        mapping.insert(20, ConditionConfig::new("CHANCE", vec!["quantity"]));
        mapping.insert(
            21,
            ConditionConfig::new(
                "TECHNOLOGY_STATE",
                vec!["quantity", "source_player", "technology", "inverted"],
            ),
        );
        mapping.insert(
            22,
            ConditionConfig::new(
                "VARIABLE_VALUE",
                vec!["quantity", "inverted", "variable", "comparison"],
            ),
        );
        mapping.insert(
            23,
            ConditionConfig::new(
                "OBJECT_HP",
                vec!["quantity", "unit_object", "inverted", "comparison"],
            ),
        );
        mapping.insert(
            24,
            ConditionConfig::new(
                "DIPLOMACY_STATE",
                vec!["quantity", "source_player", "inverted", "target_player"],
            ),
        );
        mapping.insert(25, ConditionConfig::new("SCRIPT_CALL", vec!["xs_function"]));
        mapping.insert(
            26,
            ConditionConfig::new(
                "OBJECT_SELECTED_MULTIPLAYER",
                vec!["unit_object", "source_player", "inverted"],
            ),
        );
        mapping.insert(
            27,
            ConditionConfig::new(
                "OBJECT_VISIBLE_MULTIPLAYER",
                vec!["unit_object", "source_player", "inverted"],
            ),
        );
        mapping.insert(
            28,
            ConditionConfig::new(
                "OBJECT_HAS_ACTION",
                vec!["unit_object", "next_object", "inverted", "unit_ai_action"],
            ),
        );
        mapping.insert(29, ConditionConfig::new("OR", vec![]));

        mapping.insert(
            30,
            ConditionConfig::new("AI_SIGNAL_MULTIPLAYER", vec!["ai_signal", "inverted"]),
        );
        mapping.insert(
            54,
            ConditionConfig::new("BUILDING_IS_TRADING", vec!["unit_object", "inverted"]),
        );
        mapping.insert(
            55,
            ConditionConfig::new("DISPLAY_TIMER_TRIGGERED", vec!["timer_id", "inverted"]),
        );
        mapping.insert(
            56,
            ConditionConfig::new(
                "VICTORY_TIMER",
                vec![
                    "quantity",
                    "source_player",
                    "inverted",
                    "comparison",
                    "victory_timer_type",
                ],
            ),
        );
        mapping.insert(57, ConditionConfig::new("AND", vec![]));

        mapping
    };
}