Skip to content

Commit

Permalink
Merge branch 'main' into ts_new_options_api
Browse files Browse the repository at this point in the history
  • Loading branch information
Jarno458 authored Jun 11, 2024
2 parents ee41c6d + 54531c6 commit 73ca328
Show file tree
Hide file tree
Showing 11 changed files with 64 additions and 64 deletions.
8 changes: 4 additions & 4 deletions AdventureClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def __init__(self, server_address, password):
self.local_item_locations = {}
self.dragon_speed_info = {}

options = Utils.get_options()
options = Utils.get_settings()
self.display_msgs = options["adventure_options"]["display_msgs"]

async def server_auth(self, password_requested: bool = False):
Expand All @@ -102,7 +102,7 @@ def _set_message(self, msg: str, msg_id: int):
def on_package(self, cmd: str, args: dict):
if cmd == 'Connected':
self.locations_array = None
if Utils.get_options()["adventure_options"].get("death_link", False):
if Utils.get_settings()["adventure_options"].get("death_link", False):
self.set_deathlink = True
async_start(self.get_freeincarnates_used())
elif cmd == "RoomInfo":
Expand Down Expand Up @@ -415,8 +415,8 @@ async def atari_sync_task(ctx: AdventureContext):


async def run_game(romfile):
auto_start = Utils.get_options()["adventure_options"].get("rom_start", True)
rom_args = Utils.get_options()["adventure_options"].get("rom_args")
auto_start = Utils.get_settings()["adventure_options"].get("rom_start", True)
rom_args = Utils.get_settings()["adventure_options"].get("rom_args")
if auto_start is True:
import webbrowser
webbrowser.open(romfile)
Expand Down
2 changes: 1 addition & 1 deletion docs/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
/worlds/heretic/ @Daivuk

# Hollow Knight
/worlds/hk/ @BadMagic100 @ThePhar
/worlds/hk/ @BadMagic100 @qwint

# Hylics 2
/worlds/hylics2/ @TRPG0
Expand Down
39 changes: 20 additions & 19 deletions worlds/adventure/Options.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

from typing import Dict

from Options import Choice, Option, DefaultOnToggle, DeathLink, Range, Toggle
from dataclasses import dataclass
from Options import Choice, Option, DefaultOnToggle, DeathLink, Range, Toggle, PerGameCommonOptions


class FreeincarnateMax(Range):
Expand Down Expand Up @@ -223,22 +224,22 @@ class StartCastle(Choice):
option_white = 2
default = option_yellow

@dataclass
class AdventureOptions(PerGameCommonOptions):
dragon_slay_check: DragonSlayCheck
death_link: DeathLink
bat_logic: BatLogic
freeincarnate_max: FreeincarnateMax
dragon_rando_type: DragonRandoType
connector_multi_slot: ConnectorMultiSlot
yorgle_speed: YorgleStartingSpeed
yorgle_min_speed: YorgleMinimumSpeed
grundle_speed: GrundleStartingSpeed
grundle_min_speed: GrundleMinimumSpeed
rhindle_speed: RhindleStartingSpeed
rhindle_min_speed: RhindleMinimumSpeed
difficulty_switch_a: DifficultySwitchA
difficulty_switch_b: DifficultySwitchB
start_castle: StartCastle


adventure_option_definitions: Dict[str, type(Option)] = {
"dragon_slay_check": DragonSlayCheck,
"death_link": DeathLink,
"bat_logic": BatLogic,
"freeincarnate_max": FreeincarnateMax,
"dragon_rando_type": DragonRandoType,
"connector_multi_slot": ConnectorMultiSlot,
"yorgle_speed": YorgleStartingSpeed,
"yorgle_min_speed": YorgleMinimumSpeed,
"grundle_speed": GrundleStartingSpeed,
"grundle_min_speed": GrundleMinimumSpeed,
"rhindle_speed": RhindleStartingSpeed,
"rhindle_min_speed": RhindleMinimumSpeed,
"difficulty_switch_a": DifficultySwitchA,
"difficulty_switch_b": DifficultySwitchB,
"start_castle": StartCastle,

}
5 changes: 3 additions & 2 deletions worlds/adventure/Regions.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from BaseClasses import MultiWorld, Region, Entrance, LocationProgressType
from Options import PerGameCommonOptions
from .Locations import location_table, LocationData, AdventureLocation, dragon_room_to_region


