|
|
@ -34,6 +34,7 @@ class DBController: |
|
|
event_system.add_listener('add_new_exclusive_set', self.add_new_exclusive_set) |
|
|
event_system.add_listener('add_new_exclusive_set', self.add_new_exclusive_set) |
|
|
event_system.add_listener('save_changes', self.save_changes) |
|
|
event_system.add_listener('save_changes', self.save_changes) |
|
|
event_system.add_listener('export_database', self.export_database) |
|
|
event_system.add_listener('export_database', self.export_database) |
|
|
|
|
|
event_system.add_listener('assign_mark_to_form', self.assign_mark_to_form) |
|
|
|
|
|
|
|
|
def init_database(self): |
|
|
def init_database(self): |
|
|
disk_conn = sqlite3.connect('pokemon_forms.db') |
|
|
disk_conn = sqlite3.connect('pokemon_forms.db') |
|
|
@ -48,6 +49,7 @@ class DBController: |
|
|
self.create_encounter_exclusive_group_table(disk_cursor) |
|
|
self.create_encounter_exclusive_group_table(disk_cursor) |
|
|
self.create_encounters_table(disk_cursor) |
|
|
self.create_encounters_table(disk_cursor) |
|
|
self.create_mark_table(disk_cursor) |
|
|
self.create_mark_table(disk_cursor) |
|
|
|
|
|
self.create_form_marks_table(disk_cursor) |
|
|
|
|
|
|
|
|
# Commit changes to the file-based database |
|
|
# Commit changes to the file-based database |
|
|
disk_conn.commit() |
|
|
disk_conn.commit() |
|
|
@ -159,18 +161,20 @@ class DBController: |
|
|
("Kalos", "images/marks/Blue_pentagon_HOME.png", ["X", "Y", "Omega Ruby", "Alpha Sapphire"]), |
|
|
("Kalos", "images/marks/Blue_pentagon_HOME.png", ["X", "Y", "Omega Ruby", "Alpha Sapphire"]), |
|
|
("Alola", "images/marks/Black_clover_HOME.png", ["Sun", "Moon", "Ultra Sun", "Ultra Moon"]), |
|
|
("Alola", "images/marks/Black_clover_HOME.png", ["Sun", "Moon", "Ultra Sun", "Ultra Moon"]), |
|
|
("Let's Go", "images/marks/Let's_Go_icon_HOME.png", ["Let's Go Pikachu", "Let's Go Eevee"]), |
|
|
("Let's Go", "images/marks/Let's_Go_icon_HOME.png", ["Let's Go Pikachu", "Let's Go Eevee"]), |
|
|
("Galar", "images/marks/Galar_symbol_HOME.png", ["Sword", "Shield"]), |
|
|
("Galar", "images/marks/Galar_symbol_HOME.png", ["Sword", "Shield", "Expansion Pass"]), |
|
|
("Sinnoh", "images/marks/BDSP_icon_HOME.png", ["Brilliant Diamond", "Shining Pearl"]), |
|
|
("Sinnoh", "images/marks/BDSP_icon_HOME.png", ["Brilliant Diamond", "Shining Pearl"]), |
|
|
("Hisui", "images/marks/Arceus_mark_HOME.png", ["Legends Arceus"]), |
|
|
("Hisui", "images/marks/Arceus_mark_HOME.png", ["Legends Arceus"]), |
|
|
("Paldea", "images/marks/Paldea_icon_HOME.png", ["Scarlet", "Violet"]), |
|
|
("Paldea", "images/marks/Paldea_icon_HOME.png", ["Scarlet", "Violet", "The Teal Mask", "The Hidden Treasure of Area Zero"]), |
|
|
] |
|
|
] |
|
|
|
|
|
|
|
|
# Check if marks already exist |
|
|
# Check if marks already exist |
|
|
cursor.execute('SELECT COUNT(*) FROM marks') |
|
|
cursor.execute('SELECT COUNT(*) FROM marks') |
|
|
marks_count = cursor.fetchone()[0] |
|
|
marks_count = cursor.fetchone()[0] |
|
|
|
|
|
|
|
|
if marks_count == 0: |
|
|
|
|
|
for mark in marks: |
|
|
for mark in marks: |
|
|
|
|
|
mark_id = None |
|
|
|
|
|
if marks_count == 0: |
|
|
cursor.execute(''' |
|
|
cursor.execute(''' |
|
|
INSERT OR IGNORE INTO marks (name, icon_path) |
|
|
INSERT OR IGNORE INTO marks (name, icon_path) |
|
|
VALUES (?, ?) |
|
|
VALUES (?, ?) |
|
|
@ -178,6 +182,12 @@ class DBController: |
|
|
|
|
|
|
|
|
mark_id = cursor.lastrowid |
|
|
mark_id = cursor.lastrowid |
|
|
|
|
|
|
|
|
|
|
|
if mark_id == None: |
|
|
|
|
|
cursor.execute(''' |
|
|
|
|
|
SELECT id FROM marks WHERE name = ? |
|
|
|
|
|
''', (mark[0],)) |
|
|
|
|
|
mark_id = cursor.fetchone()[0] |
|
|
|
|
|
|
|
|
for game_name in mark[2]: |
|
|
for game_name in mark[2]: |
|
|
cursor.execute(''' |
|
|
cursor.execute(''' |
|
|
INSERT OR IGNORE INTO mark_game_associations (mark_id, game_id) |
|
|
INSERT OR IGNORE INTO mark_game_associations (mark_id, game_id) |
|
|
@ -250,7 +260,13 @@ class DBController: |
|
|
("Pokémon Go", 99, ["Pokémon GO"]), |
|
|
("Pokémon Go", 99, ["Pokémon GO"]), |
|
|
] |
|
|
] |
|
|
|
|
|
|
|
|
|
|
|
# Check if marks already exist |
|
|
|
|
|
cursor.execute('SELECT COUNT(*) FROM games') |
|
|
|
|
|
games_count = cursor.fetchone()[0] |
|
|
|
|
|
|
|
|
for game in games: |
|
|
for game in games: |
|
|
|
|
|
game_id = None |
|
|
|
|
|
if games_count == 0: |
|
|
cursor.execute(''' |
|
|
cursor.execute(''' |
|
|
INSERT OR IGNORE INTO games (name, generation) |
|
|
INSERT OR IGNORE INTO games (name, generation) |
|
|
VALUES (?, ?) |
|
|
VALUES (?, ?) |
|
|
@ -258,6 +274,12 @@ class DBController: |
|
|
|
|
|
|
|
|
game_id = cursor.lastrowid |
|
|
game_id = cursor.lastrowid |
|
|
|
|
|
|
|
|
|
|
|
if game_id == None: |
|
|
|
|
|
cursor.execute(''' |
|
|
|
|
|
SELECT id FROM games WHERE name = ? |
|
|
|
|
|
''', (game[0],)) |
|
|
|
|
|
game_id = cursor.fetchone()[0] |
|
|
|
|
|
|
|
|
# Insert alternate names |
|
|
# Insert alternate names |
|
|
for alt_name in game[2]: |
|
|
for alt_name in game[2]: |
|
|
cursor.execute(''' |
|
|
cursor.execute(''' |
|
|
@ -265,6 +287,17 @@ class DBController: |
|
|
VALUES (?, ?) |
|
|
VALUES (?, ?) |
|
|
''', (game_id, alt_name)) |
|
|
''', (game_id, alt_name)) |
|
|
|
|
|
|
|
|
|
|
|
def create_form_marks_table(self, cursor): |
|
|
|
|
|
cursor.execute(''' |
|
|
|
|
|
CREATE TABLE IF NOT EXISTS form_marks ( |
|
|
|
|
|
pfic TEXT, |
|
|
|
|
|
mark_id INTEGER, |
|
|
|
|
|
FOREIGN KEY (pfic) REFERENCES pokemon_forms (PFIC), |
|
|
|
|
|
FOREIGN KEY (mark_id) REFERENCES marks (id), |
|
|
|
|
|
PRIMARY KEY (pfic, mark_id) |
|
|
|
|
|
) |
|
|
|
|
|
''') |
|
|
|
|
|
|
|
|
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 |
|
|
@ -448,3 +481,9 @@ class DBController: |
|
|
export_conn = sqlite3.connect('pokemon_forms_production.db') |
|
|
export_conn = sqlite3.connect('pokemon_forms_production.db') |
|
|
self.conn.backup(export_conn) |
|
|
self.conn.backup(export_conn) |
|
|
export_conn.close() |
|
|
export_conn.close() |
|
|
|
|
|
|
|
|
|
|
|
def assign_mark_to_form(self, data): |
|
|
|
|
|
pfic, mark_id = data |
|
|
|
|
|
self.cursor.execute('INSERT INTO form_marks (pfic, mark_id) VALUES (?, ?)', (pfic, mark_id)) |
|
|
|
|
|
self.conn.commit() |
|
|
|
|
|
|
|
|
|