Exemplo n.º 1
0
    def run(
        self,
        sim_info: SimInfo,
        on_completed: Callable[[bool],
                               None] = CommonFunctionUtils.noop) -> bool:
        if not CommonHouseholdUtils.has_household(sim_info):
            on_completed(False)
            return False

        def _on_submit(amount: int, outcome: CommonChoiceOutcome):
            if outcome == CommonChoiceOutcome.ERROR:
                self.run(sim_info, on_completed=on_completed)
                return
            elif CommonChoiceOutcome.is_error_or_cancel(outcome):
                on_completed(False)
                return
            CommonHouseholdUtils.get_household(sim_info).funds.try_remove(
                amount,
                Consts_pb2.FUNDS_MONEY_CHEAT,
                sim=CommonSimUtils.get_sim_instance(sim_info),
                require_full_amount=False)
            on_completed(True)
            return True

        from sims4communitylib.dialogs.common_input_integer_dialog import CommonInputIntegerDialog
        dialog = CommonInputIntegerDialog(
            S4CMSimControlMenuStringId.HOW_MANY_SIMOLEONS,
            0,
            1000,
            min_value=1,
            mod_identity=ModInfo.get_identity())
        dialog.show(on_submit=_on_submit)
        return True
Exemplo n.º 2
0
    def is_at_home(sim_info: SimInfo) -> bool:
        """is_at_home(sim_info)

        Determine if a Sim is on their home Lot.

        :param sim_info: The Sim to check.
        :type sim_info: SimInfo
        :return: True, if the Sim is on their home Lot. False, if not.
        :rtype: bool
        """
        sim = CommonSimUtils.get_sim_instance(sim_info)
        if sim is None or not CommonHouseholdUtils.has_household(sim_info):
            return False
        return sim.on_home_lot or (CommonLocationUtils.get_current_zone_id() == CommonHouseholdUtils.get_household_zone_id(sim_info) and CommonSimLocationUtils.is_on_current_lot(sim_info))