def create(cls, account): # pylint: disable=R0914 from the_tale.game.relations import GENDER, RACE from the_tale.game.actions.prototypes import ActionIdlenessPrototype from the_tale.game.logic_storage import LogicStorage start_place = places_storage.random_place() race = random.choice(RACE.records) gender = random.choice((GENDER.MASCULINE, GENDER.FEMININE)) current_turn_number = TimePrototype.get_current_turn_number() utg_name = names.generator.get_name(race, gender) hero = Hero.objects.create( created_at_turn=current_turn_number, saved_at_turn=current_turn_number, active_state_end_at=account.active_end_at, premium_state_end_at=account.premium_end_at, account=account._model, gender=gender, race=race, is_fast=account.is_fast, is_bot=account.is_bot, abilities=s11n.to_json(AbilitiesPrototype.create().serialize()), messages=s11n.to_json(messages.JournalContainer().serialize()), diary=s11n.to_json(messages.DiaryContainer().serialize()), settings_approved=False, next_spending=relations.ITEMS_OF_EXPENDITURE.BUYING_ARTIFACT, health=f.hp_on_lvl(1), energy=c.ANGEL_ENERGY_MAX, energy_bonus=heroes_settings.START_ENERGY_BONUS, pos_place=start_place._model, data=s11n.to_json({'name': utg_name.serialize()})) hero = cls(model=hero) HeroPreferencesPrototype.create( hero, energy_regeneration_type=hero.preferences.energy_regeneration_type, risk_level=relations.RISK_LEVEL.NORMAL, archetype=game_relations.ARCHETYPE.NEUTRAL, companion_dedication=relations.COMPANION_DEDICATION.NORMAL, companion_empathy=relations.COMPANION_EMPATHY.ORDINAL) return hero
def create(cls, account): # pylint: disable=R0914 from the_tale.game.relations import GENDER, RACE from the_tale.game.actions.prototypes import ActionIdlenessPrototype from the_tale.game.logic_storage import LogicStorage start_place = places_storage.random_place() race = random.choice(RACE.records) gender = random.choice((GENDER.MASCULINE, GENDER.FEMININE)) current_turn_number = TimePrototype.get_current_turn_number() utg_name = names.generator.get_name(race, gender) hero = Hero.objects.create(created_at_turn=current_turn_number, saved_at_turn=current_turn_number, active_state_end_at=account.active_end_at, premium_state_end_at=account.premium_end_at, account=account._model, gender=gender, race=race, is_fast=account.is_fast, is_bot=account.is_bot, abilities=s11n.to_json(AbilitiesPrototype.create().serialize()), messages=s11n.to_json(messages.JournalContainer().serialize()), diary=s11n.to_json(messages.DiaryContainer().serialize()), settings_approved=False, next_spending=relations.ITEMS_OF_EXPENDITURE.BUYING_ARTIFACT, health=f.hp_on_lvl(1), energy=c.ANGEL_ENERGY_MAX, energy_bonus=heroes_settings.START_ENERGY_BONUS, pos_place = start_place._model, data=s11n.to_json({'name': utg_name.serialize()})) hero = cls(model=hero) HeroPreferencesPrototype.create(hero, energy_regeneration_type=hero.preferences.energy_regeneration_type, risk_level=relations.RISK_LEVEL.NORMAL, archetype=game_relations.ARCHETYPE.NEUTRAL, companion_dedication=relations.COMPANION_DEDICATION.NORMAL, companion_empathy=relations.COMPANION_EMPATHY.ORDINAL) return hero
def max_health(self): return int(f.hp_on_lvl(self.level) * self.attribute_modifier(relations.MODIFIERS.HEALTH)) @property
def create_hero(account): from the_tale.game.relations import GENDER, RACE start_place = places_storage.places.random_place() race = random.choice(RACE.records) gender = random.choice((GENDER.MASCULINE, GENDER.FEMININE)) current_turn_number = TimePrototype.get_current_turn_number() utg_name = names.generator().get_name(race, gender) hero_position = position.Position.create(place_id=start_place.id, road_id=None) hero = objects.Hero(id=account.id, account_id=account.id, health=f.hp_on_lvl(1), level=1, experience=0, energy=c.ANGEL_ENERGY_FREE_MAX, energy_bonus=conf.heroes_settings.START_ENERGY_BONUS, money=0, next_spending=relations.ITEMS_OF_EXPENDITURE.BUYING_ARTIFACT, habit_honor=habits.Honor(raw_value=0), habit_peacefulness=habits.Peacefulness(raw_value=0), position=hero_position, statistics=statistics.Statistics.create(), preferences=preferences.HeroPreferences(), actions=actions_container.ActionsContainer(), companion=None, journal=messages.JournalContainer(), quests=quests_container.QuestsContainer(), places_history=places_help_statistics.PlacesHelpStatistics(), cards=cards_container.CardsContainer(), abilities=habilities.AbilitiesPrototype.create(), bag=bag.Bag(), equipment=bag.Equipment(), created_at_turn=current_turn_number, saved_at_turn=current_turn_number, saved_at=None, is_fast=account.is_fast, is_bot=account.is_bot, is_alive=True, gender=gender, race=race, last_energy_regeneration_at_turn=TimePrototype.get_current_turn_number(), might=account.might, ui_caching_started_at=datetime.datetime.now(), active_state_end_at=account.active_end_at, premium_state_end_at=account.premium_end_at, ban_state_end_at=account.ban_game_end_at, last_rare_operation_at_turn=TimePrototype.get_current_turn_number(), settings_approved=False, actual_bills=[], utg_name=utg_name) dress_new_hero(hero) preferences_for_new_hero(hero) save_hero(hero, new=True) models.HeroPreferences.create(hero, energy_regeneration_type=hero.preferences.energy_regeneration_type, risk_level=relations.RISK_LEVEL.NORMAL, archetype=game_relations.ARCHETYPE.NEUTRAL, companion_dedication=relations.COMPANION_DEDICATION.NORMAL, companion_empathy=relations.COMPANION_EMPATHY.ORDINAL) return hero
def create_hero(account, full_create=True): from the_tale.game.relations import GENDER, RACE start_place = places_storage.places.random_place() race = random.choice(RACE.records) gender = random.choice((GENDER.MASCULINE, GENDER.FEMININE)) current_turn_number = turn.number() utg_name = names.generator().get_name(race, gender) hero_position = position.Position.create(place_id=start_place.id, road_id=None) hero = objects.Hero( id=account.id, account_id=account.id, health=f.hp_on_lvl(1), level=1, experience=0, money=0, next_spending=relations.ITEMS_OF_EXPENDITURE.BUYING_ARTIFACT, habit_honor=habits.Honor(raw_value=0), habit_peacefulness=habits.Peacefulness(raw_value=0), position=hero_position, statistics=statistics.Statistics.create(), preferences=preferences.HeroPreferences(), actions=actions_container.ActionsContainer(), companion=None, journal=messages.JournalContainer(), quests=quests_container.QuestsContainer(), places_history=places_help_statistics.PlacesHelpStatistics(), abilities=habilities.AbilitiesPrototype.create(), bag=bag.Bag(), equipment=bag.Equipment(), created_at_turn=current_turn_number, saved_at_turn=current_turn_number, saved_at=None, is_fast=account.is_fast, is_bot=account.is_bot, is_alive=True, gender=gender, race=race, last_energy_regeneration_at_turn=turn.number(), might=account.might, ui_caching_started_at=datetime.datetime.now(), active_state_end_at=account.active_end_at, premium_state_end_at=account.premium_end_at, ban_state_end_at=account.ban_game_end_at, last_rare_operation_at_turn=turn.number(), settings_approved=False, actual_bills=[], utg_name=utg_name) dress_new_hero(hero) preferences_for_new_hero(hero) if full_create: cards_for_new_hero(hero) save_hero(hero, new=True) models.HeroPreferences.create( hero, energy_regeneration_type=hero.preferences.energy_regeneration_type, risk_level=relations.RISK_LEVEL.NORMAL, archetype=game_relations.ARCHETYPE.NEUTRAL, companion_dedication=relations.COMPANION_DEDICATION.NORMAL, companion_empathy=relations.COMPANION_EMPATHY.ORDINAL) return hero