Exemple #1
0
    def __init__(self, value: bool):
        if not isinstance(value, bool):
            raise Exceptions.IncorrectTypeException(value, "value", (bool, ))

        self._baseValue = value

        self.Locked = False

        self.Value = value

        super().__init__()

        self.RegisterSavableAttribute(
            Savable.StandardAttributeHandler("BaseValue",
                                             "_baseValue",
                                             0,
                                             requiredAttribute=True))
        self.RegisterSavableAttribute(
            Savable.StandardAttributeHandler("Value",
                                             "Value",
                                             0,
                                             requiredAttribute=True))
        self.RegisterSavableAttribute(
            Savable.StandardAttributeHandler("Locked",
                                             "Locked",
                                             False,
                                             requiredAttribute=True))
Exemple #2
0
    def __init__(self, mean: float = 0, standardDeviation: float = 0):
        """
		A type for storing a normal distribution's average and standard deviation in one convenient object. This version used tweakable real number
		objects to store the mean and standard deviation values.
		:param mean: The mean of this normal distribution.
		:type mean: float | int
		:param standardDeviation: The standard deviation of this normal distribution.
		:type standardDeviation: float | int
		"""

        self._meanTweakable = Tweakable.TweakableRealNumber(mean)
        self._standardDeviationTweakable = Tweakable.TweakableRealNumber(
            standardDeviation)

        super().__init__(mean, standardDeviation)

        self._savables = list()

        self.RegisterSavableAttribute(
            Savable.DynamicSavableAttributeHandler(
                "Mean",
                "MeanTweakable",
                lambda: Tweakable.TweakableRealNumber(0),
                lambda: Tweakable.TweakableRealNumber(0),
                requiredAttribute=True))

        self.RegisterSavableAttribute(
            Savable.DynamicSavableAttributeHandler(
                "StandardDeviation",
                "StandardDeviationTweakable",
                lambda: Tweakable.TweakableRealNumber(0),
                lambda: Tweakable.TweakableRealNumber(0),
                requiredAttribute=True))
Exemple #3
0
	def __init__ (self, targetSimInfoOrID: typing.Union[sim_info.SimInfo, int, None]):
		"""
		An object to save information for and handle interactions with the dot menstrual cycle tracker app.
		"""

		if not isinstance(targetSimInfoOrID, (sim_info.SimInfo, int)) and targetSimInfoOrID is not None:
			raise Exceptions.IncorrectTypeException(targetSimInfoOrID, "targetSimInfoOrID", (sim_info.SimInfo, int, None))

		super().__init__()

		self._targetSimPointer = SimPointer.SimPointer()
		self._targetSimPointer.ChangePointer(targetSimInfoOrID)

		self._simulating = False  # type: bool

		self.Enabled = False
		self.TrackingMode = TrackingMode.Cycle
		self.ShowFertilityNotifications = False

		self.TimeSinceCycleStart = None

		self.LastSimulatedTick = services.time_service().sim_now.absolute_ticks()

		encodeEnum = lambda value: value.name if value is not None else None
		decodeTrackingMode = lambda valueString: Parse.ParsePythonEnum(valueString, TrackingMode)

		self.RegisterSavableAttribute(Savable.StandardAttributeHandler("Enabled", "Enabled", self.Enabled))
		self.RegisterSavableAttribute(Savable.StandardAttributeHandler("TrackingMode", "TrackingMode", self.TrackingMode, encoder = encodeEnum, decoder = decodeTrackingMode))
		self.RegisterSavableAttribute(Savable.StandardAttributeHandler("ShowFertilityNotifications", "ShowFertilityNotifications", self.ShowFertilityNotifications))
		self.RegisterSavableAttribute(Savable.StandardAttributeHandler("TimeSinceCycleStart", "TimeSinceCycleStart", self.TimeSinceCycleStart))
