From 3893f9d80caf541e18044266e963ed100d9bb2dc Mon Sep 17 00:00:00 2001 From: Petr Viktorin Date: Thu, 22 Sep 2011 14:43:32 +0300 Subject: [PATCH] Add Colosseum and XD as versions. Prepare to add XD tutors from ete's list. #588 --- pokedex/data/csv/version_groups.csv | 2 + pokedex/data/csv/version_names.csv | 2 + pokedex/data/csv/versions.csv | 2 + scripts/xd-tutors.py | 121 ++++++++++++++++++++++++++++ 4 files changed, 127 insertions(+) create mode 100644 scripts/xd-tutors.py diff --git a/pokedex/data/csv/version_groups.csv b/pokedex/data/csv/version_groups.csv index 9c27720..422c81b 100644 --- a/pokedex/data/csv/version_groups.csv +++ b/pokedex/data/csv/version_groups.csv @@ -10,3 +10,5 @@ id,generation_id,pokedex_id 9,4,6 10,4,7 11,5,8 +12,3,4 +13,3,4 diff --git a/pokedex/data/csv/version_names.csv b/pokedex/data/csv/version_names.csv index 1902bfe..b0341fd 100644 --- a/pokedex/data/csv/version_names.csv +++ b/pokedex/data/csv/version_names.csv @@ -17,3 +17,5 @@ version_id,local_language_id,name 16,9,SoulSilver 17,9,Black 18,9,White +19,9,Colosseum +20,9,XD diff --git a/pokedex/data/csv/versions.csv b/pokedex/data/csv/versions.csv index a477441..e5c771d 100644 --- a/pokedex/data/csv/versions.csv +++ b/pokedex/data/csv/versions.csv @@ -17,3 +17,5 @@ id,version_group_id,identifier 16,10,soulsilver 17,11,black 18,11,white +19,12,colosseum +20,13,xd diff --git a/scripts/xd-tutors.py b/scripts/xd-tutors.py new file mode 100644 index 0000000..25fb3d2 --- /dev/null +++ b/scripts/xd-tutors.py @@ -0,0 +1,121 @@ +# Encoding: UTF-8 +"""Add XD tutors to the database + +This is an unmaintained one-shot script, only included in the repo for reference. + +""" + +from pokedex.db import connect, tables, util + +session = connect() + +emerald = util.get(session, tables.Version, 'emerald') +fire_red = util.get(session, tables.Version, 'firered') +emerald_version_group = emerald.version_group +xd_version_group = util.get(session, tables.Version, 'xd').version_group +colo_version_group = util.get(session, tables.Version, 'colosseum').version_group + +tutor = util.get(session, tables.PokemonMoveMethod, 'tutor') +level_up = util.get(session, tables.PokemonMoveMethod, 'level-up') + +# According to every source I could find, the following can be taught to +# exactly the same set of Pokémon which learn it from the FR/LG/E tutor: --ete +for move_identifier in ''' + body-slam + double-edge + dream-eater + icy-wind + mimic + seismic-toss + substitute + swagger + thunder-wave + '''.split(): + move = util.get(session, tables.Move, move_identifier) + print move + query = session.query(tables.PokemonMove.pokemon_id) + query = query.filter_by(method=tutor) + query = query.filter_by(move=move) + em = set(p for (p, ) in query.filter_by(version_group=emerald.version_group).all()) + fr = set(p for (p, ) in query.filter_by(version_group=fire_red.version_group).all()) + assert not fr or not em.symmetric_difference(fr) + for pokemon_id in em: + pokemon_move = tables.PokemonMove() + pokemon_move.pokemon_id = pokemon_id + pokemon_move.move = move + pokemon_move.method = tutor + pokemon_move.level = 0 + pokemon_move.version_group = xd_version_group + session.add(pokemon_move) + +# These are only found in XD: +xd_tutor_data = { + 'nightmare': 'butterfree clefairy clefable jigglypuff wigglytuff meowth ' + 'persian abra kadabra alakazam slowpoke slowbro gastly haunter gengar ' + 'drowzee hypno exeggcute exeggutor lickitung starmie mr-mime jynx ' + 'lapras porygon mewtwo mew hoothoot noctowl cleffa igglybuff natu xatu ' + 'aipom espeon umbreon murkrow slowking misdreavus girafarig dunsparce ' + 'sneasel houndour houndoom porygon2 stantler smoochum tyranitar lugia ' + 'ho-oh celebi ralts kirlia gardevoir masquerain shedinja sableye ' + 'roselia gulpin swalot spinda shuppet banette duskull dusclops ' + 'chimecho absol jirachi deoxys '.split(), + 'selfdestruct': 'geodude graveler golem grimer muk shellder cloyster ' + 'gastly haunter gengar onix voltorb electrode exeggcute exeggutor ' + 'koffing weezing snorlax mewtwo mew sudowoodo pineco forretress ' + 'steelix qwilfish slugma magcargo corsola seedot nuzleaf shiftry ' + 'nosepass gulpin swalot wailmer wailord camerupt torkoal lunatone ' + 'solrock baltoy claydol glalie metang metagross regirock regice ' + 'registeel'.split(), + 'sky-attack': 'pidgey pidgeotto pidgeot spearow fearow doduo dodrio ' + 'aerodactyl articuno zapdos moltres mew hoothoot noctowl togetic ' + 'natu xatu murkrow delibird skarmory ho-oh taillow swellow wingull ' + 'pelipper swablu altaria'.split(), + 'faint-attack': ['mew'], + 'fake-out': ['mew'], + 'hypnosis': ['mew'], + 'night-shade': ['mew'], + 'role-play': ['mew'], + 'zap-cannon': ['mew'], + } + +for move_identifier, pokemon_identifiers in xd_tutor_data.items(): + move = util.get(session, tables.Move, move_identifier) + for pokemon_identifier in pokemon_identifiers: + species = util.get(session, tables.PokemonSpecies, pokemon_identifier) + try: + pokemon, = species.pokemon + except ValueError: + assert pokemon_identifier == 'deoxys' + pokemon = species.default_pokemon + print move, pokemon + + pokemon_move = tables.PokemonMove() + pokemon_move.pokemon = pokemon + pokemon_move.move = move + pokemon_move.method = tutor + pokemon_move.level = 0 + pokemon_move.version_group = xd_version_group + session.add(pokemon_move) + +# And unfortunately, we have to copy level-up moves. To both XD and Colosseum. +for pokemon_id, move_id, level in set( + session.query( + tables.PokemonMove.pokemon_id, + tables.PokemonMove.move_id, + tables.PokemonMove.level, + ) + .filter_by(method=level_up) + .filter_by(version_group=emerald_version_group) + ): + for version_group in xd_version_group, colo_version_group: + print pokemon_id, move_id + pokemon_move = tables.PokemonMove() + pokemon_move.pokemon_id = pokemon_id + pokemon_move.move_id = move_id + pokemon_move.method = level_up + pokemon_move.level = level + pokemon_move.version_group = version_group + session.add(pokemon_move) + + +session.commit()