def start_pregnancy(
            sim_info: SimInfo,
            partner_sim_info: SimInfo,
            pregnancy_origin: PregnancyOrigin = PregnancyOrigin.DEFAULT
    ) -> bool:
        """start_pregnancy(sim_info, partner_sim_info, pregnancy_origin=PregnancyOrigin.DEFAULT)

        Start a pregnancy between a Sim and a Partner Sim.

        :param sim_info: The Sim getting pregnant.
        :type sim_info: SimInfo
        :param partner_sim_info: The Sim that is getting the other Sim pregnant.
        :type partner_sim_info: SimInfo
        :param pregnancy_origin: The origin of the pregnancy. Default is PregnancyOrigin.DEFAULT.
        :type pregnancy_origin: PregnancyOrigin, optional
        :return: True, if the Sim is successfully impregnated by the Partner Sim. False, if not.
        :rtype: bool
        """
        if not CommonHouseholdUtils.has_free_household_slots(sim_info):
            return False
        pregnancy_tracker = CommonSimPregnancyUtils._get_pregnancy_tracker(
            sim_info)
        if pregnancy_tracker is None:
            return False
        pregnancy_tracker.start_pregnancy(sim_info,
                                          partner_sim_info,
                                          pregnancy_origin=pregnancy_origin)
        pregnancy_tracker.clear_pregnancy_visuals()
        CommonSimStatisticUtils.set_statistic_value(
            sim_info, CommonStatisticId.PREGNANCY, 1.0)
        return True
Example #2
0
 def clear_pregnancy(sim_info: SimInfo) -> bool:
     """ Clear the pregnancy status of a Sim. """
     pregnancy_tracker = CommonSimPregnancyUtils._get_pregnancy_tracker(
         sim_info)
     if pregnancy_tracker is None:
         return False
     sim_info.pregnancy_tracker.clear_pregnancy()
     CommonSimStatisticUtils.remove_statistic(sim_info,
                                              CommonStatisticId.PREGNANCY)
     return True
Example #3
0
 def decrease_motive_level(sim_info: SimInfo, motive_id: int,
                           amount: float) -> bool:
     """ Decrease the current level of the Motive of a Sim. """
     mapped_motive_id = CommonSimMotiveUtils._map_motive_id(
         sim_info, motive_id)
     if not CommonSimMotiveUtils.has_motive(sim_info, mapped_motive_id):
         return False
     CommonSimStatisticUtils.add_statistic_value(sim_info,
                                                 mapped_motive_id,
                                                 amount * -1.0,
                                                 add=True)
     return True
