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 0000000..e674864 Binary files /dev/null and b/scores_gen3 differ diff --git a/scores_gen3.db b/scores_gen3.db new file mode 100644 index 0000000..ba5b55d Binary files /dev/null and b/scores_gen3.db differ diff --git a/scores_shinuchi.db b/scores_shinuchi.db new file mode 100644 index 0000000..ba5b55d Binary files /dev/null and b/scores_shinuchi.db differ