1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-04-02 22:05:43 +02:00

CBonusTypeHandler small refactoring

This commit is contained in:
alexvins 2014-01-19 13:29:13 +00:00
parent 16d6292be9
commit f837afdc47

View File

@ -13,7 +13,7 @@
#include "JsonNode.h" #include "JsonNode.h"
#include "filesystem/Filesystem.h" #include "filesystem/Filesystem.h"
#include "VCMI_Lib.h" #include "GameConstants.h"
#include "CCreatureHandler.h" #include "CCreatureHandler.h"
#include "CSpellHandler.h" #include "CSpellHandler.h"
@ -136,11 +136,13 @@ std::string CBonusTypeHandler::bonusToString(const Bonus *bonus, const IBonusBea
} }
else if (name == "subtype.creature") else if (name == "subtype.creature")
{ {
return VLC->creh->creatures[bonus->subtype]->namePl; const CreatureID cre(bonus->subtype);
return cre.toCreature()->namePl;
} }
else if (name == "subtype.spell") else if (name == "subtype.spell")
{ {
return VLC->spellh->spells[bonus->subtype]->name; const SpellID sp(bonus->subtype);
return sp.toSpell()->name;
} }
else if (name == "MR") else if (name == "MR")
{ {
@ -154,19 +156,9 @@ std::string CBonusTypeHandler::bonusToString(const Bonus *bonus, const IBonusBea
}; };
const CBonusType& bt = bonusTypes[bonus->type]; const CBonusType& bt = bonusTypes[bonus->type];
const MacroString& macro = description ? bt.description : bt.name;
std::string text; return macro.build(getValue);
if (description)
{
text = bt.description.build(getValue);
}
else
{
text = bt.name.build(getValue);
}
return text;
} }
std::string CBonusTypeHandler::bonusToGraphics(const Bonus* bonus) const std::string CBonusTypeHandler::bonusToGraphics(const Bonus* bonus) const