Exemple #4
0
    def __init__(self):
        """
		A cycle for creatures such as humans.
		"""

        super().__init__()

        self.FollicularLength = 20160  # type: float
        self.OvulationLength = 1800  # type: float
        self.LutealLength = 20160  # type: float
        self.MenstruationLength = 5760  # type: float

        self._phases.update({
            CycleShared.MenstrualCyclePhases.Follicular:
            self._Phase(lambda: self.InFollicularPhase,
                        lambda: self.FollicularLength,
                        lambda: self.FollicularStartMinute,
                        lambda: self.FollicularEndMinute),
            CycleShared.MenstrualCyclePhases.Ovulation:
            self._Phase(lambda: self.Ovulating, lambda: self.OvulationLength,
                        lambda: self.OvulationStartMinute,
                        lambda: self.OvulationEndMinute),
            CycleShared.MenstrualCyclePhases.Luteal:
            self._Phase(lambda: self.InLutealPhase, lambda: self.LutealLength,
                        lambda: self.LutealStartMinute,
                        lambda: self.LutealEndMinute),
            CycleShared.MenstrualCyclePhases.Menstruation:
            self._Phase(lambda: self.Menstruating,
                        lambda: self.MenstruationLength,
                        lambda: self.MenstruationStartMinute,
                        lambda: self.MenstruationEndMinute),
        })

        self.RegisterSavableAttribute(
            Savable.StandardAttributeHandler("FollicularLength",
                                             "FollicularLength",
                                             self.FollicularLength,
                                             requiredSuccess=True))
        self.RegisterSavableAttribute(
            Savable.StandardAttributeHandler("OvulationLength",
                                             "OvulationLength",
                                             self.OvulationLength,
                                             requiredSuccess=True))
        self.RegisterSavableAttribute(
            Savable.StandardAttributeHandler("LutealLength",
                                             "LutealLength",
                                             self.LutealLength,
                                             requiredSuccess=True))
        self.RegisterSavableAttribute(
            Savable.StandardAttributeHandler("MenstruationLength",
                                             "MenstruationLength",
                                             self.MenstruationLength,
                                             requiredSuccess=True))
Exemple #5
0
    def __init__(self, trackingSystem: ReproductionShared.ReproductiveSystem):
        super().__init__(trackingSystem)

        self.HandlerAddedEvent = Events.EventHandler()
        self.HandlerRemovedEvent = Events.EventHandler()

        self._activeHandlers = list(
        )  # type: typing.List[HandlersBase.HandlerBase]

        def handlerSaveSkipTest(
                testingHandler: HandlersBase.HandlerBase) -> bool:
            if not isinstance(testingHandler, HandlersBase.HandlerBase):
                return True

            return testingHandler.ShouldSave

        self.RegisterSavableAttribute(
            Savable.ListedSavableAttributeHandler(
                "ActiveHandlers",
                "_activeHandlers",
                lambda typeIdentifier: HandlersTypes.GetHandlerType(
                    typeIdentifier)(self.TrackingSystem),
                lambda: list(),
                requiredSuccess=False,
                skipEntrySaveTest=handlerSaveSkipTest,
                multiType=True,
                typeFetcher=lambda attributeValue: attributeValue.
                TypeIdentifier,
            ))
Exemple #6
0
    def __init__(self,
                 points: typing.Union[typing.Tuple[CurvePoint, ...],
                                      typing.List[CurvePoint]] = None):
        super().__init__()

        if not isinstance(points, (list, tuple)) and points is not None:
            raise Exceptions.IncorrectTypeException(points, "points",
                                                    (list, tuple, None))

        if points is None:
            points = list()
        else:
            points = list(points)

        for pointIndex in range(len(points)):
            point = points[pointIndex]  # type: CurvePoint

            if not isinstance(point, CurvePoint):
                raise Exceptions.IncorrectTypeException(
                    point, "points[%s]" % pointIndex, (CurvePoint, ))

        self._points = points  # type: typing.List[CurvePoint]
        self._SortPoints()

        self.RegisterSavableAttribute(
            Savable.ListedSavableAttributeHandler("Points",
                                                  "_points",
                                                  lambda: CurvePoint(),
                                                  lambda: list(),
                                                  requiredAttribute=True))
Exemple #7
0
	def __init__ (self, options: typing.Union[typing.List[Option], typing.Tuple[Option, ...]]):
		"""
		An object to randomly select from a set of options.
		:param options: This object's set of options. Duplicate options in this list will not be added.
		:type options: typing.List[ProbabilityOption]
		"""

		if options is None:
			options = list()

		if not isinstance(options, (list, tuple)):
			raise Exceptions.IncorrectTypeException(options, "options", (list, tuple, None))

		super().__init__()

		self._options = list(options)

		self.RegisterSavableAttribute(Savable.ListedSavableAttributeHandler(
			"Options",
			"_options",
			lambda: Option("", 0),
			lambda: list(),
			requiredAttribute = True)
		)

		self._ClearDuplicateOptions()
