|
|
@ -5,7 +5,7 @@ from cache import cache |
|
|
from db import db |
|
|
from db import db |
|
|
|
|
|
|
|
|
from utility.data import exclusive_choice_pokemon |
|
|
from utility.data import exclusive_choice_pokemon |
|
|
from utility.functions import get_shiftable_forms, parse_pfic |
|
|
from utility.functions import get_shiftable_forms, get_shiftable_forms_bidirectional, parse_pfic, sanitize_filename |
|
|
|
|
|
|
|
|
class GeneratePlanWorkerSignals(QObject): |
|
|
class GeneratePlanWorkerSignals(QObject): |
|
|
finished = pyqtSignal(dict) |
|
|
finished = pyqtSignal(dict) |
|
|
@ -66,11 +66,11 @@ class GeneratePlanWorker(QRunnable): |
|
|
games_in_group.extend(db.get_games_by_generation(generation)) |
|
|
games_in_group.extend(db.get_games_by_generation(generation)) |
|
|
pokemon_in_generation = db.get_pokemon_by_generation(generation) |
|
|
pokemon_in_generation = db.get_pokemon_by_generation(generation) |
|
|
for pokemon in pokemon_in_generation: |
|
|
for pokemon in pokemon_in_generation: |
|
|
|
|
|
pfic = pokemon["PFIC"] |
|
|
|
|
|
|
|
|
if pokemon["storable_in_home"] == False: |
|
|
if pokemon["storable_in_home"] == False: |
|
|
continue |
|
|
continue |
|
|
|
|
|
|
|
|
pfic = pokemon["PFIC"] |
|
|
|
|
|
|
|
|
|
|
|
testing = [ |
|
|
testing = [ |
|
|
"0140-01-000-1", "0138-01-000-1", "0140-01-000-2", "0138-01-000-2", |
|
|
"0140-01-000-1", "0138-01-000-1", "0140-01-000-2", "0138-01-000-2", |
|
|
"0141-01-000-1", "0139-01-000-1", "0141-01-000-2", "0139-01-000-2", |
|
|
"0141-01-000-1", "0139-01-000-1", "0141-01-000-2", "0139-01-000-2", |
|
|
@ -90,6 +90,39 @@ class GeneratePlanWorker(QRunnable): |
|
|
encounters.extend(static) |
|
|
encounters.extend(static) |
|
|
encounters.extend(starter) |
|
|
encounters.extend(starter) |
|
|
|
|
|
|
|
|
|
|
|
""" |
|
|
|
|
|
def thingy(current_pfic): |
|
|
|
|
|
evolution_chains = db.get_full_evolution_paths(current_pfic) |
|
|
|
|
|
if evolution_chains and (len(evolution_chains["predecessors"]) > 0 or len(evolution_chains["successors"]) > 0): |
|
|
|
|
|
for chains in evolution_chains["predecessors"]: |
|
|
|
|
|
for evolved_pfic, method in chains: |
|
|
|
|
|
if evolved_pfic in needed_pokemon: |
|
|
|
|
|
game_pokemon[game['id']].add(evolved_pfic) |
|
|
|
|
|
for shiftable_form in get_shiftable_forms_bidirectional(evolved_pfic): |
|
|
|
|
|
game_pokemon[game['id']].add(shiftable_form["to_pfic"]) |
|
|
|
|
|
game_pokemon[game['id']].add(shiftable_form["from_pfic"]) |
|
|
|
|
|
|
|
|
|
|
|
for chains in evolution_chains["successors"]: |
|
|
|
|
|
for evolved_pfic, method in chains: |
|
|
|
|
|
if evolved_pfic in needed_pokemon: |
|
|
|
|
|
game_pokemon[game['id']].add(evolved_pfic) |
|
|
|
|
|
for shiftable_form in get_shiftable_forms_bidirectional(evolved_pfic): |
|
|
|
|
|
game_pokemon[game['id']].add(shiftable_form["to_pfic"]) |
|
|
|
|
|
game_pokemon[game['id']].add(shiftable_form["from_pfic"]) |
|
|
|
|
|
|
|
|
|
|
|
for game in games_in_group: |
|
|
|
|
|
game_pokemon[game['id']] = set() |
|
|
|
|
|
for encounter in encounters: |
|
|
|
|
|
current_pfic = encounter['PFIC'] |
|
|
|
|
|
if game["id"] == encounter["game_id"]: |
|
|
|
|
|
game_pokemon[game['id']].add(current_pfic) |
|
|
|
|
|
for shiftable_form in get_shiftable_forms_bidirectional(current_pfic): |
|
|
|
|
|
game_pokemon[game['id']].add(shiftable_form["to_pfic"]) |
|
|
|
|
|
game_pokemon[game['id']].add(shiftable_form["from_pfic"]) |
|
|
|
|
|
thingy(shiftable_form["from_pfic"]) |
|
|
|
|
|
thingy(pfic) |
|
|
|
|
|
""" |
|
|
|
|
|
|
|
|
for game in games_in_group: |
|
|
for game in games_in_group: |
|
|
game_pokemon[game['id']] = set() |
|
|
game_pokemon[game['id']] = set() |
|
|
for encounter in encounters: |
|
|
for encounter in encounters: |
|
|
@ -117,8 +150,10 @@ class GeneratePlanWorker(QRunnable): |
|
|
for game in available_games: |
|
|
for game in available_games: |
|
|
cache[game['id']] = self.get_covered_pokemon(game, remaining_pokemon, game_pokemon[game['id']]) |
|
|
cache[game['id']] = self.get_covered_pokemon(game, remaining_pokemon, game_pokemon[game['id']]) |
|
|
|
|
|
|
|
|
best_game = max(available_games, key=lambda g: len(cache[g["id"]])) |
|
|
pokemon_covered = {} |
|
|
pokemon_covered = cache[best_game['id']] |
|
|
if cache: |
|
|
|
|
|
best_game = max(available_games, key=lambda g: len(cache[g["id"]])) |
|
|
|
|
|
pokemon_covered = cache[best_game['id']] |
|
|
|
|
|
|
|
|
if not pokemon_covered: |
|
|
if not pokemon_covered: |
|
|
print("No more Pokémon can be covered. Breaking loop.") |
|
|
print("No more Pokémon can be covered. Breaking loop.") |
|
|
@ -138,7 +173,8 @@ class GeneratePlanWorker(QRunnable): |
|
|
print(f"Removed {game['name']} as it's covered by {best_game['name']}") |
|
|
print(f"Removed {game['name']} as it's covered by {best_game['name']}") |
|
|
|
|
|
|
|
|
for game in selected_games: |
|
|
for game in selected_games: |
|
|
output_file = "./temp/"+game["name"]+".json" |
|
|
file_name = sanitize_filename(game["name"]) |
|
|
|
|
|
output_file = "./temp/"+file_name+".json" |
|
|
with open(output_file, 'w', encoding='utf-8') as f: |
|
|
with open(output_file, 'w', encoding='utf-8') as f: |
|
|
temp = [] |
|
|
temp = [] |
|
|
for pfic in catch_in_game[game["id"]]: |
|
|
for pfic in catch_in_game[game["id"]]: |
|
|
@ -154,6 +190,14 @@ class GeneratePlanWorker(QRunnable): |
|
|
exclusive_groups = self.get_exclusive_groups(game['id']) |
|
|
exclusive_groups = self.get_exclusive_groups(game['id']) |
|
|
pokemon_covered = set() |
|
|
pokemon_covered = set() |
|
|
|
|
|
|
|
|
|
|
|
search_value = "0412-04-002-2" |
|
|
|
|
|
|
|
|
|
|
|
if search_value in needed_pokemon: |
|
|
|
|
|
pass |
|
|
|
|
|
|
|
|
|
|
|
if search_value in available_pokemon: |
|
|
|
|
|
pass |
|
|
|
|
|
|
|
|
evolution_paths = {} |
|
|
evolution_paths = {} |
|
|
evolution_predecessors = {} |
|
|
evolution_predecessors = {} |
|
|
all_pokemon = needed_pokemon | available_pokemon |
|
|
all_pokemon = needed_pokemon | available_pokemon |
|
|
|