From c3553c5b951357acf5460d55e266741ccd9b0561 Mon Sep 17 00:00:00 2001 From: Valerio Date: Fri, 19 Dec 2025 19:14:15 -0500 Subject: [PATCH] Separated gen3 and shinuchi scores into their own DBs --- PyTaiko.py | 10 +++++++--- config.toml | 2 +- libs/file_navigator.py | 2 +- libs/global_data.py | 4 ++++ libs/song_hash.py | 4 ++-- scenes/game.py | 10 +++------- scores_gen3 | Bin 0 -> 12288 bytes scores_gen3.db | Bin 0 -> 12288 bytes scores_shinuchi.db | Bin 0 -> 12288 bytes 9 files changed, 18 insertions(+), 14 deletions(-) create mode 100644 scores_gen3 create mode 100644 scores_gen3.db create mode 100644 scores_shinuchi.db diff --git a/PyTaiko.py b/PyTaiko.py index 2a9bf3d..24295ea 100644 --- a/PyTaiko.py +++ b/PyTaiko.py @@ -15,7 +15,7 @@ from raylib.defines import ( ) from libs.audio import audio -from libs.global_data import PlayerNum +from libs.global_data import PlayerNum, ScoreMethod from libs.screen import Screen from libs.song_hash import DB_VERSION from libs.tja import TJAParser @@ -45,7 +45,6 @@ from scenes.dan.dan_result import DanResultScreen from pypresence.presence import Presence - logger = logging.getLogger(__name__) DISCORD_APP_ID = '1451423960401973353' try: @@ -128,7 +127,7 @@ def handle_exception(exc_type, exc_value, exc_traceback): def create_song_db(): """Create the scores database if it doesn't exist""" - with sqlite3.connect('scores.db') as con: + with sqlite3.connect(global_data.score_db) as con: cursor = con.cursor() cursor.execute(''' @@ -199,6 +198,11 @@ def update_camera_for_window_size(camera, virtual_width, virtual_height): def main(): force_dedicated_gpu() global_data.config = get_config() + match global_data.config["general"]["score_method"]: + case ScoreMethod.GEN3: + global_data.score_db = 'scores_gen3.db' + case ScoreMethod.SHINUCHI: + global_data.score_db = 'scores_shinuchi.db' log_level = global_data.config["general"]["log_level"] if sys.platform == 'win32': import io diff --git a/config.toml b/config.toml index e1ecb43..7d769f8 100644 --- a/config.toml +++ b/config.toml @@ -9,7 +9,7 @@ nijiiro_notes = false log_level = 30 fake_online = false practice_mode_bar_delay = 1 -score_method = "shinuchi" +score_method = "gen3" [nameplate_1p] name = 'どんちゃん' diff --git a/libs/file_navigator.py b/libs/file_navigator.py index 8b4fd34..5547d58 100644 --- a/libs/file_navigator.py +++ b/libs/file_navigator.py @@ -165,7 +165,7 @@ class SongBox(BaseBox): self.text_loaded = True def get_scores(self): - with sqlite3.connect('scores.db') as con: + with sqlite3.connect(global_data.score_db) as con: cursor = con.cursor() # Batch database query for all diffs at once if self.tja.metadata.course_data: diff --git a/libs/global_data.py b/libs/global_data.py index 83ac3c2..cbb9e52 100644 --- a/libs/global_data.py +++ b/libs/global_data.py @@ -14,6 +14,9 @@ class PlayerNum(IntEnum): TWO_PLAYER = 3 DAN = 4 +class ScoreMethod(): + GEN3 = "gen3" + SHINUCHI = "shinuchi" class Difficulty(IntEnum): EASY = 0 @@ -154,6 +157,7 @@ class GlobalData: config: Config = field(default_factory=dict) song_hashes: dict[str, list[dict]] = field(default_factory=lambda: dict()) #Hash to path song_paths: dict[Path, str] = field(default_factory=lambda: dict()) #path to hash + score_db: str = "" song_progress: float = 0.0 total_songs: int = 0 hit_sound: list[int] = field(default_factory=lambda: [0, 0, 0]) diff --git a/libs/song_hash.py b/libs/song_hash.py index 40a1c41..a258dfd 100644 --- a/libs/song_hash.py +++ b/libs/song_hash.py @@ -27,14 +27,14 @@ class DiffHashesDecoder(json.JSONDecoder): super().__init__(object_hook=diff_hashes_object_hook, *args, **kwargs) def get_db_version(): - with sqlite3.connect('scores.db') as con: + with sqlite3.connect(global_data.score_db) as con: cursor = con.cursor() cursor.execute('PRAGMA user_version') version = cursor.fetchone()[0] return version def update_db_version(): - with sqlite3.connect('scores.db') as con: + with sqlite3.connect(global_data.score_db) as con: cursor = con.cursor() cursor.execute(f'PRAGMA user_version = {DB_VERSION}') diff --git a/scenes/game.py b/scenes/game.py index bed2290..48d1865 100644 --- a/scenes/game.py +++ b/scenes/game.py @@ -14,7 +14,7 @@ from libs.animation import Animation from libs.audio import audio from libs.background import Background from libs.chara_2d import Chara2D -from libs.global_data import Crown, Difficulty, Modifiers, PlayerNum +from libs.global_data import Crown, Difficulty, Modifiers, PlayerNum, ScoreMethod from libs.global_objects import AllNetIcon, Nameplate from libs.screen import Screen from libs.texture import tex @@ -58,10 +58,6 @@ class Judgments(IntEnum): OK = 1 BAD = 2 -class ScoreMethod(): - GEN3 = "gen3" - SHINUCHI = "shinuchi" - class GameScreen(Screen): JUDGE_X = 414 * tex.screen_scale JUDGE_Y = 256 * tex.screen_scale @@ -156,7 +152,7 @@ class GameScreen(Screen): """Write the score to the database""" if global_data.modifiers[global_data.player_num].auto: return - with sqlite3.connect('scores.db') as con: + with sqlite3.connect(global_data.score_db) as con: session_data = global_data.session_data[global_data.player_num] cursor = con.cursor() hash = session_data.song_hash @@ -804,7 +800,7 @@ class Player: self.combo_announce = ComboAnnounce(self.combo, current_time, self.player_num, self.is_2p) if self.combo > self.max_combo: self.max_combo = self.combo - if self.combo % 100 == 0 and self.score_method == "gen3": + if self.combo % 100 == 0 and self.score_method == ScoreMethod.GEN3: self.score += 10000 self.base_score_list.append(ScoreCounterAnimation(self.player_num, 10000, self.is_2p)) diff --git a/scores_gen3 b/scores_gen3 new file mode 100644 index 0000000000000000000000000000000000000000..e674864eea4bf250b4f7540ed515282df9614c78 GIT binary patch literal 12288 zcmeI$K}+L66bJB`RNPfayEiRf=BOyrrfr&@)~*eUZ0)XT1bZse%%oP+j+;jCTEU|? zVL!osiv0+Fq4j2B>avCE9u`F5|H$NJ^4>u5BbQ10pgD*n^Hn(H5i5}ogi^A@7$GDx z9dUXH8lM-Y*GWp|$#^a@Wc&I~&;2G^)+Jdtcl%s3Y7l?`1Rwwb2tWV=5P$##An>*X zE+hJGC7-8PyAkgNvhAr*j?=TY>)3VIW^Vmc(`M;Cw!X~%ieo-LX0CnYvTx4be%_GT8GW%Y|F{nKU>7W_t{>{wLja=?Ba3q#PdsirNsP-I-P&N z$Dddr!t-IMf?)nKPYrwOiBceW_*nV_v$3fyu6)c>G8hSYG5#LJ`}!_FkJQ7wn_72^ zX-@X`?~|`ej|a{DAn}2K00bZa0SG_<0uX=z1Rwwb2teRv1^QH<=xb{YRxoDrE-B=qFOYHmgyN4>DQ{VD5S>=k{1kadcyK+meElCUi>>? znlelE8!aF|*(xQ=@q5wSFA^UJ2tWV=5P$##AOHafKmY;|fB*zupFm?_qW|}wfqMqB BpuGS9 literal 0 HcmV?d00001 diff --git a/scores_gen3.db b/scores_gen3.db new file mode 100644 index 0000000000000000000000000000000000000000..ba5b55de27bc020bd19ae8f7e872c0ccc230a428 GIT binary patch literal 12288 zcmeI#&r8EF6bJCMippR=ZezE1R1`t{19Xlc!#cH#;7%o5GgoaJZ9DKRc=RvxAJUu6 z%EUo8&yMedBu(B6G@tg8{*4o4ipDyLWJbrV!7PiN5;4Z?ylv!d9#;OaIiKXCnVYsM zY4fT>#sAMuv z{lM()+gr_(mc@eDS1;*vnBVI?InDHJ?iJSFQ8Ai({f_yos-|n04gmoOKmY;|fB*y_ t009U<00Izzz`6=l%)xN~U)Rrzb3p(C5P$##AOHafKmY;|fB*z$0^h&6aH9YK literal 0 HcmV?d00001 diff --git a/scores_shinuchi.db b/scores_shinuchi.db new file mode 100644 index 0000000000000000000000000000000000000000..ba5b55de27bc020bd19ae8f7e872c0ccc230a428 GIT binary patch literal 12288 zcmeI#&r8EF6bJCMippR=ZezE1R1`t{19Xlc!#cH#;7%o5GgoaJZ9DKRc=RvxAJUu6 z%EUo8&yMedBu(B6G@tg8{*4o4ipDyLWJbrV!7PiN5;4Z?ylv!d9#;OaIiKXCnVYsM zY4fT>#sAMuv z{lM()+gr_(mc@eDS1;*vnBVI?InDHJ?iJSFQ8Ai({f_yos-|n04gmoOKmY;|fB*y_ t009U<00Izzz`6=l%)xN~U)Rrzb3p(C5P$##AOHafKmY;|fB*z$0^h&6aH9YK literal 0 HcmV?d00001