Exemple #8
0
    def __init__(self, effectingSystem: ReproductionShared.ReproductiveSystem):
        super().__init__(effectingSystem)

        self.Need = 1
        self.Entrenchment = 0

        self.GameMinutesSinceLastPill = None

        self.RegisterSavableAttribute(
            Savable.StandardAttributeHandler("Need", "Need", self.Need))
        self.RegisterSavableAttribute(
            Savable.StandardAttributeHandler("Entrenchment", "Entrenchment",
                                             self.Entrenchment))
        self.RegisterSavableAttribute(
            Savable.StandardAttributeHandler("GameMinutesSinceLastPill",
                                             "GameMinutesSinceLastPill",
                                             self.GameMinutesSinceLastPill))
	def __init__ (self, trackingSystem: ReproductionShared.ReproductiveSystem):
		super().__init__(trackingSystem)

		self.SpermGeneratingEvent = Events.EventHandler()

		self.SpermGeneratingEvent += self._SpermGeneratingCallback

		self._spermObjectsGenerated = 0  # type: int

		self.RegisterSavableAttribute(Savable.StandardAttributeHandler("SpermObjectsGenerated", "_spermObjectsGenerated", self.SpermObjectsGenerated, requiredSuccess = False))
Exemple #10
0
    def __init__(self, trackingSystem: ReproductionShared.ReproductiveSystem):
        super().__init__(trackingSystem)

        self._activeSperm = list()  # type: typing.List[Sperm.Sperm]

        self.RegisterSavableAttribute(
            Savable.ListedSavableAttributeHandler("ActiveSperm",
                                                  "_activeSperm",
                                                  lambda: Sperm.Sperm(),
                                                  lambda: list(),
                                                  requiredSuccess=False))
Exemple #11
0
    def __init__(self, value: typing.Union[float, int]):
        if not isinstance(value, (float, int)):
            raise Exceptions.IncorrectTypeException(value, "value",
                                                    (float, int))

        self._baseValue = value

        self.Locked = False

        self.UpperBound = None
        self.LowerBound = None

        self.Value = value

        super().__init__()

        self.RegisterSavableAttribute(
            Savable.StandardAttributeHandler("BaseValue",
                                             "_baseValue",
                                             0,
                                             requiredAttribute=True))
        self.RegisterSavableAttribute(
            Savable.StandardAttributeHandler("Value",
                                             "Value",
                                             0,
                                             requiredAttribute=True))
        self.RegisterSavableAttribute(
            Savable.StandardAttributeHandler("Locked",
                                             "Locked",
                                             False,
                                             requiredAttribute=True))
        self.RegisterSavableAttribute(
            Savable.StandardAttributeHandler("UpperBound",
                                             "UpperBound",
                                             None,
                                             requiredAttribute=True))
        self.RegisterSavableAttribute(
            Savable.StandardAttributeHandler("LowerBound",
                                             "LowerBound",
                                             None,
                                             requiredAttribute=True))
Exemple #12
0
	def __init__ (self, effectingSystem: ReproductionShared.ReproductiveSystem):
		super().__init__(effectingSystem)

		self.BuffAddedEvent = Events.EventHandler()
		self.BuffRemovedEvent = Events.EventHandler()
		self.BuffSelectionTestingEvent = Events.EventHandler()

		self._buffCoolDown = None  # type: typing.Optional[float]

		self.RegisterSavableAttribute(Savable.StandardAttributeHandler("BuffCoolDown", "BuffCoolDown", self.BuffCoolDown))

		self.BuffSelectionTestingEvent += self._BuffSelectionTestingCallback
