diff options
author | Star Rauchenberger <fefferburbia@gmail.com> | 2023-05-03 14:09:40 -0400 |
---|---|---|
committer | Star Rauchenberger <fefferburbia@gmail.com> | 2023-05-03 14:09:40 -0400 |
commit | dc4a14397ae226d91041389c2a47993f9c22f83d (patch) | |
tree | e881fcac382d53961899bd60565ef77422101f6d | |
parent | 02c331f4e766558bba580d5b7db883357be005d5 (diff) | |
download | lingo-ap-tracker-dc4a14397ae226d91041389c2a47993f9c22f83d.tar.gz lingo-ap-tracker-dc4a14397ae226d91041389c2a47993f9c22f83d.tar.bz2 lingo-ap-tracker-dc4a14397ae226d91041389c2a47993f9c22f83d.zip |
Added painting shuffle support
-rw-r--r-- | ap_state.cpp | 13 | ||||
-rw-r--r-- | ap_state.h | 9 | ||||
-rw-r--r-- | game_data.cpp | 33 | ||||
-rw-r--r-- | game_data.h | 13 | ||||
-rw-r--r-- | tracker_state.cpp | 17 |
5 files changed, 84 insertions, 1 deletions
diff --git a/ap_state.cpp b/ap_state.cpp index 2c8ba0a..8400557 100644 --- a/ap_state.cpp +++ b/ap_state.cpp | |||
@@ -56,6 +56,10 @@ void APState::Connect(std::string server, std::string player, | |||
56 | 56 | ||
57 | inventory_.clear(); | 57 | inventory_.clear(); |
58 | checked_locations_.clear(); | 58 | checked_locations_.clear(); |
59 | door_shuffle_mode_ = kNO_DOORS; | ||
60 | color_shuffle_ = false; | ||
61 | painting_shuffle_ = false; | ||
62 | painting_mapping_.clear(); | ||
59 | 63 | ||
60 | bool connected = false; | 64 | bool connected = false; |
61 | bool has_connection_result = false; | 65 | bool has_connection_result = false; |
@@ -103,6 +107,15 @@ void APState::Connect(std::string server, std::string player, | |||
103 | 107 | ||
104 | door_shuffle_mode_ = slot_data["shuffle_doors"].get<DoorShuffleMode>(); | 108 | door_shuffle_mode_ = slot_data["shuffle_doors"].get<DoorShuffleMode>(); |
105 | color_shuffle_ = slot_data["shuffle_colors"].get<bool>(); | 109 | color_shuffle_ = slot_data["shuffle_colors"].get<bool>(); |
110 | painting_shuffle_ = slot_data["shuffle_paintings"].get<bool>(); | ||
111 | |||
112 | if (painting_shuffle_ && slot_data.contains("painting_entrance_to_exit")) { | ||
113 | painting_mapping_.clear(); | ||
114 | |||
115 | for (const auto& mapping_it : slot_data["painting_entrance_to_exit"].items()) { | ||
116 | painting_mapping_[mapping_it.key()] = mapping_it.value(); | ||
117 | } | ||
118 | } | ||
106 | 119 | ||
107 | connected = true; | 120 | connected = true; |
108 | has_connection_result = true; | 121 | has_connection_result = true; |
diff --git a/ap_state.h b/ap_state.h index 5ed7574..8f27a23 100644 --- a/ap_state.h +++ b/ap_state.h | |||
@@ -32,6 +32,12 @@ class APState { | |||
32 | 32 | ||
33 | bool IsColorShuffle() const { return color_shuffle_; } | 33 | bool IsColorShuffle() const { return color_shuffle_; } |
34 | 34 | ||
35 | bool IsPaintingShuffle() const { return painting_shuffle_; } | ||
36 | |||
37 | const std::map<std::string, std::string> GetPaintingMapping() const { | ||
38 | return painting_mapping_; | ||
39 | } | ||
40 | |||
35 | private: | 41 | private: |
36 | void RefreshTracker(); | 42 | void RefreshTracker(); |
37 | 43 | ||
@@ -51,6 +57,9 @@ class APState { | |||
51 | 57 | ||
52 | DoorShuffleMode door_shuffle_mode_ = kNO_DOORS; | 58 | DoorShuffleMode door_shuffle_mode_ = kNO_DOORS; |
53 | bool color_shuffle_ = false; | 59 | bool color_shuffle_ = false; |
60 | bool painting_shuffle_ = false; | ||
61 | |||
62 | std::map<std::string, std::string> painting_mapping_; | ||
54 | }; | 63 | }; |
55 | 64 | ||
56 | APState& GetAPState(); | 65 | APState& GetAPState(); |
diff --git a/game_data.cpp b/game_data.cpp index 80ffd97..2f8f505 100644 --- a/game_data.cpp +++ b/game_data.cpp | |||
@@ -63,6 +63,10 @@ GameData::GameData() { | |||
63 | door_room, entrance_it.second["door"].as<std::string>()); | 63 | door_room, entrance_it.second["door"].as<std::string>()); |
64 | } | 64 | } |
65 | 65 | ||
66 | if (entrance_it.second["painting"]) { | ||
67 | exit_obj.painting = entrance_it.second["painting"].as<bool>(); | ||
68 | } | ||
69 | |||
66 | from_room_obj.exits.push_back(exit_obj); | 70 | from_room_obj.exits.push_back(exit_obj); |
67 | break; | 71 | break; |
68 | } | 72 | } |
@@ -78,6 +82,10 @@ GameData::GameData() { | |||
78 | exit_obj.door = | 82 | exit_obj.door = |
79 | AddOrGetDoor(door_room, option["door"].as<std::string>()); | 83 | AddOrGetDoor(door_room, option["door"].as<std::string>()); |
80 | 84 | ||
85 | if (option["painting"]) { | ||
86 | exit_obj.painting = option["painting"].as<bool>(); | ||
87 | } | ||
88 | |||
81 | from_room_obj.exits.push_back(exit_obj); | 89 | from_room_obj.exits.push_back(exit_obj); |
82 | } | 90 | } |
83 | 91 | ||
@@ -225,6 +233,31 @@ GameData::GameData() { | |||
225 | } | 233 | } |
226 | } | 234 | } |
227 | } | 235 | } |
236 | |||
237 | if (room_it.second["paintings"]) { | ||
238 | for (const auto& painting : room_it.second["paintings"]) { | ||
239 | std::string painting_id = painting["id"].as<std::string>(); | ||
240 | room_by_painting_[painting_id] = room_id; | ||
241 | |||
242 | if (!painting["exit_only"] || !painting["exit_only"].as<bool>()) { | ||
243 | PaintingExit painting_exit; | ||
244 | painting_exit.id = painting_id; | ||
245 | |||
246 | if (painting["required_door"]) { | ||
247 | std::string rd_room = room_obj.name; | ||
248 | if (painting["required_door"]["room"]) { | ||
249 | rd_room = painting["required_door"]["room"].as<std::string>(); | ||
250 | } | ||
251 | |||
252 | painting_exit.door = AddOrGetDoor( | ||
253 | rd_room, | ||
254 | painting["required_door"]["door"].as<std::string>()); | ||
255 | } | ||
256 | |||
257 | room_obj.paintings.push_back(painting_exit); | ||
258 | } | ||
259 | } | ||
260 | } | ||
228 | } | 261 | } |
229 | 262 | ||
230 | map_areas_.reserve(areas_config.size()); | 263 | map_areas_.reserve(areas_config.size()); |
diff --git a/game_data.h b/game_data.h index 6ee277b..981f56f 100644 --- a/game_data.h +++ b/game_data.h | |||
@@ -45,11 +45,18 @@ struct Door { | |||
45 | struct Exit { | 45 | struct Exit { |
46 | int destination_room; | 46 | int destination_room; |
47 | std::optional<int> door; | 47 | std::optional<int> door; |
48 | bool painting = false; | ||
49 | }; | ||
50 | |||
51 | struct PaintingExit { | ||
52 | std::string id; | ||
53 | std::optional<int> door; | ||
48 | }; | 54 | }; |
49 | 55 | ||
50 | struct Room { | 56 | struct Room { |
51 | std::string name; | 57 | std::string name; |
52 | std::vector<Exit> exits; | 58 | std::vector<Exit> exits; |
59 | std::vector<PaintingExit> paintings; | ||
53 | }; | 60 | }; |
54 | 61 | ||
55 | struct Location { | 62 | struct Location { |
@@ -87,6 +94,10 @@ class GameData { | |||
87 | 94 | ||
88 | const Panel& GetPanel(int panel_id) const { return panels_.at(panel_id); } | 95 | const Panel& GetPanel(int panel_id) const { return panels_.at(panel_id); } |
89 | 96 | ||
97 | int GetRoomForPainting(const std::string& painting_id) const { | ||
98 | return room_by_painting_.at(painting_id); | ||
99 | } | ||
100 | |||
90 | private: | 101 | private: |
91 | int AddOrGetRoom(std::string room); | 102 | int AddOrGetRoom(std::string room); |
92 | int AddOrGetDoor(std::string room, std::string door); | 103 | int AddOrGetDoor(std::string room, std::string door); |
@@ -102,6 +113,8 @@ class GameData { | |||
102 | std::map<std::string, int> door_by_id_; | 113 | std::map<std::string, int> door_by_id_; |
103 | std::map<std::string, int> panel_by_id_; | 114 | std::map<std::string, int> panel_by_id_; |
104 | std::map<std::string, int> area_by_id_; | 115 | std::map<std::string, int> area_by_id_; |
116 | |||
117 | std::map<std::string, int> room_by_painting_; | ||
105 | }; | 118 | }; |
106 | 119 | ||
107 | const GameData& GetGameData(); | 120 | const GameData& GetGameData(); |
diff --git a/tracker_state.cpp b/tracker_state.cpp index a84dd6e..169d301 100644 --- a/tracker_state.cpp +++ b/tracker_state.cpp | |||
@@ -99,7 +99,22 @@ void TrackerState::CalculateState() { | |||
99 | const Room& room_obj = | 99 | const Room& room_obj = |
100 | GetGameData().GetRoom(room_exit.destination_room); | 100 | GetGameData().GetRoom(room_exit.destination_room); |
101 | for (const Exit& out_edge : room_obj.exits) { | 101 | for (const Exit& out_edge : room_obj.exits) { |
102 | new_boundary.push_back(out_edge); | 102 | if (!out_edge.painting || !GetAPState().IsPaintingShuffle()) { |
103 | new_boundary.push_back(out_edge); | ||
104 | } | ||
105 | } | ||
106 | |||
107 | if (GetAPState().IsPaintingShuffle()) { | ||
108 | for (const PaintingExit& out_edge : room_obj.paintings) { | ||
109 | if (GetAPState().GetPaintingMapping().count(out_edge.id)) { | ||
110 | Exit painting_exit; | ||
111 | painting_exit.destination_room = GetGameData().GetRoomForPainting( | ||
112 | GetAPState().GetPaintingMapping().at(out_edge.id)); | ||
113 | painting_exit.door = out_edge.door; | ||
114 | |||
115 | new_boundary.push_back(painting_exit); | ||
116 | } | ||
117 | } | ||
103 | } | 118 | } |
104 | } | 119 | } |
105 | } | 120 | } |