#include "StarPlayerBlueprints.hpp" #include "StarItemDescriptor.hpp" namespace Star { PlayerBlueprints::PlayerBlueprints() {} PlayerBlueprints::PlayerBlueprints(Json const& variant) { m_knownBlueprints = transform>(variant.get("knownBlueprints").toArray(), construct()); m_newBlueprints = transform>(variant.get("newBlueprints").toArray(), construct()); } Json PlayerBlueprints::toJson() const { return JsonObject{{"knownBlueprints", transform(m_knownBlueprints, mem_fn(&ItemDescriptor::toJson))}, {"newBlueprints", transform(m_newBlueprints, mem_fn(&ItemDescriptor::toJson))}}; } bool PlayerBlueprints::isKnown(ItemDescriptor const& itemDescriptor) const { return m_knownBlueprints.contains(itemDescriptor.singular()); } bool PlayerBlueprints::isNew(ItemDescriptor const& itemDescriptor) const { return m_newBlueprints.contains(itemDescriptor.singular()); } void PlayerBlueprints::add(ItemDescriptor const& itemDescriptor) { if (m_knownBlueprints.add(itemDescriptor.singular())) m_newBlueprints.add(itemDescriptor.singular()); } void PlayerBlueprints::markAsRead(ItemDescriptor const& itemDescriptor) { m_newBlueprints.remove(itemDescriptor.singular()); } }