1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-24 08:32:34 +02:00

Merge pull request #3190 from gamestales/gamestales/962-map-object-morale-description

Use arraytxt for object bonus description
This commit is contained in:
Ivan Savenko 2023-11-16 17:28:09 +02:00 committed by GitHub
commit c0e54b338a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 27 deletions

View File

@ -154,7 +154,7 @@
"onVisited" : [
{
"message" : 163,
"bonuses" : [ { "type" : "MORALE", "val" : -3, "duration" : "ONE_BATTLE" } ]
"bonuses" : [ { "type" : "MORALE", "val" : -3, "duration" : "ONE_BATTLE", "description" : 104 } ]
}
],
"rewards" : [
@ -162,25 +162,25 @@
"appearChance" : { "max" : 30 },
"message" : 162,
"artifacts" : [ { "class" : "TREASURE" } ],
"bonuses" : [ { "type" : "MORALE", "val" : -3, "duration" : "ONE_BATTLE" } ]
"bonuses" : [ { "type" : "MORALE", "val" : -3, "duration" : "ONE_BATTLE", "description" : 104 } ]
},
{
"appearChance" : { "min" : 30, "max" : 80 },
"message" : 162,
"artifacts" : [ { "class" : "MINOR" } ],
"bonuses" : [ { "type" : "MORALE", "val" : -3, "duration" : "ONE_BATTLE" } ]
"bonuses" : [ { "type" : "MORALE", "val" : -3, "duration" : "ONE_BATTLE", "description" : 104 } ]
},
{
"appearChance" : { "min" : 80, "max" : 95 },
"message" : 162,
"artifacts" : [ { "class" : "MAJOR" } ],
"bonuses" : [ { "type" : "MORALE", "val" : -3, "duration" : "ONE_BATTLE" } ]
"bonuses" : [ { "type" : "MORALE", "val" : -3, "duration" : "ONE_BATTLE", "description" : 104 } ]
},
{
"appearChance" : { "min" : 95 },
"message" : 162,
"artifacts" : [ { "class" : "RELIC" } ],
"bonuses" : [ { "type" : "MORALE", "val" : -3, "duration" : "ONE_BATTLE" } ]
"bonuses" : [ { "type" : "MORALE", "val" : -3, "duration" : "ONE_BATTLE", "description" : 104 } ]
}
]
}

View File

@ -427,14 +427,14 @@ static void loadBonusSubtype(BonusSubtypeID & subtype, BonusType type, const Jso
if (node.isNumber()) // Compatibility code for 1.3 or older
{
logMod->warn("Bonus subtype must be string!");
logMod->warn("Bonus subtype must be string! (%s)", node.meta);
subtype = BonusCustomSubtype(node.Integer());
return;
}
if (!node.isString())
{
logMod->warn("Bonus subtype must be string!");
logMod->warn("Bonus subtype must be string! (%s)", node.meta);
subtype = BonusSubtypeID();
return;
}

View File

@ -993,29 +993,28 @@ void GiveBonus::applyGs(CGameState *gs)
std::string &descr = b->description;
if(bdescr.empty() && (bonus.type == BonusType::LUCK || bonus.type == BonusType::MORALE))
{
if (bonus.source == BonusSource::OBJECT_TYPE || bonus.source == BonusSource::OBJECT_INSTANCE)
{
descr = VLC->generaltexth->arraytxt[bonus.val > 0 ? 110 : 109]; //+/-%d Temporary until next battle"
}
else if(bonus.source == BonusSource::TOWN_STRUCTURE)
{
descr = bonus.description;
return;
}
else
{
descr = bdescr.toString();
}
}
else
if(!bdescr.empty())
{
descr = bdescr.toString();
}
// Some of(?) versions of H3 use %s here instead of %d. Try to replace both of them
boost::replace_first(descr, "%d", std::to_string(std::abs(bonus.val)));
boost::replace_first(descr, "%s", std::to_string(std::abs(bonus.val)));
else if(!descr.empty())
{
//use preseet description
}
else if((bonus.type == BonusType::LUCK || bonus.type == BonusType::MORALE)
&& (bonus.source == BonusSource::OBJECT_TYPE || bonus.source == BonusSource::OBJECT_INSTANCE))
{
//no description, use generic
//?could use allways when Type == BonusDuration::Type::ONE_BATTLE
descr = VLC->generaltexth->arraytxt[bonus.val > 0 ? 110 : 109]; //+/-%d Temporary until next battle"
}
else
{
logGlobal->debug("Empty bonus decription. Type=%d", (int) bonus.type);
}
// Some of(?) versions of H3 use " %s" here instead of %d. Try to replace both of them
boost::replace_first(descr, "%d", std::to_string(std::abs(bonus.val))); // " +/-%d Temporary until next battle
boost::replace_first(descr, " %s", boost::str(boost::format(" %+d") % bonus.val)); // " %s" in arraytxt.69, fountian of fortune
}
void ChangeObjPos::applyGs(CGameState *gs)