Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

同名のサポートカードイベントが存在する場合、選択肢を優先して読み取るように修正 #126

Merged
merged 3 commits into from
Feb 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions UmaUmaChecker/src/Data/EventData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@ bool EventData::Load(const std::wstring& path)
if (EventMap.find(EventName) == EventMap.end()) {
EventMap[EventName] = event;
}

if (EventDuplicationCount.find(EventName) == EventDuplicationCount.end()) {
EventDuplicationCount[EventName] = 1;
}
else {
EventDuplicationCount[EventName]++;
}
}
}

Expand Down Expand Up @@ -199,6 +206,13 @@ std::shared_ptr<EventRoot> EventData::GetName(const std::wstring& name)
return itr->second;
}

bool EventData::IsEventNameDuplicate(const std::wstring& name)
{
if (EventDuplicationCount.find(name) == EventDuplicationCount.end()) return false;

return EventDuplicationCount[name] > 1;
}

void EventData::InitDB(const std::filesystem::path& path)
{
this->dbpath = path / L"event.db";
Expand Down
3 changes: 3 additions & 0 deletions UmaUmaChecker/src/Data/EventData.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ class EventData : public BaseData
std::shared_ptr<EventRoot> RetrieveName(const std::wstring& name);
std::shared_ptr<EventRoot> GetName(const std::wstring& name);

bool IsEventNameDuplicate(const std::wstring& name);

const std::vector<std::vector<std::shared_ptr<EventRoot>>>& GetRanks() const { return ByRank; }

private:
Expand All @@ -36,6 +38,7 @@ class EventData : public BaseData
std::unordered_map<std::wstring, std::shared_ptr<EventSource>> EventMap;
std::unordered_map<std::wstring, std::shared_ptr<EventSource>> OptionMap;
std::unordered_map<std::wstring, std::shared_ptr<EventRoot>> NameMap;
std::unordered_map<std::wstring, int> EventDuplicationCount;

std::filesystem::path dbpath;
std::filesystem::path optiondbpath;
Expand Down
2 changes: 1 addition & 1 deletion UmaUmaChecker/src/Recognizer/Uma.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ EventSource* Uma::DetectEvent(const cv::Mat& srcImg, uint64* pHash, std::vector<
if (pHash) *pHash = hash;

auto event = GetCardEvent(events);
if (!event) event = GetEventByBottomOption(srcImg);
if (!event || EventLib.CardEvent.IsEventNameDuplicate(event->Name)) event = GetEventByBottomOption(srcImg);
if (config->EnableDebug && event && event.get() != CurrentEvent) LOG_DEBUG << L"[サポートカード] イベント名: " << event->Name;
return event.get();
}
Expand Down
Loading