Browse Source

- Working prototype

master
Dan 1 year ago
parent
commit
8430368911
  1. 1
      .gitignore
  2. 22
      Utilities/DatabaseBuilder.py
  3. 66
      Utilities/DetermineOriginGame.py
  4. BIN
      Utilities/requirements.txt
  5. 1306
      pokemon_earliest_games.csv

1
.gitignore

@ -1,3 +1,4 @@
pokemon_cache.db pokemon_cache.db
pokemon_database.db pokemon_database.db
Utilities/venv/ Utilities/venv/
venv/

22
Utilities/DatabaseBuilder.py

@ -124,6 +124,11 @@ def tidy_location_name(name):
name += f' ({direction.capitalize()})' name += f' ({direction.capitalize()})'
break break
if name.isdigit():
name = "Route " + name
name = name.replace("Routes", "Route")
return name return name
def generate_location_description(name): def generate_location_description(name):
@ -167,11 +172,17 @@ def load_game_data(conn):
("Let's Go Eevee", 7, ["Let's Go, Eevee!", "Lets Go Eevee"]), ("Let's Go Eevee", 7, ["Let's Go, Eevee!", "Lets Go Eevee"]),
("Sword", 8, ["Sword Version"]), ("Sword", 8, ["Sword Version"]),
("Shield", 8, ["Shield Version"]), ("Shield", 8, ["Shield Version"]),
("Expansion Pass", 8, ["Expansion Pass (Sword)", "Expansion Pass (Shield)"]),
("Brilliant Diamond", 8, ["Brilliant Diamond Version", "Brilliant-Diamond"]), ("Brilliant Diamond", 8, ["Brilliant Diamond Version", "Brilliant-Diamond"]),
("Shining Pearl", 8, ["Shining Pearl Version", "Shining-Pearl"]), ("Shining Pearl", 8, ["Shining Pearl Version", "Shining-Pearl"]),
("Legends Arceus", 8, ["Legends: Arceus", "Legends-Arceus"]), ("Legends Arceus", 8, ["Legends: Arceus", "Legends-Arceus"]),
("Scarlet", 9, ["Scarlet Version"]), ("Scarlet", 9, ["Scarlet Version"]),
("Violet", 9, ["Violet Version"]), ("Violet", 9, ["Violet Version"]),
("The Teal Mask", 9, ["The Teal Mask Version", "The Teal Mask (Scarlet)", "The Teal Mask (Violet)"]),
("The Hidden Treasure of Area Zero", 9, ["The Hidden Treasure of Area Zero Version", "The Hidden Treasure of Area Zero (Scarlet)", "The Hidden Treasure of Area Zero (Violet)"]),
("Pokémon Home", 98, ["Pokémon HOME"]),
("Pokémon Go", 99, ["Pokémon GO"]),
] ]
for game in games: for game in games:
@ -278,6 +289,8 @@ def load_encounter_data(conn):
if match: if match:
base_name = match.group(1).strip() base_name = match.group(1).strip()
form_name = match.group(2).strip() if match.group(2) else "Default" form_name = match.group(2).strip() if match.group(2) else "Default"
if form_name == "None":
form_name = "Default"
else: else:
base_name = full_name base_name = full_name
form_name = "Default" form_name = "Default"
@ -341,8 +354,9 @@ def load_encounter_data(conn):
elif encounter_locations != "N/A" and encounter_locations: elif encounter_locations != "N/A" and encounter_locations:
# Process each encounter location # Process each encounter location
for location_info in encounter_locations.split('|'): for location_info in encounter_locations.split('|'):
location, method = location_info.strip().rsplit(' ', 1) location = location_info.strip()
method = method.strip('()')
location = tidy_location_name(location)
# Tidy up the location name and generate a description # Tidy up the location name and generate a description
description = tidy_location_name(location) description = tidy_location_name(location)
@ -356,8 +370,8 @@ def load_encounter_data(conn):
location_id = cursor.fetchone()[0] location_id = cursor.fetchone()[0]
# Insert or get encounter_method_id # Insert or get encounter_method_id
cursor.execute('INSERT OR IGNORE INTO encounter_methods (name) VALUES (?)', (method,)) cursor.execute('INSERT OR IGNORE INTO encounter_methods (name) VALUES (?)', (obtain_method,))
cursor.execute('SELECT id FROM encounter_methods WHERE name = ?', (method,)) cursor.execute('SELECT id FROM encounter_methods WHERE name = ?', (obtain_method,))
method_id = cursor.fetchone()[0] method_id = cursor.fetchone()[0]
# Insert form_encounter # Insert form_encounter

66
Utilities/DetermineOriginGame.py

