about summary refs log tree commit diff stats
path: root/ap_state.cpp
diff options
context:
space:
mode:
authorStar Rauchenberger <fefferburbia@gmail.com>2023-05-02 21:00:00 -0400
committerStar Rauchenberger <fefferburbia@gmail.com>2023-05-02 21:00:00 -0400
commit1ec273825497fd6feda19079fa8006096777b11d (patch)
tree6b705070cde43de5dbf167f636bd13428e26b3a0 /ap_state.cpp
parenta3eaefcd38f5f92dc342a2a43d37b6571d2a7a6d (diff)
downloadlingo-ap-tracker-1ec273825497fd6feda19079fa8006096777b11d.tar.gz
lingo-ap-tracker-1ec273825497fd6feda19079fa8006096777b11d.tar.bz2
lingo-ap-tracker-1ec273825497fd6feda19079fa8006096777b11d.zip
Support door shuffle
Diffstat (limited to 'ap_state.cpp')
-rw-r--r--ap_state.cpp24
1 files changed, 19 insertions, 5 deletions
diff --git a/ap_state.cpp b/ap_state.cpp index 9df487f..910feb7 100644 --- a/ap_state.cpp +++ b/ap_state.cpp
@@ -17,11 +17,6 @@ constexpr int AP_REVISION = 0;
17 17
18constexpr int ITEM_HANDLING = 7; // <- all 18constexpr int ITEM_HANDLING = 7; // <- all
19 19
20NLOHMANN_JSON_SERIALIZE_ENUM(DoorShuffleMode,
21 {{DoorShuffleMode::kNone, "none"},
22 {DoorShuffleMode::kSimple, "simple"},
23 {DoorShuffleMode::kComplex, "complex"}});
24
25APState::APState() { 20APState::APState() {
26 std::thread([this]() { 21 std::thread([this]() {
27 for (;;) { 22 for (;;) {
@@ -178,6 +173,17 @@ void APState::Connect(std::string server, std::string player,
178 } 173 }
179 } 174 }
180 175
176 for (const Door& door : GetGameData().GetDoors()) {
177 if (!door.skip_item) {
178 ap_id_by_item_name_[door.item_name] = GetItemId(door.item_name);
179
180 if (!door.group_name.empty() &&
181 !ap_id_by_item_name_.count(door.group_name)) {
182 ap_id_by_item_name_[door.group_name] = GetItemId(door.group_name);
183 }
184 }
185 }
186
181 ap_id_by_color_[LingoColor::kBlack] = GetItemId("Black"); 187 ap_id_by_color_[LingoColor::kBlack] = GetItemId("Black");
182 ap_id_by_color_[LingoColor::kRed] = GetItemId("Red"); 188 ap_id_by_color_[LingoColor::kRed] = GetItemId("Red");
183 ap_id_by_color_[LingoColor::kBlue] = GetItemId("Blue"); 189 ap_id_by_color_[LingoColor::kBlue] = GetItemId("Blue");
@@ -212,6 +218,14 @@ bool APState::HasColorItem(LingoColor color) const {
212 } 218 }
213} 219}
214 220
221bool APState::HasItem(const std::string& item) const {
222 if (ap_id_by_item_name_.count(item)) {
223 return inventory_.count(ap_id_by_item_name_.at(item));
224 } else {
225 return false;
226 }
227}
228
215void APState::RefreshTracker() { 229void APState::RefreshTracker() {
216 GetTrackerState().CalculateState(); 230 GetTrackerState().CalculateState();
217 tracker_frame_->UpdateIndicators(); 231 tracker_frame_->UpdateIndicators();