def _cm_max_motive(motive_name: str, opt_sim: OptionalSimInfoParam = None, _connection: int = None): output = CheatOutput(_connection) sim_info = get_optional_target(opt_sim, target_type=OptionalSimInfoParam, _connection=_connection) if sim_info is None: output('Failed, No Sim found!') return False if not CMMotiveUtils().can_translate_motive(sim_info, motive_name): output( 'Invalid motive: Valid motives for \'{}\' are as follows:'.format( CommonSimNameUtils.get_full_name(sim_info))) for motive in CMMotiveUtils().get_valid_motives(sim_info): output('- {}'.format(motive)) return False output('Setting motive \'{}\' to \'{}\' for \'{}\''.format( motive_name, 100.0, CommonSimNameUtils.get_full_name(sim_info))) result = CMMotiveUtils().change_motive_level(sim_info, motive_name, 100.0) if not result: output('Failed to set motive level.') else: output('Success!') output('Done')
def _cm_help(opt_sim: OptionalSimInfoParam = None, _connection: int = None): output = CheatOutput(_connection) output( 'Motive values range from -100.0 to 100.0. With 0.0 being 50% of the Motive bar.' ) sim_info = get_optional_target(opt_sim, target_type=OptionalSimInfoParam, _connection=_connection) if sim_info is not None: output('Available Motives for the current Sim:') output('Hygiene is the same as Hydration for Mermaids.') output('Social is the same as Affection for Pets.') for motive in CMMotiveUtils().get_valid_motives(sim_info): output('- {}'.format(motive)) output('Available Commands:') output('cm.set <motive_name> <level>') output( ' | Set the motive level of a Sim. "level" can be -100.0 to 100.0') output('cm.max <motive_name>') output(' | Set the motive level of a Sim to its maximum 100.0.') output('cm.min <motive_name>') output(' | Set the motive level of a Sim to its minimum -100.0.') output('cm.min_all') output(' | Set all motives of a Sim to their minimum -100.0.') output('cm.max_all') output(' | Set all motives of a Sim to their maximum 100.0.')
def _cm_max_all_motives(opt_sim: OptionalSimInfoParam = None, _connection: int = None): output = CheatOutput(_connection) sim_info = get_optional_target(opt_sim, target_type=OptionalSimInfoParam, _connection=_connection) if sim_info is None: output('Failed, No Sim found!') return False output('Setting all motives to maximum for \'{}\''.format( CommonSimNameUtils.get_full_name(sim_info))) result = CMMotiveUtils().max_all_motives(sim_info) if not result: output('Failed to set motive level.') else: output('Success!') output('Done')
def _settings(self, sim_info: SimInfo) -> CommonChooseObjectOptionDialog: self.log.debug('Building change motives dialog for \'{}\'.'.format( CommonSimNameUtils.get_full_name(sim_info))) def _on_close() -> None: self.log.debug('CM dialog closed.') if self._on_close is not None: self._on_close() option_dialog = CommonChooseObjectOptionDialog( CMStringId.CHANGE_MOTIVES, CMStringId.CHOOSE_MOTIVE_TO_SET, mod_identity=self.mod_identity, on_close=_on_close) def _reopen_dialog() -> None: self.log.debug('Reopening CM dialog.') self.open(sim_info) def _on_min_all_motives() -> None: def _on_confirm(_) -> None: self.log.debug( 'Setting all motives to their minimum! Sim Death incoming!' ) self.motive_utils.min_all_motives(sim_info) _reopen_dialog() def _on_cancel(_) -> None: self.log.debug( 'Cancelled setting all motives to minimum. That was a close one!' ) _reopen_dialog() self.log.debug( 'Showing confirmation for setting all motives to minimum.') CommonOkCancelDialog( CMStringId.CONFIRMATION, CMStringId.SET_ALL_MOTIVE_LEVELS_TO_MINIMUM_CONFIRMATION, description_tokens=(sim_info, ), mod_identity=self.mod_identity).show( on_ok_selected=_on_confirm, on_cancel_selected=_on_cancel) def _on_max_all_motives() -> None: self.log.debug('Setting all motives to their maximum.') self.motive_utils.max_all_motives(sim_info) def _on_changed(chosen_motive_name: str, amount: float, outcome: CommonChoiceOutcome): if chosen_motive_name is None or amount is None or CommonChoiceOutcome.is_error_or_cancel( outcome): self.log.debug('Cancelled changing motive level.') _reopen_dialog() return self.log.debug('Changing motive \'{}\' to amount {}'.format( chosen_motive_name, amount)) self.motive_utils.change_motive_level(sim_info, chosen_motive_name, amount) _reopen_dialog() option_dialog.add_option( CommonDialogActionOption( CommonDialogOptionContext( CMStringId.SET_ALL_MOTIVE_LEVELS_TO_MINIMUM, 0, ), on_chosen=lambda *_, **__: _on_min_all_motives(), always_visible=True), ) option_dialog.add_option( CommonDialogActionOption( CommonDialogOptionContext( CMStringId.SET_ALL_MOTIVE_LEVELS_TO_MAXIMUM, 0, ), on_chosen=lambda *_, **__: _on_max_all_motives(), always_visible=True), ) motive_names: Tuple[str] = CMMotiveUtils().get_valid_motives(sim_info) sorted_motive_names = sorted(motive_names, key=lambda s: s) for motive_name in sorted_motive_names: if motive_name is None: continue motive_string_id = CMMotiveUtils().get_motive_string( sim_info, motive_name) if motive_string_id == -1: motive_string_id = motive_name.upper() # noinspection PyTypeChecker option_dialog.add_option( CommonDialogInputFloatOption( motive_name, self.motive_utils.get_motive_level(sim_info, motive_name), CommonDialogOptionContext( motive_string_id, CMStringId.SET_MOTIVE_LEVEL_OF_SIM, description_tokens=(motive_string_id, sim_info)), min_value=-100.0, max_value=100.0, on_chosen=_on_changed, dialog_description_identifier=CMStringId.MIN_AND_MAX, dialog_description_tokens=( CommonLocalizationUtils.create_localized_string( CMStringId.SET_MOTIVE_LEVEL_OF_SIM, tokens=(motive_string_id, sim_info)), ))) return option_dialog
def __init__( self, on_close: Callable[..., Any] = CommonFunctionUtils.noop) -> None: super().__init__() self._on_close = on_close self.motive_utils = CMMotiveUtils()