From c9a21a387634e8fdd13110906ebe786f055c446d Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Thu, 3 Aug 2023 11:34:57 -0400 Subject: LEVEL 2 and required_panel support --- src/ap_state.cpp | 13 +++++++++++++ src/ap_state.h | 6 ++++++ src/game_data.cpp | 28 ++++++++++++++++++++++++++++ src/game_data.h | 3 +++ src/tracker_state.cpp | 25 +++++++++++++++++++++++++ 5 files changed, 75 insertions(+) diff --git a/src/ap_state.cpp b/src/ap_state.cpp index 6c4e42d..02f1f5a 100644 --- a/src/ap_state.cpp +++ b/src/ap_state.cpp @@ -61,7 +61,9 @@ struct APState { bool color_shuffle = false; bool painting_shuffle = false; int mastery_requirement = 21; + int level_2_requirement = 223; bool reduce_checks = false; + VictoryCondition victory_condition = kTHE_END; std::map painting_mapping; @@ -119,7 +121,9 @@ struct APState { painting_shuffle = false; painting_mapping.clear(); mastery_requirement = 21; + level_2_requirement = 223; reduce_checks = false; + victory_condition = kTHE_END; connected = false; has_connection_result = false; @@ -208,8 +212,11 @@ struct APState { color_shuffle = slot_data["shuffle_colors"].get(); painting_shuffle = slot_data["shuffle_paintings"].get(); mastery_requirement = slot_data["mastery_achievements"].get(); + level_2_requirement = slot_data["level_2_requirement"].get(); reduce_checks = (door_shuffle_mode == kNO_DOORS) && slot_data["reduce_checks"].get(); + victory_condition = + slot_data["victory_condition"].get(); if (painting_shuffle && slot_data.contains("painting_entrance_to_exit")) { painting_mapping.clear(); @@ -435,8 +442,14 @@ const std::map AP_GetPaintingMapping() { int AP_GetMasteryRequirement() { return GetState().mastery_requirement; } +int AP_GetLevel2Requirement() { return GetState().level_2_requirement; } + bool AP_IsReduceChecks() { return GetState().reduce_checks; } +VictoryCondition AP_GetVictoryCondition() { + return GetState().victory_condition; +} + bool AP_HasAchievement(const std::string& achievement_name) { return GetState().HasAchievement(achievement_name); } diff --git a/src/ap_state.h b/src/ap_state.h index a9edd9e..fb5c969 100644 --- a/src/ap_state.h +++ b/src/ap_state.h @@ -10,6 +10,8 @@ class TrackerFrame; enum DoorShuffleMode { kNO_DOORS = 0, kSIMPLE_DOORS = 1, kCOMPLEX_DOORS = 2 }; +enum VictoryCondition { kTHE_END = 0, kTHE_MASTER = 1, kLEVEL_2 = 2 }; + void AP_SetTrackerFrame(TrackerFrame* tracker_frame); void AP_Connect(std::string server, std::string player, std::string password); @@ -30,8 +32,12 @@ const std::map AP_GetPaintingMapping(); int AP_GetMasteryRequirement(); +int AP_GetLevel2Requirement(); + bool AP_IsReduceChecks(); +VictoryCondition AP_GetVictoryCondition(); + bool AP_HasAchievement(const std::string& achievement_name); #endif /* end of include guard: AP_STATE_H_664A4180 */ diff --git a/src/game_data.cpp b/src/game_data.cpp index 9d4dae0..fafc88c 100644 --- a/src/game_data.cpp +++ b/src/game_data.cpp @@ -125,6 +125,7 @@ struct GameData { int panel_id = AddOrGetPanel(room_obj.name, panel_it.first.as()); Panel &panel_obj = panels_[panel_id]; + room_obj.panels.push_back(panel_id); if (panel_it.second["colors"]) { if (panel_it.second["colors"].IsScalar()) { @@ -174,6 +175,29 @@ struct GameData { } } + if (panel_it.second["required_panel"]) { + if (panel_it.second["required_panel"].IsMap()) { + std::string rp_room = room_obj.name; + if (panel_it.second["required_panel"]["room"]) { + rp_room = panel_it.second["required_panel"]["room"].as(); + } + + panel_obj.required_panels.push_back(AddOrGetPanel( + rp_room, panel_it.second["required_panel"]["panel"] + .as())); + } else { + for (const auto &rp_node : panel_it.second["required_panel"]) { + std::string rp_room = room_obj.name; + if (rp_node["room"]) { + rp_room = rp_node["room"].as(); + } + + panel_obj.required_panels.push_back( + AddOrGetPanel(rp_room, rp_node["panel"].as())); + } + } + } + if (panel_it.second["check"]) { panel_obj.check = panel_it.second["check"].as(); } @@ -189,6 +213,10 @@ struct GameData { panel_obj.exclude_reduce = panel_it.second["exclude_reduce"].as(); } + + if (panel_it.second["non_counting"]) { + panel_obj.non_counting = panel_it.second["non_counting"].as(); + } } } diff --git a/src/game_data.h b/src/game_data.h index 672d8a4..31a0c87 100644 --- a/src/game_data.h +++ b/src/game_data.h @@ -26,10 +26,12 @@ struct Panel { std::vector colors; std::vector required_rooms; std::vector required_doors; + std::vector required_panels; bool check = false; bool exclude_reduce = false; bool achievement = false; std::string achievement_name; + bool non_counting = false; }; struct ProgressiveRequirement { @@ -65,6 +67,7 @@ struct Room { std::string name; std::vector exits; std::vector paintings; + std::vector panels; }; struct Location { diff --git a/src/tracker_state.cpp b/src/tracker_state.cpp index 37a7da8..b0e7ccc 100644 --- a/src/tracker_state.cpp +++ b/src/tracker_state.cpp @@ -45,6 +45,25 @@ bool IsPanelReachable_Helper(int panel_id, return (achievements_accessible >= AP_GetMasteryRequirement()); } + if (panel_obj.name == "LEVEL 2" && AP_GetVictoryCondition() == kLEVEL_2) { + int counting_panels_accessible = 0; + + for (int reachable_room : reachable_rooms) { + const Room& room = GD_GetRoom(reachable_room); + + for (int roomed_panel_id : room.panels) { + const Panel& roomed_panel = GD_GetPanel(roomed_panel_id); + + if (!roomed_panel.non_counting && + IsPanelReachable_Helper(roomed_panel_id, reachable_rooms)) { + counting_panels_accessible++; + } + } + } + + return (counting_panels_accessible >= AP_GetLevel2Requirement()); + } + for (int room_id : panel_obj.required_rooms) { if (!reachable_rooms.count(room_id)) { return false; @@ -57,6 +76,12 @@ bool IsPanelReachable_Helper(int panel_id, } } + for (int panel_id : panel_obj.required_panels) { + if (!IsPanelReachable_Helper(panel_id, reachable_rooms)) { + return false; + } + } + if (AP_IsColorShuffle()) { for (LingoColor color : panel_obj.colors) { if (!AP_HasColorItem(color)) { -- cgit 1.4.1