Exemple #1
0
 def quality_mod_update(self, quality_mods, amount=None):
     if isinstance(quality_mods, dict):
         quality_copies = quality_mods.copy()
         self.quality_mods_dict.update(quality_copies)
     elif isinstance(quality_mods, basestring) and amount is not None:
         current = math_helpers.get_val(self.quality_mods_dict, val=quality_mods, default=0)
         current += amount
         math_helpers.set_val(self.quality_mods_dict, val=quality_mods, amount=current)
Exemple #2
0
 def attribute_mod_update(self, attribute_mods, amount=None):
     if isinstance(attribute_mods, dict):
         attribute_copies = attribute_mods.copy()
         self.attribute_mods_dict.update(attribute_copies)
     elif isinstance(attribute_mods, basestring) and amount is not None:
         current = math_helpers.get_val(self.attribute_mods_dict, val=attribute_mods, default=0)
         current += amount
         math_helpers.set_val(self.attribute_mods_dict, val=attribute_mods, amount=current)
Exemple #3
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
Exemple #4
0
    def __init__(self, world_data={}):
        self.world_data = world_data

        self.year = self.get('year', numpy.random.randint(1000, 2000))

        self.world_data = math_helpers.extend(WORLD_DEFAULT_DICT, self.world_data)

        self.tag_manager = {}
        starting_tags = math_helpers.get_val(world_data, 'tags', '')
        math_helpers.add_tags(self.tag_manager, 'initial', starting_tags)

        magic = self.get('magic', random_number=True)
        magic = round(magic, 1)
        self.set('magic', magic)

        tech = self.get('technology', random_number=True)
        tech = round(tech, 1)
        self.set('technology', tech)

        self.people = self.get('people', [])
        self.people_objects = []
Exemple #5
0
 def get(self, val='', default=None, random_number=False, min=0.0, mid=0.2, max=120.0, weight=4, use_words=False):
     return math_helpers.get_val(self.pointer, val=val, default=default, use_words=use_words,
                                 random_number=random_number, min=min, mid=mid, max=max, weight=weight)