Exemple #13
0
	def __init__ (self):
		"""
		An object for keeping track of sperm that has entered the cervix.
		"""

		super().__init__()

		self._uniqueIdentifier = None  # type: typing.Optional[uuid.UUID]
		self._uniqueSeed = None  # type: typing.Optional[int]

		self.DecayedCallback = None

		self.SourcePointer = SimPointer.SimPointer()

		self.Age = 0

		self.MotilePercentage = 0.8
		self.ViablePercentage = 0.8

		self.LifetimeDistribution = Distribution.NormalDistribution(4320, 960)

		self.SpermCount = 0

		encodeUUID = lambda value: str(value) if value is not None else None
		decodeUUID = lambda valueString: uuid.UUID(valueString) if valueString is not None else None

		# noinspection PyUnusedLocal
		def uniqueSeedUpdater (data: dict, lastVersion: typing.Optional[Version.Version]) -> None:
			if isinstance(data.get(self._uniqueSeedSavingKey, None), list):
				data.pop(self._uniqueSeedSavingKey)

		def uniqueIdentifierVerifier (value: typing.Optional[uuid.UUID]) -> None:
			if not isinstance(value, uuid.UUID) and value is not None:
				raise Exceptions.IncorrectTypeException(value, self._uniqueIdentifierSavingKey, (uuid.UUID, None))

		def uniqueSeedVerifier (value: typing.Optional[int]) -> None:
			if not isinstance(value, int) and value is not None:
				raise Exceptions.IncorrectTypeException(value, self._uniqueSeedSavingKey, (int, None))

		self.RegisterSavableAttribute(Savable.StandardAttributeHandler(self._uniqueIdentifierSavingKey, "_uniqueIdentifier", None, encoder = encodeUUID, decoder = decodeUUID, typeVerifier = uniqueIdentifierVerifier))
		self.RegisterSavableAttribute(Savable.StandardAttributeHandler(self._uniqueSeedSavingKey, "_uniqueSeed", None, updater = uniqueSeedUpdater, typeVerifier = uniqueSeedVerifier))

		self.RegisterSavableAttribute(Savable.StaticSavableAttributeHandler("SourcePointer", "SourcePointer"))
		self.RegisterSavableAttribute(Savable.StandardAttributeHandler("SpermCount", "SpermCount", self.SpermCount, requiredAttribute = True))
		self.RegisterSavableAttribute(Savable.StandardAttributeHandler("Age", "Age", self.Age, requiredAttribute = True))

		self.RegisterSavableAttribute(Savable.StandardAttributeHandler("MotilePercentage", "MotilePercentage", self.MotilePercentage))
		self.RegisterSavableAttribute(Savable.StandardAttributeHandler("ViablePercentage", "ViablePercentage", self.ViablePercentage))

		self.RegisterSavableAttribute(Savable.StaticSavableAttributeHandler("LifetimeDistribution", "LifetimeDistribution"))
Exemple #14
0
	def __init__ (self, trackingSystem: ReproductionShared.ReproductiveSystem):
		super().__init__(trackingSystem)

		self.CycleStartTestingEvent = Events.EventHandler()
		self.CycleAbortTestingEvent = Events.EventHandler()
		self.CycleGeneratingEvent = Events.EventHandler()
		self.CycleChangedEvent = Events.EventHandler()
		self.CycleCompletedEvent = Events.EventHandler()
		self.CycleReleaseOvumTestingEvent = Events.EventHandler()

		self.CycleStartTestingEvent += self._CycleStartTestingCallback
		self.CycleAbortTestingEvent += self._CycleAbortTestingCallback

		self.CompletedInitialCycle = False
		self.CompletedFirstCycle = False

		self.CycleStartTestingSeed = None

		self.TimeSinceLastCycle = None
		self.LastCycleCompletionReason = None

		self.CurrentCycle = None

		self._cycleObjectsGenerated = 0  # type: int

		encodeLastCycleCompletionReason = lambda value: value.name if value is not None else None
		decodeLastCycleCompletionReason = lambda valueString: Parse.ParsePythonEnum(valueString, CycleShared.CompletionReasons) if valueString is not None else None

		self.RegisterSavableAttribute(Savable.StandardAttributeHandler("CompletedInitialCycle", "CompletedInitialCycle", self.CompletedInitialCycle, requiredSuccess = False))
		self.RegisterSavableAttribute(Savable.StandardAttributeHandler("CompletedFirstCycle", "CompletedFirstCycle", self.CompletedFirstCycle, requiredSuccess = False))
		self.RegisterSavableAttribute(Savable.StandardAttributeHandler("CycleStartTestingSeed", "CycleStartTestingSeed", self.CycleStartTestingSeed, requiredSuccess = False))
		self.RegisterSavableAttribute(Savable.StandardAttributeHandler("TimeSinceLastCycle", "TimeSinceLastCycle", self.TimeSinceLastCycle, requiredSuccess = False))

		self.RegisterSavableAttribute(Savable.StandardAttributeHandler(
			"LastCycleCompletionReason",
			"LastCycleCompletionReason",
			self.LastCycleCompletionReason,
			requiredSuccess = False,
			encoder = encodeLastCycleCompletionReason,
			decoder = decodeLastCycleCompletionReason
		))

		self.RegisterSavableAttribute(Savable.StandardAttributeHandler("CycleObjectsGenerated", "_cycleObjectsGenerated", self.CycleObjectsGenerated, requiredSuccess = False))

		self.RegisterSavableAttribute(Savable.DynamicSavableAttributeHandler(
			"CurrentCycle",
			"CurrentCycle",
			lambda typeIdentifier: CycleTypes.GetCycleType(typeIdentifier)(),
			lambda: None,
			requiredSuccess = False,
			nullable = True,
			multiType = True,
			typeFetcher = lambda attributeValue: attributeValue.TypeIdentifier,
			typeSavingKey = "CurrentCycleType"
		))