Expand All @@ -24,7 +25,7 @@ def connect(world: MultiWorld, player: int, source: str, target: str, rule: call
connect(world, player, target, source, rule, True)


def create_regions(multiworld: MultiWorld, player: int, dragon_rooms: []) -> None:
def create_regions(options: PerGameCommonOptions, multiworld: MultiWorld, player: int, dragon_rooms: []) -> None:

menu = Region("Menu", player, multiworld)

Expand Down Expand Up @@ -74,7 +75,7 @@ def create_regions(multiworld: MultiWorld, player: int, dragon_rooms: []) -> Non
credits_room_far_side.exits.append(Entrance(player, "CreditsFromFarSide", credits_room_far_side))
multiworld.regions.append(credits_room_far_side)

dragon_slay_check = multiworld.dragon_slay_check[player].value
dragon_slay_check = options.dragon_slay_check.value
priority_locations = determine_priority_locations(multiworld, dragon_slay_check)

for name, location_data in location_table.items():
Expand Down
4 changes: 2 additions & 2 deletions worlds/adventure/Rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

def set_rules(self) -> None:
world = self.multiworld
use_bat_logic = world.bat_logic[self.player].value == BatLogic.option_use_logic
use_bat_logic = self.options.bat_logic.value == BatLogic.option_use_logic

set_rule(world.get_entrance("YellowCastlePort", self.player),
lambda state: state.has("Yellow Key", self.player))
Expand All @@ -28,7 +28,7 @@ def set_rules(self) -> None:
lambda state: state.has("Bridge", self.player) or
state.has("Magnet", self.player))

dragon_slay_check = world.dragon_slay_check[self.player].value
dragon_slay_check = self.options.dragon_slay_check.value
if dragon_slay_check:
if self.difficulty_switch_b == DifficultySwitchB.option_hard_with_unlock_item:
set_rule(world.get_location("Slay Yorgle", self.player),
Expand Down
37 changes: 19 additions & 18 deletions worlds/adventure/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
from worlds.AutoWorld import WebWorld, World
from Fill import fill_restrictive
from worlds.generic.Rules import add_rule, set_rule
from .Options import adventure_option_definitions, DragonRandoType, DifficultySwitchA, DifficultySwitchB
from .Options import DragonRandoType, DifficultySwitchA, DifficultySwitchB, \
AdventureOptions
from .Rom import get_base_rom_bytes, get_base_rom_path, AdventureDeltaPatch, apply_basepatch, \
AdventureAutoCollectLocation
from .Items import item_table, ItemData, nothing_item_id, event_table, AdventureItem, standard_item_max
Expand Down Expand Up @@ -109,7 +110,7 @@ class AdventureWorld(World):
game: ClassVar[str] = "Adventure"
web: ClassVar[WebWorld] = AdventureWeb()

option_definitions: ClassVar[Dict[str, AssembleOptions]] = adventure_option_definitions
options_dataclass = AdventureOptions
settings: ClassVar[AdventureSettings]
item_name_to_id: ClassVar[Dict[str, int]] = {name: data.id for name, data in item_table.items()}
location_name_to_id: ClassVar[Dict[str, int]] = {name: data.location_id for name, data in location_table.items()}
Expand Down Expand Up @@ -149,18 +150,18 @@ def generate_early(self) -> None:
bytearray(f"ADVENTURE{__version__.replace('.', '')[:3]}_{self.player}_{self.multiworld.seed}", "utf8")[:21]
self.rom_name.extend([0] * (21 - len(self.rom_name)))

self.dragon_rando_type = self.multiworld.dragon_rando_type[self.player].value
self.dragon_slay_check = self.multiworld.dragon_slay_check[self.player].value
self.connector_multi_slot = self.multiworld.connector_multi_slot[self.player].value
self.yorgle_speed = self.multiworld.yorgle_speed[self.player].value
self.yorgle_min_speed = self.multiworld.yorgle_min_speed[self.player].value
self.grundle_speed = self.multiworld.grundle_speed[self.player].value
self.grundle_min_speed = self.multiworld.grundle_min_speed[self.player].value
self.rhindle_speed = self.multiworld.rhindle_speed[self.player].value
self.rhindle_min_speed = self.multiworld.rhindle_min_speed[self.player].value
self.difficulty_switch_a = self.multiworld.difficulty_switch_a[self.player].value
self.difficulty_switch_b = self.multiworld.difficulty_switch_b[self.player].value
self.start_castle = self.multiworld.start_castle[self.player].value
self.dragon_rando_type = self.options.dragon_rando_type.value
self.dragon_slay_check = self.options.dragon_slay_check.value
self.connector_multi_slot = self.options.connector_multi_slot.value
self.yorgle_speed = self.options.yorgle_speed.value
self.yorgle_min_speed = self.options.yorgle_min_speed.value
self.grundle_speed = self.options.grundle_speed.value
self.grundle_min_speed = self.options.grundle_min_speed.value
self.rhindle_speed = self.options.rhindle_speed.value
self.rhindle_min_speed = self.options.rhindle_min_speed.value
self.difficulty_switch_a = self.options.difficulty_switch_a.value
self.difficulty_switch_b = self.options.difficulty_switch_b.value
self.start_castle = self.options.start_castle.value
self.created_items = 0

if self.dragon_slay_check == 0:
Expand Down Expand Up @@ -227,7 +228,7 @@ def create_items(self) -> None:
extra_filler_count = num_locations - self.created_items

# traps would probably go here, if enabled
freeincarnate_max = self.multiworld.freeincarnate_max[self.player].value
freeincarnate_max = self.options.freeincarnate_max.value
actual_freeincarnates = min(extra_filler_count, freeincarnate_max)
self.multiworld.itempool += [self.create_item("Freeincarnate") for _ in range(actual_freeincarnates)]
self.created_items += actual_freeincarnates
Expand All @@ -247,7 +248,7 @@ def create_dragon_slow_items(self, min_speed: int, speed: int, item_name: str, m
self.created_items += 1

def create_regions(self) -> None:
create_regions(self.multiworld, self.player, self.dragon_rooms)
create_regions(self.options, self.multiworld, self.player, self.dragon_rooms)

set_rules = set_rules

Expand Down Expand Up @@ -354,7 +355,7 @@ def generate_output(self, output_directory: str) -> None:
auto_collect_locations: [AdventureAutoCollectLocation] = []
local_item_to_location: {int, int} = {}
bat_no_touch_locs: [LocationData] = []
bat_logic: int = self.multiworld.bat_logic[self.player].value
bat_logic: int = self.options.bat_logic.value
try:
rom_deltas: { int, int } = {}
self.place_dragons(rom_deltas)
Expand Down Expand Up @@ -421,7 +422,7 @@ def generate_output(self, output_directory: str) -> None:
item_position_data_start = get_item_position_data_start(unplaced_item.table_index)
rom_deltas[item_position_data_start] = 0xff

if self.multiworld.connector_multi_slot[self.player].value:
if self.options.connector_multi_slot.value:
rom_deltas[connector_port_offset] = (self.player & 0xff)
else:
rom_deltas[connector_port_offset] = 0
Expand Down
2 changes: 1 addition & 1 deletion worlds/messenger/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from Options import Accessibility, Choice, DeathLinkMixin, DefaultOnToggle, OptionDict, PerGameCommonOptions, \
PlandoConnections, Range, StartInventoryPool, Toggle, Visibility
from worlds.messenger.portals import CHECKPOINTS, PORTALS, SHOP_POINTS
from .portals import CHECKPOINTS, PORTALS, SHOP_POINTS


class MessengerAccessibility(Accessibility):
Expand Down
22 changes: 9 additions & 13 deletions worlds/musedash/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,9 +249,7 @@ def create_items(self) -> None:

def create_regions(self) -> None:
menu_region = Region("Menu", self.player, self.multiworld)
song_select_region = Region("Song Select", self.player, self.multiworld)
self.multiworld.regions += [menu_region, song_select_region]
menu_region.connect(song_select_region)
self.multiworld.regions += [menu_region]

# Make a collection of all songs available for this rando.
# 1. All starting songs
Expand All @@ -265,18 +263,16 @@ def create_regions(self) -> None:
self.random.shuffle(included_song_copy)
all_selected_locations.extend(included_song_copy)

# Make a region per song/album, then adds 1-2 item locations to them
# 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]
region = Region(name, self.player, self.multiworld)
self.multiworld.regions.append(region)
song_select_region.connect(region, name, lambda state, place=name: state.has(place, self.player))

# Muse Dash requires 2 locations per song to be *interesting*. Balanced out by filler.
region.add_locations({
name + "-0": self.md_collection.song_locations[name + "-0"],
name + "-1": self.md_collection.song_locations[name + "-1"]
}, MuseDashLocation)
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)
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)
menu_region.locations.append(loc2)

