diff options
Diffstat (limited to 'apworld/__init__.py')
| -rw-r--r-- | apworld/__init__.py | 17 |
1 files changed, 16 insertions, 1 deletions
| diff --git a/apworld/__init__.py b/apworld/__init__.py index 54f870f..8b2e42e 100644 --- a/apworld/__init__.py +++ b/apworld/__init__.py | |||
| @@ -3,7 +3,7 @@ Archipelago init file for Lingo 2 | |||
| 3 | """ | 3 | """ |
| 4 | from BaseClasses import ItemClassification, Item, Tutorial | 4 | from BaseClasses import ItemClassification, Item, Tutorial |
| 5 | from worlds.AutoWorld import WebWorld, World | 5 | from worlds.AutoWorld import WebWorld, World |
| 6 | from .items import Lingo2Item | 6 | from .items import Lingo2Item, ANTI_COLLECTABLE_TRAPS |
| 7 | from .options import Lingo2Options | 7 | from .options import Lingo2Options |
| 8 | from .player_logic import Lingo2PlayerLogic | 8 | from .player_logic import Lingo2PlayerLogic |
| 9 | from .regions import create_regions | 9 | from .regions import create_regions |
| @@ -62,6 +62,20 @@ class Lingo2World(World): | |||
| 62 | total_locations = sum(len(locs) for locs in self.player_logic.locations_by_room.values()) | 62 | total_locations = sum(len(locs) for locs in self.player_logic.locations_by_room.values()) |
| 63 | 63 | ||
| 64 | item_difference = total_locations - len(pool) | 64 | item_difference = total_locations - len(pool) |
| 65 | |||
| 66 | if self.options.trap_percentage > 0: | ||
| 67 | num_traps = int(item_difference * self.options.trap_percentage / 100) | ||
| 68 | item_difference = item_difference - num_traps | ||
| 69 | |||
| 70 | trap_names = [] | ||
| 71 | trap_weights = [] | ||
| 72 | for letter_name, weight in self.static_logic.letter_weights.items(): | ||
| 73 | trap_names.append(f"Anti {letter_name}") | ||
| 74 | trap_weights.append(weight) | ||
| 75 | |||
| 76 | bad_letters = self.random.choices(trap_names, weights=trap_weights, k=num_traps) | ||
| 77 | pool += [self.create_item(trap_name) for trap_name in bad_letters] | ||
| 78 | |||
| 65 | for i in range(0, item_difference): | 79 | for i in range(0, item_difference): |
| 66 | pool.append(self.create_item(self.get_filler_item_name())) | 80 | pool.append(self.create_item(self.get_filler_item_name())) |
| 67 | 81 | ||
| @@ -69,6 +83,7 @@ class Lingo2World(World): | |||
| 69 | 83 | ||
| 70 | def create_item(self, name: str) -> Item: | 84 | def create_item(self, name: str) -> Item: |
| 71 | return Lingo2Item(name, ItemClassification.filler if name == self.get_filler_item_name() else | 85 | return Lingo2Item(name, ItemClassification.filler if name == self.get_filler_item_name() else |
| 86 | ItemClassification.trap if name in ANTI_COLLECTABLE_TRAPS else | ||
| 72 | ItemClassification.progression, | 87 | ItemClassification.progression, |
| 73 | self.item_name_to_id.get(name), self.player) | 88 | self.item_name_to_id.get(name), self.player) |
| 74 | 89 | ||
