2025-04-16 17:05:52 +03:00
|
|
|
/*
|
2025-04-29 12:10:19 +03:00
|
|
|
* CArtifactSet.h, part of VCMI engine
|
2025-04-16 17:05:52 +03:00
|
|
|
*
|
|
|
|
* Authors: listed in file AUTHORS in main folder
|
|
|
|
*
|
|
|
|
* License: GNU General Public License v2.0 or later
|
|
|
|
* Full text of license available in license.txt file, in main folder
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
2025-04-29 12:10:19 +03:00
|
|
|
#include "ArtBearer.h"
|
|
|
|
#include "ArtSlotInfo.h"
|
|
|
|
#include "../../serializer/Serializeable.h"
|
2025-04-16 17:05:52 +03:00
|
|
|
|
|
|
|
VCMI_LIB_NAMESPACE_BEGIN
|
|
|
|
|
2025-04-29 12:10:19 +03:00
|
|
|
class CArtifactInstance;
|
|
|
|
class CMap;
|
2025-04-16 17:05:52 +03:00
|
|
|
|
|
|
|
class DLL_LINKAGE CArtifactSet : public virtual Serializeable
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
using ArtPlacementMap = std::map<const CArtifactInstance*, ArtifactPosition>;
|
|
|
|
|
|
|
|
std::vector<ArtSlotInfo> artifactsInBackpack; //hero's artifacts from bag
|
|
|
|
std::map<ArtifactPosition, ArtSlotInfo> artifactsWorn; //map<position,artifact_id>; positions: 0 - head; 1 - shoulders; 2 - neck; 3 - right hand; 4 - left hand; 5 - torso; 6 - right ring; 7 - left ring; 8 - feet; 9 - misc1; 10 - misc2; 11 - misc3; 12 - misc4; 13 - mach1; 14 - mach2; 15 - mach3; 16 - mach4; 17 - spellbook; 18 - misc5
|
|
|
|
ArtSlotInfo artifactsTransitionPos; // Used as transition position for dragAndDrop artifact exchange
|
|
|
|
|
|
|
|
const ArtSlotInfo * getSlot(const ArtifactPosition & pos) const;
|
|
|
|
void lockSlot(const ArtifactPosition & pos);
|
|
|
|
const CArtifactInstance * getArt(const ArtifactPosition & pos, bool excludeLocked = true) const;
|
|
|
|
ArtifactInstanceID getArtID(const ArtifactPosition & pos, bool excludeLocked = true) const;
|
|
|
|
/// Looks for first artifact with given ID
|
|
|
|
ArtifactPosition getArtPos(const ArtifactID & aid, bool onlyWorn = true, bool allowLocked = true) const;
|
2025-05-06 16:00:21 +03:00
|
|
|
ArtifactPosition getScrollPos(const SpellID & aid, bool onlyWorn = true) const;
|
2025-04-16 17:05:52 +03:00
|
|
|
ArtifactPosition getArtPos(const CArtifactInstance * art) const;
|
|
|
|
const CArtifactInstance * getArtByInstanceId(const ArtifactInstanceID & artInstId) const;
|
|
|
|
bool hasArt(const ArtifactID & aid, bool onlyWorn = false, bool searchCombinedParts = false) const;
|
2025-05-06 16:00:21 +03:00
|
|
|
bool hasScroll(const SpellID & aid, bool onlyWorn = false) const;
|
2025-04-16 17:05:52 +03:00
|
|
|
bool isPositionFree(const ArtifactPosition & pos, bool onlyLockCheck = false) const;
|
|
|
|
|
2025-05-14 13:39:37 +03:00
|
|
|
virtual CGameInfoCallback * getCallback() const = 0;
|
2025-05-05 16:05:59 +03:00
|
|
|
virtual ArtBearer bearerType() const = 0;
|
2025-04-16 17:05:52 +03:00
|
|
|
virtual ArtPlacementMap putArtifact(const ArtifactPosition & slot, const CArtifactInstance * art);
|
|
|
|
virtual void removeArtifact(const ArtifactPosition & slot);
|
2025-05-14 13:39:37 +03:00
|
|
|
CArtifactSet(CGameInfoCallback * cb);
|
2025-04-16 17:05:52 +03:00
|
|
|
virtual ~CArtifactSet() = default;
|
|
|
|
|
|
|
|
template <typename Handler> void serialize(Handler &h)
|
|
|
|
{
|
|
|
|
h & artifactsInBackpack;
|
|
|
|
h & artifactsWorn;
|
|
|
|
}
|
|
|
|
|
2025-04-19 14:14:12 +03:00
|
|
|
void artDeserializationFix(CGameState & gs, CBonusSystemNode *node);
|
2025-04-16 17:05:52 +03:00
|
|
|
|
|
|
|
void serializeJsonArtifacts(JsonSerializeFormat & handler, const std::string & fieldName, CMap * map);
|
|
|
|
const CArtifactInstance * getCombinedArtWithPart(const ArtifactID & partId) const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
void serializeJsonHero(JsonSerializeFormat & handler, CMap * map);
|
|
|
|
void serializeJsonCreature(JsonSerializeFormat & handler);
|
|
|
|
void serializeJsonCommander(JsonSerializeFormat & handler);
|
|
|
|
|
|
|
|
void serializeJsonSlot(JsonSerializeFormat & handler, const ArtifactPosition & slot, CMap * map);//normal slots
|
|
|
|
};
|
|
|
|
|
|
|
|
VCMI_LIB_NAMESPACE_END
|