From c456854263be17264aeb8446986bc401d3921f33 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Sat, 13 Sep 2025 11:34:49 -0400 Subject: Added anti collectable traps --- apworld/__init__.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'apworld/__init__.py') 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 """ from BaseClasses import ItemClassification, Item, Tutorial from worlds.AutoWorld import WebWorld, World -from .items import Lingo2Item +from .items import Lingo2Item, ANTI_COLLECTABLE_TRAPS from .options import Lingo2Options from .player_logic import Lingo2PlayerLogic from .regions import create_regions @@ -62,6 +62,20 @@ class Lingo2World(World): total_locations = sum(len(locs) for locs in self.player_logic.locations_by_room.values()) item_difference = total_locations - len(pool) + + if self.options.trap_percentage > 0: + num_traps = int(item_difference * self.options.trap_percentage / 100) + item_difference = item_difference - num_traps + + trap_names = [] + trap_weights = [] + for letter_name, weight in self.static_logic.letter_weights.items(): + trap_names.append(f"Anti {letter_name}") + trap_weights.append(weight) + + bad_letters = self.random.choices(trap_names, weights=trap_weights, k=num_traps) + pool += [self.create_item(trap_name) for trap_name in bad_letters] + for i in range(0, item_difference): pool.append(self.create_item(self.get_filler_item_name())) @@ -69,6 +83,7 @@ class Lingo2World(World): def create_item(self, name: str) -> Item: return Lingo2Item(name, ItemClassification.filler if name == self.get_filler_item_name() else + ItemClassification.trap if name in ANTI_COLLECTABLE_TRAPS else ItemClassification.progression, self.item_name_to_id.get(name), self.player) -- cgit 1.4.1