mirror of
https://github.com/vcmi/vcmi.git
synced 2025-03-21 21:17:49 +02:00
CArtifactSet::getSlotByInstance
This commit is contained in:
parent
a8220c551f
commit
1f4897e841
@ -1205,6 +1205,25 @@ const CArtifactInstance * CArtifactSet::getArtByInstanceId(const ArtifactInstanc
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const ArtifactPosition CArtifactSet::getSlotByInstance(const CArtifactInstance * artInst) const
|
||||
{
|
||||
if(artInst)
|
||||
{
|
||||
for(auto & slot : artInst->artType->possibleSlots.at(bearerType()))
|
||||
if(getArt(slot) == artInst)
|
||||
return slot;
|
||||
|
||||
auto backpackSlot = GameConstants::BACKPACK_START;
|
||||
for(auto & slotInfo : artifactsInBackpack)
|
||||
{
|
||||
if(slotInfo.getArt() == artInst)
|
||||
return backpackSlot;
|
||||
backpackSlot = ArtifactPosition(backpackSlot + 1);
|
||||
}
|
||||
}
|
||||
return ArtifactPosition::PRE_FIRST;
|
||||
}
|
||||
|
||||
bool CArtifactSet::hasArt(const ArtifactID & aid, bool onlyWorn, bool searchBackpackAssemblies, bool allowLocked) const
|
||||
{
|
||||
return getArtPosCount(aid, onlyWorn, searchBackpackAssemblies, allowLocked) > 0;
|
||||
|
@ -328,6 +328,7 @@ public:
|
||||
std::vector<ArtifactPosition> getAllArtPositions(const ArtifactID & aid, bool onlyWorn, bool allowLocked, bool getAll) const;
|
||||
std::vector<ArtifactPosition> getBackpackArtPositions(const ArtifactID & aid) const;
|
||||
const CArtifactInstance * getArtByInstanceId(const ArtifactInstanceID & artInstId) const;
|
||||
const ArtifactPosition getSlotByInstance(const CArtifactInstance * artInst) const;
|
||||
/// Search for constituents of assemblies in backpack which do not have an ArtifactPosition
|
||||
const CArtifactInstance * getHiddenArt(const ArtifactID & aid) const;
|
||||
const CCombinedArtifactInstance * getAssemblyByConstituent(const ArtifactID & aid) const;
|
||||
|
Loading…
x
Reference in New Issue
Block a user