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

ManageBackpackArtifacts

This commit is contained in:
SoundSSGood
2024-03-06 15:16:35 +02:00
parent d143f53d7e
commit b1f52eec41
18 changed files with 110 additions and 33 deletions

View File

@@ -2857,6 +2857,25 @@ bool CGameHandler::bulkMoveArtifacts(ObjectInstanceID srcId, ObjectInstanceID ds
return true;
}
bool CGameHandler::scrollBackpackArtifacts(const ObjectInstanceID heroID, bool left)
{
auto artSet = getArtSet(heroID);
COMPLAIN_RET_FALSE_IF(artSet == nullptr, "scrollBackpackArtifacts: wrong hero's ID");
BulkMoveArtifacts bma(heroID, heroID, false);
const auto backpackEnd = ArtifactPosition(ArtifactPosition::BACKPACK_START + artSet->artifactsInBackpack.size() - 1);
if(backpackEnd > ArtifactPosition::BACKPACK_START)
{
if(left)
bma.artsPack0.push_back(BulkMoveArtifacts::LinkedSlots(backpackEnd, ArtifactPosition::BACKPACK_START));
else
bma.artsPack0.push_back(BulkMoveArtifacts::LinkedSlots(ArtifactPosition::BACKPACK_START, backpackEnd));
sendAndApply(&bma);
}
return true;
}
/**
* Assembles or disassembles a combination artifact.
* @param heroID ID of hero holding the artifact(s).