def set_cond_area(cond: ConditionObject, x1: int, y1: int, x2: int, y2: int) -> None: """ Sets the area selected by cond to minimum (x1, y1) and maximum (x2, y2). """ cond.area_1_x = x1 cond.area_1_y = y1 cond.area_2_x = x2 cond.area_2_y = y2
def _reconstruct_object(parsed_header, parsed_data, objects, **kwargs): # Expected {trigger=triggerStruct} trigger_data_retriever = find_retriever( parsed_data['TriggerPiece'].retrievers, "Trigger data") trigger = kwargs['trigger'] trigger.effect_order = parser.listify(trigger.effect_order) trigger.condition_order = parser.listify(trigger.condition_order) effects_list = [] for effect_obj in trigger.effects: EffectObject._reconstruct_object(parsed_header, parsed_data, objects, effect=effect_obj, effects=effects_list) helper.update_order_array(trigger.effect_order, len(trigger.effects)) conditions_list = [] for condition_obj in trigger.conditions: ConditionObject._reconstruct_object(parsed_header, parsed_data, objects, condition=condition_obj, conditions=conditions_list) helper.update_order_array(trigger.condition_order, len(trigger.conditions)) trigger_data_retriever.data.append( TriggerStruct(data=[ trigger.enabled, trigger.looping, trigger.description_stid, trigger.display_as_objective, trigger.description_order, trigger.header, trigger.short_description_stid, trigger.display_on_screen, b'\x00\x00\x00\x00\x00', # Unknown trigger.mute_objectives, trigger.description, trigger.name, trigger.short_description, len(trigger.effects), effects_list, trigger.effect_order, len(trigger.conditions), conditions_list, trigger.condition_order, ]))
def add_condition(self, condition_type: Condition, amount_or_quantity=None, resource_type_or_tribute_list=None, unit_object=None, next_object=None, object_list=None, source_player=None, technology=None, timer=None, area_1_x=None, area_1_y=None, area_2_x=None, area_2_y=None, object_group=None, object_type=None, ai_signal=None, inverted=None, variable=None, comparison=None, target_player=None) -> ConditionObject: condition_defaults = conditions.default_attributes[condition_type] condition_attr = {} for key, value in condition_defaults.items(): condition_attr[key] = (locals()[key] if locals()[key] is not None else value) new_cond = ConditionObject( **conditions.default_attributes[condition_type.value]) self.conditions.append(new_cond) helper.update_order_array(self.condition_order, len(self.conditions)) return new_cond
def _parse_object( parsed_data, **kwargs): # Expected {trigger=triggerStruct, trigger_id=id} trigger = kwargs['trigger'] effects_list = [] effect_structs = parser.listify( find_retriever(trigger.retrievers, "Effect data").data) for effect_struct in effect_structs: effects_list.append( EffectObject._parse_object(parsed_data, effect=effect_struct)) conditions_list = [] condition_structs = parser.listify( find_retriever(trigger.retrievers, "Condition data").data) for condition_struct in condition_structs: conditions_list.append( ConditionObject._parse_object(parsed_data, condition=condition_struct)) return TriggerObject( name=find_retriever(trigger.retrievers, "Trigger name").data, description=find_retriever(trigger.retrievers, "Trigger description").data, description_stid=find_retriever( trigger.retrievers, "Description string Table ID").data, display_as_objective=find_retriever(trigger.retrievers, "Act as objective").data, short_description=find_retriever(trigger.retrievers, "Short description").data, short_description_stid=find_retriever( trigger.retrievers, "Short description string Table ID").data, display_on_screen=find_retriever(trigger.retrievers, "Display on screen").data, description_order=find_retriever( trigger.retrievers, "Description order (in objectives)").data, enabled=find_retriever(trigger.retrievers, "Enabled").data, looping=find_retriever(trigger.retrievers, "Looping").data, header=find_retriever(trigger.retrievers, "Make header").data, mute_objectives=find_retriever(trigger.retrievers, "Mute objectives").data, conditions_list=conditions_list, condition_order=parser.listify( find_retriever(trigger.retrievers, "Condition display order array").data), effects_list=effects_list, effect_order=parser.listify( find_retriever(trigger.retrievers, "Effect display order array").data), trigger_id=kwargs['trigger_id'], )
def add_condition(self, condition_type: Condition): new_cond = ConditionObject( **conditions.default_attributes[condition_type.value]) self.conditions.append(new_cond) helper.update_order_array(self.condition_order, len(self.conditions)) return new_cond
def add_condition(self, condition_type): new_cond = ConditionObject(condition_type) self.conditions.append(new_cond) helper.update_order_array(self.condition_order, len(self.conditions)) return new_cond