Add script category to script creation function in AngelScript.
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -59,7 +59,9 @@ void StopBeforeAttack(ExecutingMove@ attack, bool& result) override{
|
||||
|
||||
};
|
||||
|
||||
static const char* _testLoadFunc(const char* name) { return _scripts[name]; }
|
||||
static const char* _testLoadFunc(CreatureLib::Battling::ScriptResolver::ScriptCategory category, const char* name) {
|
||||
return _scripts[name];
|
||||
}
|
||||
|
||||
static AngelScripResolver* _resolverCache = nullptr;
|
||||
static AngelScripResolver* GetScriptResolver(PkmnLib::Battling::BattleLibrary* mainLib) {
|
||||
@@ -68,7 +70,7 @@ static AngelScripResolver* GetScriptResolver(PkmnLib::Battling::BattleLibrary* m
|
||||
_resolverCache->Initialize(mainLib);
|
||||
_resolverCache->SetCreateFunction(&_testLoadFunc);
|
||||
for (auto kv : _scripts) {
|
||||
_resolverCache->CreateScript(kv.first);
|
||||
_resolverCache->CreateScript(AngelScripResolver::ScriptCategory::Attack, kv.first);
|
||||
}
|
||||
_resolverCache->FinalizeModule();
|
||||
}
|
||||
|
||||
@@ -4,8 +4,7 @@
|
||||
#include "../TestLibrary/TestLibrary.hpp"
|
||||
|
||||
static std::unordered_map<const char*, const char*> _scripts =
|
||||
std::unordered_map<const char*, const char*>{
|
||||
{"testScript1", R"(
|
||||
std::unordered_map<const char*, const char*>{{"testScript1", R"(
|
||||
class testScript1 {
|
||||
int add(int a, int b) {
|
||||
return a + b;
|
||||
@@ -17,10 +16,11 @@ class testScript1 {
|
||||
}
|
||||
}
|
||||
}
|
||||
)"}
|
||||
};
|
||||
)"}};
|
||||
|
||||
static const char* _testLoadFunc(const char* name) { return _scripts[name]; }
|
||||
static const char* _testLoadFunc(CreatureLib::Battling::ScriptResolver::ScriptCategory category, const char* name) {
|
||||
return _scripts[name];
|
||||
}
|
||||
|
||||
TEST_CASE("Get a script resolver, initialize it, then delete it") {
|
||||
auto lib = PkmnLib::Battling::BattleLibrary::CreateScriptResolver();
|
||||
@@ -39,7 +39,7 @@ TEST_CASE("Get a script resolver, set script load function, load script, then bu
|
||||
auto lib = dynamic_cast<AngelScripResolver*>(PkmnLib::Battling::BattleLibrary::CreateScriptResolver());
|
||||
lib->Initialize(TestLibrary::GetLibrary());
|
||||
lib->SetCreateFunction(&_testLoadFunc);
|
||||
lib->CreateScript("testScript1");
|
||||
lib->CreateScript(AngelScripResolver::ScriptCategory::Attack ,"testScript1");
|
||||
lib->FinalizeModule();
|
||||
delete lib;
|
||||
}
|
||||
@@ -48,7 +48,7 @@ TEST_CASE("Build script resolver, then create object") {
|
||||
auto lib = dynamic_cast<AngelScripResolver*>(PkmnLib::Battling::BattleLibrary::CreateScriptResolver());
|
||||
lib->Initialize(TestLibrary::GetLibrary());
|
||||
lib->SetCreateFunction(&_testLoadFunc);
|
||||
lib->CreateScript("testScript1");
|
||||
lib->CreateScript(AngelScripResolver::ScriptCategory::Attack ,"testScript1");
|
||||
lib->FinalizeModule();
|
||||
|
||||
auto obj = lib->LoadScript(AngelScripResolver::ScriptCategory::Creature, "testScript1");
|
||||
@@ -61,7 +61,7 @@ TEST_CASE("Build script resolver, create object, invoke addition method") {
|
||||
auto lib = dynamic_cast<AngelScripResolver*>(PkmnLib::Battling::BattleLibrary::CreateScriptResolver());
|
||||
lib->Initialize(TestLibrary::GetLibrary());
|
||||
lib->SetCreateFunction(&_testLoadFunc);
|
||||
lib->CreateScript("testScript1");
|
||||
lib->CreateScript(AngelScripResolver::ScriptCategory::Attack ,"testScript1");
|
||||
lib->FinalizeModule();
|
||||
|
||||
auto obj =
|
||||
@@ -76,7 +76,7 @@ TEST_CASE("Build script resolver, create object, invoke addition method") {
|
||||
ctx->SetArgDWord(1, 100);
|
||||
|
||||
auto result = ctx->Execute();
|
||||
if (result == asEXECUTION_EXCEPTION){
|
||||
if (result == asEXECUTION_EXCEPTION) {
|
||||
FAIL(ctx->GetExceptionString());
|
||||
}
|
||||
CHECK(result == asEXECUTION_FINISHED);
|
||||
|
||||
@@ -26,7 +26,9 @@ class testScript1 {
|
||||
}
|
||||
)"}};
|
||||
|
||||
static const char* _testLoadFunc(const char* name) { return _scripts[name]; }
|
||||
static const char* _testLoadFunc(CreatureLib::Battling::ScriptResolver::ScriptCategory category, const char* name) {
|
||||
return _scripts[name];
|
||||
}
|
||||
|
||||
struct ScriptData {
|
||||
AngelScriptScript* Script = nullptr;
|
||||
@@ -46,7 +48,7 @@ static AngelScripResolver* GetScriptResolver(PkmnLib::Battling::BattleLibrary* m
|
||||
_resolverCache = dynamic_cast<AngelScripResolver*>(PkmnLib::Battling::BattleLibrary::CreateScriptResolver());
|
||||
_resolverCache->Initialize(mainLib);
|
||||
_resolverCache->SetCreateFunction(&_testLoadFunc);
|
||||
_resolverCache->CreateScript("testScript1");
|
||||
_resolverCache->CreateScript(AngelScripResolver::ScriptCategory::Attack ,"testScript1");
|
||||
_resolverCache->FinalizeModule();
|
||||
}
|
||||
return _resolverCache;
|
||||
|
||||
@@ -17,7 +17,9 @@ class testScript1 {
|
||||
}
|
||||
)"}};
|
||||
|
||||
static const char* _testLoadFunc(const char* name) { return _scripts[name]; }
|
||||
static const char* _testLoadFunc(CreatureLib::Battling::ScriptResolver::ScriptCategory category, const char* name) {
|
||||
return _scripts[name];
|
||||
}
|
||||
|
||||
struct ScriptData {
|
||||
AngelScriptScript* Script = nullptr;
|
||||
@@ -37,7 +39,7 @@ static AngelScripResolver* GetScriptResolver(PkmnLib::Battling::BattleLibrary* m
|
||||
_resolverCache = dynamic_cast<AngelScripResolver*>(PkmnLib::Battling::BattleLibrary::CreateScriptResolver());
|
||||
_resolverCache->Initialize(mainLib);
|
||||
_resolverCache->SetCreateFunction(&_testLoadFunc);
|
||||
_resolverCache->CreateScript("testScript1");
|
||||
_resolverCache->CreateScript(AngelScripResolver::ScriptCategory::Attack ,"testScript1");
|
||||
_resolverCache->FinalizeModule();
|
||||
}
|
||||
return _resolverCache;
|
||||
|
||||
@@ -13,7 +13,9 @@ class testScript1 {
|
||||
}
|
||||
)"}};
|
||||
|
||||
static const char* _testLoadFunc(const char* name) { return _scripts[name]; }
|
||||
static const char* _testLoadFunc(CreatureLib::Battling::ScriptResolver::ScriptCategory category, const char* name) {
|
||||
return _scripts[name];
|
||||
}
|
||||
|
||||
struct ScriptData {
|
||||
AngelScriptScript* Script = nullptr;
|
||||
@@ -33,7 +35,7 @@ static AngelScripResolver* GetScriptResolver(PkmnLib::Battling::BattleLibrary* m
|
||||
_resolverCache = dynamic_cast<AngelScripResolver*>(PkmnLib::Battling::BattleLibrary::CreateScriptResolver());
|
||||
_resolverCache->Initialize(mainLib);
|
||||
_resolverCache->SetCreateFunction(&_testLoadFunc);
|
||||
_resolverCache->CreateScript("testScript1");
|
||||
_resolverCache->CreateScript(AngelScripResolver::ScriptCategory::Attack ,"testScript1");
|
||||
_resolverCache->FinalizeModule();
|
||||
}
|
||||
return _resolverCache;
|
||||
|
||||
@@ -17,7 +17,9 @@ class testScript1 {
|
||||
}
|
||||
)"}};
|
||||
|
||||
static const char* _testLoadFunc(const char* name) { return _scripts[name]; }
|
||||
static const char* _testLoadFunc(CreatureLib::Battling::ScriptResolver::ScriptCategory category, const char* name) {
|
||||
return _scripts[name];
|
||||
}
|
||||
|
||||
struct ScriptData {
|
||||
AngelScriptScript* Script = nullptr;
|
||||
@@ -37,7 +39,7 @@ static AngelScripResolver* GetScriptResolver(PkmnLib::Battling::BattleLibrary* m
|
||||
_resolverCache = dynamic_cast<AngelScripResolver*>(PkmnLib::Battling::BattleLibrary::CreateScriptResolver());
|
||||
_resolverCache->Initialize(mainLib);
|
||||
_resolverCache->SetCreateFunction(&_testLoadFunc);
|
||||
_resolverCache->CreateScript("testScript1");
|
||||
_resolverCache->CreateScript(AngelScripResolver::ScriptCategory::Attack ,"testScript1");
|
||||
_resolverCache->FinalizeModule();
|
||||
}
|
||||
return _resolverCache;
|
||||
|
||||
@@ -15,7 +15,9 @@ class testScript1 {
|
||||
}
|
||||
)"}};
|
||||
|
||||
static const char* _testLoadFunc(const char* name) { return _scripts[name]; }
|
||||
static const char* _testLoadFunc(CreatureLib::Battling::ScriptResolver::ScriptCategory category, const char* name) {
|
||||
return _scripts[name];
|
||||
}
|
||||
|
||||
struct ScriptData {
|
||||
AngelScriptScript* Script;
|
||||
@@ -35,7 +37,7 @@ static AngelScripResolver* GetScriptResolver(PkmnLib::Battling::BattleLibrary* m
|
||||
_resolverCache = dynamic_cast<AngelScripResolver*>(PkmnLib::Battling::BattleLibrary::CreateScriptResolver());
|
||||
_resolverCache->Initialize(mainLib);
|
||||
_resolverCache->SetCreateFunction(&_testLoadFunc);
|
||||
_resolverCache->CreateScript("testScript1");
|
||||
_resolverCache->CreateScript(AngelScripResolver::ScriptCategory::Attack ,"testScript1");
|
||||
_resolverCache->FinalizeModule();
|
||||
}
|
||||
return _resolverCache;
|
||||
|
||||
@@ -16,7 +16,9 @@ class testScript1 {
|
||||
}
|
||||
)"}};
|
||||
|
||||
static const char* _testLoadFunc(const char* name) { return _scripts[name]; }
|
||||
static const char* _testLoadFunc(CreatureLib::Battling::ScriptResolver::ScriptCategory category, const char* name) {
|
||||
return _scripts[name];
|
||||
}
|
||||
|
||||
struct ScriptData {
|
||||
AngelScriptScript* Script;
|
||||
@@ -36,7 +38,7 @@ static AngelScripResolver* GetScriptResolver(PkmnLib::Battling::BattleLibrary* m
|
||||
_resolverCache = dynamic_cast<AngelScripResolver*>(PkmnLib::Battling::BattleLibrary::CreateScriptResolver());
|
||||
_resolverCache->Initialize(mainLib);
|
||||
_resolverCache->SetCreateFunction(&_testLoadFunc);
|
||||
_resolverCache->CreateScript("testScript1");
|
||||
_resolverCache->CreateScript(AngelScripResolver::ScriptCategory::Attack ,"testScript1");
|
||||
_resolverCache->FinalizeModule();
|
||||
}
|
||||
return _resolverCache;
|
||||
|
||||
Reference in New Issue
Block a user