From 8161bd84e4c44c15640cf04c23e5b858a510e7ec Mon Sep 17 00:00:00 2001 From: Andrew Ekstedt Date: Fri, 12 Jul 2019 18:48:07 -0700 Subject: [PATCH] gift-pokemon: fix Cosplay Pikachu and Sinnoh starter gift locations Cosplay Pikachu was listed as being encountered in contest-hall, but that's a Sinnoh location. In OR/AS, the contest halls are not a first-class location but rather just treated as part of the town or city they are in. Cosplay Pikachu is given to the player after they participate in their first contest, so its location can be any of the four cities with a contest hall. The Sinnoh starter that the player obtains in OR/AS is on Hoenn Route 101, not Sinnoh Route 201 (probably a copy/paste error). Add a test to make sure that encounter regions always match the region(s) that their game takes place in. --- pokedex/data/csv/encounters.csv | 144 ++++++++++++----------- pokedex/data/csv/location_area_prose.csv | 4 + pokedex/data/csv/location_areas.csv | 4 + pokedex/tests/test_database_sanity.py | 22 ++++ scripts/add-gift-encounters.py | 12 +- 5 files changed, 113 insertions(+), 73 deletions(-) diff --git a/pokedex/data/csv/encounters.csv b/pokedex/data/csv/encounters.csv index 240688d..3ffc6f1 100644 --- a/pokedex/data/csv/encounters.csv +++ b/pokedex/data/csv/encounters.csv @@ -46757,72 +46757,78 @@ id,version_id,location_area_id,encounter_slot_id,pokemon_id,min_level,max_level 50467,26,393,503,255,5,5 50468,25,393,503,258,5,5 50469,26,393,503,258,5,5 -50470,25,784,503,25,20,20 -50471,26,784,503,25,20,20 -50472,25,785,503,381,30,30 -50473,26,785,503,380,30,30 -50474,25,769,503,351,30,30 -50475,26,769,503,351,30,30 -50476,25,393,503,152,5,5 -50477,26,393,503,152,5,5 -50478,25,393,503,155,5,5 -50479,26,393,503,155,5,5 -50480,25,393,503,158,5,5 -50481,26,393,503,158,5,5 -50482,25,393,503,495,5,5 -50483,26,393,503,495,5,5 -50484,25,393,503,498,5,5 -50485,26,393,503,498,5,5 -50486,25,393,503,501,5,5 -50487,26,393,503,501,5,5 -50488,25,770,503,374,1,1 -50489,26,770,503,374,1,1 -50490,25,141,503,387,5,5 -50491,26,141,503,387,5,5 -50492,25,141,503,390,5,5 -50493,26,141,503,390,5,5 -50494,25,141,503,393,5,5 -50495,26,141,503,393,5,5 -50496,25,786,503,323,40,40 -50497,26,786,503,323,40,40 -50498,25,786,503,319,40,40 -50499,26,786,503,319,40,40 -50500,4,189,504,175,5,5 -50501,5,189,504,175,5,5 -50502,6,189,505,175,5,5 -50503,6,205,505,172,5,5 -50504,6,205,505,173,5,5 -50505,6,205,505,174,5,5 -50506,6,205,505,236,5,5 -50507,6,205,505,238,5,5 -50508,6,205,505,239,5,5 -50509,6,205,505,240,5,5 -50510,7,787,506,360,5,5 -50511,8,787,506,360,5,5 -50512,9,787,507,360,5,5 -50513,10,518,508,175,5,5 -50514,11,518,508,175,5,5 -50515,12,788,509,175,1,1 -50516,13,788,509,175,1,1 -50517,14,788,510,175,1,1 -50518,12,789,509,440,1,1 -50519,13,789,509,440,1,1 -50520,12,124,509,447,1,1 -50521,13,124,509,447,1,1 -50522,14,124,510,447,1,1 -50523,15,790,511,175,1,1 -50524,16,790,511,175,1,1 -50525,15,791,511,179,1,1 -50526,16,791,511,179,1,1 -50527,15,791,511,194,1,1 -50528,16,791,511,194,1,1 -50529,15,791,511,218,1,1 -50530,16,791,511,218,1,1 -50531,17,653,512,636,1,1 -50532,18,653,512,636,1,1 -50533,21,792,513,440,1,1 -50534,22,792,513,440,1,1 -50535,25,787,514,360,1,1 -50536,26,787,514,360,1,1 -50537,25,787,514,175,1,1 -50538,26,787,514,175,1,1 +50470,25,793,503,25,20,20 +50471,26,793,503,25,20,20 +50472,25,794,503,25,20,20 +50473,26,794,503,25,20,20 +50474,25,795,503,25,20,20 +50475,26,795,503,25,20,20 +50476,25,796,503,25,20,20 +50477,26,796,503,25,20,20 +50478,25,785,503,381,30,30 +50479,26,785,503,380,30,30 +50480,25,769,503,351,30,30 +50481,26,769,503,351,30,30 +50482,25,393,503,152,5,5 +50483,26,393,503,152,5,5 +50484,25,393,503,155,5,5 +50485,26,393,503,155,5,5 +50486,25,393,503,158,5,5 +50487,26,393,503,158,5,5 +50488,25,393,503,495,5,5 +50489,26,393,503,495,5,5 +50490,25,393,503,498,5,5 +50491,26,393,503,498,5,5 +50492,25,393,503,501,5,5 +50493,26,393,503,501,5,5 +50494,25,770,503,374,1,1 +50495,26,770,503,374,1,1 +50496,25,393,503,387,5,5 +50497,26,393,503,387,5,5 +50498,25,393,503,390,5,5 +50499,26,393,503,390,5,5 +50500,25,393,503,393,5,5 +50501,26,393,503,393,5,5 +50502,25,786,503,323,40,40 +50503,26,786,503,323,40,40 +50504,25,786,503,319,40,40 +50505,26,786,503,319,40,40 +50506,4,189,504,175,5,5 +50507,5,189,504,175,5,5 +50508,6,189,505,175,5,5 +50509,6,205,505,172,5,5 +50510,6,205,505,173,5,5 +50511,6,205,505,174,5,5 +50512,6,205,505,236,5,5 +50513,6,205,505,238,5,5 +50514,6,205,505,239,5,5 +50515,6,205,505,240,5,5 +50516,7,787,506,360,5,5 +50517,8,787,506,360,5,5 +50518,9,787,507,360,5,5 +50519,10,518,508,175,5,5 +50520,11,518,508,175,5,5 +50521,12,788,509,175,1,1 +50522,13,788,509,175,1,1 +50523,14,788,510,175,1,1 +50524,12,789,509,440,1,1 +50525,13,789,509,440,1,1 +50526,12,124,509,447,1,1 +50527,13,124,509,447,1,1 +50528,14,124,510,447,1,1 +50529,15,790,511,175,1,1 +50530,16,790,511,175,1,1 +50531,15,791,511,179,1,1 +50532,16,791,511,179,1,1 +50533,15,791,511,194,1,1 +50534,16,791,511,194,1,1 +50535,15,791,511,218,1,1 +50536,16,791,511,218,1,1 +50537,17,653,512,636,1,1 +50538,18,653,512,636,1,1 +50539,21,792,513,440,1,1 +50540,22,792,513,440,1,1 +50541,25,787,514,360,1,1 +50542,26,787,514,360,1,1 +50543,25,787,514,175,1,1 +50544,26,787,514,175,1,1 diff --git a/pokedex/data/csv/location_area_prose.csv b/pokedex/data/csv/location_area_prose.csv index fc45a51..a696bf1 100644 --- a/pokedex/data/csv/location_area_prose.csv +++ b/pokedex/data/csv/location_area_prose.csv @@ -650,3 +650,7 @@ location_area_id,local_language_id,name 790,9,Poke Mart 791,9,Pokemon Center 792,9,West Gate +793,9,Contest Hall +794,9,Contest Hall +795,9,Contest Hall +796,9,Contest Hall diff --git a/pokedex/data/csv/location_areas.csv b/pokedex/data/csv/location_areas.csv index 3a9b1fc..4b360a0 100644 --- a/pokedex/data/csv/location_areas.csv +++ b/pokedex/data/csv/location_areas.csv @@ -682,3 +682,7 @@ id,location_id,game_index,identifier 790,153,0,poke-mart 791,153,0,pokemon-center 792,349,0,west-gate +793,430,0,contest-hall +794,571,0,contest-hall +795,570,0,contest-hall +796,431,0,contest-hall diff --git a/pokedex/tests/test_database_sanity.py b/pokedex/tests/test_database_sanity.py index f5747ca..228effc 100644 --- a/pokedex/tests/test_database_sanity.py +++ b/pokedex/tests/test_database_sanity.py @@ -26,6 +26,28 @@ def test_encounter_slots(session): # Encounter slots all match the encounters they belong to assert sanity_q.count() == 0 +def test_encounter_regions(session): + """Check that encounter locations match the region of the game they're from. + """ + + sanity_q = session.query(tables.Encounter) \ + .join((tables.Version, tables.Encounter.version)) \ + .join((tables.VersionGroup, tables.Version.version_group)) \ + .join((tables.LocationArea, tables.Encounter.location_area)) \ + .join((tables.Location, tables.LocationArea.location)) \ + .join((tables.Region, tables.Location.region)) \ + .filter(~tables.VersionGroup.version_group_regions.any(tables.VersionGroupRegion.region_id == tables.Region.id)) + + for e in sanity_q.limit(20): + acceptable_regions = " or ".join(r.identifier for r in e.version.version_group.regions) + if e.location_area.location.region is not None: + print("{e} ({e.pokemon.identifier}, {e.slot.method.identifier}, {e.version.identifier}) is in {e.location_area.location.region.identifier} ({e.location_area.location.identifier}) but should be in {acceptable_regions} ({e.version.identifier})".format(e=e, acceptable_regions=acceptable_regions)) + else: + print("{e} ({e.pokemon.identifier}, {e.slot.method.identifier}, {e.version.identifier}) is in a pseudo-location ({e.location_area.location.identifier}) that is not part of any region, but should be in {acceptable_regions} ({e.version.identifier})".format(e=e, acceptable_regions=acceptable_regions)) + + # Encounter regions match the games they belong to + assert sanity_q.count() == 0 + @parametrize('cls', tables.mapped_classes) def test_nonzero_autoincrement_ids(session, cls): """Check that autoincrementing ids don't contain zeroes diff --git a/scripts/add-gift-encounters.py b/scripts/add-gift-encounters.py index 2100358..16714ee 100644 --- a/scripts/add-gift-encounters.py +++ b/scripts/add-gift-encounters.py @@ -184,7 +184,11 @@ def normal_gift_data(): [ u'treecko', [ OR, AS ], 5, u'hoenn-route-101' ], [ u'torchic', [ OR, AS ], 5, u'hoenn-route-101' ], [ u'mudkip', [ OR, AS ], 5, u'hoenn-route-101' ], - [ u'pikachu', [ OR, AS ], 20, u'contest-hall' ], # suprisingly, this location exists already + # cosplay pikachu is given to you the first time you participate in a contest + [ u'pikachu', [ OR, AS ], 20, u'slateport-city', u'contest-hall', u"Contest Hall" ], + [ u'pikachu', [ OR, AS ], 20, u'verdanturf-town', u'contest-hall', u"Contest Hall" ], + [ u'pikachu', [ OR, AS ], 20, u'fallarbor-town', u'contest-hall', u"Contest Hall" ], + [ u'pikachu', [ OR, AS ], 20, u'lilycove-city', u'contest-hall', u"Contest Hall" ], [ u'latios', [ OR ], 30, u'southern-island' ], # eon tickets ignored here - they're not gifts? [ u'latias', [ AS ], 30, u'southern-island' ], [ u'castform', [ OR, AS ], 30, u'hoenn-route-119', u'weather-institute' ], @@ -195,9 +199,9 @@ def normal_gift_data(): [ u'tepig', [ OR, AS ], 5, u'hoenn-route-101' ], [ u'oshawott', [ OR, AS ], 5, u'hoenn-route-101' ], [ u'beldum', [ OR, AS ], 1, u'mossdeep-city', u'stevens-house' ], - [ u'turtwig', [ OR, AS ], 5, u'sinnoh-route-201' ], - [ u'chimchar', [ OR, AS ], 5, u'sinnoh-route-201' ], - [ u'piplup', [ OR, AS ], 5, u'sinnoh-route-201' ], + [ u'turtwig', [ OR, AS ], 5, u'hoenn-route-101' ], + [ u'chimchar', [ OR, AS ], 5, u'hoenn-route-101' ], + [ u'piplup', [ OR, AS ], 5, u'hoenn-route-101' ], [ u'camerupt', [ OR, AS ], 40, u'battle-resort' ], [ u'sharpedo', [ OR, AS ], 40, u'battle-resort' ], ]