Пример #1
0
std::string CBonusTypeHandler::bonusToString(const std::shared_ptr<Bonus> & bonus, const IBonusBearer * bearer, bool description) const
{
	auto getValue = [=](const std::string & name) -> std::string
	{
		if(name == "val")
		{
			 return boost::lexical_cast<std::string>(bearer->valOfBonuses(Selector::typeSubtype(bonus->type, bonus->subtype)));
		}
		else if(name == "subtype.creature")
		{
			 const CreatureID cre(bonus->subtype);
			 return cre.toCreature()->namePl;
		}
		else if(name == "subtype.spell")
		{
			 const SpellID sp(bonus->subtype);
			 return sp.toSpell()->name;
		}
		else if(name == "MR")
		{
			 return boost::lexical_cast<std::string>(bearer->magicResistance());
		}
		else
		{
			 logBonus->warn("Unknown macro in bonus config: %s", name);
			 return "[error]";
		}
	};

	const CBonusType & bt = bonusTypes[bonus->type];
	if(bt.hidden)
		return "";
	const MacroString & macro = description ? bt.description : bt.name;

	return macro.build(getValue);
}
Пример #2
0
bool BattleInfo::resurrects(SpellID spellid) const
{
	return spellid.toSpell()->isRisingSpell();
}