Muse Dash: Change Data storage from a .txt file to a .py file and Filter Webhost Song Lists correctly (#4234)

This commit is contained in:
Justus Lind
2025-01-13 03:59:16 +10:00
committed by GitHub
parent 9928639ce2
commit 3f935aac13
7 changed files with 656 additions and 705 deletions

View File

@@ -1,13 +1,9 @@
from .Items import SongData, AlbumData
from typing import Dict, List, Set, Optional
from .Items import SongData
from .MuseDashData import SONG_DATA
from typing import Dict, List, Set
from collections import ChainMap
def load_text_file(name: str) -> str:
import pkgutil
return pkgutil.get_data(__name__, name).decode()
class MuseDashCollections:
"""Contains all the data of Muse Dash, loaded from MuseDashData.txt."""
STARTING_CODE = 2900000
@@ -33,15 +29,6 @@ class MuseDashCollections:
"Rin Len's Mirrorland", # Paid DLC not included in Muse Plus
]
DIFF_OVERRIDES: List[str] = [
"MuseDash ka nanika hi",
"Rush-Hour",
"Find this Month's Featured Playlist",
"PeroPero in the Universe",
"umpopoff",
"P E R O P E R O Brother Dance",
]
REMOVED_SONGS = [
"CHAOS Glitch",
"FM 17314 SUGAR RADIO",
@@ -50,9 +37,7 @@ class MuseDashCollections:
"Tsukuyomi Ni Naru Replaced",
]
album_items: Dict[str, AlbumData] = {}
album_locations: Dict[str, int] = {}
song_items: Dict[str, SongData] = {}
song_items = SONG_DATA
song_locations: Dict[str, int] = {}
trap_items: Dict[str, int] = {
@@ -65,7 +50,7 @@ class MuseDashCollections:
"Gray Scale Trap": STARTING_CODE + 7,
"Nyaa SFX Trap": STARTING_CODE + 8,
"Error SFX Trap": STARTING_CODE + 9,
"Focus Line Trap": STARTING_CODE + 10,
"Focus Line Trap": STARTING_CODE + 10,
}
sfx_trap_items: List[str] = [
@@ -85,65 +70,13 @@ class MuseDashCollections:
"Extra Life": 1,
}
item_names_to_id: ChainMap = ChainMap({}, filler_items, trap_items)
location_names_to_id: ChainMap = ChainMap(song_locations, album_locations)
item_names_to_id: ChainMap = ChainMap({k: v.code for k, v in SONG_DATA.items()}, filler_items, trap_items)
location_names_to_id: ChainMap = ChainMap(song_locations)
def __init__(self) -> None:
self.item_names_to_id[self.MUSIC_SHEET_NAME] = self.MUSIC_SHEET_CODE
item_id_index = self.STARTING_CODE + 50
full_file = load_text_file("MuseDashData.txt")
seen_albums = set()
for line in full_file.splitlines():
line = line.strip()
sections = line.split("|")
album = sections[2]
if album not in seen_albums:
seen_albums.add(album)
self.album_items[album] = AlbumData(item_id_index)
item_id_index += 1
# 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.
steamer_mode = sections[3] == "True"
if song_name in self.DIFF_OVERRIDES:
# These songs use non-standard difficulty values. Which are being overriden with standard values.
# But also avoid filling any missing difficulties (i.e. 0s) with a difficulty value.
if sections[4] != '0':
diff_of_easy = 4
else:
diff_of_easy = None
if sections[5] != '0':
diff_of_hard = 7
else:
diff_of_hard = None
if sections[6] != '0':
diff_of_master = 10
else:
diff_of_master = None
else:
diff_of_easy = self.parse_song_difficulty(sections[4])
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, album, steamer_mode,
diff_of_easy, diff_of_hard, diff_of_master)
item_id_index += 1
self.item_names_to_id.update({name: data.code for name, data in self.song_items.items()})
self.item_names_to_id.update({name: data.code for name, data in self.album_items.items()})
location_id_index = self.STARTING_CODE
for name in self.album_items.keys():
self.album_locations[f"{name}-0"] = location_id_index
self.album_locations[f"{name}-1"] = location_id_index + 1
location_id_index += 2
for name in self.song_items.keys():
self.song_locations[f"{name}-0"] = location_id_index
self.song_locations[f"{name}-1"] = location_id_index + 1
@@ -157,7 +90,7 @@ class MuseDashCollections:
for songKey, songData in self.song_items.items():
if not self.song_matches_dlc_filter(songData, dlc_songs):
continue
if songKey in self.REMOVED_SONGS:
continue
@@ -193,18 +126,3 @@ class MuseDashCollections:
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 == "¿":
return None
# 0 is used as a filler and no songs actually have a 0 difficulty song.
if difficulty == "0":
return None
# Curse the 2023 april fools update. Used on 3rd Avenue.
if difficulty == "":
return 10
return int(difficulty)