1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-27 22:49:25 +02:00

Remove artifact from slot as reward

This commit is contained in:
Ivan Savenko
2025-05-01 21:02:56 +03:00
parent 6688d28198
commit 0212b6e37d
9 changed files with 72 additions and 2 deletions

View File

@@ -117,6 +117,16 @@ void Rewardable::Reward::loadComponents(std::vector<Component> & comps, const CG
for(const auto & entry : takenArtifacts)
comps.emplace_back(ComponentType::ARTIFACT, entry);
for(const auto & entry : takenArtifactSlots)
{
if (h)
{
const auto & slotContent = h->getSlot(entry);
if (slotContent->artifactID.hasValue())
comps.emplace_back(ComponentType::ARTIFACT, slotContent->getArt()->getTypeId());
}
}
for(const SpellID & spell : scrolls)
comps.emplace_back(ComponentType::SPELL, spell);
@@ -149,6 +159,7 @@ void Rewardable::Reward::serializeJson(JsonSerializeFormat & handler)
handler.serializeInt("movePoints", movePoints);
handler.serializeIdArray("artifacts", grantedArtifacts);
handler.serializeIdArray("takenArtifacts", takenArtifacts);
handler.serializeIdArray("takenArtifactSlots", takenArtifactSlots);
handler.serializeIdArray("scrolls", scrolls);
handler.serializeIdArray("spells", spells);
handler.enterArray("creatures").serializeStruct(creatures);