Update to latest PkmnLib.
This commit is contained in:
@@ -58,9 +58,38 @@ PkmnLib::Library::ItemLibrary* BuildItems::Build(const std::string& path) {
|
||||
flags.insert(ArbUt::StringView(flagIndex.value().get<std::string>().c_str()));
|
||||
}
|
||||
|
||||
CreatureLib::Library::SecondaryEffect* effect = nullptr;
|
||||
auto effectJson = val["effect"];
|
||||
if (effectJson != nullptr) {
|
||||
auto effectName = effectJson["name"];
|
||||
auto parametersJson = effectJson["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;
|
||||
default: continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
effect = 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>(),
|
||||
flags, _flingPower.get<uint8_t>());
|
||||
effect, flags, _flingPower.get<uint8_t>());
|
||||
lib->Insert(item->GetName(), item);
|
||||
}
|
||||
return lib;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "ScriptCompiler.hpp"
|
||||
#include <PkmnLib/Battling/PkmnScriptCategory.hpp>
|
||||
#include <PkmnLib/ScriptResolving/AngelScript/AngelScriptResolver.hpp>
|
||||
#include <filesystem>
|
||||
|
||||
@@ -31,17 +32,32 @@ void ScriptCompiler::Compile(const std::string& inPath, const std::string& outPa
|
||||
if (dirEntry.path().parent_path().stem() == "Interfaces") {
|
||||
continue;
|
||||
}
|
||||
std::cout << dirEntry.path().stem() << std::endl;
|
||||
|
||||
std::ifstream t(dirEntry.path().c_str());
|
||||
std::string str((std::istreambuf_iterator<char>(t)),
|
||||
std::istreambuf_iterator<char>());
|
||||
resolver->CreateScript(dirEntry.path().stem().c_str(), str.c_str());
|
||||
std::string str((std::istreambuf_iterator<char>(t)), std::istreambuf_iterator<char>());
|
||||
resolver->CreateScript(
|
||||
(dirEntry.path().parent_path().stem().string() + "/" + dirEntry.path().stem().string()).c_str(),
|
||||
str.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
resolver->FinalizeModule();
|
||||
|
||||
auto scripts = resolver->GetTypeDatabase();
|
||||
for (const auto& type : scripts) {
|
||||
|
||||
std::cout << "=== ";
|
||||
if ((uint8_t)type.first < 128) {
|
||||
std::cout << ScriptCategoryHelper::ToString(type.first);
|
||||
} else {
|
||||
std::cout << PkmnScriptCategoryHelper::ToString((PkmnScriptCategory)type.first);
|
||||
}
|
||||
std::cout << "\t===" << std::endl;
|
||||
|
||||
for (const auto& s: type.second){
|
||||
std::cout << s.first << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
std::filesystem::path dir(outPath);
|
||||
std::cout << dir << std::endl;
|
||||
resolver->WriteByteCodeToFile(outPath.c_str());
|
||||
|
||||
Reference in New Issue
Block a user