Example #4
0
 def start_pregnancy(sim_info: SimInfo, partner_sim_info: SimInfo) -> bool:
     """ Start a pregnancy between a Sim and a Partner Sim. """
     if not CommonHouseholdUtils.has_free_household_slots(sim_info):
         return False
     pregnancy_tracker = CommonSimPregnancyUtils._get_pregnancy_tracker(
         sim_info)
     if pregnancy_tracker is None:
         return False
     pregnancy_tracker.start_pregnancy(sim_info, partner_sim_info)
     pregnancy_tracker.clear_pregnancy_visuals()
     CommonSimStatisticUtils.set_statistic_value(
         sim_info, CommonStatisticId.PREGNANCY, 1.0)
     return True
 def get_progress_toward_max_skill_level(sim_info: SimInfo,
                                         skill_id: int,
                                         add: bool = True) -> float:
     """ Retrieve the amount of progress a Sim has made toward the max level of a Skill.  """
     return CommonSimStatisticUtils.get_statistic_value(sim_info,
                                                        skill_id,
                                                        add=add)
 def _get_motive_level(sim_info: SimInfo,
                       motive_id: CommonMotiveId) -> float:
     motive_id: int = CommonSimMotiveUtils._map_motive_id(
         sim_info, motive_id)
     if motive_id == -1:
         return 0.0
     return CommonSimStatisticUtils.get_statistic_value(sim_info, motive_id)
 def get_skill(sim_info: SimInfo,
               skill_id: int,
               add: bool = True) -> Union[Skill, None]:
     """ Retrieve a Skill for the specified Sim. """
     return CommonSimStatisticUtils.get_statistic(sim_info,
                                                  skill_id,
                                                  add=add)
 def is_at_max_skill_level(sim_info: SimInfo, skill_id: int) -> bool:
     """ Determine if a Sim has reached the Maximum Level of a Skill. """
     from statistics.skill import Skill
     statistic: Skill = CommonSimStatisticUtils.get_statistic(
         sim_info, skill_id)
     if statistic is None:
         return False
     return statistic.reached_max_level
 def set_current_skill_level(sim_info: SimInfo,
                             skill_id: int,
                             level: float,
                             add: bool = True) -> bool:
     """ Set the Skill Level of the Skill for the specified Sim. """
     return CommonSimStatisticUtils.set_statistic_user_value(sim_info,
                                                             skill_id,
                                                             level,
                                                             add=add)
    def clear_pregnancy(sim_info: SimInfo) -> bool:
        """clear_pregnancy(sim_info)

        Clear the pregnancy status of a Sim.

        :param sim_info: The Sim being cleared.
        :type sim_info: SimInfo
        :return: True, if successful. False, if not.
        :rtype: bool
        """
        pregnancy_tracker = CommonSimPregnancyUtils._get_pregnancy_tracker(
            sim_info)
        if pregnancy_tracker is None:
            return False
        sim_info.pregnancy_tracker.clear_pregnancy()
        CommonSimStatisticUtils.remove_statistic(sim_info,
                                                 CommonStatisticId.PREGNANCY)
        return True
 def change_progress_toward_max_skill_level(sim_info: SimInfo,
                                            skill_id: int,
                                            value: float,
                                            add: bool = True) -> bool:
     """ Modify the amount of progress a Sim has made toward the max level of a Skill. """
     return CommonSimStatisticUtils.add_statistic_value(sim_info,
                                                        skill_id,
                                                        value,
                                                        add=add)
    def decrease_motive_level(sim_info: SimInfo, motive_id: int, amount: float) -> bool:
        """decrease_motive_level(sim_info, motive_id, amount)

        Decrease the current level of a Motive of a Sim.

        :param sim_info: The Sim to modify.
        :type sim_info: SimInfo
        :param motive_id: The identifier of the Motive to change.
        :type motive_id: int
        :param amount: The amount to decrease the motive by.
        :type amount: float
        :return: True, if the specified Motive was changed successfully. False, if not.
        :rtype: bool
        """
        mapped_motive_id = CommonSimMotiveUtils._map_motive_id(sim_info, motive_id)
        if not CommonSimMotiveUtils.has_motive(sim_info, mapped_motive_id):
            return False
        CommonSimStatisticUtils.add_statistic_value(sim_info, mapped_motive_id, amount * -1.0, add=True)
        return True
    def get_current_skill_level(sim_info: SimInfo, skill_id: int) -> float:
        """get_current_skill_level(sim_info, skill_id)

        Retrieve the Skill Level of a sim.

        :param sim_info: The Sim to check.
        :type sim_info: SimInfo
        :param skill_id: The identifier of the Skill to use.
        :type skill_id: int
        :return: The current skill level of the specified Skill or `-1.0` if a problem occurs.
        :rtype: float
        """
        return CommonSimStatisticUtils.get_statistic_level(sim_info, skill_id)
    def remove_skill(sim_info: SimInfo, skill_id: int) -> bool:
        """remove_skill(sim_info, skill_id)

        Remove a Skill from the specified Sim.

        :param sim_info: The Sim to modify.
        :type sim_info: SimInfo
        :param skill_id: The identifier of the Skill to remove.
        :type skill_id: int
        :return: True, if the skill was removed successfully. False, if not.
        :rtype: bool
        """
        return CommonSimStatisticUtils.remove_statistic(sim_info, skill_id)
    def has_skill(sim_info: SimInfo, skill_id: int) -> bool:
        """has_skill(sim_info, skill_id)

        Determine if a Sim has a Skill.

        :param sim_info: The Sim to check.
        :type sim_info: SimInfo
        :param skill_id: The identifier of the Skill to check.
        :type skill_id: int
        :return: True, if the Sim has the skill. False, if the Sim does not.
        :rtype: bool
        """
        return CommonSimStatisticUtils.has_statistic(sim_info, skill_id)
    def start_pregnancy(sim_info: SimInfo, partner_sim_info: SimInfo) -> bool:
        """start_pregnancy(sim_info, partner_sim_info)

        Start a pregnancy between a Sim and a Partner Sim.

        :param sim_info: The Sim getting pregnant.
        :type sim_info: SimInfo
        :param partner_sim_info: The Sim that is getting the other Sim pregnant.
        :type partner_sim_info: SimInfo
        :return: True, if successful. False, if not.
        :rtype: bool
        """
        if not CommonHouseholdUtils.has_free_household_slots(sim_info):
            return False
        pregnancy_tracker = CommonSimPregnancyUtils._get_pregnancy_tracker(
            sim_info)
        if pregnancy_tracker is None:
            return False
        pregnancy_tracker.start_pregnancy(sim_info, partner_sim_info)
        pregnancy_tracker.clear_pregnancy_visuals()
        CommonSimStatisticUtils.set_statistic_value(
            sim_info, CommonStatisticId.PREGNANCY, 1.0)
        return True
    def get_progress_toward_max_skill_level(sim_info: SimInfo, skill_id: int, add: bool=True) -> float:
        """get_progress_toward_max_skill_level(sim_info, skill_id, add=True)

        Retrieve the amount of progress a Sim has made toward the max level of a Skill.

        :param sim_info: The Sim to modify.
        :type sim_info: SimInfo
        :param skill_id: The identifier of the Skill to modify.
        :type skill_id: int
        :param add: If True, the skill will be added to the Sim before it is modified.
        :type add: bool, optional
        :return: True, if successful. False, if not.
        :rtype: bool
        """
        return CommonSimStatisticUtils.get_statistic_value(sim_info, skill_id, add=add)
    def get_skill(sim_info: SimInfo, skill_id: int, add: bool=True) -> Union[Skill, None]:
        """get_skill(sim_info, skill_id, add=True)

        Retrieve a Skill for the specified Sim.

        :param sim_info: The Sim to check.
        :type sim_info: SimInfo
        :param skill_id: The identifier of the Skill to use.
        :type skill_id: int
        :param add: If True, the skill will be added to the Sim before it is checked.
        :type add: bool, optional
        :return: An instance of a Skill of the Sim or None if the Skill does not exist.
        :rtype: Union[Skill, None]
        """
        return CommonSimStatisticUtils.get_statistic(sim_info, skill_id, add=add)
    def set_motive_level(sim_info: SimInfo, motive_id: CommonMotiveId,
                         amount: float) -> bool:
        """set_motive_level(sim_info, motive_id, amount)

        Set the current level of a Motive of a Sim.

        :param sim_info: The Sim to modify.
        :type sim_info: SimInfo
        :param motive_id: The identifier of the Motive to change.
        :type motive_id: CommonMotiveId
        :param amount: The amount to set the motive level to.
        :type amount: float
        :return: True, if the specified Motive was changed successfully. False, if not.
        :rtype: bool
        """
        if not CommonSimMotiveUtils.has_motive(sim_info, motive_id):
            return False
        mapped_motive_id: int = CommonSimMotiveUtils._map_motive_id(
            sim_info, motive_id)
        CommonSimStatisticUtils.set_statistic_value(sim_info,
                                                    mapped_motive_id,
                                                    amount,
                                                    add=True)
        return True
    def has_motive(sim_info: SimInfo, motive_id: int) -> bool:
        """has_motive(sim_info, motive_id)

        Determine if a Sim has the specified Motive.

        .. note:: For example, you could use this to determine if a Sim has a vampire power level.

        :param sim_info: The Sim to check.
        :type sim_info: SimInfo
        :param motive_id: The identifier of the Motive to look for.
        :type motive_id: int
        :return: True, if the Sim has the specified Motive. False, if not.
        :rtype: bool
        """
        mapped_motive_id = CommonSimMotiveUtils._map_motive_id(sim_info, motive_id)
        return CommonSimStatisticUtils.has_statistic(sim_info, mapped_motive_id)
    def change_progress_toward_max_skill_level(sim_info: SimInfo, skill_id: int, value: float, add: bool=True) -> bool:
        """change_progress_toward_max_skill_level(sim_info, skill_id, value, add=True)

        Modify the amount of progress a Sim has made toward the max level of a Skill.

        :param sim_info: The Sim to modify.
        :type sim_info: SimInfo
        :param skill_id: The identifier of the Skill to modify.
        :type skill_id: int
        :param value: The level to add or subtract to/from the skill.
        :type value: int
        :param add: If True, the skill will be added to the Sim before it is modified.
        :type add: bool, optional
        :return: True, if successful. False, if not.
        :rtype: bool
        """
        return CommonSimStatisticUtils.add_statistic_value(sim_info, skill_id, value, add=add)
    def set_progress_toward_max_skill_level(sim_info: SimInfo, skill_id: Union[int, CommonSkillId], value: float, add: bool=True) -> bool:
        """set_progress_toward_max_skill_level(sim_info, skill_id, value, add=True)

        Set the amount of progress a Sim has made toward the max level of a Skill.

        :param sim_info: The Sim to modify.
        :type sim_info: SimInfo
        :param skill_id: The identifier of the Skill to set.
        :type skill_id: Union[int, CommonSkillId]
        :param value: The amount to add.
        :type value: Union[int, CommonSkillId]
        :param add: If True, the skill will be added to the Sim before it is modified.
        :type add: bool, optional
        :return: True, if successful. False, if not.
        :rtype: bool
        """
        return CommonSimStatisticUtils.set_statistic_value(sim_info, skill_id, value, add=add)
    def set_current_skill_level(sim_info: SimInfo, skill_id: int, level: float, add: bool=True) -> bool:
        """set_current_skill_level(sim_info, skill_id, level, add=True)

        Set the Skill Level of the Skill for the specified Sim.

        :param sim_info: The Sim to modify.
        :type sim_info: SimInfo
        :param skill_id: The identifier of the Skill to set.
        :type skill_id: int
        :param level: The level to set the skill to.
        :type level: int
        :param add: If True, the skill will be added to the Sim before it is modified.
        :type add: bool, optional
        :return: True, if successful. False, if not.
        :rtype: bool
        """
        return CommonSimStatisticUtils.set_statistic_user_value(sim_info, skill_id, level, add=add)
    def is_at_max_skill_level(sim_info: SimInfo, skill_id: int) -> bool:
        """is_at_max_skill_level(sim_info, skill_id)

        Determine if a Sim has reached the Maximum Level of a Skill.

        .. note:: Max level depends on the skill itself. Each skill can have a different max level.

        :param sim_info: The Sim to check.
        :type sim_info: SimInfo
        :param skill_id: The identifier of the Skill to check.
        :type skill_id: int
        :return: True, if the Sim has the skill at the maximum level. False, if the Sim does not.
        :rtype: bool
        """
        from statistics.skill import Skill
        statistic: Skill = CommonSimStatisticUtils.get_statistic(sim_info, skill_id)
        if statistic is None:
            return False
        return statistic.reached_max_level
 def get_current_skill_level(sim_info: SimInfo, skill_id: int) -> float:
     """ Retrieve the Skill Level of a sim. """
     return CommonSimStatisticUtils.get_statistic_level(sim_info, skill_id)
 def remove_skill(sim_info: SimInfo, skill_id: int) -> bool:
     """ Remove a Skill from the specified Sim. """
     return CommonSimStatisticUtils.remove_statistic(sim_info, skill_id)
Example #27
0
 def has_motive(sim_info: SimInfo, motive_id: int) -> bool:
     """ Determine if a Sim has the specified motive. """
     mapped_motive_id = CommonSimMotiveUtils._map_motive_id(
         sim_info, motive_id)
     return CommonSimStatisticUtils.has_statistic(sim_info,
                                                  mapped_motive_id)
 def _get_motive_level(sim_info: SimInfo, motive_id: int) -> float:
     motive_id = CommonSimMotiveUtils._map_motive_id(sim_info, motive_id)
     return CommonSimStatisticUtils.get_statistic_value(sim_info, motive_id)
 def has_skill(sim_info: SimInfo, skill_id: int) -> bool:
     """ Determine if the specified Sim has a Skill. """
     return CommonSimStatisticUtils.has_statistic(sim_info, skill_id)