def create_place(self, x, y, size, roads_to, persons=(), name_forms=None, is_frontier=False): # pylint: disable=R0914 place_power = int(max(place.power for place in places_storage.all()) * float(size) / places_settings.MAX_SIZE) place_power_steps = int(places_settings.POWER_HISTORY_LENGTH / c.MAP_SYNC_TIME) place_power_per_step = (place_power / place_power_steps) + 1 place = PlacePrototype.create( x=x, y=y, utg_name=name_forms.word, is_frontier=is_frontier, size=size) initial_turn = TimePrototype.get_current_turn_number() - places_settings.POWER_HISTORY_LENGTH for i in xrange(place_power_steps): place.push_power(int(initial_turn+i*c.MAP_SYNC_TIME), int(place_power_per_step)) for person_name_forms, power_percent, race, gender, tp in persons: person = PersonPrototype.create(place=place, race=race, gender=gender, tp=tp, name_forms=person_name_forms) person_power = place_power * power_percent person_power_steps = int(persons_conf.settings.POWER_HISTORY_LENGTH / c.MAP_SYNC_TIME) person_power_per_step = (person_power / person_power_steps) + 1 initial_turn = TimePrototype.get_current_turn_number() - persons_conf.settings.POWER_HISTORY_LENGTH for i in xrange(person_power_steps): person.push_power(int(initial_turn+i*c.MAP_SYNC_TIME), int(person_power_per_step)) person.save() place.sync_persons(force_add=True) power_delta = self.INITIAL_PERSON_POWER for person in place.persons: person.fill_power_evenly(power_delta) person.save() power_delta /= 2 place.sync_race() place.save() for destination in roads_to: Road.objects.create(point_1=place._model, point_2=destination._model) persons_storage.update_version() places_storage.update_version() roads_storage.update_version() persons_storage.refresh() places_storage.refresh() roads_storage.refresh() return place
def create_person(place, state): race = random.choice(RACE.records) gender = random.choice((GENDER.MASCULINE, GENDER.FEMININE)) return PersonPrototype.create(place, state=state, race=race, tp=random.choice(PERSON_TYPE.records), utg_name=names.generator.get_name( race, gender), gender=gender)
def create_person(place, state): race = random.choice(RACE.records) gender = random.choice((GENDER.MASCULINE, GENDER.FEMININE)) return PersonPrototype.create( place, state=state, race=race, tp=random.choice(PERSON_TYPE.records), utg_name=names.generator.get_name(race, gender), gender=gender, )
def add_person(self): from the_tale.game.persons.relations import PERSON_TYPE from the_tale.game.persons.prototypes import PersonPrototype race = random.choice(RACE.records) gender = random.choice((GENDER.MASCULINE, GENDER.FEMININE)) new_person = PersonPrototype.create(place=self, race=race, gender=gender, tp=random.choice(PERSON_TYPE.records), utg_name=names.generator.get_name(race, gender)) signals.place_person_arrived.send(self.__class__, place=self, person=new_person) return new_person
def add_person(self): from the_tale.game.persons.relations import PERSON_TYPE from the_tale.game.persons.prototypes import PersonPrototype race = random.choice(RACE.records) gender = random.choice((GENDER.MASCULINE, GENDER.FEMININE)) new_person = PersonPrototype.create( place=self, race=race, gender=gender, tp=random.choice(PERSON_TYPE.records), utg_name=names.generator.get_name(race, gender)) signals.place_person_arrived.send(self.__class__, place=self, person=new_person) return new_person
def __init__(self, choosen_person_id, *args, **kwargs): # pylint: disable=W0613 super(UserForm, self).__init__(*args, **kwargs) self.fields['person'].choices = PersonPrototype.form_choices( predicate=self._person_has_building)
def __init__(self, choosen_person_id, *args, **kwargs): super(UserForm, self).__init__(*args, **kwargs) self.fields['person'].choices = PersonPrototype.form_choices(only_weak=False, choosen_person=persons_storage.get(choosen_person_id))
def __init__(self, choosen_person_id, *args, **kwargs): super(UserForm, self).__init__(*args, **kwargs) self.fields['person'].choices = PersonPrototype.form_choices(only_weak=True, choosen_person=persons_storage.get(choosen_person_id))
def __init__(self, *args, **kwargs): super(PersonForm, self).__init__(*args, **kwargs) self.fields['person'].choices = PersonPrototype.form_choices(only_weak=False)
def name(self, obj): from the_tale.game.persons.prototypes import PersonPrototype return PersonPrototype(model=obj).name
def negative_bonus(self, obj): person = PersonPrototype(obj) return round(person.power_negative, 2)
def raw_power(self, obj): person = PersonPrototype(obj) return int(person.raw_power)
def __init__(self, choosen_person_id, *args, **kwargs): # pylint: disable=W0613 super(UserForm, self).__init__(*args, **kwargs) self.fields['person'].choices = PersonPrototype.form_choices(predicate=lambda place, person: not person.has_building)
def create_place(self, x, y, size, roads_to, persons=(), name_forms=None, is_frontier=False): # pylint: disable=R0914 place_power = int( max(place.power for place in places_storage.all()) * float(size) / places_settings.MAX_SIZE) place_power_steps = int(places_settings.POWER_HISTORY_LENGTH / c.MAP_SYNC_TIME) place_power_per_step = (place_power / place_power_steps) + 1 place = PlacePrototype.create(x=x, y=y, utg_name=name_forms.word, is_frontier=is_frontier, size=size) initial_turn = TimePrototype.get_current_turn_number( ) - places_settings.POWER_HISTORY_LENGTH for i in xrange(place_power_steps): place.push_power(int(initial_turn + i * c.MAP_SYNC_TIME), int(place_power_per_step)) for person_name_forms, power_percent, race, gender, tp in persons: person = PersonPrototype.create(place=place, race=race, gender=gender, tp=tp, name_forms=person_name_forms) person_power = place_power * power_percent person_power_steps = int( persons_conf.settings.POWER_HISTORY_LENGTH / c.MAP_SYNC_TIME) person_power_per_step = (person_power / person_power_steps) + 1 initial_turn = TimePrototype.get_current_turn_number( ) - persons_conf.settings.POWER_HISTORY_LENGTH for i in xrange(person_power_steps): person.push_power(int(initial_turn + i * c.MAP_SYNC_TIME), int(person_power_per_step)) person.save() place.sync_persons(force_add=True) power_delta = self.INITIAL_PERSON_POWER for person in place.persons: person.fill_power_evenly(power_delta) person.save() power_delta /= 2 place.sync_race() place.save() for destination in roads_to: Road.objects.create(point_1=place._model, point_2=destination._model) persons_storage.update_version() places_storage.update_version() roads_storage.update_version() persons_storage.refresh() places_storage.refresh() roads_storage.refresh() return place
def __init__(self, choosen_person_id, *args, **kwargs): # pylint: disable=W0613 super(UserForm, self).__init__(*args, **kwargs) self.fields["person"].choices = PersonPrototype.form_choices(predicate=self._person_has_building)
def __init__(self, *args, **kwargs): super(PersonForm, self).__init__(*args, **kwargs) self.fields['person'].choices = PersonPrototype.form_choices( only_weak=False)