From 004fb711a86d91985d8e94e1b87089db2ac2cadc Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Tue, 16 Apr 2024 11:34:49 -0400 Subject: Support panels mode door shuffle --- src/game_data.cpp | 123 +++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 109 insertions(+), 14 deletions(-) (limited to 'src/game_data.cpp') diff --git a/src/game_data.cpp b/src/game_data.cpp index ee818c4..eece8d7 100644 --- a/src/game_data.cpp +++ b/src/game_data.cpp @@ -43,11 +43,13 @@ struct GameData { std::vector rooms_; std::vector doors_; std::vector panels_; + std::vector panel_doors_; std::vector map_areas_; std::map room_by_id_; std::map door_by_id_; std::map panel_by_id_; + std::map panel_doors_by_id_; std::map area_by_id_; std::vector door_definition_order_; @@ -408,6 +410,59 @@ struct GameData { } } + if (room_it.second["panel_doors"]) { + for (const auto &panel_door_it : room_it.second["panel_doors"]) { + std::string panel_door_name = panel_door_it.first.as(); + int panel_door_id = + AddOrGetPanelDoor(rooms_[room_id].name, panel_door_name); + + for (const auto &panel_node : panel_door_it.second["panels"]) { + int panel_id = -1; + + if (panel_node.IsScalar()) { + panel_id = AddOrGetPanel(rooms_[room_id].name, + panel_node.as()); + } else { + panel_id = AddOrGetPanel(panel_node["room"].as(), + panel_node["panel"].as()); + } + + Panel &panel = panels_[panel_id]; + panel.panel_door = panel_door_id; + } + + if (ids_config["panel_doors"] && + ids_config["panel_doors"][rooms_[room_id].name] && + ids_config["panel_doors"][rooms_[room_id].name] + [panel_door_name]) { + panel_doors_[panel_door_id].ap_item_id = + ids_config["panel_doors"][rooms_[room_id].name][panel_door_name] + .as(); + } else { + std::ostringstream errmsg; + errmsg << "Missing AP item ID for panel door " + << rooms_[room_id].name << " - " << panel_door_name; + TrackerLog(errmsg.str()); + } + + if (panel_door_it.second["panel_group"]) { + std::string panel_group = + panel_door_it.second["panel_group"].as(); + + if (ids_config["panel_groups"] && + ids_config["panel_groups"][panel_group]) { + panel_doors_[panel_door_id].group_ap_item_id = + ids_config["panel_groups"][panel_group].as(); + } else { + std::ostringstream errmsg; + errmsg << "Missing AP item ID for panel door group " + << panel_group; + TrackerLog(errmsg.str()); + } + } + } + } + if (room_it.second["paintings"]) { for (const auto &painting : room_it.second["paintings"]) { std::string painting_id = painting["id"].as(); @@ -449,23 +504,47 @@ struct GameData { TrackerLog(errmsg.str()); } - int index = 1; - for (const auto &stage : progression_it.second) { - int door_id = -1; + if (progression_it.second["doors"]) { + int index = 1; + for (const auto &stage : progression_it.second["doors"]) { + int door_id = -1; + + if (stage.IsScalar()) { + door_id = + AddOrGetDoor(rooms_[room_id].name, stage.as()); + } else { + door_id = AddOrGetDoor(stage["room"].as(), + stage["door"].as()); + } - if (stage.IsScalar()) { - door_id = - AddOrGetDoor(rooms_[room_id].name, stage.as()); - } else { - door_id = AddOrGetDoor(stage["room"].as(), - stage["door"].as()); + doors_[door_id].progressives.push_back( + {.item_name = progressive_item_name, + .ap_item_id = progressive_item_id, + .quantity = index}); + index++; } + } + + if (progression_it.second["panel_doors"]) { + int index = 1; + for (const auto &stage : progression_it.second["panel_doors"]) { + int panel_door_id = -1; + + if (stage.IsScalar()) { + panel_door_id = AddOrGetPanelDoor(rooms_[room_id].name, + stage.as()); + } else { + panel_door_id = + AddOrGetPanelDoor(stage["room"].as(), + stage["panel_door"].as()); + } - doors_[door_id].progressives.push_back( - {.item_name = progressive_item_name, - .ap_item_id = progressive_item_id, - .quantity = index}); - index++; + panel_doors_[panel_door_id].progressives.push_back( + {.item_name = progressive_item_name, + .ap_item_id = progressive_item_id, + .quantity = index}); + index++; + } } } } @@ -643,6 +722,18 @@ struct GameData { return panel_by_id_[full_name]; } + int AddOrGetPanelDoor(std::string room, std::string panel) { + std::string full_name = room + " - " + panel; + + if (!panel_doors_by_id_.count(full_name)) { + int panel_door_id = panel_doors_.size(); + panel_doors_by_id_[full_name] = panel_door_id; + panel_doors_.push_back({}); + } + + return panel_doors_by_id_[full_name]; + } + int AddOrGetArea(std::string area) { if (!area_by_id_.count(area)) { if (loaded_area_data_) { @@ -679,6 +770,10 @@ const std::vector &GD_GetDoors() { return GetState().doors_; } const Door &GD_GetDoor(int door_id) { return GetState().doors_.at(door_id); } +const PanelDoor &GD_GetPanelDoor(int panel_door_id) { + return GetState().panel_doors_.at(panel_door_id); +} + const Panel &GD_GetPanel(int panel_id) { return GetState().panels_.at(panel_id); } -- cgit 1.4.1