From 82a67e0792da4a7850630a5e5823e43648b7f1aa Mon Sep 17 00:00:00 2001 From: seth Date: Sun, 6 Dec 2020 02:11:55 +0000 Subject: [PATCH] MUSECA: Support Museca Plus modpack --- .gitignore | 3 +++ bemani/backend/museca/base.py | 29 +++++++++++++++------ bemani/backend/museca/museca1.py | 6 ++--- bemani/backend/museca/museca1plus.py | 39 ++++++++++++++++++++-------- bemani/utils/read.py | 13 +++++++--- 5 files changed, 64 insertions(+), 26 deletions(-) diff --git a/.gitignore b/.gitignore index 0d0e65f..c59dc2d 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,6 @@ build/ .hgignore .venv/ bemani.egg-info/ +server/ +emblems +.vscode/ diff --git a/bemani/backend/museca/base.py b/bemani/backend/museca/base.py index 8bbc789..a5190e4 100644 --- a/bemani/backend/museca/base.py +++ b/bemani/backend/museca/base.py @@ -1,10 +1,10 @@ # vim: set fileencoding=utf-8 -from typing import Dict, Optional +from typing import Dict, Optional, Any from bemani.backend.base import Base from bemani.backend.core import CoreHandler, CardManagerHandler, PASELIHandler -from bemani.common import ValidatedDict, GameConstants, DBConstants, Parallel -from bemani.data import UserID +from bemani.common import ValidatedDict, GameConstants, DBConstants, Parallel, Model +from bemani.data import UserID, Data from bemani.protocol import Node @@ -33,6 +33,19 @@ class MusecaBase(CoreHandler, CardManagerHandler, PASELIHandler, Base): CLEAR_TYPE_CLEARED = DBConstants.MUSECA_CLEAR_TYPE_CLEARED CLEAR_TYPE_FULL_COMBO = DBConstants.MUSECA_CLEAR_TYPE_FULL_COMBO + def __init__(self, data: Data, config: Dict[str, Any], model: Model) -> None: + super().__init__(data, config, model) + if model.rev == 'X': + self.omnimix = True + else: + self.omnimix = False + + @property + def music_version(self) -> int: + if self.omnimix: + return DBConstants.OMNIMIX_VERSION_BUMP + self.version + return self.version + def previous_version(self) -> Optional['MusecaBase']: """ Returns the previous version of the game, based on this game. Should @@ -128,11 +141,11 @@ class MusecaBase(CoreHandler, CardManagerHandler, PASELIHandler, Base): all_attempts, remote_attempts = Parallel.execute([ lambda: self.data.local.music.get_all_attempts( game=self.game, - version=self.version, + version=self.music_version, ), lambda: self.data.remote.music.get_clear_rates( game=self.game, - version=self.version, + version=self.music_version, ) ]) attempts: Dict[int, Dict[int, Dict[str, int]]] = {} @@ -214,7 +227,7 @@ class MusecaBase(CoreHandler, CardManagerHandler, PASELIHandler, Base): if userid is not None: oldscore = self.data.local.music.get_score( self.game, - self.version, + self.music_version, userid, songid, chart, @@ -262,7 +275,7 @@ class MusecaBase(CoreHandler, CardManagerHandler, PASELIHandler, Base): # Write the new score back self.data.local.music.put_score( self.game, - self.version, + self.music_version, userid, songid, chart, @@ -275,7 +288,7 @@ class MusecaBase(CoreHandler, CardManagerHandler, PASELIHandler, Base): # Save the history of this score too self.data.local.music.put_attempt( self.game, - self.version, + self.music_version, userid, songid, chart, diff --git a/bemani/backend/museca/museca1.py b/bemani/backend/museca/museca1.py index 25b7431..541b1fa 100644 --- a/bemani/backend/museca/museca1.py +++ b/bemani/backend/museca/museca1.py @@ -117,7 +117,7 @@ class Museca1( game_config = self.get_game_config() if game_config.get_bool('force_unlock_songs'): ids = set() - songs = self.data.local.music.get_all_songs(self.game, self.version) + songs = self.data.local.music.get_all_songs(self.game, self.music_version) for song in songs: if song.data.get_int('limited') in (self.GAME_LIMITED_LOCKED, self.GAME_LIMITED_UNLOCKABLE): ids.add((song.id, song.chart)) @@ -175,7 +175,7 @@ class Museca1( userid = None if userid is not None: - scores = self.data.remote.music.get_scores(self.game, self.version, userid) + scores = self.data.remote.music.get_scores(self.game, self.music_version, userid) else: scores = [] @@ -269,7 +269,7 @@ class Museca1( if game_config.get_bool('force_unlock_songs'): ids: Dict[int, int] = {} - songs = self.data.local.music.get_all_songs(self.game, self.version) + songs = self.data.local.music.get_all_songs(self.game, self.music_version) for song in songs: if song.id not in ids: ids[song.id] = 0 diff --git a/bemani/backend/museca/museca1plus.py b/bemani/backend/museca/museca1plus.py index 5771178..0929d7a 100644 --- a/bemani/backend/museca/museca1plus.py +++ b/bemani/backend/museca/museca1plus.py @@ -129,7 +129,7 @@ class Museca1Plus( game_config = self.get_game_config() if game_config.get_bool('force_unlock_songs'): ids = set() - songs = self.data.local.music.get_all_songs(self.game, self.version) + songs = self.data.local.music.get_all_songs(self.game, self.music_version) for song in songs: if song.data.get_int('limited') in (self.GAME_LIMITED_LOCKED, self.GAME_LIMITED_UNLOCKABLE): ids.add((song.id, song.chart)) @@ -153,16 +153,33 @@ class Museca1Plus( if not game_config.get_bool('disable_matching'): enable_event(143) # Matching enabled - enable_event(1) # Extended pedal options - enable_event(83) # Light start - enable_event(130) # Curator rank - enable_event(195) # Fictional curator - # Event 194 is continuation mode, but it doesn't seem to work on latest data. + # These events are meant specifically for Museca Plus + museca_plus_events = [ + 140, # Agetta Moratta (vmlink_phase 3 in musicdb) + 211, # News 1 + ] + event_ids = [ + 1, # Extended pedal options + 56, # Generator grafica icon + 83, # Paseli Light Start + 86, # Generator grafica icon + 98, # Caption 2 notice (grs_grafica_caption_2.png) + 105, # Makes the "Number of Layers" option visible in game settings + 130, # Curator Rank + 141, # Coconatsu & Mukipara grafica effects + 145, # MUKIPARA UNLOCKS + 146, # MUKIPARA UNLOCKS + 147, # MUKIPARA UNLOCKS + 148, # MUKIPARA UNLOCKS + 149, # MUKIPARA UNLOCKS + 195, # Fictional Curator (foot pedal options) + ] - enable_event(98) # Mission mode - for evtid in [145, 146, 147, 148, 149]: + for evtid in event_ids: enable_event(evtid) # Mission stuff - + if self.omnimix: + for evtid in museca_plus_events: + enable_event(evtid) return game def handle_game_3_lounge_request(self, request: Node) -> Node: @@ -210,7 +227,7 @@ class Museca1Plus( userid = None if userid is not None: - scores = self.data.remote.music.get_scores(self.game, self.version, userid) + scores = self.data.remote.music.get_scores(self.game, self.music_version, userid) else: scores = [] @@ -310,7 +327,7 @@ class Museca1Plus( if game_config.get_bool('force_unlock_songs'): ids: Dict[int, int] = {} - songs = self.data.local.music.get_all_songs(self.game, self.version) + songs = self.data.local.music.get_all_songs(self.game, self.music_version) for song in songs: if song.id not in ids: ids[song.id] = 0 diff --git a/bemani/utils/read.py b/bemani/utils/read.py index 1688463..d705d35 100644 --- a/bemani/utils/read.py +++ b/bemani/utils/read.py @@ -2839,13 +2839,18 @@ class ImportMuseca(ImportBase): no_combine: bool, update: bool, ) -> None: - actual_version = { - '1': VersionConstants.MUSECA, - '1+1/2': VersionConstants.MUSECA_1_PLUS, - }.get(version, -1) + if version in ['1', '1+1/2']: + actual_version = { + '1': VersionConstants.MUSECA, + '1+1/2': VersionConstants.MUSECA_1_PLUS, + }.get(version, -1) + elif version == 'plus': + actual_version = VersionConstants.MUSECA_1_PLUS + DBConstants.OMNIMIX_VERSION_BUMP if actual_version in [VersionConstants.MUSECA, VersionConstants.MUSECA_1_PLUS]: self.charts = [0, 1, 2, 3] + elif actual_version == VersionConstants.MUSECA_1_PLUS + DBConstants.OMNIMIX_VERSION_BUMP: + self.charts = [0, 1, 2, 3] else: raise Exception("Unsupported Museca version, expected one of the following: 1, 1+1/2!")