Muse Dash: Make item_name_to_id and location_name_to_id ordering deterministic (#2086)
* Fix up non-deterministic order of item_name_to_id and location_name_to_id. * Remove debug line. * Change to use a Chainmap instead and simplify logic a bit. * Add the forgotten music sheet item.
This commit is contained in:
parent
d0c6eaf239
commit
3643b1de2c
|
@ -1,5 +1,6 @@
|
||||||
from .Items import SongData, AlbumData
|
from .Items import SongData, AlbumData
|
||||||
from typing import Dict, List, Optional
|
from typing import Dict, List, Optional
|
||||||
|
from collections import ChainMap
|
||||||
|
|
||||||
|
|
||||||
def load_text_file(name: str) -> str:
|
def load_text_file(name: str) -> str:
|
||||||
|
@ -10,6 +11,7 @@ def load_text_file(name: str) -> str:
|
||||||
class MuseDashCollections:
|
class MuseDashCollections:
|
||||||
"""Contains all the data of Muse Dash, loaded from MuseDashData.txt."""
|
"""Contains all the data of Muse Dash, loaded from MuseDashData.txt."""
|
||||||
|
|
||||||
|
MUSIC_SHEET_NAME: str = "Music Sheet"
|
||||||
MUSIC_SHEET_CODE: int
|
MUSIC_SHEET_CODE: int
|
||||||
|
|
||||||
FREE_ALBUMS = [
|
FREE_ALBUMS = [
|
||||||
|
@ -45,11 +47,15 @@ class MuseDashCollections:
|
||||||
"Error SFX Trap": 9,
|
"Error SFX Trap": 9,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
item_names_to_id = ChainMap({}, sfx_trap_items, vfx_trap_items)
|
||||||
|
location_names_to_id = ChainMap(song_locations, album_locations)
|
||||||
|
|
||||||
def __init__(self, start_item_id: int, items_per_location: int):
|
def __init__(self, start_item_id: int, items_per_location: int):
|
||||||
self.MUSIC_SHEET_CODE = start_item_id
|
self.MUSIC_SHEET_CODE = start_item_id
|
||||||
|
self.item_names_to_id[self.MUSIC_SHEET_NAME] = self.MUSIC_SHEET_CODE
|
||||||
|
|
||||||
self.vfx_trap_items = {k: (v + start_item_id) for (k, v) in self.vfx_trap_items.items()}
|
self.vfx_trap_items.update({k: (v + start_item_id) for (k, v) in self.vfx_trap_items.items()})
|
||||||
self.sfx_trap_items = {k: (v + start_item_id) for (k, v) in self.sfx_trap_items.items()}
|
self.sfx_trap_items.update({k: (v + start_item_id) for (k, v) in self.sfx_trap_items.items()})
|
||||||
|
|
||||||
item_id_index = start_item_id + 50
|
item_id_index = start_item_id + 50
|
||||||
location_id_index = start_item_id
|
location_id_index = start_item_id
|
||||||
|
@ -85,6 +91,9 @@ class MuseDashCollections:
|
||||||
diff_of_easy, diff_of_hard, diff_of_master)
|
diff_of_easy, diff_of_hard, diff_of_master)
|
||||||
item_id_index += 1
|
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()})
|
||||||
|
|
||||||
for name in self.album_items.keys():
|
for name in self.album_items.keys():
|
||||||
for i in range(0, items_per_location):
|
for i in range(0, items_per_location):
|
||||||
new_name = f"{name}-{i}"
|
new_name = f"{name}-{i}"
|
||||||
|
|
|
@ -40,24 +40,14 @@ class MuseDashWorld(World):
|
||||||
game = "Muse Dash"
|
game = "Muse Dash"
|
||||||
option_definitions = musedash_options
|
option_definitions = musedash_options
|
||||||
topology_present = False
|
topology_present = False
|
||||||
data_version = 7
|
data_version = 8
|
||||||
web = MuseDashWebWorld()
|
web = MuseDashWebWorld()
|
||||||
|
|
||||||
music_sheet_name: str = "Music Sheet"
|
|
||||||
|
|
||||||
# Necessary Data
|
# Necessary Data
|
||||||
md_collection = MuseDashCollections(2900000, 2)
|
md_collection = MuseDashCollections(2900000, 2)
|
||||||
|
|
||||||
item_name_to_id = {
|
item_name_to_id = md_collection.item_names_to_id
|
||||||
name: data.code for name, data in md_collection.album_items.items() | md_collection.song_items.items()
|
location_name_to_id = md_collection.location_names_to_id
|
||||||
}
|
|
||||||
item_name_to_id[music_sheet_name] = md_collection.MUSIC_SHEET_CODE
|
|
||||||
for item in md_collection.sfx_trap_items.items() | md_collection.vfx_trap_items.items():
|
|
||||||
item_name_to_id[item[0]] = item[1]
|
|
||||||
|
|
||||||
location_name_to_id = {
|
|
||||||
name: id for name, id in md_collection.album_locations.items() | md_collection.song_locations.items()
|
|
||||||
}
|
|
||||||
|
|
||||||
# Working Data
|
# Working Data
|
||||||
victory_song_name: str = ""
|
victory_song_name: str = ""
|
||||||
|
@ -165,7 +155,7 @@ class MuseDashWorld(World):
|
||||||
self.location_count = minimum_location_count
|
self.location_count = minimum_location_count
|
||||||
|
|
||||||
def create_item(self, name: str) -> Item:
|
def create_item(self, name: str) -> Item:
|
||||||
if name == self.music_sheet_name:
|
if name == self.md_collection.MUSIC_SHEET_NAME:
|
||||||
return MuseDashFixedItem(name, ItemClassification.progression_skip_balancing,
|
return MuseDashFixedItem(name, ItemClassification.progression_skip_balancing,
|
||||||
self.md_collection.MUSIC_SHEET_CODE, self.player)
|
self.md_collection.MUSIC_SHEET_CODE, self.player)
|
||||||
|
|
||||||
|
@ -191,7 +181,7 @@ class MuseDashWorld(World):
|
||||||
|
|
||||||
# First add all goal song tokens
|
# First add all goal song tokens
|
||||||
for _ in range(0, item_count):
|
for _ in range(0, item_count):
|
||||||
self.multiworld.itempool.append(self.create_item(self.music_sheet_name))
|
self.multiworld.itempool.append(self.create_item(self.md_collection.MUSIC_SHEET_NAME))
|
||||||
|
|
||||||
# Then add all traps
|
# Then add all traps
|
||||||
trap_count = self.get_trap_count()
|
trap_count = self.get_trap_count()
|
||||||
|
@ -255,7 +245,7 @@ class MuseDashWorld(World):
|
||||||
|
|
||||||
def set_rules(self) -> None:
|
def set_rules(self) -> None:
|
||||||
self.multiworld.completion_condition[self.player] = lambda state: \
|
self.multiworld.completion_condition[self.player] = lambda state: \
|
||||||
state.has(self.music_sheet_name, self.player, self.get_music_sheet_win_count())
|
state.has(self.md_collection.MUSIC_SHEET_NAME, self.player, self.get_music_sheet_win_count())
|
||||||
|
|
||||||
def get_available_traps(self) -> List[str]:
|
def get_available_traps(self) -> List[str]:
|
||||||
dlc_songs = self.multiworld.allow_just_as_planned_dlc_songs[self.player]
|
dlc_songs = self.multiworld.allow_just_as_planned_dlc_songs[self.player]
|
||||||
|
|
Loading…
Reference in New Issue