فهرست منبع

Bonus type ARTIFACT_CHARGE

SoundSSGood 5 ماه پیش
والد
کامیت
a750adf705

+ 2 - 0
Mods/vcmi/Content/config/english.json

@@ -28,6 +28,8 @@
 	"vcmi.adventureMap.movementPointsHeroInfo"           : "(Movement points: %REMAINING / %POINTS)",
 	"vcmi.adventureMap.replayOpponentTurnNotImplemented" : "Sorry, replay opponent turn is not implemented yet!",
 
+	"vcmi.artifact.charges" : "Charges",
+
 	"vcmi.bonusSource.artifact" : "Artifact",
 	"vcmi.bonusSource.creature" : "Ability",
 	"vcmi.bonusSource.spell" : "Spell",

+ 8 - 1
client/widgets/CArtifactsOfHeroBase.cpp

@@ -271,7 +271,14 @@ void CArtifactsOfHeroBase::setSlotData(ArtPlacePtr artPlace, const ArtifactPosit
 	{
 		artPlace->lockSlot(slotInfo->locked);
 		artPlace->setArtifact(slotInfo->getArt()->getTypeId(), slotInfo->getArt()->getScrollSpellID());
-		if(slotInfo->locked || slotInfo->getArt()->isCombined())
+		if(slotInfo->locked)
+			return;
+
+		const auto curArt = slotInfo->getArt();
+		// If the artifact has charges, add charges information
+		artPlace->addChargesArtInfo(curArt->valOfBonuses(BonusType::ARTIFACT_CHARGE));
+
+		if(curArt->isCombined())
 			return;
 
 		// If the artifact is part of at least one combined artifact, add additional information

+ 12 - 0
client/widgets/CComponentHolder.cpp

@@ -263,6 +263,18 @@ void CArtPlace::addCombinedArtInfo(const std::map<const ArtifactID, std::vector<
 	}
 }
 
+void CArtPlace::addChargesArtInfo(const int charges)
+{
+	if(charges > 0)
+	{
+		MetaString info;
+		info.appendTextID("vcmi.artifact.charges");
+		info.appendRawString(" %d");
+		info.replaceNumber(charges);
+		text += info.toString();
+	}
+}
+
 CSecSkillPlace::CSecSkillPlace(const Point & position, const ImageSize & imageSize, const SecondarySkill & newSkillId, const uint8_t level)
 	: CComponentHolder(Rect(position, Point()), Point())
 {

+ 1 - 0
client/widgets/CComponentHolder.h

@@ -44,6 +44,7 @@ public:
 	void lockSlot(bool on);
 	bool isLocked() const;
 	void addCombinedArtInfo(const std::map<const ArtifactID, std::vector<ArtifactID>> & arts);
+	void addChargesArtInfo(const int charges);
 
 private:
 	ArtifactID artId;

+ 7 - 1
docs/modders/Bonus/Bonus_Types.md

@@ -1031,10 +1031,16 @@ Increases amount of information available in affected thieves guild (in town or
 
 - val: additional number of 'levels' of information to grant access to
 
-### LEVEL_COUNTER
+### ARTIFACT_GROWING
 
 Internal bonus, do not use
 
+### ARTIFACT_CHARGE
+
+Consumable bonus. Used to perform actions specified by a specific artifact.
+
+- val: number of charges
+
 ### DISINTEGRATE
 
 When a unit affected by this bonus dies, no corpse is left behind

+ 1 - 0
lib/bonuses/BonusEnum.h

@@ -17,6 +17,7 @@ class JsonNode;
 #define BONUS_LIST										\
 	BONUS_NAME(NONE) 									\
 	BONUS_NAME(ARTIFACT_GROWING) \
+	BONUS_NAME(ARTIFACT_CHARGE) \
 	BONUS_NAME(MOVEMENT) /*Subtype is 1 - land, 0 - sea*/ \
 	BONUS_NAME(MORALE) \
 	BONUS_NAME(LUCK) \