Пример #1
0
    def age(self):
        birth_year = self.birth_year
        if birth_year is None:
            age_mod = math_helpers.rand_range(low=0, high=40 if self.gender is 'Male' else 30, avg=0.1)
            age = self.world_obj.age_of_consent + age_mod
            self.set("birth_year", int(self.world_obj.year - age))
        else:
            age = int(self.world_obj.year) - int(birth_year)

        return age
Пример #2
0
    def update_biorhythms(self, age=None):
        if age is None:
            age = self.age

        HUSBAND_IMPROVEMENTS = "Extraversion,Artistic,Happiness,Happiness,Happiness,Business,Meekness,Conscienciousness,Religiousness"
        HUSBAND_DEGRADATIONS = "Extraversion,Artistic,Happiness,Meekness,Conscienciousness"
        WIFE_IMPROVEMENTS    = "Extraversion,Artistic,Happiness,Happiness,Happiness,Business,Meekness,Conscienciousness,Religiousness"
        WIFE_DEGRADATIONS    = "Extraversion,Artistic,Happiness,Conscienciousness,Religiousness"
        HAPPY_FORMULA = "Happiness,Anger-,Terror-,Extraversion,Intelligence-,Meekness,Appearance,Realism-"
        PASSION_FORMULA = "Artistic,Extraversion,Constitution,Religiousness-,Constraint-,Realism-,Passion,Meekness-"
        CONSCIENCE_FORMULA = "Conscienciousness,Terror-,Intelligence,Manipulation-,Charisma"
        HEALTH_FORMULA = "Constitution,Strength,Dexterity,Anger-,Intelligence,Weight-,Lifespan,Neuroticism-,Immune System"

        happy = math_helpers.get_formula_from_obj(self.attribute_mods, HAPPY_FORMULA, -10, 20)
        passion = math_helpers.get_formula_from_obj(self.attribute_mods, PASSION_FORMULA, -10, 20)
        conscience = math_helpers.get_formula_from_obj(self.attribute_mods, CONSCIENCE_FORMULA, -10, 20)
        health = math_helpers.get_formula_from_obj(self.attribute_mods, HEALTH_FORMULA, -10, 20)

        if self.education is None or not isinstance(self.education, float):
            self.education = math_helpers.rand_range(1.0, 120.0, 3, 4.0)
        if self.economic is None or not isinstance(self.economic, float):
            self.economic = math_helpers.rand_range(1.0, 120.0, 3, 4.0)
        if self.conflict is None or not isinstance(self.conflict, float):
            self.conflict = math_helpers.rand_range(1.0, 120.0, 3, 4.0)

        # TODO: Revise by modified age
        if age > 60:
            self.attribute_mod_update('Constitution', -.4)
            self.attribute_mod_update('Appearance', -.2)
            conscience += 3
            passion -= 3
            health -= 1
        elif age > 40:
            self.attribute_mod_update('Constitution', -.3)
            self.attribute_mod_update('Appearance', -.1)
            self.attribute_mod_update('Wisdom', .3)
            conscience += 1
            passion -= 1
        elif age > 20:
            self.attribute_mod_update('Passion', .2)
            self.attribute_mod_update('Happiness', .2)
            self.attribute_mod_update('Constitution', .2)
            self.attribute_mod_update('Conscienciousness', .2)
            self.attribute_mod_update('Appearance', .1)
            conscience -= 1
            passion += 3
            happy += 2
            health += 4
        elif age > 17:
            self.attribute_mod_update('Appearance', .2)

        if self.education >= 40.0:
            conscience += 3
            happy -= 1
            passion += 1
        elif self.education >= 13:
            conscience += 1
            passion -= 1
            happy -= 1
            health -= 2
        elif self.education >= 5:
            conscience -= 1
            passion += 2
            happy += 1
            health -= 1
        else:
            health -= 1
            happy -= 1

        if self.economic >= 40.0:
            conscience -= 3
            happy += 3
            passion += 2
            health += 1
        elif self.economic >= 13:
            conscience -= 1
            passion += 1
            happy += 1
        elif self.economic >= 5:
            conscience += 1
            passion += 1
            happy -= 1
            health -= 1
        else:
            health -= 2
            happy -= 2
            passion += 2

        if self.conflict >= 40.0:
            conscience -= 3
            happy -= 2
            passion += 2
            health -= 2
        elif self.conflict >= 13:
            conscience -= 2
            passion += 1
            happy -= 2
            health -= 1
        elif self.conflict >= 5:
            conscience -= 1
            passion += 1
            happy -= 1
            health -= 1

        # rands = numpy.random.randint(-2, 2, 4)
        # happy = math_helpers.clamp(happy+rands[0], -10, 10)
        # passion = math_helpers.clamp(passion+rands[1], -10, 10)
        # conscience = math_helpers.clamp(conscience+rands[2], -10, 10)
        # health = math_helpers.clamp(health+rands[3], -10, 10)

        self.conscience = conscience
        self.passion = passion
        self.happy = happy
        self.health = health

        #Annual family modifiers
        economic_tithe = float(self.economic) * .03

        #Inflation and growth from working - #TODO: Make job dependent
        self.economic += math_helpers.weighted_number(mid=0.03, max=self.economic / 4, weight=8)

        #shift some money between parents
        if self.married and self.spouse:
            spouse = self.spouse

            #TODO: Should everyone have house?
            house = self.get("house", random_number=True, mid=0.02, max=self.economic)
            house = math_helpers.value_of_variable(house)

            if self.economic > spouse.economic:
                self.economic -= economic_tithe
                spouse.economic += economic_tithe

            #Increase parents stats through marriage
            improvements = HUSBAND_IMPROVEMENTS if self.gender is "Male" else WIFE_IMPROVEMENTS
            degradations = HUSBAND_DEGRADATIONS if self.gender is "Male" else WIFE_DEGRADATIONS
            for improvement in numpy.random.choice(improvements.split(","), 2):
                self.attribute_mod_update(improvement, 1)
            for degradation in numpy.random.choice(degradations.split(","), 1):
                self.attribute_mod_update(degradation, -1)

            house += economic_tithe
            self.set("house", house)
            self.economic -= economic_tithe

        if self.economic < 2:
            self.attribute_mod_update("Happiness", -1)

        if not self.deceased and self.health < -9:
            self.pass_away()