diff options
author | Star Rauchenberger <fefferburbia@gmail.com> | 2025-08-12 12:33:24 -0400 |
---|---|---|
committer | Star Rauchenberger <fefferburbia@gmail.com> | 2025-08-12 12:33:24 -0400 |
commit | 447a222b57e498f7904033c59e68d21d6a246abd (patch) | |
tree | e756845a971729758ba091474322fd722d44e0ec /apworld/rules.py | |
parent | 4e56e7681c0769dd247c0512a682a067426436bc (diff) | |
download | lingo2-archipelago-447a222b57e498f7904033c59e68d21d6a246abd.tar.gz lingo2-archipelago-447a222b57e498f7904033c59e68d21d6a246abd.tar.bz2 lingo2-archipelago-447a222b57e498f7904033c59e68d21d6a246abd.zip |
Items and connections in the apworld
Diffstat (limited to 'apworld/rules.py')
-rw-r--r-- | apworld/rules.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/apworld/rules.py b/apworld/rules.py new file mode 100644 index 0000000..05689e9 --- /dev/null +++ b/apworld/rules.py | |||
@@ -0,0 +1,27 @@ | |||
1 | from collections.abc import Callable | ||
2 | from typing import TYPE_CHECKING | ||
3 | |||
4 | from BaseClasses import CollectionState | ||
5 | from .player_logic import AccessRequirements | ||
6 | |||
7 | if TYPE_CHECKING: | ||
8 | from . import Lingo2World | ||
9 | |||
10 | |||
11 | def lingo2_can_satisfy_requirements(state: CollectionState, reqs: AccessRequirements, world: "Lingo2World") -> bool: | ||
12 | if not all(state.has(item, world.player) for item in reqs.items): | ||
13 | return False | ||
14 | |||
15 | if not all(state.can_reach_region(region_name, world.player) for region_name in reqs.rooms): | ||
16 | return False | ||
17 | |||
18 | # TODO: symbols, letters | ||
19 | |||
20 | for disjunction in reqs.or_logic: | ||
21 | if not any(lingo2_can_satisfy_requirements(state, sub_reqs, world) for sub_reqs in disjunction): | ||
22 | return False | ||
23 | |||
24 | return True | ||
25 | |||
26 | def make_location_lambda(reqs: AccessRequirements, world: "Lingo2World") -> Callable[[CollectionState], bool]: | ||
27 | return lambda state: lingo2_can_satisfy_requirements(state, reqs, world) | ||