Exemple #15
0
    def __init__(self,
                 x: typing.Union[float, int] = 0,
                 y: typing.Union[float, int] = 0,
                 connectionType: ConnectionType = ConnectionType.Linear):
        super().__init__()

        if not isinstance(x, (float, int)):
            raise Exceptions.IncorrectTypeException(x, "x", (float, int))

        if not isinstance(y, (float, int)):
            raise Exceptions.IncorrectTypeException(y, "y", (float, int))

        self._x = x  # type: typing.Union[float, int]
        self._y = y  # type: typing.Union[float, int]
        self._connectionType = connectionType  # type: ConnectionType

        def verifyX(value: typing.Union[float, int]) -> None:
            if not isinstance(value, (float, int)):
                raise Exceptions.IncorrectTypeException(
                    value, "X", (float, int))

        def verifyY(value: typing.Union[float, int]) -> None:
            if not isinstance(value, (float, int)):
                raise Exceptions.IncorrectTypeException(
                    value, "Y", (float, int))

        self.RegisterSavableAttribute(
            Savable.StandardAttributeHandler("X",
                                             "_x",
                                             0,
                                             requiredAttribute=True,
                                             typeVerifier=verifyX))
        self.RegisterSavableAttribute(
            Savable.StandardAttributeHandler("Y",
                                             "_y",
                                             0,
                                             requiredAttribute=True,
                                             typeVerifier=verifyY))
Exemple #16
0
	def __init__ (self, identifier: str, weight: float, weightOffset: float = 0):
		"""
		An option for a probability object to select.
		:param identifier: A string that will be returned if the option has been selected. The identifier should be unique to a probability object.
		:type identifier: str
		:param weight: This option's weight. The probability this option will be chosen is option's weight divided by the sum of every option's
		weight. This cannot be less than 0.
		:type weight: float
		:param weightOffset: The amount this option's weight is offset buy. The weight offset can never reduce the option's weight to less than 0.
		:type weightOffset: float
		"""

		if not isinstance(identifier, str):
			raise Exceptions.IncorrectTypeException(identifier, "identifier", (str,))

		super().__init__()

		self._identifier = identifier  # type: str
		self.BaseWeight = weight  # type: float
		self.WeightOffset = weightOffset  # type: float

		self.RegisterSavableAttribute(Savable.StandardAttributeHandler("Identifier", "_identifier", "", requiredAttribute = True))
		self.RegisterSavableAttribute(Savable.StandardAttributeHandler("BaseWeight", "_baseWeight", 0, requiredAttribute = True))
		self.RegisterSavableAttribute(Savable.StandardAttributeHandler("WeightOffset", "_weightOffset", 0, requiredAttribute = True))
Exemple #17
0
    def __init__(self, mean: float = 0, standardDeviation: float = 0):
        """
		A type for storing a normal distribution's average and standard deviation in one convenient object.
		:param mean: The mean of this normal distribution.
		:type mean: float
		:param standardDeviation: The standard deviation of this normal distribution.
		:type standardDeviation: float
		"""

        super().__init__()

        self.Mean = mean
        self.StandardDeviation = standardDeviation

        self.RegisterSavableAttribute(
            Savable.StandardAttributeHandler("Mean",
                                             "Mean",
                                             0,
                                             requiredAttribute=True))
        self.RegisterSavableAttribute(
            Savable.StandardAttributeHandler("StandardDeviation",
                                             "StandardDeviation",
                                             1,
                                             requiredAttribute=True))
