def game_page(context): battle = Battle1x1Prototype.get_by_account_id(context.account.id) if battle and battle.state.is_PROCESSING: return dext_views.Redirect(url('game:pvp:')) clan = None if context.account.clan_id is not None: clan = ClanPrototype.get_by_id(context.account.clan_id) cards = sorted(CARD.records, key=lambda r: (r.rarity.value, r.text)) return dext_views.Page('game/game_page.html', content={ 'map_settings': map_settings, 'game_settings': game_settings, 'EQUIPMENT_SLOT': EQUIPMENT_SLOT, 'current_map_version': map_info_storage.version, 'clan': clan, 'CARDS': cards, 'resource': context.resource, 'hero': context.account_hero, 'ABILITY_TYPE': ABILITY_TYPE })
def hero_page(self): abilities = sorted(self.hero.abilities.all, key=lambda x: x.NAME) battle_active_abilities = [a for a in abilities if a.type.is_BATTLE and a.activation_type.is_ACTIVE] # pylint: disable=W0110 battle_passive_abilities = [a for a in abilities if a.type.is_BATTLE and a.activation_type.is_PASSIVE]# pylint: disable=W0110 nonbattle_abilities = [a for a in abilities if a.type.is_NONBATTLE]# pylint: disable=W0110 companion_abilities = [a for a in abilities if a.type.is_COMPANION]# pylint: disable=W0110 edit_name_form = forms.EditNameForm(initial=forms.EditNameForm.get_initials(hero=self.hero)) master_account = AccountPrototype.get_by_id(self.hero.account_id) master_clan = None if master_account.clan_id is not None: master_clan = ClanPrototype.get_by_id(master_account.clan_id) return self.template('heroes/hero_page.html', {'battle_active_abilities': battle_active_abilities, 'battle_passive_abilities': battle_passive_abilities, 'nonbattle_abilities': nonbattle_abilities, 'companion_abilities': companion_abilities, 'heroes_settings': conf.heroes_settings, 'hero_meta_object': meta_relations.Hero.create_from_object(self.hero), 'is_owner': self.is_owner, 'edit_name_form': edit_name_form, 'master_account': master_account, 'master_clan': master_clan, 'EQUIPMENT_SLOT': relations.EQUIPMENT_SLOT, 'PREFERENCE_TYPE': relations.PREFERENCE_TYPE, 'PREFERENCES_CHANGE_DELAY': datetime.timedelta(seconds=c.PREFERENCES_CHANGE_DELAY), 'ABILITY_TYPE': habilities_relations.ABILITY_TYPE, 'HABIT_TYPE': HABIT_TYPE, 'PREFERENCE_RESET_CARDS': cards_effects.PREFERENCE_RESET_CARDS, 'CARD_TYPE': cards_relations.CARD_TYPE, 'QUEST_OPTION_MARKERS': questgen_relations.OPTION_MARKERS, 'HABITS_BORDER': c.HABITS_BORDER} )
def hero_page(self): abilities = sorted(self.hero.abilities.all, key=lambda x: x.NAME) battle_active_abilities = [ a for a in abilities if a.type.is_BATTLE and a.activation_type.is_ACTIVE ] # pylint: disable=W0110 battle_passive_abilities = [ a for a in abilities if a.type.is_BATTLE and a.activation_type.is_PASSIVE ] # pylint: disable=W0110 nonbattle_abilities = [a for a in abilities if a.type.is_NONBATTLE] # pylint: disable=W0110 companion_abilities = [a for a in abilities if a.type.is_COMPANION] # pylint: disable=W0110 edit_name_form = forms.EditNameForm( initial=forms.EditNameForm.get_initials(hero=self.hero)) master_account = AccountPrototype.get_by_id(self.hero.account_id) master_clan = None if master_account.clan_id is not None: master_clan = ClanPrototype.get_by_id(master_account.clan_id) return self.template( 'heroes/hero_page.html', { 'battle_active_abilities': battle_active_abilities, 'battle_passive_abilities': battle_passive_abilities, 'nonbattle_abilities': nonbattle_abilities, 'companion_abilities': companion_abilities, 'heroes_settings': conf.heroes_settings, 'hero_meta_object': meta_relations.Hero.create_from_object(self.hero), 'is_owner': self.is_owner, 'edit_name_form': edit_name_form, 'master_account': master_account, 'master_clan': master_clan, 'EQUIPMENT_SLOT': relations.EQUIPMENT_SLOT, 'PREFERENCE_TYPE': relations.PREFERENCE_TYPE, 'ABILITY_TYPE': habilities_relations.ABILITY_TYPE, 'HABIT_TYPE': HABIT_TYPE, 'CARD_TYPE': cards.CARD, 'QUEST_OPTION_MARKERS': questgen_relations.OPTION_MARKERS, 'HABITS_BORDER': c.HABITS_BORDER })
def pvp_page(self): battle = Battle1x1Prototype.get_by_account_id(self.account.id) if battle is None or not battle.state.is_PROCESSING: return self.redirect(reverse('game:')) own_abilities = sorted(self.own_hero.abilities.all, key=lambda x: x.NAME) enemy_account = AccountPrototype.get_by_id(battle.enemy_id) enemy_hero = HeroPrototype.get_by_account_id(battle.enemy_id) enemy_abilities = sorted(enemy_hero.abilities.all, key=lambda x: x.NAME) say_form = SayForm() clan = None if self.account.clan_id is not None: clan = ClanPrototype.get_by_id(self.account.clan_id) enemy_clan = None if enemy_account.clan_id is not None: enemy_clan = ClanPrototype.get_by_id(enemy_account.clan_id) return self.template( 'pvp/pvp_page.html', { 'enemy_account': AccountPrototype.get_by_id(battle.enemy_id), 'own_hero': self.own_hero, 'own_abilities': own_abilities, 'enemy_abilities': enemy_abilities, 'game_settings': game_settings, 'say_form': say_form, 'clan': clan, 'enemy_clan': enemy_clan, 'battle': battle, 'EQUIPMENT_SLOT': EQUIPMENT_SLOT, 'ABILITIES': (Ice, Blood, Flame) })
def pvp_page(self): battle = Battle1x1Prototype.get_by_account_id(self.account.id) if battle is None or not battle.state.is_PROCESSING: return self.redirect(reverse("game:")) own_abilities = sorted(self.own_hero.abilities.all, key=lambda x: x.NAME) enemy_account = AccountPrototype.get_by_id(battle.enemy_id) enemy_hero = HeroPrototype.get_by_account_id(battle.enemy_id) enemy_abilities = sorted(enemy_hero.abilities.all, key=lambda x: x.NAME) say_form = SayForm() clan = None if self.account.clan_id is not None: clan = ClanPrototype.get_by_id(self.account.clan_id) enemy_clan = None if enemy_account.clan_id is not None: enemy_clan = ClanPrototype.get_by_id(enemy_account.clan_id) return self.template( "pvp/pvp_page.html", { "enemy_account": AccountPrototype.get_by_id(battle.enemy_id), "own_hero": self.own_hero, "own_abilities": own_abilities, "enemy_abilities": enemy_abilities, "game_settings": game_settings, "say_form": say_form, "clan": clan, "enemy_clan": enemy_clan, "battle": battle, "EQUIPMENT_SLOT": EQUIPMENT_SLOT, "ABILITIES": (Ice, Blood, Flame), }, )
def index(self): if portal_settings.ENABLE_FIRST_TIME_REDIRECT and accounts_logic.is_first_time_visit(self.request): return self.redirect(random.choice(portal_settings.FIRST_TIME_LANDING_URLS)) news = news_logic.load_news_from_query(news_models.News.objects.all().order_by('-created_at')[:portal_settings.NEWS_ON_INDEX]) bills = BillPrototype.get_recently_modified_bills(portal_settings.BILLS_ON_INDEX) account_of_the_day_id = settings.get(portal_settings.SETTINGS_ACCOUNT_OF_THE_DAY_KEY) hero_of_the_day = None account_of_the_day = None clan_of_the_day = None if account_of_the_day_id is not None: hero_of_the_day = heroes_logic.load_hero(account_id=account_of_the_day_id) account_of_the_day = AccountPrototype.get_by_id(account_of_the_day_id) if account_of_the_day.clan_id is not None: clan_of_the_day = ClanPrototype.get_by_id(account_of_the_day.clan_id) forum_threads = ThreadPrototype.get_last_threads(account=self.account if self.account.is_authenticated() else None, limit=portal_settings.FORUM_THREADS_ON_INDEX) blog_posts = [ BlogPostPrototype(blog_post_model) for blog_post_model in BlogPost.objects.filter(state__in=[BLOG_POST_STATE.ACCEPTED, BLOG_POST_STATE.NOT_MODERATED], votes__gte=0).order_by('-created_at')[:portal_settings.BLOG_POSTS_ON_INDEX] ] map_info = map_info_storage.item chronicle_records = ChronicleRecordPrototype.get_last_records(portal_settings.CHRONICLE_RECORDS_ON_INDEX) chronicle_actors = RecordToActorPrototype.get_actors_for_records(chronicle_records) return self.template('portal/index.html', {'news': news, 'forum_threads': forum_threads, 'bills': bills, 'hero_of_the_day': hero_of_the_day, 'account_of_the_day': account_of_the_day, 'clan_of_the_day': clan_of_the_day, 'map_info': map_info, 'blog_posts': blog_posts, 'TERRAIN': TERRAIN, 'MAP_STATISTICS': MAP_STATISTICS, 'chronicle_records': chronicle_records, 'chronicle_actors': chronicle_actors, 'RACE': RACE})
def pvp_page(self): battle = Battle1x1Prototype.get_by_account_id(self.account.id) if battle is None or not battle.state.is_PROCESSING: return self.redirect(reverse('game:')) own_abilities = sorted(self.own_hero.abilities.all, key=lambda x: x.NAME) enemy_account = AccountPrototype.get_by_id(battle.enemy_id) enemy_hero = HeroPrototype.get_by_account_id(battle.enemy_id) enemy_abilities = sorted(enemy_hero.abilities.all, key=lambda x: x.NAME) say_form = SayForm() clan = None if self.account.clan_id is not None: clan = ClanPrototype.get_by_id(self.account.clan_id) enemy_clan = None if enemy_account.clan_id is not None: enemy_clan = ClanPrototype.get_by_id(enemy_account.clan_id) return self.template('pvp/pvp_page.html', {'enemy_account': AccountPrototype.get_by_id(battle.enemy_id), 'own_hero': self.own_hero, 'own_abilities': own_abilities, 'enemy_abilities': enemy_abilities, 'game_settings': game_settings, 'say_form': say_form, 'clan': clan, 'enemy_clan': enemy_clan, 'battle': battle, 'EQUIPMENT_SLOT': EQUIPMENT_SLOT, 'ABILITIES': (Ice, Blood, Flame)} )
def game_page(context): battle = Battle1x1Prototype.get_by_account_id(context.account.id) if battle and battle.state.is_PROCESSING: return dext_views.Redirect(url('game:pvp:')) clan = None if context.account.clan_id is not None: clan = ClanPrototype.get_by_id(context.account.clan_id) cards = sorted(EFFECTS.values(), key=lambda x: (x.TYPE.rarity.value, x.TYPE.text)) return dext_views.Page('game/game_page.html', content={'map_settings': map_settings, 'game_settings': game_settings, 'EQUIPMENT_SLOT': EQUIPMENT_SLOT, 'current_map_version': map_info_storage.version, 'clan': clan, 'CARDS': cards, 'resource': context.resource, 'hero': context.account_hero} )
def index(self): if portal_settings.ENABLE_FIRST_TIME_REDIRECT and accounts_logic.is_first_time_visit( self.request): return self.redirect( random.choice(portal_settings.FIRST_TIME_LANDING_URLS)) news = news_logic.load_news_from_query( news_models.News.objects.all().order_by( '-created_at')[:portal_settings.NEWS_ON_INDEX]) bills = BillPrototype.get_recently_modified_bills( portal_settings.BILLS_ON_INDEX) account_of_the_day_id = settings.get( portal_settings.SETTINGS_ACCOUNT_OF_THE_DAY_KEY) hero_of_the_day = None account_of_the_day = None clan_of_the_day = None if account_of_the_day_id is not None: hero_of_the_day = heroes_logic.load_hero( account_id=account_of_the_day_id) account_of_the_day = AccountPrototype.get_by_id( account_of_the_day_id) if account_of_the_day and account_of_the_day.clan_id is not None: clan_of_the_day = ClanPrototype.get_by_id( account_of_the_day.clan_id) forum_threads = ThreadPrototype.get_last_threads( account=self.account if self.account.is_authenticated else None, limit=portal_settings.FORUM_THREADS_ON_INDEX) blog_posts = [ BlogPostPrototype(blog_post_model) for blog_post_model in BlogPost.objects.filter(state__in=[ BLOG_POST_STATE.ACCEPTED, BLOG_POST_STATE.NOT_MODERATED ], votes__gte=0). order_by('-created_at')[:portal_settings.BLOG_POSTS_ON_INDEX] ] map_info = map_info_storage.item chronicle_records = ChronicleRecordPrototype.get_last_records( portal_settings.CHRONICLE_RECORDS_ON_INDEX) chronicle_actors = RecordToActorPrototype.get_actors_for_records( chronicle_records) return self.template( 'portal/index.html', { 'news': news, 'forum_threads': forum_threads, 'bills': bills, 'hero_of_the_day': hero_of_the_day, 'account_of_the_day': account_of_the_day, 'clan_of_the_day': clan_of_the_day, 'map_info': map_info, 'blog_posts': blog_posts, 'TERRAIN': TERRAIN, 'MAP_STATISTICS': MAP_STATISTICS, 'chronicle_records': chronicle_records, 'chronicle_actors': chronicle_actors, 'RACE': RACE })
def clan(self): if self.membership: return ClanPrototype.get_by_id(self.membership.clan_id)
def clan(self): if self.membership: return ClanPrototype.get_by_id(self.membership.clan_id)