Skip to content

Commit 37cc13d

Browse files
committed
Implemented the new FieldResolvers
1 parent 6fd0666 commit 37cc13d

12 files changed

Lines changed: 346 additions & 436 deletions

File tree

rule_builder/rules.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1353,7 +1353,7 @@ class HasFromList(Rule[TWorld], game="Archipelago"):
13531353
def __init__(
13541354
self,
13551355
*item_names: str,
1356-
count: int = 1,
1356+
count: int | FieldResolver = 1,
13571357
options: Iterable[OptionFilter] = (),
13581358
filtered_resolution: bool = False,
13591359
) -> None:
@@ -1487,7 +1487,7 @@ class HasFromListUnique(Rule[TWorld], game="Archipelago"):
14871487
def __init__(
14881488
self,
14891489
*item_names: str,
1490-
count: int = 1,
1490+
count: int | FieldResolver = 1,
14911491
options: Iterable[OptionFilter] = (),
14921492
filtered_resolution: bool = False,
14931493
) -> None:

worlds/tloz_oos/Options.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ class OracleOfSeasonsRemoveD2AltEntrance(Toggle):
369369
include_in_slot_data = True
370370

371371

372-
class OraclesOfSeasonsTreehouseOldManRequirement(Range):
372+
class OracleOfSeasonsTreehouseOldManRequirement(Range):
373373
"""
374374
The amount of essences that you need to bring to the treehouse old man for him to give his item.
375375
"""
@@ -383,7 +383,7 @@ class OraclesOfSeasonsTreehouseOldManRequirement(Range):
383383
include_in_slot_data = True
384384

385385

386-
class OraclesOfSeasonsTarmGateRequirement(Range):
386+
class OracleOfSeasonsTarmGateRequirement(Range):
387387
"""
388388
The number of jewels that you need to bring to Tarm Ruins gate to be able to open it.
389389
"""
@@ -397,7 +397,7 @@ class OraclesOfSeasonsTarmGateRequirement(Range):
397397
include_in_slot_data = True
398398

399399

