def add_buff( sim_info: SimInfo, *buff_ids: Union[int, CommonBuffId], buff_reason: Union[int, str, LocalizedString, CommonStringId] = None ) -> bool: """add_buff(sim_info, *buff_ids, buff_reason=None) Add the specified buffs to a sim. :param sim_info: The sim to add the specified buffs to. :type sim_info: SimInfo :param buff_ids: The decimal identifiers of buffs to add. :type buff_ids: int :param buff_reason: The text that will display when the player hovers over the buffs. What caused the buffs to be added. :type buff_reason: Union[int, str, LocalizedString, CommonStringId], optional :return: True, if all of the specified buffs were successfully added. False, if not. :rtype: bool """ if sim_info is None: raise AssertionError('Argument sim_info was None') if not CommonComponentUtils.has_component(sim_info, CommonComponentType.BUFF): return False localized_buff_reason = CommonLocalizationUtils.create_localized_string( buff_reason) success = True for buff_identifier in buff_ids: buff_instance = CommonBuffUtils.load_buff_by_id(buff_identifier) if buff_instance is None: continue if not sim_info.add_buff_from_op( buff_instance, buff_reason=localized_buff_reason): success = False return success
def add_buff(sim_info: SimInfo, *buff_ids: int, buff_reason: Union[int, str, LocalizedString]=None) -> bool: """add_buff(sim_info, *buff_ids, buff_reason=None) Add the specified buffs to a sim. :param sim_info: The sim to add the specified buffs to. :type sim_info: SimInfo :param buff_ids: The decimal identifiers of buffs to add. :type buff_ids: int :param buff_reason: The text that will display when the player hovers over the buffs. What caused the buffs to be added. :type buff_reason: Union[int, str, LocalizedString], optional :return: True, if all of the specified buffs were successfully added. False, if not. :rtype: bool """ if sim_info is None: CommonExceptionHandler.log_exception(ModInfo.get_identity().name, 'Argument \'sim_info\' was \'None\' for \'{}\' of class \'{}\''.format(CommonBuffUtils.add_buff.__name__, CommonBuffUtils.__name__)) return False if not CommonComponentUtils.has_component(sim_info, CommonComponentType.BUFF): return False localized_buff_reason = CommonLocalizationUtils.create_localized_string(buff_reason) success = True for buff_identifier in buff_ids: buff_instance = CommonBuffUtils._load_buff_instance(buff_identifier) if buff_instance is None: continue if not sim_info.add_buff_from_op(buff_instance, buff_reason=localized_buff_reason): success = False return success