Skip to content

Commit

Permalink
Updated hidden block yaml option
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesbrq committed Apr 22, 2024
1 parent 5f3a1b1 commit 72ad9ea
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 16 deletions.
18 changes: 7 additions & 11 deletions worlds/mlss/Options.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,18 +194,15 @@ class RandomizeBackgrounds(Toggle):
display_name = "Randomize Battle Backgrounds"


class HiddenVisible(Toggle):
class HiddenVisible(Choice):
"""
This makes any hidden blocks in the game into regular item blocks.
"""
display_name = "Hidden Blocks Visible"


class BlocksInvisible(Toggle):
"""
Turns any item blocks in the game into hidden blocks.
"""
display_name = "Item Blocks Invisible"
display_name = "Item Block Visibility"
option_disabled = 0
option_hidden_visible = 1
option_blocks_invisible = 2
default = 0


class Coins(Toggle):
Expand Down Expand Up @@ -255,8 +252,7 @@ class MLSSOptions(PerGameCommonOptions):
skip_minecart: SkipMinecart
disable_surf: DisableSurf
harhalls_pants: HarhallsPants
hidden_visible: HiddenVisible
blocks_invisible: BlocksInvisible
block_visibility: HiddenVisible
chuckle_beans: ChuckleBeans
music_options: MusicOptions
randomize_sounds: RandomSounds
Expand Down
9 changes: 4 additions & 5 deletions worlds/mlss/Rom.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,17 +94,17 @@ def randomize_music(caller: APProcedurePatch, rom: bytes):
@staticmethod
def hidden_visible(caller: APProcedurePatch, rom: bytes):
options = json.loads(caller.get_file("options.json").decode("UTF-8"))
if options["hidden_visible"] == 0 and options["blocks_invisible"] == 0:
if options["block_visibility"] == 0:
return rom
stream = io.BytesIO(rom)

for location in all_locations:
stream.seek(location.id - 6)
b = stream.read(1)
if b[0] == 0x10 and options["hidden_visible"]:
if b[0] == 0x10 and options["block_visibility"] == 1:
stream.seek(location.id - 6)
stream.write(bytes([0x0]))
if b[0] == 0x0 and options["blocks_invisible"]:
if b[0] == 0x0 and options["block_visibility"] == 2:
stream.seek(location.id - 6)
stream.write(bytes([0x10]))

Expand Down Expand Up @@ -278,8 +278,7 @@ def write_tokens(world: "MLSSWorld", patch: MLSSProcedurePatch) -> None:
"castle_skip": world.options.castle_skip.value,
"randomize_sounds": world.options.randomize_sounds.value,
"music_options": world.options.music_options.value,
"hidden_visible": world.options.hidden_visible.value,
"blocks_invisible": world.options.blocks_invisible.value,
"block_visibility": world.options.block_visibility.value,
"seed": world.multiworld.seed,
"player": world.player
}
Expand Down

0 comments on commit 72ad9ea

Please sign in to comment.