diff options
Diffstat (limited to 'apworld/__init__.py')
| -rw-r--r-- | apworld/__init__.py | 78 |
1 files changed, 78 insertions, 0 deletions
| diff --git a/apworld/__init__.py b/apworld/__init__.py index 1544c7b..f1de503 100644 --- a/apworld/__init__.py +++ b/apworld/__init__.py | |||
| @@ -1,16 +1,27 @@ | |||
| 1 | """ | 1 | """ |
| 2 | Archipelago init file for Lingo 2 | 2 | Archipelago init file for Lingo 2 |
| 3 | """ | 3 | """ |
| 4 | from BaseClasses import ItemClassification, Item, Tutorial | ||
| 4 | from worlds.AutoWorld import WebWorld, World | 5 | from worlds.AutoWorld import WebWorld, World |
| 6 | from .items import Lingo2Item, ANTI_COLLECTABLE_TRAPS | ||
| 5 | from .options import Lingo2Options | 7 | from .options import Lingo2Options |
| 6 | from .player_logic import Lingo2PlayerLogic | 8 | from .player_logic import Lingo2PlayerLogic |
| 7 | from .regions import create_regions | 9 | from .regions import create_regions |
| 8 | from .static_logic import Lingo2StaticLogic | 10 | from .static_logic import Lingo2StaticLogic |
| 11 | from .version import APWORLD_VERSION | ||
| 9 | 12 | ||
| 10 | 13 | ||
| 11 | class Lingo2WebWorld(WebWorld): | 14 | class Lingo2WebWorld(WebWorld): |
| 12 | rich_text_options_doc = True | 15 | rich_text_options_doc = True |
| 13 | 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 | )] | ||
| 14 | 25 | ||
| 15 | 26 | ||
| 16 | class Lingo2World(World): | 27 | class Lingo2World(World): |
| @@ -22,12 +33,16 @@ class Lingo2World(World): | |||
| 22 | game = "Lingo 2" | 33 | game = "Lingo 2" |
| 23 | web = Lingo2WebWorld() | 34 | web = Lingo2WebWorld() |
| 24 | 35 | ||
| 36 | topology_present = True | ||
| 37 | |||
| 25 | options_dataclass = Lingo2Options | 38 | options_dataclass = Lingo2Options |
| 26 | options: Lingo2Options | 39 | options: Lingo2Options |
| 27 | 40 | ||
| 28 | static_logic = Lingo2StaticLogic() | 41 | static_logic = Lingo2StaticLogic() |
| 29 | item_name_to_id = static_logic.item_name_to_id | 42 | item_name_to_id = static_logic.item_name_to_id |
| 30 | 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 | ||
| 31 | 46 | ||
| 32 | player_logic: Lingo2PlayerLogic | 47 | player_logic: Lingo2PlayerLogic |
| 33 | 48 | ||
| @@ -36,3 +51,66 @@ class Lingo2World(World): | |||
| 36 | 51 | ||
| 37 | def create_regions(self): | 52 | def create_regions(self): |
| 38 | create_regions(self) | 53 | create_regions(self) |
| 54 | |||
| 55 | from Utils import visualize_regions | ||
| 56 | |||
| 57 | visualize_regions(self.multiworld.get_region("Menu", self.player), "my_world.puml") | ||
| 58 | |||
| 59 | def create_items(self): | ||
| 60 | pool = [self.create_item(name) for name in self.player_logic.real_items] | ||
| 61 | |||
| 62 | total_locations = sum(len(locs) for locs in self.player_logic.locations_by_room.values()) | ||
| 63 | |||
| 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 | |||
| 79 | for i in range(0, item_difference): | ||
| 80 | pool.append(self.create_item(self.get_filler_item_name())) | ||
| 81 | |||
| 82 | self.multiworld.itempool += pool | ||
| 83 | |||
| 84 | def create_item(self, name: str) -> Item: | ||
| 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, | ||
| 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" | ||
