mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-14 02:33:51 +02:00
More battle log refactoring
This commit is contained in:
parent
7cf9bd36b7
commit
5d0ecd9cdf
@ -1350,39 +1350,47 @@ void CBattleInterface::spellCast( const BattleSpellCast * sc )
|
||||
}
|
||||
else
|
||||
{
|
||||
auto getPluralText = [attackedStack, attackedName](const int baseTextID) -> std::string
|
||||
auto getPluralFormat = [attackedStack](const int baseTextID) -> boost::format
|
||||
{
|
||||
std::string res = CGI->generaltexth->allTexts[(attackedStack->count > 1 ? baseTextID+1 : baseTextID)];
|
||||
boost::algorithm::replace_first(res, "%s", attackedName);
|
||||
return res;
|
||||
return boost::format(CGI->generaltexth->allTexts[(attackedStack->count > 1 ? baseTextID+1 : baseTextID)]);
|
||||
};
|
||||
|
||||
auto logSimple = [&logLines, getPluralFormat, attackedName](const int baseTextID)
|
||||
{
|
||||
boost::format fmt = getPluralFormat(baseTextID);
|
||||
fmt % attackedName;
|
||||
logLines.push_back(fmt.str());
|
||||
};
|
||||
|
||||
auto logPlural = [&logLines, attackedNamePl](const int baseTextID)
|
||||
{
|
||||
boost::format fmt(CGI->generaltexth->allTexts[baseTextID]);
|
||||
fmt % attackedNamePl;
|
||||
logLines.push_back(fmt.str());
|
||||
};
|
||||
|
||||
customSpell = true; //in most following cases text is custom
|
||||
switch(sc->id)
|
||||
{
|
||||
case SpellID::STONE_GAZE:
|
||||
logLines.push_back(getPluralText(558));
|
||||
logSimple(558);
|
||||
break;
|
||||
case SpellID::POISON:
|
||||
logLines.push_back(getPluralText(561));
|
||||
logSimple(561);
|
||||
break;
|
||||
case SpellID::BIND:
|
||||
{
|
||||
//Roots and vines bind the %s to the ground!
|
||||
boost::format text(CGI->generaltexth->allTexts[560]);
|
||||
text % attackedNamePl;
|
||||
logLines.push_back(text.str());
|
||||
}
|
||||
logPlural(560);//Roots and vines bind the %s to the ground!
|
||||
break;
|
||||
case SpellID::DISEASE:
|
||||
logLines.push_back(getPluralText(553));
|
||||
logSimple(553);
|
||||
break;
|
||||
case SpellID::PARALYZE:
|
||||
logLines.push_back(getPluralText(563));
|
||||
logSimple(563);
|
||||
break;
|
||||
case SpellID::AGE:
|
||||
{
|
||||
boost::format text(getPluralText(551));
|
||||
boost::format text = getPluralFormat(551);
|
||||
text % attackedName;
|
||||
//The %s shrivel with age, and lose %d hit points."
|
||||
TBonusListPtr bl = attackedStack->getBonuses(Selector::type(Bonus::STACK_HEALTH));
|
||||
const int fullHP = bl->totalValue();
|
||||
@ -1393,20 +1401,14 @@ void CBattleInterface::spellCast( const BattleSpellCast * sc )
|
||||
break;
|
||||
case SpellID::THUNDERBOLT:
|
||||
{
|
||||
std::string text = CGI->generaltexth->allTexts[367];
|
||||
boost::algorithm::replace_first(text, "%s", attackedNamePl);
|
||||
logLines.push_back(text);
|
||||
text = CGI->generaltexth->allTexts[343].substr(1, CGI->generaltexth->allTexts[343].size() - 1); //Does %d points of damage.
|
||||
logPlural(367);
|
||||
std::string text = CGI->generaltexth->allTexts[343].substr(1, CGI->generaltexth->allTexts[343].size() - 1); //Does %d points of damage.
|
||||
boost::algorithm::replace_first(text, "%d", boost::lexical_cast<std::string>(sc->dmgToDisplay)); //no more text afterwards
|
||||
logLines.push_back(text);
|
||||
}
|
||||
break;
|
||||
case SpellID::DISPEL_HELPFUL_SPELLS:
|
||||
{
|
||||
boost::format text(CGI->generaltexth->allTexts[555]);
|
||||
text % attackedNamePl;
|
||||
logLines.push_back(text.str());
|
||||
}
|
||||
logPlural(555);
|
||||
break;
|
||||
case SpellID::DEATH_STARE:
|
||||
if (sc->dmgToDisplay)
|
||||
|
Loading…
Reference in New Issue
Block a user