Files
Archipelago/worlds/jakanddaxter/Rules.py
massimilianodelliubaldini 1c42bdb353 Move Randomizer (#26)
* Finally remove debug-segment text, update Python imports to relative paths.

* HUGE refactor to Regions/Rules to support move rando, first hub area coded.

* More refactoring.

* Another refactor - may squash.

* Fix some Rules, reuse some code by returning key regions from build_regions.

* More regions added. A couple of TODOs.

* Fixed trade logic, added LPC regions.

* Added Spider, Snowy, Boggy. Fixed Misty's orbs.

* Fix circular import, assert orb counts per level, fix a few naming errors.

* Citadel added, missing locs and connections fixed. First move rando seed generated.

* Add Move Rando to Options class.

* Fixed rules for prerequisite moves.

* Implement client functionality for move rando, add blurbs to game info page.

* Fix wrong address for cache checks.

* Fix byte alignment of offsets, refactor read_memory for better code reuse.

* Refactor memory offsets and add some unit tests.

* Make green eco the filler item, also define a maximum ID. Fix Boggy tether locations.
2024-06-27 10:12:48 -04:00

41 lines
1.6 KiB
Python

import typing
from BaseClasses import MultiWorld, CollectionState
from .JakAndDaxterOptions import JakAndDaxterOptions
from .locs import CellLocations as Cells
from .Locations import location_table
from .Regions import JakAndDaxterRegion
# TODO - Until we come up with a better progressive system for the traders (that avoids hard-locking if you pay the
# wrong ones and can't afford the right ones) just make all the traders locked behind the total amount to pay them all.
def can_trade(state: CollectionState,
player: int,
multiworld: MultiWorld,
required_orbs: int,
required_previous_trade: int = None) -> bool:
accessible_orbs = 0
for region in multiworld.get_regions(player):
if state.can_reach(region, "Region", player):
accessible_orbs += typing.cast(JakAndDaxterRegion, region).orb_count
if required_previous_trade:
name_of_previous_trade = location_table[Cells.to_ap_id(required_previous_trade)]
return (accessible_orbs >= required_orbs
and state.can_reach(name_of_previous_trade, "Location", player=player))
else:
return accessible_orbs >= required_orbs
def can_free_scout_flies(state: CollectionState, player: int) -> bool:
return (state.has("Jump Dive", player)
or (state.has("Crouch", player)
and state.has("Crouch Uppercut", player)))
def can_fight(state: CollectionState, player: int) -> bool:
return (state.has("Jump Dive", player)
or state.has("Jump Kick", player)
or state.has("Punch", player)
or state.has("Kick", player))