def set_rules(self) -> None:
self.multiworld.completion_condition[self.player] = lambda state: \
Expand Down
3 changes: 2 additions & 1 deletion worlds/shorthike/Rules.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from worlds.generic.Rules import forbid_items_for_player, add_rule
from worlds.shorthike.Options import Goal, GoldenFeatherProgression, MinShopCheckLogic, ShopCheckLogic
from .Options import Goal, GoldenFeatherProgression, MinShopCheckLogic, ShopCheckLogic


def create_rules(self, location_table):
multiworld = self.multiworld
Expand Down
2 changes: 1 addition & 1 deletion worlds/yugioh06/client_bh.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import worlds._bizhawk as bizhawk
from worlds._bizhawk.client import BizHawkClient
from worlds.yugioh06 import item_to_index
from . import item_to_index

if TYPE_CHECKING:
from worlds._bizhawk.context import BizHawkClientContext
Expand Down
4 changes: 2 additions & 2 deletions worlds/yugioh06/opponents.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
from BaseClasses import MultiWorld
from worlds.generic.Rules import CollectionRule

from worlds.yugioh06 import item_to_index, tier_1_opponents, yugioh06_difficulty
from worlds.yugioh06.locations import special
from . import item_to_index, tier_1_opponents, yugioh06_difficulty
from .locations import special


class OpponentData(NamedTuple):
Expand Down

0 comments on commit 73ca328

Please sign in to comment.