Browse Source

- Working prototype

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

1
.gitignore

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

22
Utilities/DatabaseBuilder.py

@ -124,6 +124,11 @@ def tidy_location_name(name):
name += f' ({direction.capitalize()})'
break
if name.isdigit():
name = "Route " + name
name = name.replace("Routes", "Route")
return 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"]),
("Sword", 8, ["Sword Version"]),
("Shield", 8, ["Shield Version"]),
("Expansion Pass", 8, ["Expansion Pass (Sword)", "Expansion Pass (Shield)"]),
("Brilliant Diamond", 8, ["Brilliant Diamond Version", "Brilliant-Diamond"]),
("Shining Pearl", 8, ["Shining Pearl Version", "Shining-Pearl"]),
("Legends Arceus", 8, ["Legends: Arceus", "Legends-Arceus"]),
("Scarlet", 9, ["Scarlet 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:
@ -278,6 +289,8 @@ def load_encounter_data(conn):
if match:
base_name = match.group(1).strip()
form_name = match.group(2).strip() if match.group(2) else "Default"
if form_name == "None":
form_name = "Default"
else:
base_name = full_name
form_name = "Default"
@ -341,8 +354,9 @@ def load_encounter_data(conn):
elif encounter_locations != "N/A" and encounter_locations:
# Process each encounter location
for location_info in encounter_locations.split('|'):
location, method = location_info.strip().rsplit(' ', 1)
method = method.strip('()')
location = location_info.strip()
location = tidy_location_name(location)
# Tidy up the location name and generate a description
description = tidy_location_name(location)
@ -356,8 +370,8 @@ def load_encounter_data(conn):
location_id = cursor.fetchone()[0]
# Insert or get encounter_method_id
cursor.execute('INSERT OR IGNORE INTO encounter_methods (name) VALUES (?)', (method,))
cursor.execute('SELECT id FROM encounter_methods WHERE name = ?', (method,))
cursor.execute('INSERT OR IGNORE INTO encounter_methods (name) VALUES (?)', (obtain_method,))
cursor.execute('SELECT id FROM encounter_methods WHERE name = ?', (obtain_method,))
method_id = cursor.fetchone()[0]
# Insert form_encounter

68
Utilities/DetermineOriginGame.py

@ -40,7 +40,9 @@ all_games = [
"Brilliant Diamond", "Shining Pearl",
"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)",
"Unknown"
"Unknown",
"Pokémon Home",
"Pokémon Go",
]
big_pokemon_list = []
@ -163,14 +165,18 @@ class Pokemon:
self.stage = 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:
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:
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:
encounter.method = None
@ -195,13 +201,7 @@ class Pokemon:
else:
encounter.method = "Catchable"
def determine_earliest_game(self):
if not self.encounter_information:
self.earliest_game = None
return
self.update_encounter_information()
def parse_encoutners_for_games(self):
game_methods = {}
for encounter in self.encounter_information:
if encounter.method:
@ -212,17 +212,31 @@ class Pokemon:
self.earliest_game = game_methods[game.lower()]
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.parse_encoutners_for_games()
if self.earliest_game != None:
return
game_methods = {}
for encounter in self.encounter_information:
if encounter.method:
game_methods[encounter.game.lower()] = encounter
self.update_encounter_information(exclude_home=False)
self.parse_encoutners_for_games()
if self.earliest_game != None:
return
for game in all_games:
if game.lower() in game_methods:
self.earliest_game = game_methods[game.lower()]
return
self.update_encounter_information(exclude_go=False)
self.parse_encoutners_for_games()
if self.earliest_game != None:
return
self.earliest_game = None
@ -908,7 +922,9 @@ def determine_earliest_games(pokemon_list, cache):
handle_unown(pokemon, encounter_data)
handle_form_shift(pokemon, encounter_data)
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()
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:
encounter_locations = []
for encounter in pokemon.encounter_information:
if encounter.game == pokemon.earliest_game and encounter.method == pokemon.obtain_method:
encounter_locations.append(encounter.locations)
if encounter.game == pokemon.earliest_game.game:
encounter_locations.extend(encounter.locations)
writer.writerow({
'number': pokemon.number,
'name': pokemon.name,
'earliest_game': pokemon.earliest_game,
'obtain_method': pokemon.obtain_method,
'encounter_locations': ' | '.join(str(item) for item in encounter_locations)
'name': f"{pokemon.name} ({pokemon.form})",
'earliest_game': pokemon.earliest_game.game,
'obtain_method': pokemon.earliest_game.method,
'encounter_locations': ' | '.join((str(item) for item in encounter_locations))
})
def parse_encounter_locations(encounter_data, game):
@ -1151,7 +1167,7 @@ def check_alternative_sources(pokemon, cache):
def handle_unknown_encounters(pokemon_list, cache):
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}")
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