400-
class OraclesOfSeasonsGoldenBeastsRequirement(Range):
400+
class OracleOfSeasonsGoldenBeastsRequirement(Range):
401401
"""
402402
The amount of golden beasts that need to be beaten for the golden old man to give his item.
403403
Golden beasts are 4 unique enemies that appear at specific spots on specific seasons, and beating all four of them
@@ -803,9 +803,9 @@ class OracleOfSeasonsOptions(PerGameCommonOptions):
803803
starting_maps_compasses: OracleOfSeasonsStartingMapsCompasses
804804

805805
# Numeric requirements for some checks / access to regions
806-
treehouse_old_man_requirement: OraclesOfSeasonsTreehouseOldManRequirement
807-
tarm_gate_required_jewels: OraclesOfSeasonsTarmGateRequirement
808-
golden_beasts_requirement: OraclesOfSeasonsGoldenBeastsRequirement
806+
treehouse_old_man_requirement: OracleOfSeasonsTreehouseOldManRequirement
807+
tarm_gate_required_jewels: OracleOfSeasonsTarmGateRequirement
808+
golden_beasts_requirement: OracleOfSeasonsGoldenBeastsRequirement
809809
sign_guy_requirement: OracleOfSeasonsSignGuyRequirement
810810
gasha_nut_kill_requirement: OracleOfSeasonsGashaNutKillRequirement
811811

@@ -884,9 +884,9 @@ class OracleOfSeasonsOptions(PerGameCommonOptions):
884884
OracleOfSeasonsStartingMapsCompasses
885885
]),
886886
OptionGroup("Numeric Requirements", [
887-
OraclesOfSeasonsTreehouseOldManRequirement,
888-
OraclesOfSeasonsTarmGateRequirement,
889-
OraclesOfSeasonsGoldenBeastsRequirement,
887+
OracleOfSeasonsTreehouseOldManRequirement,
888+
OracleOfSeasonsTarmGateRequirement,
889+
OracleOfSeasonsGoldenBeastsRequirement,
890890
OracleOfSeasonsSignGuyRequirement,
891891
OracleOfSeasonsGashaNutKillRequirement,
892892
]),

worlds/tloz_oos/data/Constants.py

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@
204204
"subrosianMarket3": 40,
205205
"subrosianMarket4": 50,
206206
"subrosianMarket5": 60,
207+
"subrosianMarket": 180,
207208
"spoolSwampScrub": 100,
208209
"samasaCaveScrub": 100,
209210
"d2Scrub": 30,
@@ -439,25 +440,6 @@
439440
]
440441
}
441442

442-
GASHA_SPOT_REGIONS = [
443-
"impa gasha spot",
444-
"horon gasha spot",
445-
"suburbs gasha spot",
446-
"holodrum plain gasha spot",
447-
"holodrum plain island gasha spot",
448-
"spool swamp north gasha spot",
449-
"spool swamp south gasha spot",
450-
"sunken city gasha spot",
451-
"mt cucco gasha spot",
452-
"goron mountain left gasha spot",
453-
"goron mountain right gasha spot",
454-
"eyeglass lake gasha spot",
455-
"tarm ruins gasha spot",
456-
"western coast gasha spot",
457-
"samasa desert gasha spot",
458-
"onox gasha spot",
459-
]
460-
461443
TREASURE_SPAWN_INSTANT = 0x00
462444
TREASURE_SPAWN_POOF = 0x10
463445
TREASURE_SPAWN_DROP = 0x20

worlds/tloz_oos/data/Regions.py

Lines changed: 33 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,39 @@
4646
"d11 floor 5 boomerang maze",
4747
"d11 final chest"
4848
]
49-
49+
SCRUB_REGIONS = [
50+
"spool swamp scrub",
51+
"samasa desert scrub",
52+
"d2 scrub",
53+
"d4 scrub",
54+
]
55+
GASHA_SPOT_REGIONS = [
56+
"impa gasha spot",
57+
"horon gasha spot",
58+
"suburbs gasha spot",
59+
"holodrum plain gasha spot",
60+
"holodrum plain island gasha spot",
61+
"spool swamp north gasha spot",
62+
"spool swamp south gasha spot",
63+
"sunken city gasha spot",
64+
"mt cucco gasha spot",
65+
"goron mountain left gasha spot",
66+
"goron mountain right gasha spot",
67+
"eyeglass lake gasha spot",
68+
"tarm ruins gasha spot",
69+
"western coast gasha spot",
70+
"samasa desert gasha spot",
71+
"onox gasha spot",
72+
]
73+
SECRET_REGIONS = [
74+
"clock shop secret",
75+
"graveyard secret",
76+
"subrosian secret",
77+
"diver secret",
78+
"smith secret",
79+
"natzu deku",
80+
"deku secret"
81+
]
5082
REGIONS = [
5183
"impa's house",
5284
"horon village",
@@ -55,7 +87,6 @@
5587
"horon village SE chest",
5688
"horon village SW chest",
5789
"horon heart piece",
58-
"advance shop",
5990
"dr. left reward",
6091
"old man trade",
6192
"malon trade",
@@ -130,7 +161,6 @@
130161
"spool swamp tree",
131162
"floodgate keeper's house",
132163
"floodgate keyhole",
133-
"spool swamp scrub",
134164
"spool stump",
135165
"d3 entrance",
136166
"d1 island",
@@ -183,7 +213,6 @@
183213
"samasa desert",
184214
"samasa desert pit",
185215
"samasa desert chest",
186-
"samasa desert scrub",
187216
"temple remains lower stump",
188217
"temple remains upper stump",
189218
"temple remains lower portal",
@@ -258,7 +287,6 @@
258287
"d2 rope chest",
259288
"d2 blade chest",
260289
"d2 alt entrances",
261-
"d2 scrub",
262290
"d2 roller chest",
263291
"d2 spiral chest",
264292
"d2 spinner",
@@ -297,7 +325,6 @@
297325
"greater distance owl",
298326
"d4 stalfos stairs",
299327
"d4 terrace",
300-
"d4 scrub",
301328
"d4 miniboss room",
302329
"d4 final minecart",
303330
"d4 torch chest",
@@ -414,29 +441,4 @@
414441
"subrosia market digging spot",
415442
"subrosia temple digging spot",
416443
"subrosia bridge digging spot",
417-
418-
"impa gasha spot",
419-
"horon gasha spot",
420-
"suburbs gasha spot",
421-
"holodrum plain gasha spot",
422-
"holodrum plain island gasha spot",
423-
"spool swamp north gasha spot",
424-
"spool swamp south gasha spot",
425-
"sunken city gasha spot",
426-
"mt cucco gasha spot",
427-
"goron mountain left gasha spot",
428-
"goron mountain right gasha spot",
429-
"eyeglass lake gasha spot",
430-
"tarm ruins gasha spot",
431-
"western coast gasha spot",
432-
"samasa desert gasha spot",
433-
"onox gasha spot",
434-
435-
"clock shop secret",
436-
"graveyard secret",
437-
"subrosian secret",
438-
"diver secret",
439-
"smith secret",
440-
"natzu deku",
441-
"deku secret"
442444
]

worlds/tloz_oos/data/logic/DungeonsLogic.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def make_d1_logic():
8888
]
8989

9090

91-
def make_d2_logic():
91+
def make_d2_logic(options: OracleOfSeasonsOptions):
9292
return [
9393
# 0 keys
9494
["enter d2", "d2 torch room", True, None],
@@ -125,7 +125,7 @@ def make_d2_logic():
125125
)
126126
)
127127
)],
128-
["d2 alt entrances", "d2 scrub", False, oos_has_rupees_for_shop("d2Scrub")],
128+
["d2 alt entrances", "d2 scrub", False, oos_has_rupees_for_shop("d2Scrub"), options.shuffle_business_scrubs],
129129

130130
# 2 keys
131131
["d2 roller chest", "d2 spinner", False, And(
@@ -255,7 +255,7 @@ def make_d3_logic():
255255
]
256256

257257

258-
def make_d4_logic():
258+
def make_d4_logic(options: OracleOfSeasonsOptions):
259259
return [
260260
# 0 keys
261261
["enter d4", "d4 north of entrance", False, Or(
@@ -362,7 +362,7 @@ def make_d4_logic():
362362
)],
363363

364364
["d4 stalfos stairs", "d4 terrace", False, None],
365-
["d4 terrace", "d4 scrub", False, oos_has_rupees_for_shop("d4Scrub")],
365+
["d4 terrace", "d4 scrub", False, oos_has_rupees_for_shop("d4Scrub"), options.shuffle_business_scrubs],
366366

367367
["d4 stalfos stairs", "d4 torch chest", False, And(
368368
oos_has_seed_thrower(),

worlds/tloz_oos/data/logic/LogicPredicates.py

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1-
from rule_builder.rules import And, Or, CanReachRegion
1+
from rule_builder.field_resolvers import FromOption
2+
from rule_builder.rules import And, Or, CanReachRegion, AtLeast
23
from .Rulebuilder import *
34
from ..Constants import *
5+
from ..Regions import GASHA_SPOT_REGIONS
46
from ...Options import OracleOfSeasonsLogicDifficulty, OracleOfSeasonsDefaultSeedType, OracleOfSeasonsMasterKeys, OracleOfSeasonsDungeonShuffle, \
57
OracleOfSeasonsRemoveD0AltEntrance, OracleOfSeasonsRemoveD2AltEntrance, OracleOfSeasonsAnimalCompanion, OracleOfSeasonsLostWoodsItemSequence, \
6-
OracleOfSeasonsLostWoodsMainSequence, OracleOfSeasonsHoronSeason
8+
OracleOfSeasonsLostWoodsMainSequence, OracleOfSeasonsHoronSeason, OracleOfSeasonsRequiredEssences, OracleOfSeasonsTreehouseOldManRequirement, \
9+
OracleOfSeasonsTarmGateRequirement, OracleOfSeasonsGoldenBeastsRequirement
710

811

912
# Items predicates ############################################################
@@ -225,7 +228,7 @@ def oos_is_companion_dimitri() -> Rule:
225228

226229

227230
def oos_is_default_season(area_name: str, season: int, is_season: bool = True) -> Rule:
228-
return Season(area_name, season, is_season)
231+
return from_world_field(f"default_seasons.{area_name}", season, "eq" if is_season else "ne")
229232

230233

231234
def oos_can_remove_season(season: int) -> Rule:
@@ -240,15 +243,15 @@ def oos_has_essences(target_count: int) -> Rule:
240243

241244

242245
def oos_has_essences_for_maku_seed() -> Rule:
243-
return HasGroupOption("Essences", "required_essences")
246+
return HasGroup("Essences", FromOption(OracleOfSeasonsRequiredEssences))
244247

245248

246249
def oos_has_essences_for_treehouse() -> Rule:
247-
return HasGroupOption("Essences", "treehouse_old_man_requirement")
250+
return HasGroup("Essences", FromOption(OracleOfSeasonsTreehouseOldManRequirement))
248251

249252

250253
def oos_has_required_jewels() -> Rule:
251-
return HasGroupOption("Jewels", "tarm_gate_required_jewels")
254+
return HasGroup("Jewels", FromOption(OracleOfSeasonsTarmGateRequirement))
252255

253256

254257
def oos_can_reach_lost_woods_pedestal(allow_default: bool = False) -> Rule:
@@ -280,14 +283,14 @@ def oos_can_complete_lost_woods_main_sequence(allow_default: bool = False) -> Ru
280283

281284

282285
def oos_can_beat_required_golden_beasts() -> Rule:
283-
return HasFromListOption("_beat_golden_darknut", "_beat_golden_lynel", "_beat_golden_moblin", "_beat_golden_octorok",
284-
option_name="golden_beasts_requirement")
286+
return HasFromList("_beat_golden_darknut", "_beat_golden_lynel", "_beat_golden_moblin", "_beat_golden_octorok",
287+
count=FromOption(OracleOfSeasonsGoldenBeastsRequirement))
285288

286289

287290
def oos_can_complete_d11_puzzle() -> Rule:
288291
return Or(
289292
from_option(OracleOfSeasonsDungeonShuffle, OracleOfSeasonsDungeonShuffle.option_false),
290-
CanReachNumRegions([f"enter d{i}" for i in range(1, 9)], 7) # And then deduce the last
293+
AtLeast(7, *[CanReachRegion(f"enter d{i}") for i in range(1, 9)]) # And then deduce the last
291294
)
292295

293296

@@ -298,7 +301,11 @@ def oos_has_rupees_for_shop(shop_name: str) -> Rule:
298301
oos_option_hard_logic(),
299302
oos_has_shovel()
300303
),
301-
HasRupeesForShop(shop_name)
304+
from_world_field(f"shop_rupee_requirements.{shop_name}", 0, "eq"),
305+
And(
306+
oos_can_farm_rupees(),
307+
Has("Rupees", FromWorldAttr(f"shop_rupee_requirements.{shop_name}"))
308+
)
302309
)
303310

304311

@@ -311,7 +318,16 @@ def oos_can_farm_rupees() -> Rule:
311318

312319

313320
def oos_can_buy_market() -> Rule:
314-
return HasOresForShop()
321+
return Or(
322+
from_world_field(f"shop_prices.subrosianMarket", 0, "eq"),
323+
And(
324+
oos_can_farm_ore_chunks(),
325+
Or(
326+
Has("Ore Chunks", FromWorldAttr(f"shop_prices.subrosianMarket")),
327+
from_option(OracleOfSeasonsGoldenOreSpotsShuffle, OracleOfSeasonsGoldenOreSpotsShuffle.option_false, "eq"),
328+
)
329+
)
330+
)
315331

316332

317333
def oos_can_farm_ore_chunks() -> Rule:
@@ -1324,7 +1340,7 @@ def oos_roosters(region: str, any_amount: int = 0, top_amount: int = 0, bottom_a
13241340
oos_roosters("horon", any_amount + 1, top_amount, bottom_amount, set(visited_regions)),
13251341
oos_season_in_eyeglass_lake(SEASON_WINTER),
13261342
Or(
1327-
Season("EYEGLASS_LAKE", SEASON_SUMMER, True),
1343+
oos_is_default_season("EYEGLASS_LAKE", SEASON_SUMMER, True),
13281344
oos_can_remove_season(SEASON_SUMMER)
13291345
),
13301346
oos_can_swim(True)

0 commit comments

Comments
 (0)