Browse Source

- Added shiftable forms

master
Quildra 1 year ago
parent
commit
eb57e11e2c
  1. 62
      DBEditor/DBEditor.py
  2. 18
      DBEditor/db_controller.py
  3. 18
      DataGatherers/update_location_information.py
  4. BIN
      pokemon_forms.db

62
DBEditor/DBEditor.py

@ -438,6 +438,11 @@ class DBEditor(QMainWindow):
QMessageBox.information(self, 'Database Reinitialized', 'The database has been cleared and reinitialized.') QMessageBox.information(self, 'Database Reinitialized', 'The database has been cleared and reinitialized.')
def determine_origin_mark(self, pfic, target_generation): def determine_origin_mark(self, pfic, target_generation):
shiftable_forms = event_system.call_sync('get_shiftable_forms', pfic)
if len(shiftable_forms) > 0:
for shiftable_form in shiftable_forms:
mark_id = self.determine_origin_mark(shiftable_form[2], target_generation)
return mark_id
encounters = event_system.call_sync('get_encounter_locations', pfic) encounters = event_system.call_sync('get_encounter_locations', pfic)
if encounters: if encounters:
generation_encounters = [] generation_encounters = []
@ -459,6 +464,29 @@ class DBEditor(QMainWindow):
return mark_id return mark_id
return None return None
def test_evolve_encounters(self, pfic, target_generation):
evolve_encounters = event_system.call_sync('get_evolve_encounters', pfic)
if evolve_encounters:
available_encounters = []
for encounter in evolve_encounters:
game_id = encounter.game_id
game_info = event_system.call_sync('get_game_by_id', game_id)
if game_info[2] == target_generation:
available_encounters.append(encounter)
if len(available_encounters) > 0:
available_encounters = sorted(available_encounters, key=lambda x: x.game_id)
mark_id = self.determine_origin_mark(available_encounters[0].from_pfic, target_generation)
if mark_id != None:
return mark_id
mark_id = self.test_evolve_encounters(available_encounters[0].from_pfic, target_generation)
if mark_id != None:
return mark_id
return None
def gather_marks_info(self, data): def gather_marks_info(self, data):
event_system.emit_sync('clear_log_display') event_system.emit_sync('clear_log_display')
self.logger.info("Starting to gather marks information...") self.logger.info("Starting to gather marks information...")
@ -520,18 +548,7 @@ class DBEditor(QMainWindow):
# If there are no encounters for the pokemon form from this generation, # If there are no encounters for the pokemon form from this generation,
# look to see if a previous evolution has an encounter from this generation, and use the mark of the earliest # look to see if a previous evolution has an encounter from this generation, and use the mark of the earliest
# game from this generation that the previous evolution is encounterable in. # game from this generation that the previous evolution is encounterable in.
evolve_encounters = event_system.call_sync('get_evolve_encounters', pfic) mark_id = self.test_evolve_encounters(pfic, target_generation)
if evolve_encounters:
available_encounters = []
for encounter in evolve_encounters:
game_id = encounter.game_id
game_info = event_system.call_sync('get_game_by_id', game_id)
if game_info[2] == target_generation:
available_encounters.append(encounter)
if len(available_encounters) > 0:
available_encounters = sorted(available_encounters, key=lambda x: x.game_id)
mark_id = self.determine_origin_mark(available_encounters[0].from_pfic, target_generation)
if mark_id != None: if mark_id != None:
event_system.emit_sync('assign_mark_to_form', (pfic, mark_id)) event_system.emit_sync('assign_mark_to_form', (pfic, mark_id))
continue; continue;
@ -547,18 +564,29 @@ class DBEditor(QMainWindow):
if count == 0: if count == 0:
#Rule 2b #Rule 2b
# Check to see if this is a sub-form pokemon, and if so, use the mark of the base form. # Check to see if this is a sub-form pokemon, and if so, use the mark of the base form.
base = pfic[:-6] shiftable_forms = event_system.call_sync('get_shiftable_forms', pfic)
alternate_forms = event_system.call_sync('find_default_form', base) if len(shiftable_forms) > 0:
if alternate_forms:
form_found = False form_found = False
for alternate_form in alternate_forms: for shiftable_form in shiftable_forms:
mark_id = self.determine_origin_mark(alternate_form.pfic, target_generation) mark_id = self.determine_origin_mark(shiftable_form[2], target_generation)
if mark_id != None: if mark_id != None:
event_system.emit_sync('assign_mark_to_form', (pfic, mark_id)) event_system.emit_sync('assign_mark_to_form', (pfic, mark_id))
form_found = True form_found = True
break; break;
if form_found: if form_found:
continue; continue;
#base = pfic[:-6]
#alternate_forms = event_system.call_sync('find_default_form', base)
#if alternate_forms:
# form_found = False
# for alternate_form in alternate_forms:
# mark_id = self.determine_origin_mark(alternate_form.pfic, target_generation)
# if mark_id != None:
# event_system.emit_sync('assign_mark_to_form', (pfic, mark_id))
# form_found = True
# break;
# if form_found:
# continue;
#Rule 4 #Rule 4
# If there are no encounters for the pokemon form or its evolution line from this generation, # If there are no encounters for the pokemon form or its evolution line from this generation,

