mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
#2903-morale-description-#1442
This commit is contained in:
parent
439ce114cb
commit
a574f18e69
@ -579,8 +579,13 @@ void MoraleLuckBox::set(const AFactionMember * node)
|
||||
std::string addInfo = "";
|
||||
for(auto & bonus : * modifierList)
|
||||
{
|
||||
if(bonus->val)
|
||||
addInfo += "\n" + bonus->Description();
|
||||
if(bonus->val) {
|
||||
const std::string& description = bonus->Description();
|
||||
//arraytxt already contains \n
|
||||
if (description.size() && description[0] != '\n')
|
||||
addInfo += '\n';
|
||||
addInfo += description;
|
||||
}
|
||||
}
|
||||
text = addInfo.empty()
|
||||
? text + CGI->generaltexth->arraytxt[noneTxtId]
|
||||
|
@ -91,7 +91,7 @@ JsonNode CAddInfo::toJsonNode() const
|
||||
}
|
||||
std::string Bonus::Description(std::optional<si32> customValue) const
|
||||
{
|
||||
std::ostringstream str;
|
||||
std::string str;
|
||||
|
||||
if(description.empty())
|
||||
{
|
||||
@ -100,38 +100,42 @@ std::string Bonus::Description(std::optional<si32> customValue) const
|
||||
switch(source)
|
||||
{
|
||||
case BonusSource::ARTIFACT:
|
||||
str << sid.as<ArtifactID>().toEntity(VLC)->getNameTranslated();
|
||||
str = sid.as<ArtifactID>().toEntity(VLC)->getNameTranslated();
|
||||
break;
|
||||
case BonusSource::SPELL_EFFECT:
|
||||
str << sid.as<SpellID>().toEntity(VLC)->getNameTranslated();
|
||||
str = sid.as<SpellID>().toEntity(VLC)->getNameTranslated();
|
||||
break;
|
||||
case BonusSource::CREATURE_ABILITY:
|
||||
str << sid.as<CreatureID>().toEntity(VLC)->getNamePluralTranslated();
|
||||
str = sid.as<CreatureID>().toEntity(VLC)->getNamePluralTranslated();
|
||||
break;
|
||||
case BonusSource::SECONDARY_SKILL:
|
||||
str << VLC->skills()->getById(sid.as<SecondarySkill>())->getNameTranslated();
|
||||
str = VLC->skills()->getById(sid.as<SecondarySkill>())->getNameTranslated();
|
||||
break;
|
||||
case BonusSource::HERO_SPECIAL:
|
||||
str << VLC->heroTypes()->getById(sid.as<HeroTypeID>())->getNameTranslated();
|
||||
str = VLC->heroTypes()->getById(sid.as<HeroTypeID>())->getNameTranslated();
|
||||
break;
|
||||
default:
|
||||
//todo: handle all possible sources
|
||||
str << "Unknown";
|
||||
str = "Unknown";
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
str << stacking;
|
||||
str = stacking;
|
||||
}
|
||||
else
|
||||
{
|
||||
str << description;
|
||||
str = description;
|
||||
}
|
||||
|
||||
if(auto value = customValue.value_or(val))
|
||||
str << " " << std::showpos << value;
|
||||
if(auto value = customValue.value_or(val)) {
|
||||
//arraytxt already contains +-value
|
||||
std::string valueString = boost::str(boost::format(" %+d") % value);
|
||||
if(!boost::algorithm::ends_with(str, valueString))
|
||||
str += valueString;
|
||||
}
|
||||
|
||||
return str.str();
|
||||
return str;
|
||||
}
|
||||
|
||||
static JsonNode additionalInfoToJson(BonusType type, CAddInfo addInfo)
|
||||
|
@ -760,7 +760,7 @@ public:
|
||||
DIMENSION_DOOR = 8,
|
||||
TOWN_PORTAL = 9,
|
||||
|
||||
// Combar spells
|
||||
// Combat spells
|
||||
QUICKSAND = 10,
|
||||
LAND_MINE = 11,
|
||||
FORCE_FIELD = 12,
|
||||
|
@ -111,7 +111,7 @@ void CArmedInstance::updateMoraleBonusFromArmy()
|
||||
{
|
||||
b->val = 2 - static_cast<si32>(factionsInArmy);
|
||||
description = boost::str(boost::format(VLC->generaltexth->arraytxt[114]) % factionsInArmy % b->val); //Troops of %d alignments %d
|
||||
description = b->description.substr(0, description.size()-2);//trim value
|
||||
description = description.substr(0, description.size()-3);//trim value
|
||||
}
|
||||
|
||||
boost::algorithm::trim(description);
|
||||
|
Loading…
Reference in New Issue
Block a user