mirror of
https://github.com/Yonokid/PyTaiko.git
synced 2026-02-04 03:30:13 +01:00
Merge pull request #179 from magickale/gen3-scoring
Separated shinuchi and gen3 scores into their own databases
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,10 +1,11 @@
|
||||
__pycache__
|
||||
.venv
|
||||
.ruff_cache
|
||||
scores.db
|
||||
cache
|
||||
dev-config.toml
|
||||
libaudio.so
|
||||
latest.log
|
||||
libaudio.dll
|
||||
libaudio.dylib
|
||||
scores.db
|
||||
scores_shinuchi.db
|
||||
|
||||
10
PyTaiko.py
10
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.db'
|
||||
log_level = global_data.config["general"]["log_level"]
|
||||
if sys.platform == 'win32':
|
||||
import io
|
||||
|
||||
@@ -219,7 +219,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:
|
||||
|
||||
@@ -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])
|
||||
|
||||
@@ -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}')
|
||||
|
||||
|
||||
@@ -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))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user