Forráskód Böngészése

Merge pull request #5137 from Laserlicht/bonus

[1.6.1] Bonus display
Ivan Savenko 10 hónapja
szülő
commit
d58202d2a1

+ 12 - 1
Mods/vcmi/Content/config/english.json

@@ -607,6 +607,11 @@
 	
 	"mapObject.core.hillFort.object.description" : "Upgrades creatures. Levels 1 - 4 are less expensive than in associated town.",
 	
+	"core.spellSchools.0": "Air",
+	"core.spellSchools.1": "Fire",
+	"core.spellSchools.2": "Water",
+	"core.spellSchools.3": "Earth",
+
 	"core.bonus.ADDITIONAL_ATTACK.name": "Double Strike",
 	"core.bonus.ADDITIONAL_ATTACK.description": "Attacks twice",
 	"core.bonus.ADDITIONAL_RETALIATION.name": "Additional retaliations",
@@ -762,5 +767,11 @@
 	"core.bonus.MECHANICAL.name": "Mechanical",
 	"core.bonus.MECHANICAL.description": "Immunity to many effects, repairable",
 	"core.bonus.PRISM_HEX_ATTACK_BREATH.name": "Prism Breath",
-	"core.bonus.PRISM_HEX_ATTACK_BREATH.description": "Prism Breath Attack (three directions)"
+	"core.bonus.PRISM_HEX_ATTACK_BREATH.description": "Prism Breath Attack (three directions)",
+	"core.bonus.SPELL_SCHOOL_IMMUNITY.name": "Spell immunity",
+	"core.bonus.SPELL_SCHOOL_IMMUNITY.description": "Immune to all spell schools",
+	"core.bonus.SPELL_SCHOOL_IMMUNITY.name.specific": "${subtype.spellSchool} immunity",
+	"core.bonus.SPELL_SCHOOL_IMMUNITY.description.specific": "Immune to ${subtype.spellSchool} school",
+	"core.bonus.OPENING_BATTLE_SPELL.name": "Starts with spell",
+	"core.bonus.OPENING_BATTLE_SPELL.description": "Casts ${subtype.spell} on battle start"
 }

+ 13 - 2
Mods/vcmi/Content/config/german.json

@@ -607,6 +607,11 @@
 	
 	"mapObject.core.hillFort.object.description" : "Aufwertungen von Kreaturen. Die Stufen 1 - 4 sind billiger als in der zugehörigen Stadt.",
 	
+	"core.spellSchools.0": "Luft",
+	"core.spellSchools.1": "Feuer",
+	"core.spellSchools.2": "Wasser",
+	"core.spellSchools.3": "Erde",
+	
 	"core.bonus.ADDITIONAL_ATTACK.name": "Doppelschlag",
 	"core.bonus.ADDITIONAL_ATTACK.description": "Greift zweimal an",
 	"core.bonus.ADDITIONAL_RETALIATION.name": "Zusätzliche Vergeltungsmaßnahmen",
@@ -678,7 +683,7 @@
 	"core.bonus.JOUSTING.name": "Champion Charge",
 	"core.bonus.JOUSTING.description": "+${val}% Schaden pro zurückgelegtem Feld",
 	"core.bonus.KING.name": "König",
-	"core.bonus.KING.description": "Anfällig für SLAYER Level ${val} oder höher",
+	"core.bonus.KING.description": "Anfällig für Drachentöter Level ${val} oder höher",
 	"core.bonus.LEVEL_SPELL_IMMUNITY.name": "Zauberimmunität 1-${val}",
 	"core.bonus.LEVEL_SPELL_IMMUNITY.description": "Immun gegen Zaubersprüche der Stufen 1-${val}",
 	"core.bonus.LIMITED_SHOOTING_RANGE.name" : "Begrenzte Schussweite",
@@ -762,5 +767,11 @@
 	"core.bonus.MECHANICAL.name": "Mechanisch",
 	"core.bonus.MECHANICAL.description": "Immunität gegen viele Effekte, reparierbar",
 	"core.bonus.PRISM_HEX_ATTACK_BREATH.name": "Prisma-Atem",
