From: Eevee Date: Thu, 8 Jul 2010 05:32:32 +0000 (-0700) Subject: Implemented an ugly (but complete!) GTS listing. X-Git-Tag: veekun-promotions/2010070701^0 X-Git-Url: http://git.veekun.com/zzz-spline-gts.git/commitdiff_plain/30d693c5e60d1ddbe99fadaf22583d02d79c93b5 Implemented an ugly (but complete!) GTS listing. --- diff --git a/splinext/gts/__init__.py b/splinext/gts/__init__.py index 370be29..174e8db 100644 --- a/splinext/gts/__init__.py +++ b/splinext/gts/__init__.py @@ -5,6 +5,7 @@ from pylons import c, session from spline.lib.plugin import PluginBase from spline.lib.plugin import PluginBase, PluginLink, Priority import splinext.gts.controllers.gts +import splinext.gts.controllers.gts_browse def add_routes_hook(map, *args, **kwargs): """Hook to inject some of our behavior into the routes configuration.""" @@ -12,11 +13,15 @@ def add_routes_hook(map, *args, **kwargs): map.connect('/pokemondpds/worldexchange/{page}.asp', controller='gts', action='dispatch') map.connect('/pokemondpds/common/{page}.asp', controller='gts', action='dispatch') + # Web-side stuff + map.connect('/gts', controller='gts_browse', action='list') + class GTSPlugin(PluginBase): def controllers(self): return dict( gts = splinext.gts.controllers.gts.GTSController, + gts_browse = splinext.gts.controllers.gts_browse.GTSBrowseController, ) def hooks(self): diff --git a/splinext/gts/controllers/gts.py b/splinext/gts/controllers/gts.py index 5f7bfaf..15b3457 100644 --- a/splinext/gts/controllers/gts.py +++ b/splinext/gts/controllers/gts.py @@ -12,7 +12,7 @@ import struct import pokedex.db import pokedex.db.tables as tables import pokedex.formulae -from pokedex.savefile import PokemonSave +from pokedex.struct import SaveFilePokemon from pylons import config, request, response, session, tmpl_context as c, url from pylons.controllers.util import abort, redirect_to from sqlalchemy import and_, or_, not_ @@ -156,7 +156,7 @@ class GTSController(BaseController): .one() # We've got one! Cool, send it back. The game will ask us to # delete it after receiving successfully - pokemon_save = PokemonSave(stored_pokemon.pokemon_blob) + pokemon_save = SaveFilePokemon(stored_pokemon.pokemon_blob) return pokemon_save.as_encrypted except: @@ -186,7 +186,7 @@ class GTSController(BaseController): try: # The uploaded Pokémon is encrypted, which is not very useful - pokemon_save = PokemonSave(data, encrypted=True) + pokemon_save = SaveFilePokemon(data, encrypted=True) # Create a record... stored_pokemon = gts_model.GTSPokemon( diff --git a/splinext/gts/controllers/gts_browse.py b/splinext/gts/controllers/gts_browse.py new file mode 100644 index 0000000..09a398b --- /dev/null +++ b/splinext/gts/controllers/gts_browse.py @@ -0,0 +1,32 @@ +# encoding: utf8 +from __future__ import absolute_import, division + +import logging + +import pokedex.db +import pokedex.db.tables as tables +from pokedex.struct import SaveFilePokemon +from pylons import config, request, response, session, tmpl_context as c, url +from pylons.controllers.util import abort, redirect_to +from sqlalchemy.orm.exc import NoResultFound + +from spline.model import meta +from spline.lib.base import BaseController, render +from spline.lib import helpers as h +from splinext.gts import model as gts_model + +log = logging.getLogger(__name__) + +class GTSBrowseController(BaseController): + + def list(self): + u"""Show a list of all Pokémon currently uploaded to the GTS.""" + + gts_pokemons = meta.Session.query(gts_model.GTSPokemon).all() + + c.savefiles = [] + for gts_pokemon in gts_pokemons: + savefile = SaveFilePokemon(gts_pokemon.pokemon_blob) + c.savefiles.append(savefile) + + return render('/gts/list.mako') diff --git a/splinext/gts/templates/css/gts.mako b/splinext/gts/templates/css/gts.mako index e69de29..9a21ba1 100644 --- a/splinext/gts/templates/css/gts.mako +++ b/splinext/gts/templates/css/gts.mako @@ -0,0 +1,12 @@ +.gts-pokemon { margin: 1em 0; } +.gts-pokemon .icon { display: block; float: right; margin: 0 0 16px 16px; } +.gts-pokemon .header { height: 32px; line-height: 32px; margin-right: 96px; border: 1px solid #b4c7e6; background: url(${h.static_uri('local', 'images/layout/th-background.png')}) left bottom repeat-x; vertical-align: middle; } +.gts-pokemon .header .name { float: left; font-size: 1.5em; padding: 0 1em; line-height: 32px; } +.gts-pokemon .header .name .gender { font-size: 0.67em; vertical-align: top; } +.gts-pokemon .header .personality { float: right; font-size: 0.83em; padding: 0 0.5em; line-height: 16px; font-family: monospace; text-align: right; } +.gts-pokemon p { margin: 0.5em 0.75em; } +.gts-pokemon .secret-id { color: #909090; } +.gts-pokemon ul.gts-pokemon-markings li { display: inline; } +.gts-pokemon ul.gts-pokemon-ribbons li { display: inline; } +.gts-pokemon ul.gts-pokemon-leaves li { display: inline-block; width: 16px; height: 16px; } +.gts-pokemon .gts-pokemon-columns table tbody th { text-align: left; } diff --git a/splinext/gts/templates/gts/list.mako b/splinext/gts/templates/gts/list.mako new file mode 100644 index 0000000..a94259b --- /dev/null +++ b/splinext/gts/templates/gts/list.mako @@ -0,0 +1,237 @@ +<%inherit file="/base.mako" /> + +<%def name="title()">Stored Pokémon + +% for savefile in c.savefiles: +
+ % if savefile.structure.ivs.is_egg: + ${h.pokedex.pokedex_img("heartgold-soulsilver/egg.png", class_='icon')} + % else: + ${h.pokedex.pokedex_img("heartgold-soulsilver/{0}{1}.png".format( + 'shiny/' if savefile.is_shiny else '', + savefile.structure.national_id), + class_='icon')} + % endif +
+
+ % if savefile.structure.ivs.is_nicknamed: + “${savefile.structure.nickname}” + % else: + ## XXX pokemon name + ${savefile.structure.nickname} + % endif + + % if savefile.structure.gender == 'male': + ♂ + % elif savefile.structure.gender == 'female': + ♀ + % else: + ∅ + % endif + + % if savefile.structure.alternate_form: + ~ ${savefile.structure.alternate_form} + % endif +
+
+ ${savefile.structure.personality}
+ ${u"0x{0:08x}".format(savefile.structure.personality)} +
+
+ +

