Browse Source

Fix generation of placeholders for banks

Ivan Savenko 1 year ago
parent
commit
d20d9bd96b

+ 1 - 0
config/gameConfig.json

@@ -57,6 +57,7 @@
 		"config/objects/magicWell.json",
 		"config/objects/moddables.json",
 		"config/objects/observatory.json",
+		"config/objects/pyramid.json",
 		"config/objects/rewardableBonusing.json",
 		"config/objects/rewardableOncePerHero.json",
 		"config/objects/rewardableOncePerWeek.json",

+ 0 - 43
config/objects/creatureBanks.json

@@ -973,48 +973,5 @@
 				]
 			}
 		}
-	},
-	"pyramid" : {
-		"index" :63,
-		"handler" : "configurable",
-		"base" : {
-			"sounds" : {
-				"visit" : ["MYSTERY"]
-			}
-		},
-		"types" : {
-			"pyramid" : {
-				"index" : 0,
-
-				"name" : "Pyramid",
-				"aiValue" : 8000,
-				"rmg" : {
-					"value"		: 5000,
-					"rarity"	: 20
-				},
-				
-				"onGuardedMessage" : 105,
-				"visitMode" : "once",
-				"selectMode" : "selectFirst",
-				"onVisited" : [
-					{
-						"message" : 107,
-						"bonuses" : [ { "type" : "LUCK", "val" : -2, "duration" : "ONE_BATTLE", "description" : 70 } ]
-					}
-				],
-				"guardsLayout" : "default",
-				"rewards" : [
-					{
-						"message" : 106,
-						"guards" : [
-							{ "amount" : 40, "type" : "goldGolem" },
-							{ "amount" : 10, "type" : "diamondGolem" },
-							{ "amount" : 10, "type" : "diamondGolem" }
-						],
-						"spells" : [ { "level" : 5 } ]
-					}
-				]
-			}
-		}
 	}
 }

+ 76 - 0
config/objects/pyramid.json

@@ -0,0 +1,76 @@
+{
+	"pyramid" : {
+		"index" :63,
+		"handler" : "configurable",
+		"base" : {
+			"sounds" : {
+				"visit" : ["MYSTERY"]
+			}
+		},
+		"types" : {
+			"pyramid" : {
+				"index" : 0,
+
+				"name" : "Pyramid",
+				"aiValue" : 8000,
+				"rmg" : {
+					"value"		: 5000,
+					"rarity"	: 20
+				},
+				
+				"variables" : {
+					"spell" : {
+						"gainedSpell" : {
+							"level": 5
+						}
+					}
+				},
+
+				"onGuardedMessage" : 105,
+				"visitMode" : "once",
+				"selectMode" : "selectFirst",
+				"onVisited" : [
+					{
+						"message" : 107,
+						"bonuses" : [ { "type" : "LUCK", "val" : -2, "duration" : "ONE_BATTLE", "description" : 70 } ]
+					}
+				],
+				"guardsLayout" : "default",
+				"rewards" : [
+					{
+						"limiter" : {
+							"canLearnSpells" : [
+								"@gainedSpell"
+							]
+						},
+						"spells" : [
+							"@gainedSpell"
+						],
+						"message" : [ 106, "%s." ] // Upon defeating monsters, you learn new spell
+						"guards" : [
+							{ "amount" : 40, "type" : "goldGolem" },
+							{ "amount" : 10, "type" : "diamondGolem" },
+							{ "amount" : 10, "type" : "diamondGolem" }
+						]
+					}
+				],
+				"onEmpty" : [
+					{
+						"limiter" : {
+							"artifacts" : [
+								{
+									"type" : "spellBook"
+								}
+							]
+						},
+						"message" : [ 106, "%s.", 108 ] // No Wisdom
+					},
+					{
+						"message" : [ 106, "%s.", 109 ] // No spellbook
+					}
+				]
+
+			}
+		}
+	}
+}

+ 4 - 4
lib/battle/BattleLayout.cpp

@@ -59,16 +59,16 @@ BattleLayout BattleLayout::createLayout(IGameCallback * cb, const std::string &
 		result.warMachines[BattleSide::DEFENDER][i] = loadHex(config["attackerWarMachines"][i]);
 
 	if (attacker->formation == EArmyFormation::LOOSE && !config["attackerUnitsLoose"].isNull())
-		result.units[BattleSide::ATTACKER] = loadUnits(config["attackerUnitsLoose"][attacker->stacksCount()]);
+		result.units[BattleSide::ATTACKER] = loadUnits(config["attackerUnitsLoose"][attacker->stacksCount() - 1]);
 	else if (attacker->formation == EArmyFormation::TIGHT && !config["attackerUnitsTight"].isNull())
-		result.units[BattleSide::ATTACKER] = loadUnits(config["attackerUnitsTight"][attacker->stacksCount()]);
+		result.units[BattleSide::ATTACKER] = loadUnits(config["attackerUnitsTight"][attacker->stacksCount() - 1]);
 	else
 		result.units[BattleSide::ATTACKER] = loadUnits(config["attackerUnits"]);
 
 	if (attacker->formation == EArmyFormation::LOOSE && !config["defenderUnitsLoose"].isNull())
-		result.units[BattleSide::DEFENDER] = loadUnits(config["defenderUnitsLoose"][attacker->stacksCount()]);
+		result.units[BattleSide::DEFENDER] = loadUnits(config["defenderUnitsLoose"][attacker->stacksCount() - 1]);
 	else if (attacker->formation == EArmyFormation::TIGHT && !config["defenderUnitsTight"].isNull())
-		result.units[BattleSide::DEFENDER] = loadUnits(config["defenderUnitsTight"][attacker->stacksCount()]);
+		result.units[BattleSide::DEFENDER] = loadUnits(config["defenderUnitsTight"][attacker->stacksCount() - 1]);
 	else
 		result.units[BattleSide::DEFENDER] = loadUnits(config["defenderUnits"]);
 

+ 12 - 5
lib/rewardable/Info.cpp

@@ -268,6 +268,8 @@ void Rewardable::Info::replaceTextPlaceholders(MetaString & target, const Variab
 {
 	if (!info.reward.guards.empty())
 	{
+		replaceTextPlaceholders(target, variables);
+
 		CreatureID strongest = info.reward.guards.at(0).getId();
 
 		for (const auto & guard : info.reward.guards )
@@ -297,15 +299,20 @@ void Rewardable::Info::replaceTextPlaceholders(MetaString & target, const Variab
 
 		for (const auto & spell : info.reward.spells )
 		{
-			target.replaceName(spell);
+			loot.appendRawString("%s");
+			loot.replaceName(spell);
 		}
 
 		for (const auto & secondary : info.reward.secondary )
-			target.replaceName(secondary.first);
+		{
+			loot.appendRawString("%s");
+			loot.replaceName(secondary.first);
+		}
+
+		target.replaceRawString(loot.buildList());
 	}
 	else
 	{
-
 		for (const auto & artifact : info.reward.artifacts )
 			target.replaceName(artifact);
 
@@ -314,9 +321,9 @@ void Rewardable::Info::replaceTextPlaceholders(MetaString & target, const Variab
 
 		for (const auto & secondary : info.reward.secondary )
 			target.replaceName(secondary.first);
-	}
 
-	replaceTextPlaceholders(target, variables);
+		replaceTextPlaceholders(target, variables);
+	}
 }
 
 void Rewardable::Info::configureRewards(