Muse Dash: Add support for specifying specific DLCs (#2329)

This commit is contained in:
Justus Lind
2023-10-20 10:13:17 +10:00
committed by GitHub
parent fb6b66463d
commit 385803eb5c
7 changed files with 166 additions and 99 deletions

View File

@@ -1,5 +1,5 @@
from .Items import SongData, AlbumData
from typing import Dict, List, Optional
from typing import Dict, List, Set, Optional
from collections import ChainMap
@@ -15,13 +15,21 @@ class MuseDashCollections:
MUSIC_SHEET_NAME: str = "Music Sheet"
MUSIC_SHEET_CODE: int = STARTING_CODE
FREE_ALBUMS = [
FREE_ALBUMS: List[str] = [
"Default Music",
"Budget Is Burning: Nano Core",
"Budget Is Burning Vol.1",
]
DIFF_OVERRIDES = [
MUSE_PLUS_DLC: str = "Muse Plus"
DLC: List[str] = [
# MUSE_PLUS_DLC, # To be included when OptionSets are rendered as part of basic settings.
# "maimai DX Limited-time Suite", # Part of Muse Plus. Goes away 31st Jan 2026.
"Miku in Museland", # Paid DLC not included in Muse Plus
"MSR Anthology", # Part of Muse Plus. Goes away 20th Jan 2024.
]
DIFF_OVERRIDES: List[str] = [
"MuseDash ka nanika hi",
"Rush-Hour",
"Find this Month's Featured Playlist",
@@ -48,8 +56,8 @@ class MuseDashCollections:
"Error SFX Trap": STARTING_CODE + 9,
}
item_names_to_id = ChainMap({}, sfx_trap_items, vfx_trap_items)
location_names_to_id = ChainMap(song_locations, album_locations)
item_names_to_id: ChainMap = ChainMap({}, sfx_trap_items, vfx_trap_items)
location_names_to_id: ChainMap = ChainMap(song_locations, album_locations)
def __init__(self) -> None:
self.item_names_to_id[self.MUSIC_SHEET_NAME] = self.MUSIC_SHEET_CODE
@@ -70,7 +78,6 @@ class MuseDashCollections:
# Data is in the format 'Song|UID|Album|StreamerMode|EasyDiff|HardDiff|MasterDiff|SecretDiff'
song_name = sections[0]
# [1] is used in the client copy to make sure item id's match.
song_is_free = album in self.FREE_ALBUMS
steamer_mode = sections[3] == "True"
if song_name in self.DIFF_OVERRIDES:
@@ -84,7 +91,7 @@ class MuseDashCollections:
diff_of_hard = self.parse_song_difficulty(sections[5])
diff_of_master = self.parse_song_difficulty(sections[6])
self.song_items[song_name] = SongData(item_id_index, song_is_free, steamer_mode,
self.song_items[song_name] = SongData(item_id_index, album, steamer_mode,
diff_of_easy, diff_of_hard, diff_of_master)
item_id_index += 1
@@ -102,13 +109,13 @@ class MuseDashCollections:
self.song_locations[f"{name}-1"] = location_id_index + 1
location_id_index += 2
def get_songs_with_settings(self, dlc_songs: bool, streamer_mode_active: bool,
def get_songs_with_settings(self, dlc_songs: Set[str], streamer_mode_active: bool,
diff_lower: int, diff_higher: int) -> List[str]:
"""Gets a list of all songs that match the filter settings. Difficulty thresholds are inclusive."""
filtered_list = []
for songKey, songData in self.song_items.items():
if not dlc_songs and not songData.song_is_free:
if not self.song_matches_dlc_filter(songData, dlc_songs):
continue
if streamer_mode_active and not songData.streamer_mode:
@@ -128,6 +135,19 @@ class MuseDashCollections:
return filtered_list
def song_matches_dlc_filter(self, song: SongData, dlc_songs: Set[str]) -> bool:
if song.album in self.FREE_ALBUMS:
return True
if song.album in dlc_songs:
return True
# Muse Plus provides access to any DLC not included as a seperate pack
if song.album not in self.DLC and self.MUSE_PLUS_DLC in dlc_songs:
return True
return False
def parse_song_difficulty(self, difficulty: str) -> Optional[int]:
"""Attempts to parse the song difficulty."""
if len(difficulty) <= 0 or difficulty == "?" or difficulty == "¿":