+ Original trainer: + ${savefile.structure.original_trainer_name} + ${u'♂' if savefile.structure.original_trainer_gender == 'male' else u'♀'} + ${savefile.structure.original_country}, + ID ${savefile.structure.original_trainer_id} + / ${savefile.structure.original_trainer_secret_id} +

+

+ % if savefile.structure.date_egg_received == savefile.structure.date_met: + Born and hatched on ${savefile.structure.date_egg_received} + % elif savefile.structure.date_egg_received: + Born on ${savefile.structure.date_egg_received}; + hatched on ${savefile.structure.date_met}) + % else: + [${savefile.structure.dppt_pokeball} ${savefile.structure.hgss_pokeball}] + Caught on ${savefile.structure.date_met} + at level ${savefile.structure.met_at_level} + % endif + + at place number ${savefile.structure.dp_met_location_id} + or maybe ${savefile.structure.dp_egg_location_id} + orrrr ${savefile.structure.pt_met_location_id} + or???? ${savefile.structure.pt_egg_location_id} + ${h.pokedex.pokedex_img("versions/{0}.png".format(savefile.structure.original_version))} + + ps was a ${savefile.structure.encounter_type} + % if savefile.structure.fateful_encounter: + also fateful + % endif +

+ +

Stats

+
+
Experience
+
${savefile.structure.exp}
+
Happiness
+
${savefile.structure.happiness}
+
Held item
+
${savefile.structure.held_item_id}
+
Ability
+
${savefile.structure.ability_id}
+
Pokérus
+
${savefile.structure.pokerus}
+
Markings
+
+
    + % if savefile.structure.markings.heart: +
  • + % else: +
  • + % endif + % if savefile.structure.markings.diamond: +
  • + % else: +
  • + % endif + % if savefile.structure.markings.triangle: +
  • + % else: +
  • + % endif + % if savefile.structure.markings.square: +
  • + % else: +
  • + % endif + % if savefile.structure.markings.star: +
  • + % else: +
  • + % endif + % if savefile.structure.markings.circle: +
  • + % else: +
  • + % endif +
+
+
Shiny leaves
+
+ % if savefile.structure.shining_leaves.crown: + ${h.pokedex.pokedex_img('chrome/leaf-crown.png', alt='Leaf Crown', title='Leaf Crown')} + % else: +
    + % for leaf_n in range(1, 6): +
  • + % if savefile.structure.shining_leaves['leaf' + str(leaf_n)]: + ${h.pokedex.pokedex_img('chrome/shiny-leaf.png', alt='Shiny Leaf', title='Shiny Leaf')} + % endif +
  • + % endfor +
+ % endif +
+
Ribbons
+
+
    + % for region, ribbon_container in ('hoenn', savefile.structure.hoenn_ribbons), \ + ('sinnoh', savefile.structure.sinnoh_ribbons), \ + ('sinnoh', savefile.structure.sinnoh_contest_ribbons): + % for ribbon in reversed(ribbon_container.__attrs__): + % if ribbon_container[ribbon]: +
  • ${h.pokedex.pokedex_img("ribbons/{0}/{1}.png".format(region, ribbon.replace(u'_', u'-')), alt=ribbon.replace(u'_', u' ').title(), title=ribbon.replace(u'_', u' ').title())}
  • + % endif + % endfor + % endfor +
+
+
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
StatGeneExp
HP${savefile.structure.ivs.iv_hp}${savefile.structure.effort_hp}
Attack${savefile.structure.ivs.iv_attack}${savefile.structure.effort_attack}
Defense${savefile.structure.ivs.iv_defense}${savefile.structure.effort_defense}
Special Attack${savefile.structure.ivs.iv_special_attack}${savefile.structure.effort_special_attack}
Special Defense${savefile.structure.ivs.iv_special_defense}${savefile.structure.effort_special_defense}
Speed${savefile.structure.ivs.iv_speed}${savefile.structure.effort_speed}
+
+
+ + + + + + + + + + % for i in range(1, 5): + + + + + + % endfor + +
move_idpppp_ups
${savefile.structure['move' + str(i) + '_id']}${savefile.structure['move' + str(i) + '_pp']}${savefile.structure['move' + str(i) + '_pp_ups']}
+
+
+ + + + + + + + + % for contest_stat in ('beauty', 'cool', 'cute', 'smart', 'tough'): + + + + + % endfor + +
${contest_stat}${savefile.structure['contest_' + contest_stat]}
+
+
+
+% endfor