about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorStar Rauchenberger <fefferburbia@gmail.com>2023-08-03 11:34:57 -0400
committerStar Rauchenberger <fefferburbia@gmail.com>2023-08-03 11:34:57 -0400
commitc9a21a387634e8fdd13110906ebe786f055c446d (patch)
tree44389e404b729392e997c7b2723479f1539e9173 /src
parentb09e7749e54e21d1ccf45ef51be471e3c6200641 (diff)
downloadlingo-ap-tracker-c9a21a387634e8fdd13110906ebe786f055c446d.tar.gz
lingo-ap-tracker-c9a21a387634e8fdd13110906ebe786f055c446d.tar.bz2
lingo-ap-tracker-c9a21a387634e8fdd13110906ebe786f055c446d.zip
LEVEL 2 and required_panel support
Diffstat (limited to 'src')
-rw-r--r--src/ap_state.cpp13
-rw-r--r--src/ap_state.h6
-rw-r--r--src/game_data.cpp28
-rw-r--r--src/game_data.h3
-rw-r--r--src/tracker_state.cpp25
5 files changed, 75 insertions, 0 deletions
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 {
61 bool color_shuffle = false; 61 bool color_shuffle = false;
62 bool painting_shuffle = false; 62 bool painting_shuffle = false;
63 int mastery_requirement = 21; 63 int mastery_requirement = 21;
64 int level_2_requirement = 223;
64 bool reduce_checks = false; 65 bool reduce_checks = false;
66 VictoryCondition victory_condition = kTHE_END;
65 67
66 std::map<std::string, std::string> painting_mapping; 68 std::map<std::string, std::string> painting_mapping;
67 69
@@ -119,7 +121,9 @@ struct APState {
119 painting_shuffle = false; 121 painting_shuffle = false;
120 painting_mapping.clear(); 122 painting_mapping.clear();
121 mastery_requirement = 21; 123 mastery_requirement = 21;
124 level_2_requirement = 223;
122 reduce_checks = false; 125 reduce_checks = false;
126 victory_condition = kTHE_END;
123 127
124 connected = false; 128 connected = false;
125 has_connection_result = false; 129 has_connection_result = false;
@@ -208,8 +212,11 @@ struct APState {
208 color_shuffle = slot_data["shuffle_colors"].get<bool>(); 212 color_shuffle = slot_data["shuffle_colors"].get<bool>();
209 painting_shuffle = slot_data["shuffle_paintings"].get<bool>(); 213 painting_shuffle = slot_data["shuffle_paintings"].get<bool>();
210 mastery_requirement = slot_data["mastery_achievements"].get<int>(); 214 mastery_requirement = slot_data["mastery_achievements"].get<int>();
215 level_2_requirement = slot_data["level_2_requirement"].get<int>();
211 reduce_checks = (door_shuffle_mode == kNO_DOORS) && 216 reduce_checks = (door_shuffle_mode == kNO_DOORS) &&
212 slot_data["reduce_checks"].get<bool>(); 217 slot_data["reduce_checks"].get<bool>();
218 victory_condition =
219 slot_data["victory_condition"].get<VictoryCondition>();
213 220
214 if (painting_shuffle && slot_data.contains("painting_entrance_to_exit")) { 221 if (painting_shuffle && slot_data.contains("painting_entrance_to_exit")) {
215 painting_mapping.clear(); 222 painting_mapping.clear();
@@ -435,8 +442,14 @@ const std::map<std::string, std::string> AP_GetPaintingMapping() {
435 442
436int AP_GetMasteryRequirement() { return GetState().mastery_requirement; } 443int AP_GetMasteryRequirement() { return GetState().mastery_requirement; }
437 444
445int AP_GetLevel2Requirement() { return GetState().level_2_requirement; }
446
438bool AP_IsReduceChecks() { return GetState().reduce_checks; } 447bool AP_IsReduceChecks() { return GetState().reduce_checks; }
439 448
449VictoryCondition AP_GetVictoryCondition() {
450 return GetState().victory_condition;
451}
452
440bool AP_HasAchievement(const std::string& achievement_name) { 453bool AP_HasAchievement(const std::string& achievement_name) {
441 return GetState().HasAchievement(achievement_name); 454 return GetState().HasAchievement(achievement_name);
442} 455}
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;
10 10
11enum DoorShuffleMode { kNO_DOORS = 0, kSIMPLE_DOORS = 1, kCOMPLEX_DOORS = 2 }; 11enum DoorShuffleMode { kNO_DOORS = 0, kSIMPLE_DOORS = 1, kCOMPLEX_DOORS = 2 };
12 12
13enum VictoryCondition { kTHE_END = 0, kTHE_MASTER = 1, kLEVEL_2 = 2 };
14
13void AP_SetTrackerFrame(TrackerFrame* tracker_frame); 15void AP_SetTrackerFrame(TrackerFrame* tracker_frame);
14 16
15void AP_Connect(std::string server, std::string player, std::string password); 17void AP_Connect(std::string server, std::string player, std::string password);
@@ -30,8 +32,12 @@ const std::map<std::string, std::string> AP_GetPaintingMapping();
30 32
31int AP_GetMasteryRequirement(); 33int AP_GetMasteryRequirement();
32 34
35int AP_GetLevel2Requirement();
36
33bool AP_IsReduceChecks(); 37bool AP_IsReduceChecks();
34 38
39VictoryCondition AP_GetVictoryCondition();
40
35bool AP_HasAchievement(const std::string& achievement_name); 41bool AP_HasAchievement(const std::string& achievement_name);
36 42
37#endif /* end of include guard: AP_STATE_H_664A4180 */ 43#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 {
125 int panel_id = 125 int panel_id =
126 AddOrGetPanel(room_obj.name, panel_it.first.as<std::string>()); 126 AddOrGetPanel(room_obj.name, panel_it.first.as<std::string>());
127 Panel &panel_obj = panels_[panel_id]; 127 Panel &panel_obj = panels_[panel_id];
128 room_obj.panels.push_back(panel_id);
128 129
129 if (panel_it.second["colors"]) { 130 if (panel_it.second["colors"]) {
130 if (panel_it.second["colors"].IsScalar()) { 131 if (panel_it.second["colors"].IsScalar()) {
@@ -174,6 +175,29 @@ struct GameData {
174 } 175 }
175 } 176 }
176 177
178 if (panel_it.second["required_panel"]) {
179 if (panel_it.second["required_panel"].IsMap()) {
180 std::string rp_room = room_obj.name;
181 if (panel_it.second["required_panel"]["room"]) {
182 rp_room = panel_it.second["required_panel"]["room"].as<std::string>();
183 }
184
185 panel_obj.required_panels.push_back(AddOrGetPanel(
186 rp_room, panel_it.second["required_panel"]["panel"]
187 .as<std::string>()));
188 } else {
189 for (const auto &rp_node : panel_it.second["required_panel"]) {
190 std::string rp_room = room_obj.name;
191 if (rp_node["room"]) {
192 rp_room = rp_node["room"].as<std::string>();
193 }
194
195 panel_obj.required_panels.push_back(
196 AddOrGetPanel(rp_room, rp_node["panel"].as<std::string>()));
197 }
198 }
199 }
200
177 if (panel_it.second["check"]) { 201 if (panel_it.second["check"]) {
178 panel_obj.check = panel_it.second["check"].as<bool>(); 202 panel_obj.check = panel_it.second["check"].as<bool>();
179 } 203 }
@@ -189,6 +213,10 @@ struct GameData {
189 panel_obj.exclude_reduce = 213 panel_obj.exclude_reduce =
190 panel_it.second["exclude_reduce"].as<bool>(); 214 panel_it.second["exclude_reduce"].as<bool>();
191 } 215 }
216
217 if (panel_it.second["non_counting"]) {
218 panel_obj.non_counting = panel_it.second["non_counting"].as<bool>();
219 }
192 } 220 }
193 } 221 }
194 222
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 {
26 std::vector<LingoColor> colors; 26 std::vector<LingoColor> colors;
27 std::vector<int> required_rooms; 27 std::vector<int> required_rooms;
28 std::vector<int> required_doors; 28 std::vector<int> required_doors;
29 std::vector<int> required_panels;
29 bool check = false; 30 bool check = false;
30 bool exclude_reduce = false; 31 bool exclude_reduce = false;
31 bool achievement = false; 32 bool achievement = false;
32 std::string achievement_name; 33 std::string achievement_name;
34 bool non_counting = false;
33}; 35};
34 36
35struct ProgressiveRequirement { 37struct ProgressiveRequirement {
@@ -65,6 +67,7 @@ struct Room {
65 std::string name; 67 std::string name;
66 std::vector<Exit> exits; 68 std::vector<Exit> exits;
67 std::vector<PaintingExit> paintings; 69 std::vector<PaintingExit> paintings;
70 std::vector<int> panels;
68}; 71};
69 72
70struct Location { 73struct 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,
45 return (achievements_accessible >= AP_GetMasteryRequirement()); 45 return (achievements_accessible >= AP_GetMasteryRequirement());
46 } 46 }
47 47
48 if (panel_obj.name == "LEVEL 2" && AP_GetVictoryCondition() == kLEVEL_2) {
49 int counting_panels_accessible = 0;
50
51 for (int reachable_room : reachable_rooms) {
52 const Room& room = GD_GetRoom(reachable_room);
53
54 for (int roomed_panel_id : room.panels) {
55 const Panel& roomed_panel = GD_GetPanel(roomed_panel_id);
56
57 if (!roomed_panel.non_counting &&
58 IsPanelReachable_Helper(roomed_panel_id, reachable_rooms)) {
59 counting_panels_accessible++;
60 }
61 }
62 }
63
64 return (counting_panels_accessible >= AP_GetLevel2Requirement());
65 }
66
48 for (int room_id : panel_obj.required_rooms) { 67 for (int room_id : panel_obj.required_rooms) {
49 if (!reachable_rooms.count(room_id)) { 68 if (!reachable_rooms.count(room_id)) {
50 return false; 69 return false;
@@ -57,6 +76,12 @@ bool IsPanelReachable_Helper(int panel_id,
57 } 76 }
58 } 77 }
59 78
79 for (int panel_id : panel_obj.required_panels) {
80 if (!IsPanelReachable_Helper(panel_id, reachable_rooms)) {
81 return false;
82 }
83 }
84
60 if (AP_IsColorShuffle()) { 85 if (AP_IsColorShuffle()) {
61 for (LingoColor color : panel_obj.colors) { 86 for (LingoColor color : panel_obj.colors) {
62 if (!AP_HasColorItem(color)) { 87 if (!AP_HasColorItem(color)) {