Separated gen3 and shinuchi scores into their own DBs

This commit is contained in:
Valerio
2025-12-19 19:14:15 -05:00
parent 252c3c3e0b
commit c3553c5b95
9 changed files with 18 additions and 14 deletions

View File

@@ -15,7 +15,7 @@ from raylib.defines import (
) )
from libs.audio import audio 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.screen import Screen
from libs.song_hash import DB_VERSION from libs.song_hash import DB_VERSION
from libs.tja import TJAParser from libs.tja import TJAParser
@@ -45,7 +45,6 @@ from scenes.dan.dan_result import DanResultScreen
from pypresence.presence import Presence from pypresence.presence import Presence
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
DISCORD_APP_ID = '1451423960401973353' DISCORD_APP_ID = '1451423960401973353'
try: try:
@@ -128,7 +127,7 @@ def handle_exception(exc_type, exc_value, exc_traceback):
def create_song_db(): def create_song_db():
"""Create the scores database if it doesn't exist""" """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 = con.cursor()
cursor.execute(''' cursor.execute('''
@@ -199,6 +198,11 @@ def update_camera_for_window_size(camera, virtual_width, virtual_height):
def main(): def main():
force_dedicated_gpu() force_dedicated_gpu()
global_data.config = get_config() 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"] log_level = global_data.config["general"]["log_level"]
if sys.platform == 'win32': if sys.platform == 'win32':
import io import io

View File

@@ -9,7 +9,7 @@ nijiiro_notes = false
log_level = 30 log_level = 30
fake_online = false fake_online = false
practice_mode_bar_delay = 1 practice_mode_bar_delay = 1
score_method = "shinuchi" score_method = "gen3"
[nameplate_1p] [nameplate_1p]
name = 'どんちゃん' name = 'どんちゃん'

View File

@@ -165,7 +165,7 @@ class SongBox(BaseBox):
self.text_loaded = True self.text_loaded = True
def get_scores(self): def get_scores(self):
with sqlite3.connect('scores.db') as con: with sqlite3.connect(global_data.score_db) as con:
cursor = con.cursor() cursor = con.cursor()
# Batch database query for all diffs at once # Batch database query for all diffs at once
if self.tja.metadata.course_data: if self.tja.metadata.course_data:

View File

@@ -14,6 +14,9 @@ class PlayerNum(IntEnum):
TWO_PLAYER = 3 TWO_PLAYER = 3
DAN = 4 DAN = 4
class ScoreMethod():
GEN3 = "gen3"
SHINUCHI = "shinuchi"
class Difficulty(IntEnum): class Difficulty(IntEnum):
EASY = 0 EASY = 0
@@ -154,6 +157,7 @@ class GlobalData:
config: Config = field(default_factory=dict) config: Config = field(default_factory=dict)
song_hashes: dict[str, list[dict]] = field(default_factory=lambda: dict()) #Hash to path 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 song_paths: dict[Path, str] = field(default_factory=lambda: dict()) #path to hash
score_db: str = ""
song_progress: float = 0.0 song_progress: float = 0.0
total_songs: int = 0 total_songs: int = 0
hit_sound: list[int] = field(default_factory=lambda: [0, 0, 0]) hit_sound: list[int] = field(default_factory=lambda: [0, 0, 0])

View File

@@ -27,14 +27,14 @@ class DiffHashesDecoder(json.JSONDecoder):
super().__init__(object_hook=diff_hashes_object_hook, *args, **kwargs) super().__init__(object_hook=diff_hashes_object_hook, *args, **kwargs)
def get_db_version(): def get_db_version():
with sqlite3.connect('scores.db') as con: with sqlite3.connect(global_data.score_db) as con:
cursor = con.cursor() cursor = con.cursor()
cursor.execute('PRAGMA user_version') cursor.execute('PRAGMA user_version')
version = cursor.fetchone()[0] version = cursor.fetchone()[0]
return version return version
def update_db_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 = con.cursor()
cursor.execute(f'PRAGMA user_version = {DB_VERSION}') cursor.execute(f'PRAGMA user_version = {DB_VERSION}')

View File

@@ -14,7 +14,7 @@ from libs.animation import Animation
from libs.audio import audio from libs.audio import audio
from libs.background import Background from libs.background import Background
from libs.chara_2d import Chara2D 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.global_objects import AllNetIcon, Nameplate
from libs.screen import Screen from libs.screen import Screen
from libs.texture import tex from libs.texture import tex
@@ -58,10 +58,6 @@ class Judgments(IntEnum):
OK = 1 OK = 1
BAD = 2 BAD = 2
class ScoreMethod():
GEN3 = "gen3"
SHINUCHI = "shinuchi"
class GameScreen(Screen): class GameScreen(Screen):
JUDGE_X = 414 * tex.screen_scale JUDGE_X = 414 * tex.screen_scale
JUDGE_Y = 256 * tex.screen_scale JUDGE_Y = 256 * tex.screen_scale
@@ -156,7 +152,7 @@ class GameScreen(Screen):
"""Write the score to the database""" """Write the score to the database"""
if global_data.modifiers[global_data.player_num].auto: if global_data.modifiers[global_data.player_num].auto:
return 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] session_data = global_data.session_data[global_data.player_num]
cursor = con.cursor() cursor = con.cursor()
hash = session_data.song_hash 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) self.combo_announce = ComboAnnounce(self.combo, current_time, self.player_num, self.is_2p)
if self.combo > self.max_combo: if self.combo > self.max_combo:
self.max_combo = self.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.score += 10000
self.base_score_list.append(ScoreCounterAnimation(self.player_num, 10000, self.is_2p)) self.base_score_list.append(ScoreCounterAnimation(self.player_num, 10000, self.is_2p))

BIN
scores_gen3 Normal file

Binary file not shown.

BIN
scores_gen3.db Normal file

Binary file not shown.

BIN
scores_shinuchi.db Normal file

Binary file not shown.