Exemple #18
0
    def __init__(self):
        super().__init__()

        self._uniqueIdentifier = None  # type: typing.Optional[uuid.UUID]
        self._uniqueSeed = None  # type: typing.Optional[int]

        self.DecayedCallback = None
        self.AttemptImplantationCallback = None

        self.SourcePointer = SimPointer.SimPointer()

        self.NormalLifetime = 1080
        self.ImplantationTime = 11520
        self.Age = 0

        self.Viable = True

        self.FertilizationSeed = random.randint(-1000000000, 1000000000)
        self.Fertilized = False
        self.FertilizerPointer = SimPointer.SimPointer()

        self._blockedSperm = list()  # type: typing.List[str]

        encodeUUID = lambda value: str(value) if value is not None else None
        decodeUUID = lambda valueString: uuid.UUID(
            valueString) if valueString is not None else None

        # noinspection PyUnusedLocal
        def uniqueSeedUpdater(
                data: dict,
                lastVersion: typing.Optional[Version.Version]) -> None:
            if isinstance(data.get(self._uniqueSeedSavingKey, None), list):
                data[self._uniqueSeedSavingKey] = None

        def uniqueIdentifierVerifier(
                value: typing.Optional[uuid.UUID]) -> None:
            if not isinstance(value, uuid.UUID) and value is not None:
                raise Exceptions.IncorrectTypeException(
                    value, self._uniqueIdentifierSavingKey, (uuid.UUID, None))

        def uniqueSeedVerifier(value: typing.Optional[int]) -> None:
            if not isinstance(value, int) and value is not None:
                raise Exceptions.IncorrectTypeException(
                    value, self._uniqueSeedSavingKey, (int, None))

        self.RegisterSavableAttribute(
            Savable.StandardAttributeHandler(
                self._uniqueIdentifierSavingKey,
                "_uniqueIdentifier",
                None,
                encoder=encodeUUID,
                decoder=decodeUUID,
                typeVerifier=uniqueIdentifierVerifier))
        self.RegisterSavableAttribute(
            Savable.StandardAttributeHandler(self._uniqueSeedSavingKey,
                                             "_uniqueSeed",
                                             None,
                                             updater=uniqueSeedUpdater,
                                             typeVerifier=uniqueSeedVerifier))

        def blockedSpermTypeVerifier(value: typing.List[str]) -> None:
            if not isinstance(value, list):
                raise Exceptions.IncorrectTypeException(
                    value, "BlockedSperm", (list, ))

            for blockedSpermIndex in range(len(value)):  # type: int
                blockedSperm = value[blockedSpermIndex]  # type: str

                if not isinstance(blockedSperm, str):
                    raise Exceptions.IncorrectTypeException(
                        value, "BlockedSperm[%s]" % blockedSpermIndex, (str, ))

        self.RegisterSavableAttribute(
            Savable.StaticSavableAttributeHandler("SourcePointer",
                                                  "SourcePointer",
                                                  requiredSuccess=False))
        self.RegisterSavableAttribute(
            Savable.StandardAttributeHandler("NormalLifetime",
                                             "NormalLifetime",
                                             self.NormalLifetime))
        self.RegisterSavableAttribute(
            Savable.StandardAttributeHandler("ImplantationTime",
                                             "ImplantationTime",
                                             self.ImplantationTime))
        self.RegisterSavableAttribute(
            Savable.StandardAttributeHandler("Age", "Age", self.Age))
        self.RegisterSavableAttribute(
            Savable.StandardAttributeHandler("Viable", "Viable", self.Viable))
        self.RegisterSavableAttribute(
            Savable.StandardAttributeHandler("FertilizationSeed",
                                             "FertilizationSeed",
                                             self.FertilizationSeed))
        self.RegisterSavableAttribute(
            Savable.StandardAttributeHandler("Fertilized", "Fertilized",
                                             self.Fertilized))
        self.RegisterSavableAttribute(
            Savable.StaticSavableAttributeHandler("FertilizerPointer",
                                                  "FertilizerPointer",
                                                  requiredSuccess=False))
        self.RegisterSavableAttribute(
            Savable.StandardAttributeHandler("Fertilized", "Fertilized",
                                             self.Fertilized))
        self.RegisterSavableAttribute(
            Savable.StandardAttributeHandler(
                "BlockedSperm",
                "_blockedSperm",
                list(),
                typeVerifier=blockedSpermTypeVerifier))
