about summary refs log tree commit diff stats
path: root/apworld/__init__.py
diff options
context:
space:
mode:
Diffstat (limited to 'apworld/__init__.py')
-rw-r--r--apworld/__init__.py65
1 files changed, 61 insertions, 4 deletions
diff --git a/apworld/__init__.py b/apworld/__init__.py index 07e3982..f1de503 100644 --- a/apworld/__init__.py +++ b/apworld/__init__.py
@@ -1,18 +1,27 @@
1""" 1"""
2Archipelago init file for Lingo 2 2Archipelago init file for Lingo 2
3""" 3"""
4from BaseClasses import ItemClassification, Item 4from BaseClasses import ItemClassification, Item, Tutorial
5from worlds.AutoWorld import WebWorld, World 5from worlds.AutoWorld import WebWorld, World
6from .items import Lingo2Item 6from .items import Lingo2Item, ANTI_COLLECTABLE_TRAPS
7from .options import Lingo2Options 7from .options import Lingo2Options
8from .player_logic import Lingo2PlayerLogic 8from .player_logic import Lingo2PlayerLogic
9from .regions import create_regions 9from .regions import create_regions
10from .static_logic import Lingo2StaticLogic 10from .static_logic import Lingo2StaticLogic
11from .version import APWORLD_VERSION
11 12
12 13
13class Lingo2WebWorld(WebWorld): 14class Lingo2WebWorld(WebWorld):
14 rich_text_options_doc = True 15 rich_text_options_doc = True
15 theme = "grass" 16 theme = "grass"
17 tutorials = [Tutorial(
18 "Multiworld Setup Guide",
19 "A guide to playing Lingo 2 with Archipelago.",
20 "English",
21 "en_Lingo_2.md",
22 "setup/en",
23 ["hatkirby"]
24 )]
16 25
17 26
18class Lingo2World(World): 27class Lingo2World(World):
@@ -24,12 +33,16 @@ class Lingo2World(World):
24 game = "Lingo 2" 33 game = "Lingo 2"
25 web = Lingo2WebWorld() 34 web = Lingo2WebWorld()
26 35
36 topology_present = True
37
27 options_dataclass = Lingo2Options 38 options_dataclass = Lingo2Options
28 options: Lingo2Options 39 options: Lingo2Options
29 40
30 static_logic = Lingo2StaticLogic() 41 static_logic = Lingo2StaticLogic()
31 item_name_to_id = static_logic.item_name_to_id 42 item_name_to_id = static_logic.item_name_to_id
32 location_name_to_id = static_logic.location_name_to_id 43 location_name_to_id = static_logic.location_name_to_id
44 item_name_groups = static_logic.item_name_groups
45 location_name_groups = static_logic.location_name_groups
33 46
34 player_logic: Lingo2PlayerLogic 47 player_logic: Lingo2PlayerLogic
35 48
@@ -49,11 +62,55 @@ class Lingo2World(World):
49 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())
50 63
51 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
52 for i in range(0, item_difference): 79 for i in range(0, item_difference):
53 pool.append(self.create_item("Nothing")) 80 pool.append(self.create_item(self.get_filler_item_name()))
54 81
55 self.multiworld.itempool += pool 82 self.multiworld.itempool += pool
56 83
57 def create_item(self, name: str) -> Item: 84 def create_item(self, name: str) -> Item:
58 return Lingo2Item(name, ItemClassification.filler if name == "Nothing" else ItemClassification.progression, 85 return Lingo2Item(name, ItemClassification.filler if name == self.get_filler_item_name() else
86 ItemClassification.trap if name in ANTI_COLLECTABLE_TRAPS else
87 ItemClassification.progression,
59 self.item_name_to_id.get(name), self.player) 88 self.item_name_to_id.get(name), self.player)
89
90 def set_rules(self):
91 self.multiworld.completion_condition[self.player] = lambda state: state.has("Victory", self.player)
92
93 def fill_slot_data(self):
94 slot_options = [
95 "cyan_door_behavior",
96 "daedalus_roof_access",
97 "keyholder_sanity",
98 "shuffle_control_center_colors",
99 "shuffle_doors",
100 "shuffle_gallery_paintings",
101 "shuffle_letters",
102 "shuffle_symbols",
103 "strict_cyan_ending",
104 "strict_purple_ending",
105 "victory_condition",
106 ]
107
108 slot_data = {
109 **self.options.as_dict(*slot_options),
110 "version": [self.static_logic.get_data_version(), APWORLD_VERSION],
111 }
112
113 return slot_data
114
115 def get_filler_item_name(self) -> str:
116 return "A Job Well Done"