Laserlicht 3 ماه پیش
والد
کامیت
cf32f00472

+ 1 - 1
client/windows/CCreatureWindow.cpp

@@ -936,7 +936,7 @@ void CStackWindow::initBonusesList()
 		bonusInfo.bonusSource = b->source;
 
 		//if it's possible to give any description or image for this kind of bonus
-		if(!bonusInfo.description.empty())
+		if(!bonusInfo.description.empty() && !b->hidden)
 			activeBonuses.push_back(bonusInfo);
 	}
 }

+ 4 - 0
config/schemas/bonusInstance.json

@@ -252,6 +252,10 @@
 				{ "type" : "number" }
 			],
 			"description" : "description"
+		},
+		"hidden" : {
+			"type" : "boolean",
+			"description" : "Optional, hide bonus in creature window"
 		}
 	}
 }

+ 3 - 0
docs/modders/Bonus_Format.md

@@ -72,6 +72,9 @@ All parameters but type are optional.
 	// Optional, path to custom icon that will be visible in creature window
 	"icon" : "",
 	
+	// Optional, hide bonus in creature window
+	"hidden" : true,
+	
 	// Stacking string allows to block stacking of bonuses from different entities
 	// For example, devils and archdevils (different entities) both have battle-wide debuff to luck
 	// Normally, having both such units in combat would result in bonus stacking, providing -2 debuff to luck in total

+ 1 - 0
lib/bonuses/Bonus.cpp

@@ -203,6 +203,7 @@ JsonNode Bonus::toJsonNode() const
 		root["updater"] = updater->toJsonNode();
 	if(propagator)
 		root["propagator"].String() = vstd::findKey(bonusPropagatorMap, propagator);
+	root["hidden"].Bool() = hidden;
 	return root;
 }
 

+ 4 - 0
lib/bonuses/Bonus.h

@@ -75,6 +75,8 @@ struct DLL_LINKAGE Bonus : public std::enable_shared_from_this<Bonus>, public Se
 	MetaString description;
 	PlayerColor bonusOwner = PlayerColor::CANNOT_DETERMINE;
 
+	bool hidden;
+
 	Bonus(BonusDuration::Type Duration, BonusType Type, BonusSource Src, si32 Val, BonusSourceID sourceID);
 	Bonus(BonusDuration::Type Duration, BonusType Type, BonusSource Src, si32 Val, BonusSourceID sourceID, BonusSubtypeID subtype);
 	Bonus(BonusDuration::Type Duration, BonusType Type, BonusSource Src, si32 Val, BonusSourceID sourceID, BonusSubtypeID subtype, BonusValueType ValType);
@@ -92,6 +94,8 @@ struct DLL_LINKAGE Bonus : public std::enable_shared_from_this<Bonus>, public Se
 		h & description;
 		if (h.hasFeature(Handler::Version::CUSTOM_BONUS_ICONS))
 			h & customIconPath;
+		if (h.hasFeature(Handler::Version::BONUS_HIDDEN))
+			h & hidden;
 		h & additionalInfo;
 		h & turnsRemain;
 		h & valType;

+ 2 - 0
lib/json/JsonBonus.cpp

@@ -723,6 +723,8 @@ bool JsonUtils::parseBonus(const JsonNode &ability, Bonus *b, const TextIdentifi
 	if(!ability["icon"].isNull())
 		b->customIconPath = ImagePath::fromJson(ability["icon"]);
 
+	b->hidden = !ability["hidden"].isNull() && ability["hidden"].Bool();
+
 	value = &ability["effectRange"];
 	if (!value->isNull())
 		b->effectRange = static_cast<BonusLimitEffect>(parseByMapN(bonusLimitEffect, value, "effect range "));

+ 2 - 1
lib/serializer/ESerializationVersion.h

@@ -47,8 +47,9 @@ enum class ESerializationVersion : int32_t
 	OPPOSITE_SIDE_LIMITER_OWNER, // opposite side limiter no longer stores owner in itself
 	UNIVERSITY_CONFIG, // town university is configurable
 	CAMPAIGN_BONUSES, // new format for scenario bonuses in campaigns
+	BONUS_HIDDEN, // hidden bonus
 
-	CURRENT = CAMPAIGN_BONUSES,
+	CURRENT = BONUS_HIDDEN,
 };
 
 static_assert(ESerializationVersion::MINIMAL <= ESerializationVersion::CURRENT, "Invalid serialization version definition!");