From d79984b099c3f762b95d3b4257bef113d3a8d6ee Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Sun, 7 Sep 2025 15:42:00 -0400 Subject: Added door groups --- apworld/options.py | 9 ++++ apworld/player_logic.py | 35 ++++++++++--- apworld/static_logic.py | 3 ++ data/door_groups.txtpb | 84 ++++++++++++++++++++++++++++++ data/ids.yaml | 12 ++++- data/maps/daedalus/doors.txtpb | 4 -- data/maps/the_entry/connections.txtpb | 2 +- data/maps/the_entry/doors.txtpb | 2 +- data/maps/the_repetitive/connections.txtpb | 2 +- data/maps/the_repetitive/doors.txtpb | 2 +- proto/data.proto | 23 ++++++++ proto/human.proto | 11 ++++ tools/assign_ids/main.cpp | 20 +++++++ tools/datapacker/container.cpp | 17 ++++++ tools/datapacker/container.h | 3 ++ tools/datapacker/main.cpp | 31 +++++++++++ tools/util/ids_yaml_format.cpp | 12 +++++ tools/validator/human_processor.cpp | 33 ++++++++++++ tools/validator/structs.h | 9 ++++ tools/validator/validator.cpp | 28 ++++++++++ 20 files changed, 326 insertions(+), 16 deletions(-) create mode 100644 data/door_groups.txtpb diff --git a/apworld/options.py b/apworld/options.py index f7dc5bd..dbf09e7 100644 --- a/apworld/options.py +++ b/apworld/options.py @@ -8,6 +8,14 @@ class ShuffleDoors(Toggle): display_name = "Shuffle Doors" +class ShuffleControlCenterColors(Toggle): + """ + Some doors open after solving the COLOR panel in the Control Center. If this option is enabled, these doors will + instead open upon receiving an item. + """ + display_name = "Shuffle Control Center Colors" + + class ShuffleLetters(Choice): """ Controls how letter unlocks are handled. Note that H1, I1, N1, and T1 will always be present at their vanilla @@ -71,6 +79,7 @@ class VictoryCondition(Choice): @dataclass class Lingo2Options(PerGameCommonOptions): shuffle_doors: ShuffleDoors + shuffle_control_center_colors: ShuffleControlCenterColors shuffle_letters: ShuffleLetters keyholder_sanity: KeyholderSanity daedalus_roof_access: DaedalusRoofAccess diff --git a/apworld/player_logic.py b/apworld/player_logic.py index 5cb9011..ce9a4e5 100644 --- a/apworld/player_logic.py +++ b/apworld/player_logic.py @@ -123,16 +123,39 @@ class Lingo2PlayerLogic: self.item_by_door[progressive.doors[i]] = (progressive.name, i + 1) self.real_items.append(progressive.name) + for door_group in world.static_logic.objects.door_groups: + if door_group.type == data_pb2.DoorGroupType.CONNECTOR and not self.world.options.shuffle_doors: + continue + + if (door_group.type == data_pb2.DoorGroupType.COLOR_CONNECTOR and + not self.world.options.shuffle_control_center_colors): + continue + + for door in door_group.doors: + self.item_by_door[door] = (door_group.name, 1) + + self.real_items.append(door_group.name) + # We iterate through the doors in two parts because it is essential that we determine which doors are shuffled # before we calculate any access requirements. for door in world.static_logic.objects.doors: - if door.type in [data_pb2.DoorType.STANDARD, data_pb2.DoorType.ITEM_ONLY] and self.world.options.shuffle_doors: - if door.id in self.item_by_door: - continue + if door.type in [data_pb2.DoorType.EVENT, data_pb2.DoorType.LOCATION_ONLY, data_pb2.DoorType.GRAVESTONE]: + continue + + if door.id in self.item_by_door: + continue + + if (door.type in [data_pb2.DoorType.STANDARD, data_pb2.DoorType.ITEM_ONLY] and + not self.world.options.shuffle_doors): + continue + + if (door.type == data_pb2.DoorType.CONTROL_CENTER_COLOR and + not self.world.options.shuffle_control_center_colors): + continue - door_item_name = self.world.static_logic.get_door_item_name(door) - self.item_by_door[door.id] = (door_item_name, 1) - self.real_items.append(door_item_name) + door_item_name = self.world.static_logic.get_door_item_name(door) + self.item_by_door[door.id] = (door_item_name, 1) + self.real_items.append(door_item_name) for door in world.static_logic.objects.doors: if door.type in [data_pb2.DoorType.STANDARD, data_pb2.DoorType.LOCATION_ONLY, data_pb2.DoorType.GRAVESTONE]: diff --git a/apworld/static_logic.py b/apworld/static_logic.py index b699d59..3f6cdea 100644 --- a/apworld/static_logic.py +++ b/apworld/static_logic.py @@ -44,6 +44,9 @@ class Lingo2StaticLogic: for progressive in self.objects.progressives: self.item_id_to_name[progressive.ap_id] = progressive.name + for door_group in self.objects.door_groups: + self.item_id_to_name[door_group.ap_id] = door_group.name + for keyholder in self.objects.keyholders: if keyholder.HasField("key"): location_name = f"{self.get_room_object_location_prefix(keyholder)} - {keyholder.key.upper()} Keyholder" diff --git a/data/door_groups.txtpb b/data/door_groups.txtpb new file mode 100644 index 0000000..ca8ce54 --- /dev/null +++ b/data/door_groups.txtpb @@ -0,0 +1,84 @@ +door_groups { + name: "The Entry - Repetitive Entrance" + type: CONNECTOR + doors { + map: "the_entry" + name: "Starting Room West Wall North Door" + } + doors { + map: "the_repetitive" + name: "Entry Entrance" + } +} +door_groups { + name: "The Repetitive - Plaza Entrance" + type: CONNECTOR + doors { + map: "the_repetitive" + name: "Black Hallway" + } + doors { + map: "the_plaza" + name: "Repetitive Entrance" + } +} +door_groups { + name: "Control Center White Doors" + type: COLOR_CONNECTOR + doors { + map: "daedalus" + name: "White Hallway From Entry" + } + doors { + map: "the_entry" + name: "Control Center White Door" + } +} +door_groups { + name: "Control Center Purple Doors" + type: COLOR_CONNECTOR + doors { + map: "daedalus" + name: "Purple Hallway From Great" + } + doors { + map: "the_great" + name: "Control Center Purple Door" + } +} +door_groups { + name: "Control Center Orange Doors" + type: COLOR_CONNECTOR + doors { + map: "daedalus" + name: "Control Center Orange Door" + } + doors { + map: "the_unkempt" + name: "Control Center Orange Door" + } +} +door_groups { + name: "Control Center Brown Doors" + type: COLOR_CONNECTOR + doors { + map: "the_bearer" + name: "Control Center Brown Door" + } + doors { + map: "the_tree" + name: "Control Center Brown Door" + } +} +door_groups { + name: "Control Center Blue Doors" + type: COLOR_CONNECTOR + doors { + map: "the_digital" + name: "Control Center Blue Door" + } + doors { + map: "the_unyielding" + name: "Digital Entrance" + } +} diff --git a/data/ids.yaml b/data/ids.yaml index 6498619..bd6cbc1 100644 --- a/data/ids.yaml +++ b/data/ids.yaml @@ -1743,13 +1743,13 @@ maps: Red Blue Area Left Door: 302 Red Blue Area Right Door: 303 Red Room Painting: 323 - Repetitive Entrance: 312 Revitalized Entrance: 306 Right Eye Entrance: 301 Scarf Door: 296 Second Room Left Door: 298 Second Room Right Door: 290 Shop Entrance: 313 + Starting Room West Wall North Door: 2781 Third Eye Painting: 324 Trick Door: 287 Trick To Shop Door: 289 @@ -2760,6 +2760,7 @@ maps: ZEROING: 1118 doors: Anti-Collectable Room: 1025 + Black Hallway: 2780 Cyan Door: 1028 Cyan Puzzles: 1032 Dot Area Entrance: 1026 @@ -2768,7 +2769,6 @@ maps: Lime Puzzles: 1031 Magenta Door: 1029 Magenta Puzzles: 1033 - Plaza Entrance: 1024 Yellow Door: 1030 Yellow Puzzles: 1034 the_revitalized: @@ -3840,3 +3840,11 @@ special: A Job Well Done: 1160 progressives: Progressive Gold Ending: 2753 +door_groups: + Control Center Blue Doors: 2788 + Control Center Brown Doors: 2787 + Control Center Orange Doors: 2786 + Control Center Purple Doors: 2785 + Control Center White Doors: 2784 + The Entry - Repetitive Entrance: 2782 + The Repetitive - Plaza Entrance: 2783 diff --git a/data/maps/daedalus/doors.txtpb b/data/maps/daedalus/doors.txtpb index 7359c5e..d6c33f4 100644 --- a/data/maps/daedalus/doors.txtpb +++ b/data/maps/daedalus/doors.txtpb @@ -892,16 +892,12 @@ doors { } doors { name: "White Hallway From Entry" - # TODO: This should be combined with the corresponding door in the_entry, at - # least when connections are not shuffled. type: CONTROL_CENTER_COLOR receivers: "Components/Doors/Halls/froom_6" control_center_color: "white" } doors { name: "Purple Hallway From Great" - # TODO: This should be combined with the corresponding door in the_great, at - # least when connections are not shuffled. type: CONTROL_CENTER_COLOR receivers: "Components/Doors/Halls/froom_7" control_center_color: "purple" diff --git a/data/maps/the_entry/connections.txtpb b/data/maps/the_entry/connections.txtpb index 6f847da..a2e325a 100644 --- a/data/maps/the_entry/connections.txtpb +++ b/data/maps/the_entry/connections.txtpb @@ -192,7 +192,7 @@ connections { connections { from_room: "Starting Room" to_room: "Repetitive Entrance" - door { name: "Repetitive Entrance" } + door { name: "Starting Room West Wall North Door" } } connections { from_room: "Lime Room" diff --git a/data/maps/the_entry/doors.txtpb b/data/maps/the_entry/doors.txtpb index 78ffa52..6bef160 100644 --- a/data/maps/the_entry/doors.txtpb +++ b/data/maps/the_entry/doors.txtpb @@ -193,7 +193,7 @@ doors { location_room: "Starting Room" } doors { - name: "Repetitive Entrance" + name: "Starting Room West Wall North Door" type: ITEM_ONLY receivers: "Components/Doors/Entry/entry_proxied_9" double_letters: true diff --git a/data/maps/the_repetitive/connections.txtpb b/data/maps/the_repetitive/connections.txtpb index 2b115a9..0afe72d 100644 --- a/data/maps/the_repetitive/connections.txtpb +++ b/data/maps/the_repetitive/connections.txtpb @@ -6,7 +6,7 @@ connections { connections { from_room: "Main Room" to_room: "Plaza Connector" - door { name: "Plaza Entrance" } + door { name: "Black Hallway" } oneway: true } connections { diff --git a/data/maps/the_repetitive/doors.txtpb b/data/maps/the_repetitive/doors.txtpb index 9e63c1d..8171dc4 100644 --- a/data/maps/the_repetitive/doors.txtpb +++ b/data/maps/the_repetitive/doors.txtpb @@ -6,7 +6,7 @@ doors { location_room: "Main Room" } doors { - name: "Plaza Entrance" + name: "Black Hallway" type: STANDARD receivers: "Components/Doors/Door12" panels { room: "Main Room" name: "I" } diff --git a/proto/data.proto b/proto/data.proto index 855c28c..84d14ef 100644 --- a/proto/data.proto +++ b/proto/data.proto @@ -29,6 +29,20 @@ enum DoorType { GRAVESTONE = 6; } +enum DoorGroupType { + DOOR_GROUP_TYPE_UNKNOWN = 0; + + // These doors border a worldport. They should be grouped when connections are + // not shuffled. + CONNECTOR = 1; + + // Similar to CONNECTOR, but these doors are also ordinarily opened by solving + // the COLOR panel in the Control Center. These should be grouped when + // connections are not shuffled, but are not items at all when control center + // colors are not shuffled. + COLOR_CONNECTOR = 2; +} + enum AxisDirection { AXIS_DIRECTION_UNKNOWN = 0; @@ -232,6 +246,14 @@ message Progressive { repeated uint64 doors = 4; } +message DoorGroup { + optional uint64 id = 1; + optional string name = 2; + optional uint64 ap_id = 3; + optional DoorGroupType type = 4; + repeated uint64 doors = 5; +} + message AllObjects { repeated Map maps = 7; repeated Room rooms = 1; @@ -245,5 +267,6 @@ message AllObjects { repeated Ending endings = 12; repeated Connection connections = 6; repeated Progressive progressives = 13; + repeated DoorGroup door_groups = 14; map special_ids = 8; } diff --git a/proto/human.proto b/proto/human.proto index 205b867..89fd076 100644 --- a/proto/human.proto +++ b/proto/human.proto @@ -203,6 +203,16 @@ message HumanProgressives { repeated HumanProgressive progressives = 1; } +message HumanDoorGroup { + optional string name = 1; + optional DoorGroupType type = 2; + repeated DoorIdentifier doors = 3; +} + +message HumanDoorGroups { + repeated HumanDoorGroup door_groups = 1; +} + message IdMappings { message RoomIds { map panels = 1; @@ -220,4 +230,5 @@ message IdMappings { map letters = 3; map endings = 4; map progressives = 5; + map door_groups = 6; } diff --git a/tools/assign_ids/main.cpp b/tools/assign_ids/main.cpp index e3add66..d212767 100644 --- a/tools/assign_ids/main.cpp +++ b/tools/assign_ids/main.cpp @@ -42,6 +42,7 @@ class AssignIds { ProcessMaps(datadir_path); ProcessSpecialIds(); ProcessProgressivesFile(datadir_path / "progressives.txtpb"); + ProcessDoorGroupsFile(datadir_path / "door_groups.txtpb"); WriteIds(ids_path); @@ -61,6 +62,7 @@ class AssignIds { for (const auto& [_, room] : map.rooms()) { UpdateNextId(room.panels()); UpdateNextId(room.masteries()); + UpdateNextId(room.keyholders()); } } @@ -68,6 +70,7 @@ class AssignIds { UpdateNextId(id_mappings_.letters()); UpdateNextId(id_mappings_.endings()); UpdateNextId(id_mappings_.progressives()); + UpdateNextId(id_mappings_.door_groups()); next_id_++; } @@ -267,6 +270,23 @@ class AssignIds { } } + void ProcessDoorGroupsFile(std::filesystem::path path) { + if (!std::filesystem::exists(path)) { + return; + } + + auto h_groups = ReadMessageFromFile(path.string()); + auto& groups = *output_.mutable_door_groups(); + + for (const HumanDoorGroup& h_group : h_groups.door_groups()) { + if (!id_mappings_.door_groups().contains(h_group.name())) { + groups[h_group.name()] = next_id_++; + } else { + groups[h_group.name()] = id_mappings_.door_groups().at(h_group.name()); + } + } + } + private: void UpdateNextId(const google::protobuf::Map& ids) { for (const auto& [_, id] : ids) { diff --git a/tools/datapacker/container.cpp b/tools/datapacker/container.cpp index 624caf8..4a656b3 100644 --- a/tools/datapacker/container.cpp +++ b/tools/datapacker/container.cpp @@ -348,6 +348,23 @@ uint64_t Container::FindOrAddProgressive(std::string prog_name) { } } +uint64_t Container::FindOrAddDoorGroup(std::string group_name) { + auto it = door_group_id_by_name_.find(group_name); + + if (it == door_group_id_by_name_.end()) { + uint64_t new_id = all_objects_.door_groups_size(); + DoorGroup* door_group = all_objects_.add_door_groups(); + door_group->set_id(new_id); + door_group->set_name(group_name); + + door_group_id_by_name_[group_name] = new_id; + + return new_id; + } else { + return it->second; + } +} + void Container::AddConnection(const Connection& connection) { *all_objects_.add_connections() = connection; } diff --git a/tools/datapacker/container.h b/tools/datapacker/container.h index 8cec560..bc02ba4 100644 --- a/tools/datapacker/container.h +++ b/tools/datapacker/container.h @@ -62,6 +62,8 @@ class Container { uint64_t FindOrAddProgressive(std::string prog_name); + uint64_t FindOrAddDoorGroup(std::string group_name); + AllObjects& all_objects() { return all_objects_; } private: @@ -85,6 +87,7 @@ class Container { door_id_by_map_door_names_; std::map ending_id_by_name_; std::map progressive_id_by_name_; + std::map door_group_id_by_name_; }; } // namespace com::fourisland::lingo2_archipelago diff --git a/tools/datapacker/main.cpp b/tools/datapacker/main.cpp index 595647d..c72462d 100644 --- a/tools/datapacker/main.cpp +++ b/tools/datapacker/main.cpp @@ -44,6 +44,7 @@ class DataPacker { ProcessConnectionsFile(datadir_path / "connections.txtpb", std::nullopt); ProcessMaps(datadir_path); ProcessProgressivesFile(datadir_path / "progressives.txtpb"); + ProcessDoorGroupsFile(datadir_path / "door_groups.txtpb"); ProcessIdsFile(datadir_path / "ids.yaml"); { @@ -577,6 +578,31 @@ class DataPacker { } } + void ProcessDoorGroupsFile(std::filesystem::path path) { + if (!std::filesystem::exists(path)) { + return; + } + + auto h_groups = ReadMessageFromFile(path.string()); + + for (const HumanDoorGroup& h_group : h_groups.door_groups()) { + ProcessDoorGroup(h_group); + } + } + + void ProcessDoorGroup(const HumanDoorGroup& h_group) { + uint64_t group_id = container_.FindOrAddDoorGroup(h_group.name()); + DoorGroup& group = *container_.all_objects().mutable_door_groups(group_id); + + group.set_type(h_group.type()); + + for (const DoorIdentifier& di : h_group.doors()) { + uint64_t door_id = + container_.FindOrAddDoor(di.map(), di.name(), std::nullopt); + group.add_doors(door_id); + } + } + void ProcessIdsFile(std::filesystem::path path) { auto ids = ReadIdsFromYaml(path.string()); @@ -631,6 +657,11 @@ class DataPacker { uint64_t prog_id = container_.FindOrAddProgressive(prog_name); container_.all_objects().mutable_progressives(prog_id)->set_ap_id(ap_id); } + + for (const auto& [group_name, ap_id] : ids.door_groups()) { + uint64_t group_id = container_.FindOrAddDoorGroup(group_name); + container_.all_objects().mutable_door_groups(group_id)->set_ap_id(ap_id); + } } std::string mapdir_; diff --git a/tools/util/ids_yaml_format.cpp b/tools/util/ids_yaml_format.cpp index 67c21d6..71bfd63 100644 --- a/tools/util/ids_yaml_format.cpp +++ b/tools/util/ids_yaml_format.cpp @@ -104,6 +104,13 @@ IdMappings ReadIdsFromYaml(const std::string& filename) { } } + if (document["door_groups"]) { + for (const auto& group_it : document["door_groups"]) { + (*result.mutable_door_groups())[group_it.first.as()] = + group_it.second.as(); + } + } + return result; } @@ -171,6 +178,11 @@ void WriteIdsAsYaml(const IdMappings& ids, const std::string& filename) { result["progressives"][prog_name] = prog_id; }); + OperateOnSortedMap(ids.door_groups(), [&result](const std::string& group_name, + uint64_t group_id) { + result["door_groups"][group_name] = group_id; + }); + std::ofstream output_stream(filename); output_stream << result << std::endl; } diff --git a/tools/validator/human_processor.cpp b/tools/validator/human_processor.cpp index 5720ba9..561225e 100644 --- a/tools/validator/human_processor.cpp +++ b/tools/validator/human_processor.cpp @@ -43,6 +43,7 @@ class HumanProcessor { ProcessConnectionsFile(datadir_path / "connections.txtpb", std::nullopt); ProcessMaps(datadir_path); ProcessProgressivesFile(datadir_path / "progressives.txtpb"); + ProcessDoorGroupsFile(datadir_path / "door_groups.txtpb"); ProcessIdsFile(datadir_path / "ids.yaml"); } @@ -510,6 +511,33 @@ class HumanProcessor { } } + void ProcessDoorGroupsFile(std::filesystem::path path) { + if (!std::filesystem::exists(path)) { + return; + } + + auto h_groups = ReadMessageFromFile(path.string()); + + for (const HumanDoorGroup& h_group : h_groups.door_groups()) { + ProcessDoorGroup(h_group); + } + } + + void ProcessDoorGroup(const HumanDoorGroup& h_group) { + DoorGroupInfo& group_info = info_.door_groups[h_group.name()]; + group_info.definitions.push_back(h_group); + + for (const DoorIdentifier& di : h_group.doors()) { + if (!di.has_map()) { + group_info.malformed_doors.push_back(di); + continue; + } + + DoorInfo& door_info = info_.doors[di]; + door_info.door_groups_referenced_by.push_back(h_group.name()); + } + } + void ProcessIdsFile(std::filesystem::path path) { auto ids = ReadIdsFromYaml(path.string()); @@ -573,6 +601,11 @@ class HumanProcessor { ProgressiveInfo& prog_info = info_.progressives[prog_name]; prog_info.has_id = true; } + + for (const auto& [group_name, ap_id] : ids.door_groups()) { + DoorGroupInfo& group_info = info_.door_groups[group_name]; + group_info.has_id = true; + } } std::string mapdir_; diff --git a/tools/validator/structs.h b/tools/validator/structs.h index e24ed3d..17ed33a 100644 --- a/tools/validator/structs.h +++ b/tools/validator/structs.h @@ -47,6 +47,7 @@ struct DoorInfo { std::vector paintings_referenced_by; std::vector ports_referenced_by; std::vector progressives_referenced_by; + std::vector door_groups_referenced_by; MalformedIdentifiers malformed_identifiers; }; @@ -115,6 +116,13 @@ struct ProgressiveInfo { std::vector malformed_doors; }; +struct DoorGroupInfo { + std::vector definitions; + bool has_id = false; + + std::vector malformed_doors; +}; + struct CollectedInfo { std::map maps; std::map rooms; @@ -128,6 +136,7 @@ struct CollectedInfo { std::map endings; std::map panel_names; std::map progressives; + std::map door_groups; }; } // namespace com::fourisland::lingo2_archipelago diff --git a/tools/validator/validator.cpp b/tools/validator/validator.cpp index ab1612e..4149caa 100644 --- a/tools/validator/validator.cpp +++ b/tools/validator/validator.cpp @@ -48,6 +48,9 @@ class Validator { for (const auto& [prog_name, prog_info] : info_.progressives) { ValidateProgressive(prog_name, prog_info); } + for (const auto& [group_name, group_info] : info_.door_groups) { + ValidateDoorGroup(group_name, group_info); + } } private: @@ -173,6 +176,11 @@ class Validator { std::cout << " PROGRESSIVE " << prog_name << std::endl; } + for (const std::string& group_name : + door_info.door_groups_referenced_by) { + std::cout << " DOOR GROUP " << group_name << std::endl; + } + if (door_info.has_id) { std::cout << " An AP ID is present." << std::endl; } @@ -460,6 +468,26 @@ class Validator { } } + void ValidateDoorGroup(const std::string& group_name, + const DoorGroupInfo& group_info) const { + if (group_info.definitions.empty()) { + std::cout << "Door group \"" << group_name + << "\" has no definition, but was referenced:" << std::endl; + + if (group_info.has_id) { + std::cout << " An AP ID is present." << std::endl; + } + } else if (group_info.definitions.size() > 1) { + std::cout << "Door group \"" << group_name + << "\" has multiple definitions." << std::endl; + } + + if (!group_info.has_id) { + std::cout << "Door group \"" << group_name << "\" is missing an AP ID." + << std::endl; + } + } + const CollectedInfo& info_; }; -- cgit 1.4.1