Exemplo n.º 1
0
    def kingdoms(self, name):
        try:
            c.kingdom = db.get_by_name_query(t.ConquestKingdom, name).one()
        except NoResultFound:
            return self._not_found()

        # We have pretty much nothing for kingdoms.  Yet.
        c.prev_kingdom, c.next_kingdom = self._prev_next_id(
            c.kingdom, t.ConquestKingdom, 'id')

        return render('/pokedex/conquest/kingdom.mako')
Exemplo n.º 2
0
    def kingdoms(self, name):
        try:
            c.kingdom = db.get_by_name_query(t.ConquestKingdom, name).one()
        except NoResultFound:
            return self._not_found()

        # We have pretty much nothing for kingdoms.  Yet.
        c.prev_kingdom, c.next_kingdom = self._prev_next_id(
            c.kingdom, t.ConquestKingdom, 'id')

        return render('/pokedex/conquest/kingdom.mako')
Exemplo n.º 3
0
    def skills(self, name):
        try:
            c.skill = (db.get_by_name_query(t.ConquestWarriorSkill,
                                            name).one())
        except NoResultFound:
            return self._not_found()

        ### Prev/next for header
        c.prev_skill, c.next_skill = self._prev_next_name(
            t.ConquestWarriorSkill, c.skill)

        return render('/pokedex/conquest/skill.mako')
Exemplo n.º 4
0
    def skills(self, name):
        try:
            c.skill = (db.get_by_name_query(t.ConquestWarriorSkill, name)
                .one())
        except NoResultFound:
            return self._not_found()

        ### Prev/next for header
        c.prev_skill, c.next_skill = self._prev_next_name(
            t.ConquestWarriorSkill, c.skill)

        return render('/pokedex/conquest/skill.mako')
Exemplo n.º 5
0
    def abilities(self, name):
        try:
            c.ability = db.get_by_name_query(t.Ability, name).one()
        except NoResultFound:
            return self._not_found()

        # XXX The ability might exist, but not in Conquest
        if not c.ability.conquest_pokemon:
            return self._not_found()

        c.prev_ability, c.next_ability = self._prev_next_name(
            t.Ability, c.ability, filters=[t.Ability.conquest_pokemon.any()])

        return render('/pokedex/conquest/ability.mako')
Exemplo n.º 6
0
    def abilities(self, name):
        try:
            c.ability = db.get_by_name_query(t.Ability, name).one()
        except NoResultFound:
            return self._not_found()

        # XXX The ability might exist, but not in Conquest
        if not c.ability.conquest_pokemon:
            return self._not_found()

        c.prev_ability, c.next_ability = self._prev_next_name(
            t.Ability, c.ability,
            filters=[t.Ability.conquest_pokemon.any()])

        return render('/pokedex/conquest/ability.mako')
Exemplo n.º 7
0
    def moves(self, name):
        try:
            c.move = (db.get_by_name_query(t.Move, name).options(
                sqla.orm.joinedload('conquest_data'),
                sqla.orm.joinedload('conquest_pokemon'),
                sqla.orm.subqueryload('conquest_pokemon.conquest_abilities'),
                sqla.orm.subqueryload('conquest_pokemon.conquest_stats'),
            ).one())
        except NoResultFound:
            return self._not_found()

        if not c.move.conquest_pokemon:
            return self._not_found()

        ### Prev/next for header
        c.prev_move, c.next_move = self._prev_next_name(
            t.Move, c.move, filters=[t.Move.conquest_pokemon.any()])

        return render('/pokedex/conquest/move.mako')
Exemplo n.º 8
0
    def moves(self, name):
        try:
            c.move = (db.get_by_name_query(t.Move, name)
                .options(
                    sqla.orm.joinedload('conquest_data'),
                    sqla.orm.joinedload('conquest_pokemon'),
                    sqla.orm.subqueryload('conquest_pokemon.conquest_abilities'),
                    sqla.orm.subqueryload('conquest_pokemon.conquest_stats'),
                )
                .one())
        except NoResultFound:
            return self._not_found()

        if not c.move.conquest_pokemon:
            return self._not_found()

        ### Prev/next for header
        c.prev_move, c.next_move = self._prev_next_name(t.Move, c.move,
            filters=[t.Move.conquest_pokemon.any()])

        return render('/pokedex/conquest/move.mako')
