Adds battle effect for items
This commit is contained in:
parent
efca5ca06d
commit
fd24ce63c1
|
@ -85,7 +85,8 @@ PkmnLib::Library::ItemLibrary* BuildItems::Build(const std::string& path) {
|
|||
break;
|
||||
case json::value_t ::string: {
|
||||
auto s = p.get<std::string>();
|
||||
parameters.Append(new CreatureLib::Library::EffectParameter(ArbUt::StringView(s.c_str(), s.length())));
|
||||
parameters.Append(
|
||||
new CreatureLib::Library::EffectParameter(ArbUt::StringView(s.c_str(), s.length())));
|
||||
break;
|
||||
}
|
||||
default: continue;
|
||||
|
@ -96,9 +97,44 @@ PkmnLib::Library::ItemLibrary* BuildItems::Build(const std::string& path) {
|
|||
100, ArbUt::StringView(effectName.get<std::string>().c_str()), parameters);
|
||||
}
|
||||
|
||||
CreatureLib::Library::SecondaryEffect* battleEffect = nullptr;
|
||||
auto& battleEffectJson = val["battleEffect"];
|
||||
if (battleEffectJson != nullptr) {
|
||||
auto& effectName = battleEffectJson["name"];
|
||||
auto& parametersJson = battleEffectJson["parameters"];
|
||||
ArbUt::List<CreatureLib::Library::EffectParameter*> parameters;
|
||||
if (parametersJson != nullptr) {
|
||||
for (auto& kv : parametersJson.items()) {
|
||||
auto& p = kv.value();
|
||||
auto t = p.type();
|
||||
switch (t) {
|
||||
case json::value_t::boolean:
|
||||
parameters.Append(new CreatureLib::Library::EffectParameter(p.get<bool>()));
|
||||
break;
|
||||
case json::value_t::number_integer:
|
||||
case json::value_t::number_unsigned:
|
||||
parameters.Append(new CreatureLib::Library::EffectParameter(p.get<int64_t>()));
|
||||
break;
|
||||
case json::value_t::number_float:
|
||||
parameters.Append(new CreatureLib::Library::EffectParameter(p.get<float>()));
|
||||
break;
|
||||
case json::value_t ::string: {
|
||||
auto s = p.get<std::string>();
|
||||
parameters.Append(
|
||||
new CreatureLib::Library::EffectParameter(ArbUt::StringView(s.c_str(), s.length())));
|
||||
break;
|
||||
}
|
||||
default: continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
battleEffect = new CreatureLib::Library::SecondaryEffect(
|
||||
100, ArbUt::StringView(effectName.get<std::string>().c_str()), parameters);
|
||||
}
|
||||
|
||||
auto item = new PkmnLib::Library::Item(ArbUt::StringView(_name.get<std::string>().c_str()), itemType,
|
||||
CreatureLib::Library::BattleItemCategory::None, _price.get<int32_t>(),
|
||||
effect, flags, _flingPower.get<uint8_t>());
|
||||
effect, battleEffect, flags, _flingPower.get<uint8_t>());
|
||||
lib->Insert(item->GetName(), item);
|
||||
}
|
||||
return lib;
|
||||
|
|
Loading…
Reference in New Issue