18
DBEditor/db_controller.py

@ -56,6 +56,7 @@ class DBController:
event_system.add_listener('get_game_by_id', self.get_game_by_id) event_system.add_listener('get_game_by_id', self.get_game_by_id)
event_system.add_listener('get_pokemon_form_by_pfic', self.get_pokemon_form_by_pfic) event_system.add_listener('get_pokemon_form_by_pfic', self.get_pokemon_form_by_pfic)
event_system.add_listener('find_default_form', self.find_default_form) event_system.add_listener('find_default_form', self.find_default_form)
event_system.add_listener('get_shiftable_forms', self.get_shiftable_forms)
def init_database(self): def init_database(self):
disk_conn = sqlite3.connect('pokemon_forms.db') disk_conn = sqlite3.connect('pokemon_forms.db')
@ -72,6 +73,7 @@ class DBController:
self.create_mark_table(disk_cursor) self.create_mark_table(disk_cursor)
self.create_form_marks_table(disk_cursor) self.create_form_marks_table(disk_cursor)
self.create_evolve_encounter_table(disk_cursor) self.create_evolve_encounter_table(disk_cursor)
self.create_shiftable_forms_table(disk_cursor)
# Commit changes to the file-based database # Commit changes to the file-based database
disk_conn.commit() disk_conn.commit()
@ -346,6 +348,17 @@ class DBController:
) )
''') ''')
def create_shiftable_forms_table(self, cursor):
cursor.execute('''
CREATE TABLE IF NOT EXISTS shiftable_forms (
id INTEGER PRIMARY KEY AUTOINCREMENT,
from_pfic TEXT,
to_pfic TEXT,
FOREIGN KEY (from_pfic) REFERENCES pokemon_forms (PFIC),
FOREIGN KEY (to_pfic) REFERENCES pokemon_forms (PFIC)
)
''')
def load_pokemon_details(self, pfic): def load_pokemon_details(self, pfic):
self.cursor.execute(''' self.cursor.execute('''
SELECT pf.name, pf.form_name, pf.national_dex, pf.generation, ps.storable_in_home, pf.is_baby_form SELECT pf.name, pf.form_name, pf.national_dex, pf.generation, ps.storable_in_home, pf.is_baby_form
@ -589,6 +602,11 @@ class DBController:
results = self.cursor.fetchall() results = self.cursor.fetchall()
return [PokemonForm(result[0], result[1], result[2], result[3], result[4], result[6], result[5]) for result in results] return [PokemonForm(result[0], result[1], result[2], result[3], result[4], result[6], result[5]) for result in results]
def get_shiftable_forms(self, data):
pfic = data
self.cursor.execute('SELECT * FROM shiftable_forms WHERE from_pfic = ?', (pfic,))
return self.cursor.fetchall()
def get_connection(self): def get_connection(self):
return self.connection_pool.get() return self.connection_pool.get()

18
DataGatherers/update_location_information.py

@ -447,15 +447,6 @@ def process_pokemon_for_location_data(pfic, name, form, national_dex, default_fo
test_location_text = BeautifulSoup(test_location, 'html.parser').get_text().lower() test_location_text = BeautifulSoup(test_location, 'html.parser').get_text().lower()
ignore_location = False
for ignore in encounters_to_ignore:
if ignore in test_location_text:
ignore_location = True
break
if ignore_location:
continue
if print_encounter: if print_encounter:
logger.info(f"Found in {encounter}:") logger.info(f"Found in {encounter}:")
print_encounter = False print_encounter = False
@ -487,6 +478,15 @@ def process_pokemon_for_location_data(pfic, name, form, national_dex, default_fo
if remaining_location.strip() == "": if remaining_location.strip() == "":
continue continue
ignore_location = False
for ignore in encounters_to_ignore:
if ignore in remaining_location.lower():
ignore_location = True
break
if ignore_location:
continue
save_encounter(db_controller, pfic, encounter, remaining_location.strip(), details["days"], details["times"], details["dual_slot"], details["static_encounter"], details["static_encounter_count"], details["extra_text"], details["stars"], details["Rods"], details["Fishing"], details["starter"] ) save_encounter(db_controller, pfic, encounter, remaining_location.strip(), details["days"], details["times"], details["dual_slot"], details["static_encounter"], details["static_encounter_count"], details["extra_text"], details["stars"], details["Rods"], details["Fishing"], details["starter"] )
def extract_evolve_information(s: str, db_controller): def extract_evolve_information(s: str, db_controller):

BIN
pokemon_forms.db

Binary file not shown.
Loading…
Cancel
Save