about summary refs log tree commit diff stats
path: root/apworld/items.py
blob: 28158c37078e886f5f19035f5c57ccf22de2a619 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from .generated import data_pb2 as data_pb2
from BaseClasses import Item


class Lingo2Item(Item):
    game: str = "Lingo 2"


SYMBOL_ITEMS: dict[data_pb2.PuzzleSymbol, str] = {
    data_pb2.PuzzleSymbol.SUN: "Sun Symbol",
    data_pb2.PuzzleSymbol.SPARKLES: "Sparkles Symbol",
    data_pb2.PuzzleSymbol.ZERO: "Zero Symbol",
    data_pb2.PuzzleSymbol.EXAMPLE: "Example Symbol",
    data_pb2.PuzzleSymbol.BOXES: "Boxes Symbol",
    data_pb2.PuzzleSymbol.PLANET: "Planet Symbol",
    data_pb2.PuzzleSymbol.PYRAMID: "Pyramid Symbol",
    data_pb2.PuzzleSymbol.CROSS: "Cross Symbol",
    data_pb2.PuzzleSymbol.SWEET: "Sweet Symbol",
    data_pb2.PuzzleSymbol.GENDER: "Gender Symbol",
    data_pb2.PuzzleSymbol.AGE: "Age Symbol",
    data_pb2.PuzzleSymbol.SOUND: "Sound Symbol",
    data_pb2.PuzzleSymbol.ANAGRAM: "Anagram Symbol",
    data_pb2.PuzzleSymbol.JOB: "Job Symbol",
    data_pb2.PuzzleSymbol.STARS: "Stars Symbol",
    data_pb2.PuzzleSymbol.NULL: "Null Symbol",
    data_pb2.PuzzleSymbol.EVAL: "Eval Symbol",
    data_pb2.PuzzleSymbol.LINGO: "Lingo Symbol",
    data_pb2.PuzzleSymbol.QUESTION: "Question Symbol",
}

ANTI_COLLECTABLE_TRAPS: list[str] = [f"Anti {letter}" for letter in "ABCDEFGHIJKLMNOPQRSTUVWXYZ"]
= static_logic.item_name_to_id location_name_to_id = static_logic.location_name_to_id item_name_groups = static_logic.item_name_groups location_name_groups = static_logic.location_name_groups player_logic: Lingo2PlayerLogic def generate_early(self): self.player_logic = Lingo2PlayerLogic(self) def create_regions(self): create_regions(self) from Utils import visualize_regions visualize_regions(self.multiworld.get_region("Menu", self.player), "my_world.puml") def create_items(self): pool = [self.create_item(name) for name in self.player_logic.real_items] 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())) self.multiworld.itempool += pool 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) def set_rules(self): self.multiworld.completion_condition[self.player] = lambda state: state.has("Victory", self.player) def fill_slot_data(self): slot_options = [ "cyan_door_behavior", "daedalus_roof_access", "keyholder_sanity", "shuffle_control_center_colors", "shuffle_doors", "shuffle_gallery_paintings", "shuffle_letters", "shuffle_symbols", "victory_condition", ] slot_data = { **self.options.as_dict(*slot_options), "version": [self.static_logic.get_data_version(), APWORLD_VERSION], } return slot_data def get_filler_item_name(self) -> str: return "A Job Well Done"