Exemplo n.º 9
0
    def warriors(self, name):
        try:
            c.warrior = db.get_by_name_query(t.ConquestWarrior, name).one()
        except NoResultFound:
            return self._not_found()

        c.prev_warrior, c.next_warrior = self._prev_next_id(
            c.warrior, t.ConquestWarrior, 'id')

        c.rank_count = len(c.warrior.ranks)

        c.perfect_links = (c.warrior.ranks[-1].max_links.filter_by(
            max_link=100).join(t.PokemonSpecies).order_by(
                t.PokemonSpecies.conquest_order).all())

        ### Stats
        # Percentiles!  Percentiles are hard.
        stats = t.ConquestWarriorRankStatMap
        all_stats = sqla.orm.aliased(t.ConquestWarriorRankStatMap)

        # We need this to be a float so the percentile equation can divide by it
        stat_count = sqla.cast(sqla.func.count(all_stats.base_stat),
                               sqla.types.FLOAT)

        # Grab all of a rank's stats, and also get percentiles
        stat_q = (db.pokedex_session.query(
            stats.warrior_stat_id, stats.base_stat).join(
                all_stats,
                stats.warrior_stat_id == all_stats.warrior_stat_id).group_by(
                    stats.warrior_rank_id, stats.warrior_stat_id, stats.
                    base_stat).order_by(stats.warrior_stat_id).add_columns(
                        sqla.func.sum(
                            sqla.cast(stats.base_stat > all_stats.base_stat,
                                      sqla.types.INT)) / stat_count +
                        sqla.func.sum(
                            sqla.cast(stats.base_stat == all_stats.base_stat,
                                      sqla.types.INT)) / stat_count / 2))

        # XXX There's probably a better way to query all the names
        stat_names = [
            stat.name
            for stat in db.pokedex_session.query(t.ConquestWarriorStat).
            order_by(t.ConquestWarriorStat.id).all()
        ]

        # Go through the query for each rank
        c.stats = []
        for rank in c.warrior.ranks:
            c.stats.append([])
            info = stat_q.filter(stats.warrior_rank_id == rank.id).all()

            # We need a bit more info than what the query directly provides
            for stat, value, percentile in info:
                percentile = float(percentile)
                c.stats[-1].append(
                    (stat_names[stat - 1], value, percentile,
                     bar_color(percentile, 0.9), bar_color(percentile, 0.8)))

        ### Max links
        default_link = 70 if c.warrior.archetype else 90

        c.link_form = LinkThresholdForm(request.params, link=default_link)
        if request.params and c.link_form.validate():
            link_threshold = c.link_form.link.data
        else:
            link_threshold = default_link

        link_pokemon = (db.pokedex_session.query(
            t.ConquestMaxLink.pokemon_species_id).filter(
                t.ConquestMaxLink.warrior_rank_id == c.warrior.ranks[-1].id).
                        filter(t.ConquestMaxLink.max_link >= link_threshold))

        max_links = []
        for rank in c.warrior.ranks:
            max_links.append(
                rank.max_links.filter(
                    t.ConquestMaxLink.pokemon_species_id.in_(link_pokemon)).
                join(t.PokemonSpecies).order_by(
                    t.PokemonSpecies.conquest_order).options(
                        sqla.orm.joinedload('pokemon'),
                        sqla.orm.subqueryload('pokemon.conquest_abilities'),
                        sqla.orm.subqueryload('pokemon.conquest_stats'),
                    ).all())

        c.max_links = izip(*max_links)

        return render('/pokedex/conquest/warrior.mako')
Exemplo n.º 10
0
    def warriors(self, name):
        try:
            c.warrior = db.get_by_name_query(t.ConquestWarrior, name).one()
        except NoResultFound:
            return self._not_found()

        c.prev_warrior, c.next_warrior = self._prev_next_id(
            c.warrior, t.ConquestWarrior, 'id')

        c.rank_count = len(c.warrior.ranks)

        c.perfect_links = (c.warrior.ranks[-1].max_links
            .filter_by(max_link=100)
            .join(t.PokemonSpecies)
            .order_by(t.PokemonSpecies.conquest_order)
            .all())

        ### Stats
        # Percentiles!  Percentiles are hard.
        stats = t.ConquestWarriorRankStatMap
        all_stats = sqla.orm.aliased(t.ConquestWarriorRankStatMap)

        # We need this to be a float so the percentile equation can divide by it
        stat_count = sqla.cast(sqla.func.count(all_stats.base_stat),
            sqla.types.FLOAT)

        # Grab all of a rank's stats, and also get percentiles
        stat_q = (db.pokedex_session.query(stats.warrior_stat_id, stats.base_stat)
            .join(all_stats, stats.warrior_stat_id == all_stats.warrior_stat_id)
            .group_by(stats.warrior_rank_id, stats.warrior_stat_id,
                      stats.base_stat)
            .order_by(stats.warrior_stat_id)
            .add_columns(
                sqla.func.sum(sqla.cast(stats.base_stat > all_stats.base_stat,
                    sqla.types.INT)) / stat_count +
                sqla.func.sum(sqla.cast(stats.base_stat == all_stats.base_stat,
                    sqla.types.INT)) / stat_count / 2
            )
        )

        # XXX There's probably a better way to query all the names
        stat_names = [stat.name for stat in
            db.pokedex_session.query(t.ConquestWarriorStat)
            .order_by(t.ConquestWarriorStat.id)
            .all()]

        # Go through the query for each rank
        c.stats = []
        for rank in c.warrior.ranks:
            c.stats.append([])
            info = stat_q.filter(stats.warrior_rank_id == rank.id).all()

            # We need a bit more info than what the query directly provides
            for stat, value, percentile in info:
                percentile = float(percentile)
                c.stats[-1].append((
                    stat_names[stat - 1], value, percentile,
                    bar_color(percentile, 0.9), bar_color(percentile, 0.8)
                ))


        ### Max links
        default_link = 70 if c.warrior.archetype else 90

        c.link_form = LinkThresholdForm(request.params, link=default_link)
        if request.params and c.link_form.validate():
            link_threshold = c.link_form.link.data
        else:
            link_threshold = default_link

        link_pokemon = (
            db.pokedex_session.query(t.ConquestMaxLink.pokemon_species_id)
            .filter(t.ConquestMaxLink.warrior_rank_id ==
                    c.warrior.ranks[-1].id)
            .filter(t.ConquestMaxLink.max_link >= link_threshold)
        )

        max_links = []
        for rank in c.warrior.ranks:
            max_links.append(rank.max_links
                .filter(t.ConquestMaxLink.pokemon_species_id
                        .in_(link_pokemon))
                .join(t.PokemonSpecies)
                .order_by(t.PokemonSpecies.conquest_order)
                .options(
                    sqla.orm.joinedload('pokemon'),
                    sqla.orm.subqueryload('pokemon.conquest_abilities'),
                    sqla.orm.subqueryload('pokemon.conquest_stats'),
                )
                .all())

        c.max_links = izip(*max_links)

        return render('/pokedex/conquest/warrior.mako')