implement card auctions

This commit is contained in:
Martin Michelsen
2022-11-27 23:52:18 -08:00
parent 9f2f0ccc14
commit 41a858935b
10 changed files with 209 additions and 24 deletions
+10
View File
@@ -1241,6 +1241,11 @@ DataIndex::DataIndex(const string& directory, bool debug)
"duplicate card id: %08" PRIX32, entry->def.card_id.load()));
}
// Some cards intentionally have the same name, so we just leave them
// unindexed (they can still be looked up by ID, of course)
string name = entry->def.en_name;
this->card_definitions_by_name.emplace(name, entry);
entry->def.hp.decode_code();
entry->def.ap.decode_code();
entry->def.tp.decode_code();
@@ -1320,6 +1325,11 @@ shared_ptr<const DataIndex::CardEntry> DataIndex::definition_for_card_id(
return this->card_definitions.at(id);
}
shared_ptr<const DataIndex::CardEntry> DataIndex::definition_for_card_name(
const string& name) const {
return this->card_definitions_by_name.at(name);
}
set<uint32_t> DataIndex::all_card_ids() const {
set<uint32_t> ret;
for (const auto& it : this->card_definitions) {
+3
View File
@@ -790,6 +790,8 @@ public:
const std::string& get_compressed_card_definitions() const;
std::shared_ptr<const CardEntry> definition_for_card_id(uint32_t id) const;
std::shared_ptr<const CardEntry> definition_for_card_name(
const std::string& name) const;
std::set<uint32_t> all_card_ids() const;
const std::string& get_compressed_map_list() const;
@@ -801,6 +803,7 @@ private:
std::string compressed_card_definitions;
std::unordered_map<uint32_t, std::shared_ptr<CardEntry>> card_definitions;
std::unordered_map<std::string, std::shared_ptr<CardEntry>> card_definitions_by_name;
// The compressed map list is generated on demand from the maps map below.
// It's marked mutable because the logical consistency of the DataIndex object