Exemple #19
0
	def __init__ (self):
		super().__init__()

		self.SimID = None
		self.RegisterSavableAttribute(Savable.StandardAttributeHandler("SimID", "SimID", None, requiredSuccess = False))
Exemple #20
0
    def __init__(self):
        """
		An object to keep track of the release of an individual ovum during a cycle.
		"""

        super().__init__()

        self.BaseReleaseMinute = 20160
        self.ReleaseDelay = 0

        self.Released = False

        self._releaseGuarantors = list()  # type: typing.List[str]
        self._blockGuarantors = list()  # type: typing.List[str]

        self._releaseMinuteGuarantors = list()  # type: typing.List[str]

        # noinspection PyUnusedLocal
        def releaseMinuteUpdater(
                data: dict,
                lastVersion: typing.Optional[Version.Version]) -> None:
            if self._baseReleaseMinuteOldSavingKey in data and not self._baseReleaseMinuteSavingKey in data:
                data[self._baseReleaseMinuteSavingKey] = data[
                    self._baseReleaseMinuteOldSavingKey]

        def releaseGuarantorsTypeVerifier(value: typing.List[str]) -> None:
            if not isinstance(value, list):
                raise Exceptions.IncorrectTypeException(
                    value, "ReleaseGuarantors", (list, ))

            for guarantorIndex in range(len(value)):  # type: int
                guarantor = value[guarantorIndex]  # type: str

                if not isinstance(guarantor, str):
                    raise Exceptions.IncorrectTypeException(
                        value, "ReleaseGuarantors[%s]" % guarantorIndex,
                        (str, ))

        def blockGuarantorsTypeVerifier(value: typing.List[str]) -> None:
            if not isinstance(value, list):
                raise Exceptions.IncorrectTypeException(
                    value, "BlockGuarantors", (list, ))

            for guarantorIndex in range(len(value)):  # type: int
                guarantor = value[guarantorIndex]  # type: str

                if not isinstance(guarantor, str):
                    raise Exceptions.IncorrectTypeException(
                        value, "BlockGuarantors[%s]" % guarantorIndex, (str, ))

        def releaseMinuteGuarantorsTypeVerifier(
                value: typing.List[str]) -> None:
            if not isinstance(value, list):
                raise Exceptions.IncorrectTypeException(
                    value, "ReleaseMinuteGuarantors", (list, ))

            for guarantorIndex in range(len(value)):  # type: int
                guarantor = value[guarantorIndex]  # type: str

                if not isinstance(guarantor, str):
                    raise Exceptions.IncorrectTypeException(
                        value, "ReleaseMinuteGuarantors[%s]" % guarantorIndex,
                        (str, ))

        self.RegisterSavableAttribute(
            Savable.StandardAttributeHandler("BaseReleaseMinute",
                                             "BaseReleaseMinute",
                                             self.ReleaseMinute,
                                             requiredAttribute=True,
                                             updater=releaseMinuteUpdater))
        self.RegisterSavableAttribute(
            Savable.StandardAttributeHandler("ReleaseDelay",
                                             "ReleaseDelay",
                                             self.ReleaseDelay,
                                             requiredAttribute=True))

        self.RegisterSavableAttribute(
            Savable.StandardAttributeHandler("Released", "Released",
                                             self.Released))

        self.RegisterSavableAttribute(
            Savable.StandardAttributeHandler(
                "ReleaseGuarantors",
                "_releaseGuarantors",
                list(),
                typeVerifier=releaseGuarantorsTypeVerifier))
        self.RegisterSavableAttribute(
            Savable.StandardAttributeHandler(
                "BlockGuarantors",
                "_blockGuarantors",
                list(),
                typeVerifier=blockGuarantorsTypeVerifier))
        self.RegisterSavableAttribute(
            Savable.StandardAttributeHandler(
                "ReleaseMinuteGuarantors",
                "_releaseMinuteGuarantors",
                list(),
                typeVerifier=releaseMinuteGuarantorsTypeVerifier))