diff options
| author | Star Rauchenberger <fefferburbia@gmail.com> | 2026-02-07 13:24:58 -0500 |
|---|---|---|
| committer | Star Rauchenberger <fefferburbia@gmail.com> | 2026-02-07 13:24:58 -0500 |
| commit | 3d03fcd82991d201f32a8313d4b44a4b17de4526 (patch) | |
| tree | a489ab0fd1143c5734e5e7234279661a8992e38d /apworld/locations.py | |
| parent | 1ff5dd9bb2199967bad531518a2d31e650ce107c (diff) | |
| download | lingo2-archipelago-3d03fcd82991d201f32a8313d4b44a4b17de4526.tar.gz lingo2-archipelago-3d03fcd82991d201f32a8313d4b44a4b17de4526.tar.bz2 lingo2-archipelago-3d03fcd82991d201f32a8313d4b44a4b17de4526.zip | |
Add restrict_letter_placements option
Diffstat (limited to 'apworld/locations.py')
| -rw-r--r-- | apworld/locations.py | 27 |
1 files changed, 26 insertions, 1 deletions
| diff --git a/apworld/locations.py b/apworld/locations.py index 3d619dc..174a0dd 100644 --- a/apworld/locations.py +++ b/apworld/locations.py | |||
| @@ -1,4 +1,13 @@ | |||
| 1 | from BaseClasses import Location | 1 | from enum import Enum |
| 2 | |||
| 3 | from BaseClasses import Location, Item | ||
| 4 | from .items import Lingo2Item | ||
| 5 | |||
| 6 | |||
| 7 | class LetterPlacementType(Enum): | ||
| 8 | ANY = 0 | ||
| 9 | DISALLOW = 1 | ||
| 10 | FORCE = 2 | ||
| 2 | 11 | ||
| 3 | 12 | ||
| 4 | class Lingo2Location(Location): | 13 | class Lingo2Location(Location): |
| @@ -6,3 +15,19 @@ class Lingo2Location(Location): | |||
| 6 | 15 | ||
| 7 | port_id: int | 16 | port_id: int |
| 8 | goal: bool | 17 | goal: bool |
| 18 | letter_placement_type: LetterPlacementType | ||
| 19 | |||
| 20 | def set_up_letter_rule(self, lpt: LetterPlacementType): | ||
| 21 | self.letter_placement_type = lpt | ||
| 22 | self.item_rule = self._l2_item_rule | ||
| 23 | |||
| 24 | def _l2_item_rule(self, item: Item) -> bool: | ||
| 25 | if not isinstance(item, Lingo2Item): | ||
| 26 | return True | ||
| 27 | |||
| 28 | if self.letter_placement_type == LetterPlacementType.FORCE: | ||
| 29 | return item.is_letter | ||
| 30 | elif self.letter_placement_type == LetterPlacementType.DISALLOW: | ||
| 31 | return not item.is_letter | ||
| 32 | |||
| 33 | return True | ||
