Browse Source

- Fix up the storable in home filter

feature-new-db-implementation
Dan 1 year ago
parent
commit
35c14c9a57
  1. 23
      database/db_controller.py
  2. 7
      ui/main_window_controller.py
  3. 7
      ui/workers/gather_home_storage_status_worker.py

23
database/db_controller.py

@ -99,16 +99,17 @@ class DBController:
return query return query
def get_pokemon_details(self, pfic): def get_pokemon_details(self, pfic, fields = None):
fields = [ if fields == None:
"name", fields = [
"form_name", "name",
"national_dex", "form_name",
"generation", "national_dex",
"is_baby_form", "generation",
"storable_in_home", "is_baby_form",
"gender_relevant" "storable_in_home",
] "gender_relevant"
]
query = self.craft_pokemon_json_query(fields, pfic) query = self.craft_pokemon_json_query(fields, pfic)
self.cursor.execute(query) self.cursor.execute(query)
results = self.cursor.fetchone() results = self.cursor.fetchone()
@ -360,7 +361,7 @@ class DBController:
gender_specific_nodes.extend([from_node, to_node]) gender_specific_nodes.extend([from_node, to_node])
return list(set(gender_specific_nodes)) # Return unique nodes return list(set(gender_specific_nodes)) # Return unique nodes
def get_gender_relevant_pokemon(self): def get_gender_relevant_pokemon(self):
self.cursor.execute(f"SELECT PFIC FROM pokemon_forms WHERE JSON_EXTRACT(data, '$.gender_relevant') = true") self.cursor.execute(f"SELECT PFIC FROM pokemon_forms WHERE JSON_EXTRACT(data, '$.gender_relevant') = true")
results = self.cursor.fetchall() results = self.cursor.fetchall()

7
ui/main_window_controller.py

@ -46,6 +46,7 @@ class MainWindowController:
if show_only_home_storable: if show_only_home_storable:
# TODO: update the call to correctly filter the data, or better yet update the data at the source to include this info. # TODO: update the call to correctly filter the data, or better yet update the data at the source to include this info.
home_storable = True #event_system.call_sync('get_home_storable', pfic) home_storable = True #event_system.call_sync('get_home_storable', pfic)
home_storable = db.get_pokemon_details(pfic, ["storable_in_home"])["storable_in_home"]
# Check to see if the pokemon has encounters # Check to see if the pokemon has encounters
has_encounters = True has_encounters = True
@ -74,8 +75,9 @@ class MainWindowController:
context_menu.exec(self.pokemon_list.viewport().mapToGlobal(position)) context_menu.exec(self.pokemon_list.viewport().mapToGlobal(position))
def on_pokemon_selected(self, item): def on_pokemon_selected(self, item):
pfic = item.data(Qt.ItemDataRole.UserRole) if item:
self.refresh_pokemon_details_panel(pfic) pfic = item.data(Qt.ItemDataRole.UserRole)
self.refresh_pokemon_details_panel(pfic)
def edit_encounter(self): def edit_encounter(self):
pass pass
@ -183,6 +185,5 @@ class MainWindowController:
self.current_pfic = pfic self.current_pfic = pfic
def load_evolution_chain(self, pfic): def load_evolution_chain(self, pfic):
#chain = db.get_evolution_paths(pfic)
chain = db.get_full_evolution_paths(pfic) chain = db.get_full_evolution_paths(pfic)
self.view.update_evolution_tree(chain, pfic) self.view.update_evolution_tree(chain, pfic)

7
ui/workers/gather_home_storage_status_worker.py

@ -49,6 +49,10 @@ class GatherHomeStorageStatus(QRunnable):
if working_form and name in working_form: if working_form and name in working_form:
working_form = working_form.replace(name, "").strip() working_form = working_form.replace(name, "").strip()
if working_form:
working_form = working_form.replace("Female", "").replace("female", "").strip()
working_form = working_form.replace("Male", "").replace("male", "").strip()
# serebii doesn't list gender in the table so we have to assume based on form name. # serebii doesn't list gender in the table so we have to assume based on form name.
if working_form and ("male" in working_form.lower() or "working_form" in working_form.lower()): if working_form and ("male" in working_form.lower() or "working_form" in working_form.lower()):
working_form = None working_form = None
@ -63,6 +67,9 @@ class GatherHomeStorageStatus(QRunnable):
if name == "Alcremie": if name == "Alcremie":
working_form = None working_form = None
if working_form == "":
working_form = None
for pokemon in pokemon_by_national_dex[national_dex]: for pokemon in pokemon_by_national_dex[national_dex]:
if working_form: if working_form:
parts = pokemon['name'].split(" ") parts = pokemon['name'].split(" ")

Loading…
Cancel
Save