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

Backpack limit part1 (move, disassemble)

This commit is contained in:
SoundSSGood
2023-03-18 12:44:01 +02:00
parent 37edffd788
commit 96e8a1f21c
9 changed files with 110 additions and 68 deletions

View File

@@ -153,10 +153,9 @@ bool CArtifact::canBePutAt(const CArtifactSet * artSet, ArtifactPosition slot, b
{
if(ArtifactUtils::isSlotBackpack(slot))
{
if(isBig())
if(isBig() || !ArtifactUtils::isBackpackFreeSlots(artSet))
return false;
//TODO backpack limit
return true;
}
@@ -1566,15 +1565,14 @@ DLL_LINKAGE ArtifactPosition ArtifactUtils::getArtifactDstPosition(const Artifac
const auto * art = aid.toArtifact();
for(const auto & slot : art->possibleSlots.at(target->bearerType()))
{
const auto * existingArtInfo = target->getSlot(slot);
if((!existingArtInfo || !existingArtInfo->locked)
&& art->canBePutAt(target, slot))
{
if(art->canBePutAt(target, slot))
return slot;
}
}
return GameConstants::BACKPACK_START;
if(art->canBePutAt(target, GameConstants::BACKPACK_START))
{
return GameConstants::BACKPACK_START;
}
return ArtifactPosition::PRE_FIRST;
}
DLL_LINKAGE const std::vector<ArtifactPosition::EArtifactPosition> & ArtifactUtils::unmovableSlots()
@@ -1643,4 +1641,13 @@ DLL_LINKAGE bool ArtifactUtils::isSlotEquipment(const ArtifactPosition & slot)
return slot < GameConstants::BACKPACK_START && slot >= 0;
}
DLL_LINKAGE bool ArtifactUtils::isBackpackFreeSlots(const CArtifactSet * target, const size_t reqSlots)
{
const auto backpackCap = VLC->settings()->getInteger(EGameSettings::HEROES_BACKPACK_CAP);
if(backpackCap < 0)
return true;
else
return target->artifactsInBackpack.size() + reqSlots <= backpackCap;
}
VCMI_LIB_NAMESPACE_END