@ -40,7 +40,9 @@ all_games = [
"Brilliant Diamond", "Shining Pearl", "Brilliant Diamond", "Shining Pearl",
"Legends: Arceus", "Legends: Arceus",
"Scarlet", "Violet", "The Teal Mask", "The Hidden Treasure of Area Zero", "The Hidden Treasure of Area Zero (Scarlet)", "The Hidden Treasure of Area Zero (Violet)", "The Teal Mask (Scarlet)", "The Teal Mask (Violet)", "Scarlet", "Violet", "The Teal Mask", "The Hidden Treasure of Area Zero", "The Hidden Treasure of Area Zero (Scarlet)", "The Hidden Treasure of Area Zero (Violet)", "The Teal Mask (Scarlet)", "The Teal Mask (Violet)",
"Unknown" "Unknown",
"Pokémon Home",
"Pokémon Go",
] ]
big_pokemon_list = [] big_pokemon_list = []
@ -163,14 +165,18 @@ class Pokemon:
self.stage = stage self.stage = stage
self.is_baby = self.stage is not None and 'Baby' in self.stage self.is_baby = self.stage is not None and 'Baby' in self.stage
def update_encounter_information(self, exclude_events=True): def update_encounter_information(self, exclude_events=True, exclude_home=True, exclude_go=True):
if not self.encounter_information: if not self.encounter_information:
return return
non_catchable_methods = ["trade", "global link", "poké transfer", "time capsule", "unobtainable", "pokémon home"] non_catchable_methods = ["trade", "global link", "poké transfer", "time capsule", "unobtainable"]
if exclude_events: if exclude_events:
non_catchable_methods.append("event") non_catchable_methods.append("event")
if exclude_home:
non_catchable_methods.append("pokemon home")
if exclude_go:
non_catchable_methods.append("pokémon go")
for encounter in self.encounter_information: for encounter in self.encounter_information:
encounter.method = None encounter.method = None
@ -195,13 +201,7 @@ class Pokemon:
else: else:
encounter.method = "Catchable" encounter.method = "Catchable"
def determine_earliest_game(self): def parse_encoutners_for_games(self):
if not self.encounter_information:
self.earliest_game = None
return
self.update_encounter_information()
game_methods = {} game_methods = {}
for encounter in self.encounter_information: for encounter in self.encounter_information:
if encounter.method: if encounter.method:
@ -212,16 +212,30 @@ class Pokemon:
self.earliest_game = game_methods[game.lower()] self.earliest_game = game_methods[game.lower()]
return return
def determine_earliest_game(self):
if not self.encounter_information:
self.earliest_game = None
return
self.update_encounter_information()
self.parse_encoutners_for_games()
if self.earliest_game != None:
return
self.update_encounter_information(exclude_events=False) self.update_encounter_information(exclude_events=False)
self.parse_encoutners_for_games()
if self.earliest_game != None:
return
game_methods = {} self.update_encounter_information(exclude_home=False)
for encounter in self.encounter_information: self.parse_encoutners_for_games()
if encounter.method: if self.earliest_game != None:
game_methods[encounter.game.lower()] = encounter return
for game in all_games: self.update_encounter_information(exclude_go=False)
if game.lower() in game_methods: self.parse_encoutners_for_games()
self.earliest_game = game_methods[game.lower()] if self.earliest_game != None:
return return
self.earliest_game = None self.earliest_game = None
@ -908,7 +922,9 @@ def determine_earliest_games(pokemon_list, cache):
handle_unown(pokemon, encounter_data) handle_unown(pokemon, encounter_data)
handle_form_shift(pokemon, encounter_data) handle_form_shift(pokemon, encounter_data)
if pokemon.name == "Gimmighoul" and pokemon.form == "Roaming Form": if pokemon.name == "Gimmighoul" and pokemon.form == "Roaming Form":
continue encounter_information = EncounterInformation("Pokémon Go", ["Pokémon Go"])
pokemon.encounter_information.append(encounter_information)
pokemon.determine_earliest_game() pokemon.determine_earliest_game()
print(f"Processed {pokemon}: {pokemon.earliest_game.game} ({pokemon.earliest_game.method})") print(f"Processed {pokemon}: {pokemon.earliest_game.game} ({pokemon.earliest_game.method})")
@ -1034,14 +1050,14 @@ def save_to_csv(pokemon_list, filename='pokemon_earliest_games.csv'):
for pokemon in big_pokemon_list: for pokemon in big_pokemon_list:
encounter_locations = [] encounter_locations = []
for encounter in pokemon.encounter_information: for encounter in pokemon.encounter_information:
if encounter.game == pokemon.earliest_game and encounter.method == pokemon.obtain_method: if encounter.game == pokemon.earliest_game.game:
encounter_locations.append(encounter.locations) encounter_locations.extend(encounter.locations)
writer.writerow({ writer.writerow({
'number': pokemon.number, 'number': pokemon.number,
'name': pokemon.name, 'name': f"{pokemon.name} ({pokemon.form})",
'earliest_game': pokemon.earliest_game, 'earliest_game': pokemon.earliest_game.game,
'obtain_method': pokemon.obtain_method, 'obtain_method': pokemon.earliest_game.method,
'encounter_locations': ' | '.join(str(item) for item in encounter_locations) 'encounter_locations': ' | '.join((str(item) for item in encounter_locations))
}) })
def parse_encounter_locations(encounter_data, game): def parse_encounter_locations(encounter_data, game):
@ -1151,7 +1167,7 @@ def check_alternative_sources(pokemon, cache):
def handle_unknown_encounters(pokemon_list, cache): def handle_unknown_encounters(pokemon_list, cache):
for pokemon in big_pokemon_list: for pokemon in big_pokemon_list:
if pokemon.earliest_game == None or pokemon.obtain_method == None: if pokemon.earliest_game == None or pokemon.earliest_game.method == None:
print(f"Checking alternative sources for {pokemon.name}") print(f"Checking alternative sources for {pokemon.name}")
return return

BIN
Utilities/requirements.txt

Binary file not shown.

1306
pokemon_earliest_games.csv

File diff suppressed because it is too large
Loading…
Cancel
Save