Beispiel #1
0
 def gender(self):
     val = self.get('gender', default='')
     if val and self.dna:
         val_dna = dna_helpers.gender_from_dna(self.dna)
         if val is not val_dna:
             self.gender = val_dna
             val = val_dna
     return val
Beispiel #2
0
    def have_child(self, child_data={}, spouse=None, event_id=0):
        father = self if self.gender is 'Male' else spouse
        mother = spouse if self.gender is 'Male' else self

        if not isinstance(father, Person):
            father = Person(self.world_obj, father, 'Male', 'Father')
            spouse = father
        if not isinstance(mother, Person):
            mother = Person(self.world_obj, mother, 'Female', 'Mother')
            spouse = mother

        child_dna, temp = dna_helpers.combine_dna(mother=mother.dna, father=father.dna)
        child_gender = dna_helpers.gender_from_dna(child_dna)
        child_dna = math_helpers.get_val(child_data, 'dna', child_dna)
        child_data_new = {
            "dna": child_dna,
            "gender": child_gender,
            "father_name": father.name,
            "mother_name": mother.name
        }
        child_data = math_helpers.extend(child_data, child_data_new)
        child = Person(self.world_obj, child_data, gender=child_gender, role='Child')
        child.create_name()

        world_data = self.world_obj.world_data
        birth_place = create_random_item(world_data=world_data, set_random_key=False, pattern='birthplace')
        birth_event_data = apply_event_effects(person_data=child.pointer, world_data=world_data, age=0,
                                               event_data=birth_place, event_type='birthplace', event_id=event_id,
                                               tag_manager=self.world_obj.tag_manager)

        child.set('birth_year', int(self.world_obj.get('year')))

        child.set('birth_event', birth_event_data)
        if spouse is None:
            child.set('parents_unmarried_while_born', True)
            child.set('family_name', mother.family_name)
            self.conflict += 2
            spouse.conflict += 2
            self.economic -= 2
            spouse.economic -= 2
        else:
            child.set('family_name', self.family_name if self.gender is 'Male' else mother.family_name)
            self.conflict -= 1
            self.economic -= 1
            spouse.economic -= 1
        self.education += 1

        child.create_name(set_to_person=True)
        self.world_obj.add_person(child)

        self.attribute_mod_update('Happiness', numpy.random.randint(-2, 2))
        self.attribute_mod_update('Constitution', numpy.random.randint(-2, 0))
        self.attribute_mod_update('Passion', numpy.random.randint(-4, -1))
        if self.gender is 'Female':
            self.attribute_mod_update('Happiness', -1)
            self.attribute_mod_update('Constitution', -1)
        return child