Hylics 2: Update to new options API (#3147)

This commit is contained in:
Trevor L 2024-04-18 10:40:53 -06:00 committed by GitHub
parent 5996a8163d
commit c3060a8b66
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 43 additions and 34 deletions

View File

@ -1,4 +1,5 @@
from Options import Choice, Toggle, DefaultOnToggle, DeathLink from dataclasses import dataclass
from Options import Choice, Toggle, DefaultOnToggle, DeathLink, PerGameCommonOptions
class PartyShuffle(Toggle): class PartyShuffle(Toggle):
"""Shuffles party members into the pool. """Shuffles party members into the pool.
@ -31,11 +32,11 @@ class Hylics2DeathLink(DeathLink):
Note that this also includes death by using the PERISH gesture. Note that this also includes death by using the PERISH gesture.
Can be toggled via in-game console command "/deathlink".""" Can be toggled via in-game console command "/deathlink"."""
hylics2_options = { @dataclass
"party_shuffle": PartyShuffle, class Hylics2Options(PerGameCommonOptions):
"gesture_shuffle" : GestureShuffle, party_shuffle: PartyShuffle
"medallion_shuffle" : MedallionShuffle, gesture_shuffle: GestureShuffle
"random_start" : RandomStart, medallion_shuffle: MedallionShuffle
"extra_items_in_logic": ExtraLogic, random_start: RandomStart
"death_link": Hylics2DeathLink extra_items_in_logic: ExtraLogic
} death_link: Hylics2DeathLink

View File

@ -129,6 +129,12 @@ def set_rules(hylics2world):
world = hylics2world.multiworld world = hylics2world.multiworld
player = hylics2world.player player = hylics2world.player
extra = hylics2world.options.extra_items_in_logic
party = hylics2world.options.party_shuffle
medallion = hylics2world.options.medallion_shuffle
random_start = hylics2world.options.random_start
start_location = hylics2world.start_location
# Afterlife # Afterlife
add_rule(world.get_location("Afterlife: TV", player), add_rule(world.get_location("Afterlife: TV", player),
lambda state: cave_key(state, player)) lambda state: cave_key(state, player))
@ -346,7 +352,7 @@ def set_rules(hylics2world):
lambda state: upper_chamber_key(state, player)) lambda state: upper_chamber_key(state, player))
# extra rules if Extra Items in Logic is enabled # extra rules if Extra Items in Logic is enabled
if world.extra_items_in_logic[player]: if extra:
for i in world.get_region("Foglast", player).entrances: for i in world.get_region("Foglast", player).entrances:
add_rule(i, lambda state: charge_up(state, player)) add_rule(i, lambda state: charge_up(state, player))
for i in world.get_region("Sage Airship", player).entrances: for i in world.get_region("Sage Airship", player).entrances:
@ -368,7 +374,7 @@ def set_rules(hylics2world):
)) ))
# extra rules if Shuffle Party Members is enabled # extra rules if Shuffle Party Members is enabled
if world.party_shuffle[player]: if party:
for i in world.get_region("Arcade Island", player).entrances: for i in world.get_region("Arcade Island", player).entrances:
add_rule(i, lambda state: party_3(state, player)) add_rule(i, lambda state: party_3(state, player))
for i in world.get_region("Foglast", player).entrances: for i in world.get_region("Foglast", player).entrances:
@ -406,7 +412,7 @@ def set_rules(hylics2world):
lambda state: party_3(state, player)) lambda state: party_3(state, player))
# extra rules if Shuffle Red Medallions is enabled # extra rules if Shuffle Red Medallions is enabled
if world.medallion_shuffle[player]: if medallion:
add_rule(world.get_location("New Muldul: Upper House Medallion", player), add_rule(world.get_location("New Muldul: Upper House Medallion", player),
lambda state: upper_house_key(state, player)) lambda state: upper_house_key(state, player))
add_rule(world.get_location("New Muldul: Vault Rear Left Medallion", player), add_rule(world.get_location("New Muldul: Vault Rear Left Medallion", player),
@ -461,7 +467,7 @@ def set_rules(hylics2world):
lambda state: upper_chamber_key(state, player)) lambda state: upper_chamber_key(state, player))
# extra rules if Shuffle Red Medallions and Party Shuffle are enabled # extra rules if Shuffle Red Medallions and Party Shuffle are enabled
if world.party_shuffle[player] and world.medallion_shuffle[player]: if party and medallion:
add_rule(world.get_location("New Muldul: Vault Rear Left Medallion", player), add_rule(world.get_location("New Muldul: Vault Rear Left Medallion", player),
lambda state: party_3(state, player)) lambda state: party_3(state, player))
add_rule(world.get_location("New Muldul: Vault Rear Right Medallion", player), add_rule(world.get_location("New Muldul: Vault Rear Right Medallion", player),
@ -493,8 +499,7 @@ def set_rules(hylics2world):
add_rule(i, lambda state: enter_hylemxylem(state, player)) add_rule(i, lambda state: enter_hylemxylem(state, player))
# random start logic (default) # random start logic (default)
if ((not world.random_start[player]) or \ if not random_start or random_start and start_location == "Waynehouse":
(world.random_start[player] and hylics2world.start_location == "Waynehouse")):
# entrances # entrances
for i in world.get_region("Viewax", player).entrances: for i in world.get_region("Viewax", player).entrances:
add_rule(i, lambda state: ( add_rule(i, lambda state: (
@ -509,7 +514,7 @@ def set_rules(hylics2world):
add_rule(i, lambda state: airship(state, player)) add_rule(i, lambda state: airship(state, player))
# random start logic (Viewax's Edifice) # random start logic (Viewax's Edifice)
elif (world.random_start[player] and hylics2world.start_location == "Viewax's Edifice"): elif random_start and start_location == "Viewax's Edifice":
for i in world.get_region("Waynehouse", player).entrances: for i in world.get_region("Waynehouse", player).entrances:
add_rule(i, lambda state: ( add_rule(i, lambda state: (
air_dash(state, player) air_dash(state, player)
@ -540,7 +545,7 @@ def set_rules(hylics2world):
add_rule(i, lambda state: airship(state, player)) add_rule(i, lambda state: airship(state, player))
# random start logic (TV Island) # random start logic (TV Island)
elif (world.random_start[player] and hylics2world.start_location == "TV Island"): elif random_start and start_location == "TV Island":
for i in world.get_region("Waynehouse", player).entrances: for i in world.get_region("Waynehouse", player).entrances:
add_rule(i, lambda state: airship(state, player)) add_rule(i, lambda state: airship(state, player))
for i in world.get_region("New Muldul", player).entrances: for i in world.get_region("New Muldul", player).entrances:
@ -559,7 +564,7 @@ def set_rules(hylics2world):
add_rule(i, lambda state: airship(state, player)) add_rule(i, lambda state: airship(state, player))
# random start logic (Shield Facility) # random start logic (Shield Facility)
elif (world.random_start[player] and hylics2world.start_location == "Shield Facility"): elif random_start and start_location == "Shield Facility":
for i in world.get_region("Waynehouse", player).entrances: for i in world.get_region("Waynehouse", player).entrances:
add_rule(i, lambda state: airship(state, player)) add_rule(i, lambda state: airship(state, player))
for i in world.get_region("New Muldul", player).entrances: for i in world.get_region("New Muldul", player).entrances:

View File

@ -1,7 +1,8 @@
from typing import Dict, List, Any from typing import Dict, List, Any
from BaseClasses import Region, Entrance, Location, Item, Tutorial, ItemClassification from BaseClasses import Region, Entrance, Location, Item, Tutorial, ItemClassification
from worlds.generic.Rules import set_rule from worlds.generic.Rules import set_rule
from . import Exits, Items, Locations, Options, Rules from . import Exits, Items, Locations, Rules
from .Options import Hylics2Options
from worlds.AutoWorld import WebWorld, World from worlds.AutoWorld import WebWorld, World
@ -32,7 +33,9 @@ class Hylics2World(World):
item_name_to_id = {data["name"]: item_id for item_id, data in all_items.items()} item_name_to_id = {data["name"]: item_id for item_id, data in all_items.items()}
location_name_to_id = {data["name"]: loc_id for loc_id, data in all_locations.items()} location_name_to_id = {data["name"]: loc_id for loc_id, data in all_locations.items()}
option_definitions = Options.hylics2_options
options_dataclass = Hylics2Options
options: Hylics2Options
data_version = 3 data_version = 3
@ -55,7 +58,7 @@ class Hylics2World(World):
# set random starting location if option is enabled # set random starting location if option is enabled
def generate_early(self): def generate_early(self):
if self.multiworld.random_start[self.player]: if self.options.random_start:
i = self.random.randint(0, 3) i = self.random.randint(0, 3)
if i == 0: if i == 0:
self.start_location = "Waynehouse" self.start_location = "Waynehouse"
@ -77,17 +80,17 @@ class Hylics2World(World):
pool.append(self.create_item(item["name"])) pool.append(self.create_item(item["name"]))
# add party members if option is enabled # add party members if option is enabled
if self.multiworld.party_shuffle[self.player]: if self.options.party_shuffle:
for item in Items.party_item_table.values(): for item in Items.party_item_table.values():
pool.append(self.create_item(item["name"])) pool.append(self.create_item(item["name"]))
# handle gesture shuffle # handle gesture shuffle
if not self.multiworld.gesture_shuffle[self.player]: # add gestures to pool like normal if not self.options.gesture_shuffle: # add gestures to pool like normal
for item in Items.gesture_item_table.values(): for item in Items.gesture_item_table.values():
pool.append(self.create_item(item["name"])) pool.append(self.create_item(item["name"]))
# add '10 Bones' items if medallion shuffle is enabled # add '10 Bones' items if medallion shuffle is enabled
if self.multiworld.medallion_shuffle[self.player]: if self.options.medallion_shuffle:
for item in Items.medallion_item_table.values(): for item in Items.medallion_item_table.values():
for _ in range(item["count"]): for _ in range(item["count"]):
pool.append(self.create_item(item["name"])) pool.append(self.create_item(item["name"]))
@ -98,7 +101,7 @@ class Hylics2World(World):
def pre_fill(self): def pre_fill(self):
# handle gesture shuffle options # handle gesture shuffle options
if self.multiworld.gesture_shuffle[self.player] == 2: # vanilla locations if self.options.gesture_shuffle == 2: # vanilla locations
gestures = Items.gesture_item_table gestures = Items.gesture_item_table
self.multiworld.get_location("Waynehouse: TV", self.player)\ self.multiworld.get_location("Waynehouse: TV", self.player)\
.place_locked_item(self.create_item("POROMER BLEB")) .place_locked_item(self.create_item("POROMER BLEB"))
@ -119,13 +122,13 @@ class Hylics2World(World):
self.multiworld.get_location("Sage Airship: TV", self.player)\ self.multiworld.get_location("Sage Airship: TV", self.player)\
.place_locked_item(self.create_item("BOMBO - GENESIS")) .place_locked_item(self.create_item("BOMBO - GENESIS"))
elif self.multiworld.gesture_shuffle[self.player] == 1: # TVs only elif self.options.gesture_shuffle == 1: # TVs only
gestures = [gesture["name"] for gesture in Items.gesture_item_table.values()] gestures = [gesture["name"] for gesture in Items.gesture_item_table.values()]
tvs = [tv["name"] for tv in Locations.tv_location_table.values()] tvs = [tv["name"] for tv in Locations.tv_location_table.values()]
# if Extra Items in Logic is enabled place CHARGE UP first and make sure it doesn't get # if Extra Items in Logic is enabled place CHARGE UP first and make sure it doesn't get
# placed at Sage Airship: TV or Foglast: TV # placed at Sage Airship: TV or Foglast: TV
if self.multiworld.extra_items_in_logic[self.player]: if self.options.extra_items_in_logic:
tv = self.random.choice(tvs) tv = self.random.choice(tvs)
while tv == "Sage Airship: TV" or tv == "Foglast: TV": while tv == "Sage Airship: TV" or tv == "Foglast: TV":
tv = self.random.choice(tvs) tv = self.random.choice(tvs)
@ -144,11 +147,11 @@ class Hylics2World(World):
def fill_slot_data(self) -> Dict[str, Any]: def fill_slot_data(self) -> Dict[str, Any]:
slot_data: Dict[str, Any] = { slot_data: Dict[str, Any] = {
"party_shuffle": self.multiworld.party_shuffle[self.player].value, "party_shuffle": self.options.party_shuffle.value,
"medallion_shuffle": self.multiworld.medallion_shuffle[self.player].value, "medallion_shuffle": self.options.medallion_shuffle.value,
"random_start" : self.multiworld.random_start[self.player].value, "random_start" : self.options.random_start.value,
"start_location" : self.start_location, "start_location" : self.start_location,
"death_link": self.multiworld.death_link[self.player].value "death_link": self.options.death_link.value
} }
return slot_data return slot_data
@ -186,7 +189,7 @@ class Hylics2World(World):
# create entrance and connect it to parent and destination regions # create entrance and connect it to parent and destination regions
ent = Entrance(self.player, f"{reg.name} {k}", reg) ent = Entrance(self.player, f"{reg.name} {k}", reg)
reg.exits.append(ent) reg.exits.append(ent)
if k == "New Game" and self.multiworld.random_start[self.player]: if k == "New Game" and self.options.random_start:
if self.start_location == "Waynehouse": if self.start_location == "Waynehouse":
ent.connect(region_table[2]) ent.connect(region_table[2])
elif self.start_location == "Viewax's Edifice": elif self.start_location == "Viewax's Edifice":
@ -209,13 +212,13 @@ class Hylics2World(World):
.append(Hylics2Location(self.player, data["name"], i, region_table[data["region"]])) .append(Hylics2Location(self.player, data["name"], i, region_table[data["region"]]))
# add party member locations if option is enabled # add party member locations if option is enabled
if self.multiworld.party_shuffle[self.player]: if self.options.party_shuffle:
for i, data in Locations.party_location_table.items(): for i, data in Locations.party_location_table.items():
region_table[data["region"]].locations\ region_table[data["region"]].locations\
.append(Hylics2Location(self.player, data["name"], i, region_table[data["region"]])) .append(Hylics2Location(self.player, data["name"], i, region_table[data["region"]]))
# add medallion locations if option is enabled # add medallion locations if option is enabled
if self.multiworld.medallion_shuffle[self.player]: if self.options.medallion_shuffle:
for i, data in Locations.medallion_location_table.items(): for i, data in Locations.medallion_location_table.items():
region_table[data["region"]].locations\ region_table[data["region"]].locations\
.append(Hylics2Location(self.player, data["name"], i, region_table[data["region"]])) .append(Hylics2Location(self.player, data["name"], i, region_table[data["region"]]))