From 1ec273825497fd6feda19079fa8006096777b11d Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Tue, 2 May 2023 21:00:00 -0400 Subject: Support door shuffle --- ap_state.cpp | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'ap_state.cpp') 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; constexpr int ITEM_HANDLING = 7; // <- all -NLOHMANN_JSON_SERIALIZE_ENUM(DoorShuffleMode, - {{DoorShuffleMode::kNone, "none"}, - {DoorShuffleMode::kSimple, "simple"}, - {DoorShuffleMode::kComplex, "complex"}}); - APState::APState() { std::thread([this]() { for (;;) { @@ -178,6 +173,17 @@ void APState::Connect(std::string server, std::string player, } } + for (const Door& door : GetGameData().GetDoors()) { + if (!door.skip_item) { + ap_id_by_item_name_[door.item_name] = GetItemId(door.item_name); + + if (!door.group_name.empty() && + !ap_id_by_item_name_.count(door.group_name)) { + ap_id_by_item_name_[door.group_name] = GetItemId(door.group_name); + } + } + } + ap_id_by_color_[LingoColor::kBlack] = GetItemId("Black"); ap_id_by_color_[LingoColor::kRed] = GetItemId("Red"); ap_id_by_color_[LingoColor::kBlue] = GetItemId("Blue"); @@ -212,6 +218,14 @@ bool APState::HasColorItem(LingoColor color) const { } } +bool APState::HasItem(const std::string& item) const { + if (ap_id_by_item_name_.count(item)) { + return inventory_.count(ap_id_by_item_name_.at(item)); + } else { + return false; + } +} + void APState::RefreshTracker() { GetTrackerState().CalculateState(); tracker_frame_->UpdateIndicators(); -- cgit 1.4.1