mirror of
https://github.com/vcmi/vcmi.git
synced 2025-07-05 00:49:09 +02:00
Support for loading custom bonuses, slightly less hardcoded Skeleton
Transformer
This commit is contained in:
@ -122,12 +122,22 @@ std::vector<JsonNode> CBonusTypeHandler::loadLegacyData()
|
||||
|
||||
void CBonusTypeHandler::loadObject(std::string scope, std::string name, const JsonNode & data)
|
||||
{
|
||||
BonusType bonus = stringToBonus(name);
|
||||
|
||||
CBonusType & bt = bonusTypes[vstd::to_underlying(bonus)];
|
||||
|
||||
loadItem(data, bt, name);
|
||||
logBonus->trace("Loaded bonus type %s", name);
|
||||
if (vstd::contains(bonusNames, name))
|
||||
{
|
||||
//h3 bonus
|
||||
BonusType bonus = stringToBonus(name);
|
||||
CBonusType & bt = bonusTypes[vstd::to_underlying(bonus)];
|
||||
loadItem(data, bt, name);
|
||||
logBonus->trace("Loaded bonus type %s", name);
|
||||
}
|
||||
else
|
||||
{
|
||||
// new bonus
|
||||
bonusNames.push_back(name);
|
||||
bonusTypes.emplace_back();
|
||||
loadItem(data, bonusTypes.back(), name);
|
||||
logBonus->trace("New bonus type %s", name);
|
||||
}
|
||||
}
|
||||
|
||||
void CBonusTypeHandler::loadObject(std::string scope, std::string name, const JsonNode & data, size_t index)
|
||||
@ -139,6 +149,7 @@ void CBonusTypeHandler::loadItem(const JsonNode & source, CBonusType & dest, con
|
||||
{
|
||||
dest.identifier = name;
|
||||
dest.hidden = source["hidden"].Bool(); //Null -> false
|
||||
dest.creatureNature = source["creatureNature"].Bool(); //Null -> false
|
||||
|
||||
if (!dest.hidden)
|
||||
LIBRARY->generaltexth->registerString( "vcmi", dest.getDescriptionTextID(), source["description"]);
|
||||
@ -197,6 +208,11 @@ const std::string CBonusTypeHandler::bonusToString(BonusType bonus) const
|
||||
return bonusNames.at(static_cast<int>(bonus));
|
||||
}
|
||||
|
||||
bool CBonusTypeHandler::isCreatureNatureBonus(BonusType bonus) const
|
||||
{
|
||||
return bonusTypes.at(static_cast<int>(bonus)).creatureNature;
|
||||
}
|
||||
|
||||
std::vector<BonusType> CBonusTypeHandler::getAllObjets() const
|
||||
{
|
||||
std::vector<BonusType> ret;
|
||||
|
Reference in New Issue
Block a user