-	"core.bonus.PRISM_HEX_ATTACK_BREATH.description": "Prisma-Atem-Angriff (drei Richtungen)"
+	"core.bonus.PRISM_HEX_ATTACK_BREATH.description": "Prisma-Atem-Angriff (drei Richtungen)",
+	"core.bonus.SPELL_SCHOOL_IMMUNITY.name": "Zauber-Immunität",
+	"core.bonus.SPELL_SCHOOL_IMMUNITY.description": "Immunität gegen alle Zauber-Schulen",
+	"core.bonus.SPELL_SCHOOL_IMMUNITY.name.specific": "${subtype.spellSchool}-Immunität",
+	"core.bonus.SPELL_SCHOOL_IMMUNITY.description.specific": "Immunität gegen Zauber der ${subtype.spellSchool}-Schule",
+	"core.bonus.OPENING_BATTLE_SPELL.name": "Startet mit Zauber",
+	"core.bonus.OPENING_BATTLE_SPELL.description": "Wirkt ${subtype.spell} beim Start des Kampfes"
 }

+ 4 - 0
client/windows/CCreatureWindow.cpp

@@ -39,6 +39,7 @@
 #include "../../lib/networkPacks/ArtifactLocation.h"
 #include "../../lib/texts/CGeneralTextHandler.h"
 #include "../../lib/texts/TextOperations.h"
+#include "../../lib/bonuses/Propagators.h"
 
 class CCreatureArtifactInstance;
 class CSelectableSkill;
@@ -856,6 +857,9 @@ void CStackWindow::initBonusesList()
 		bonusInfo.imagePath = info->stackNode->bonusToGraphics(b);
 		bonusInfo.bonusSource = b->source;
 
+		if(b->sid.getNum() != info->stackNode->getId() && b->propagator && b->propagator->getPropagatorType() == CBonusSystemNode::HERO) // Shows bonus with "propagator":"HERO" only at creature with bonus
+			continue;
+
 		//if it's possible to give any description or image for this kind of bonus
 		//TODO: figure out why half of bonuses don't have proper description
 		if(!bonusInfo.name.empty() || !bonusInfo.imagePath.empty())

+ 12 - 0
config/bonuses.json

@@ -407,6 +407,14 @@
 		}
 	},
 
+	"OPENING_BATTLE_SPELL":
+	{
+		"graphics":
+		{
+			"icon":  "zvs/Lib1.res/E_SPDFIRE"
+		}
+	},
+
 	"RANDOM_SPELLCASTER":
 	{
 		"graphics":
@@ -532,6 +540,10 @@
 		}
 	},
 
+	"SPELL_SCHOOL_IMMUNITY":
+	{
+	},
+
 	"SPELL_RESISTANCE_AURA":
 	{
 		"graphics":

+ 17 - 0
lib/CBonusTypeHandler.cpp

@@ -75,6 +75,23 @@ std::string CBonusTypeHandler::bonusToString(const std::shared_ptr<Bonus> & bonu
 	std::string textID = description ? bt.getDescriptionTextID() : bt.getNameTextID();
 	std::string text = VLC->generaltexth->translate(textID);
 
+	if (bonus->subtype.as<SpellSchool>().hasValue())
+	{
+		auto school = bonus->subtype.as<SpellSchool>();
+		if(school != SpellSchool::ANY)
+		{
+			auto specificTextID = description ? bt.getDescriptionTextID() + ".specific" : bt.getNameTextID() + ".specific";
+			auto specificText = VLC->generaltexth->translate(specificTextID);
+
+			if(specificText.find("${subtype.spellSchool}") != std::string::npos)
+			{
+				auto schoolName = VLC->generaltexth->translate(TextIdentifier("core.spellSchools", school).get());
+				boost::algorithm::replace_all(specificText, "${subtype.spellSchool}", schoolName);
+				text = specificText;
+			}
+		}
+	}
+
 	if (text.find("${val}") != std::string::npos)
 		boost::algorithm::replace_all(text, "${val}", std::to_string(bearer->valOfBonuses(Selector::typeSubtype(bonus->type, bonus->subtype))));