1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-26 03:52:01 +02:00

Fix formatting of luck/morale bonuses

This commit is contained in:
Ivan Savenko 2024-04-08 18:21:24 +03:00
parent 9e49587749
commit 7a42e21e4d
3 changed files with 9 additions and 2 deletions

View File

@ -294,7 +294,8 @@ void CArtifact::addNewBonus(const std::shared_ptr<Bonus>& b)
{
b->source = BonusSource::ARTIFACT;
b->duration = BonusDuration::PERMANENT;
b->description.appendName(id);
b->description.appendTextID(getNameTextID());
b->description.appendRawString(" %+d");
CBonusSystemNode::addNewBonus(b);
}

View File

@ -95,6 +95,7 @@ void CSkill::addNewBonus(const std::shared_ptr<Bonus> & b, int level)
b->sid = BonusSourceID(id);
b->duration = BonusDuration::PERMANENT;
b->description.appendTextID(getNameTextID());
b->description.appendRawString(" %+d");
levels[level-1].effects.push_back(b);
}

View File

@ -169,7 +169,12 @@ DLL_LINKAGE std::string MetaString::toString() const
break;
case EMessage::REPLACE_POSITIVE_NUMBER:
if (dst.find("%+d") != std::string::npos)
boost::replace_first(dst, "%+d", '+' + std::to_string(numbers[nums++]));
{
if (numbers[nums] > 0)
boost::replace_first(dst, "%+d", '+' + std::to_string(numbers[nums++]));
else
boost::replace_first(dst, "%+d", std::to_string(numbers[nums++]));
}
else
boost::replace_first(dst, "%d", std::to_string(numbers[nums++]));
break;