Muse Dash: Convert to Rule Builder (#6166)

---------

Co-authored-by: Silvris <58583688+Silvris@users.noreply.github.com>
This commit is contained in:
Justus Lind
2026-05-10 05:25:34 +10:00
committed by GitHub
parent 0cd81ff500
commit 4ef1fb7630
2 changed files with 74 additions and 4 deletions
+5 -4
View File
@@ -3,6 +3,7 @@ from BaseClasses import Region, Item, ItemClassification, Tutorial
from typing import List, ClassVar, Type, Set
from math import floor
from Options import PerGameCommonOptions, OptionError
from rule_builder.rules import Has
from .Options import MuseDashOptions, md_option_groups
from .Items import MuseDashSongItem, MuseDashFixedItem
@@ -293,17 +294,17 @@ class MuseDashWorld(World):
# Adds 2 item locations per song/album to the menu region.
for i in range(0, len(all_selected_locations)):
name = all_selected_locations[i]
rule = Has(name)
loc1 = MuseDashLocation(self.player, name + "-0", self.md_collection.song_locations[name + "-0"], menu_region)
loc1.access_rule = lambda state, place=name: state.has(place, self.player)
self.set_rule(loc1, rule)
menu_region.locations.append(loc1)
loc2 = MuseDashLocation(self.player, name + "-1", self.md_collection.song_locations[name + "-1"], menu_region)
loc2.access_rule = lambda state, place=name: state.has(place, self.player)
self.set_rule(loc2, rule)
menu_region.locations.append(loc2)
def set_rules(self) -> None:
self.multiworld.completion_condition[self.player] = lambda state: \
state.has(self.md_collection.MUSIC_SHEET_NAME, self.player, self.get_music_sheet_win_count())
self.set_completion_rule(Has(self.md_collection.MUSIC_SHEET_NAME, self.get_music_sheet_win_count()))
def get_available_traps(self) -> List[str]:
full_trap_list = self.md_collection.trap_items.keys()
+69
View File
@@ -0,0 +1,69 @@
from . import MuseDashTestBase
from typing import List
class LocationRules(MuseDashTestBase):
CHECK_SONGS: List[str] = [
"Magical Wonderland",
"Iyaiya",
"Wonderful Pain",
"Breaking Dawn",
"One-Way Subway",
"Frost Land",
"Heart-Pounding Flight",
"Pancake is Love",
"Shiguang Tuya",
"Evolution",
"Dolphin and Broadcast",
"Yuki no Shizuku Ame no Oto",
"Best One feat.tooko",
"Candy-coloured Love Theory",
"Night Wander",
"Dohna Dohna no Uta",
"Spring Carnival",
"DISCO NIGHT",
"Koi no Moonlight"
]
options = {
"starting_song_count": 3,
"additional_song_count": 15,
"streamer_mode_enabled": True,
"include_songs": CHECK_SONGS
}
def test_rules(self):
"""Due to me typoing the second rule of a location, this test exists to ensure that doesn't happen again"""
muse_dash_world = self.get_world()
for song in self.CHECK_SONGS:
if song == muse_dash_world.victory_song_name:
continue
if song in muse_dash_world.starting_songs:
self.assertTrue(self.can_reach_location(song + "-0"), f"Starting Location {song}-0 was not beatable.")
self.assertTrue(self.can_reach_location(song + "-1"), f"Starting Location {song}-1 was not beatable.")
continue
self.assertFalse(self.can_reach_location(song + "-0"), f"Location {song}-0 was unlocked without an item.")
self.assertFalse(self.can_reach_location(song + "-1"), f"Location {song}-1 was unlocked without an item.")
self.collect_by_name(song)
self.assertTrue(self.can_reach_location(song + "-0"), f"Location {song}-0 was not unlocked with its item.")
self.assertTrue(self.can_reach_location(song + "-1"), f"Location {song}-1 was not unlocked with its item.")
sheets = self.get_items_by_name("Music Sheet")
sheets_to_win = muse_dash_world.get_music_sheet_win_count()
for sheet in sheets:
if sheets_to_win <= 0:
break
self.assertBeatable(False)
self.collect(sheet)
sheets_to_win -= 1
self.assertBeatable(True)