Use namespaces to differentiate between different categories of scripts.
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:
@@ -6,6 +6,7 @@
|
||||
|
||||
static std::unordered_map<const char*, const char*> _scripts =
|
||||
std::unordered_map<const char*, const char*>{{"testScript1", R"(
|
||||
namespace Pokemon{
|
||||
class testScript1 {
|
||||
bool testSpecies(Pokemon@ p, const Species@ species){ return p.Species is species; }
|
||||
bool testForme(Pokemon@ p, const Forme@ forme){ return p.Forme is forme; }
|
||||
@@ -24,13 +25,9 @@ class testScript1 {
|
||||
void testHeal(Pokemon@ p, uint32 amount){ p.Heal(amount); }
|
||||
bool testMove(Pokemon@ p, uint index, LearnedMove@ move){ return p.GetMoves()[index] is move; }
|
||||
|
||||
}
|
||||
}}
|
||||
)"}};
|
||||
|
||||
static const char* _testLoadFunc(CreatureLib::Battling::ScriptResolver::ScriptCategory category, const char* name) {
|
||||
return _scripts[name];
|
||||
}
|
||||
|
||||
struct ScriptData {
|
||||
AngelScriptScript* Script = nullptr;
|
||||
AngelScripResolver* Resolver = nullptr;
|
||||
@@ -48,8 +45,7 @@ static AngelScripResolver* GetScriptResolver(PkmnLib::Battling::BattleLibrary* m
|
||||
if (_resolverCache == nullptr) {
|
||||
_resolverCache = dynamic_cast<AngelScripResolver*>(PkmnLib::Battling::BattleLibrary::CreateScriptResolver());
|
||||
_resolverCache->Initialize(mainLib);
|
||||
_resolverCache->SetCreateFunction(&_testLoadFunc);
|
||||
_resolverCache->CreateScript(AngelScripResolver::ScriptCategory::Attack ,"testScript1");
|
||||
_resolverCache->CreateScript("testScript1" , _scripts["testScript1"]);
|
||||
_resolverCache->FinalizeModule();
|
||||
}
|
||||
return _resolverCache;
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
static std::unordered_map<const char*, const char*> _scripts =
|
||||
std::unordered_map<const char*, const char*>{{"testScript1", R"(
|
||||
namespace Pokemon{
|
||||
class testScript1 {
|
||||
bool testName(const Forme@ s, const string &in name){ return s.Name == name; }
|
||||
bool testWeight(const Forme@ s, float weight){ return s.Weight == weight; }
|
||||
@@ -14,13 +15,9 @@ class testScript1 {
|
||||
bool testGetType(const Forme@ s, uint8 type){ return s.GetType(0) == type; }
|
||||
bool testGetStatistic(const Forme@ s, Statistic stat, uint value){ return s.GetStatistic(stat) == value; }
|
||||
bool testGetAbility(const Forme@ s, const string &in ability){ return s.GetAbility(0) == ability; }
|
||||
}
|
||||
}}
|
||||
)"}};
|
||||
|
||||
static const char* _testLoadFunc(CreatureLib::Battling::ScriptResolver::ScriptCategory category, const char* name) {
|
||||
return _scripts[name];
|
||||
}
|
||||
|
||||
struct ScriptData {
|
||||
AngelScriptScript* Script = nullptr;
|
||||
AngelScripResolver* Resolver = nullptr;
|
||||
@@ -38,8 +35,7 @@ static AngelScripResolver* GetScriptResolver(PkmnLib::Battling::BattleLibrary* m
|
||||
if (_resolverCache == nullptr) {
|
||||
_resolverCache = dynamic_cast<AngelScripResolver*>(PkmnLib::Battling::BattleLibrary::CreateScriptResolver());
|
||||
_resolverCache->Initialize(mainLib);
|
||||
_resolverCache->SetCreateFunction(&_testLoadFunc);
|
||||
_resolverCache->CreateScript(AngelScripResolver::ScriptCategory::Attack ,"testScript1");
|
||||
_resolverCache->CreateScript("testScript1" , _scripts["testScript1"]);
|
||||
_resolverCache->FinalizeModule();
|
||||
}
|
||||
return _resolverCache;
|
||||
|
||||
@@ -5,18 +5,15 @@
|
||||
|
||||
static std::unordered_map<const char*, const char*> _scripts =
|
||||
std::unordered_map<const char*, const char*>{{"testScript1", R"(
|
||||
namespace Pokemon{
|
||||
class testScript1 {
|
||||
bool testName(const Item@ i, const string &in name){ return i.Name == name; }
|
||||
bool testCategory(const Item@ i, ItemCategory category){ return i.Category == category; }
|
||||
bool testBattleCategory(const Item@ i, BattleItemCategory category){ return i.BattleCategory == category; }
|
||||
bool testPrice(const Item@ i, int price){ return i.Price == price; }
|
||||
}
|
||||
}}
|
||||
)"}};
|
||||
|
||||
static const char* _testLoadFunc(CreatureLib::Battling::ScriptResolver::ScriptCategory category, const char* name) {
|
||||
return _scripts[name];
|
||||
}
|
||||
|
||||
struct ScriptData {
|
||||
AngelScriptScript* Script = nullptr;
|
||||
AngelScripResolver* Resolver = nullptr;
|
||||
@@ -34,8 +31,7 @@ static AngelScripResolver* GetScriptResolver(PkmnLib::Battling::BattleLibrary* m
|
||||
if (_resolverCache == nullptr){
|
||||
_resolverCache = dynamic_cast<AngelScripResolver*>(PkmnLib::Battling::BattleLibrary::CreateScriptResolver());
|
||||
_resolverCache->Initialize(mainLib);
|
||||
_resolverCache->SetCreateFunction(&_testLoadFunc);
|
||||
_resolverCache->CreateScript(AngelScripResolver::ScriptCategory::Attack ,"testScript1");
|
||||
_resolverCache->CreateScript("testScript1" , _scripts["testScript1"]);
|
||||
_resolverCache->FinalizeModule();
|
||||
}
|
||||
return _resolverCache;
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
static std::unordered_map<const char*, const char*> _scripts =
|
||||
std::unordered_map<const char*, const char*>{{"testScript1", R"(
|
||||
namespace Pokemon{
|
||||
class testScript1 {
|
||||
bool testName(const MoveData@ s, const string &in name){ return s.Name == name; }
|
||||
bool testType(const MoveData@ s, uint8 type){ return s.Type == type; }
|
||||
@@ -14,13 +15,9 @@ class testScript1 {
|
||||
bool testBaseUsages(const MoveData@ s, uint8 baseUsages){ return s.BaseUsages == baseUsages; }
|
||||
bool testTarget(const MoveData@ s, MoveTarget target){ return s.Target == target; }
|
||||
bool testPriority(const MoveData@ s, int8 priority){ return s.Priority == priority; }
|
||||
}
|
||||
}}
|
||||
)"}};
|
||||
|
||||
static const char* _testLoadFunc(CreatureLib::Battling::ScriptResolver::ScriptCategory category, const char* name) {
|
||||
return _scripts[name];
|
||||
}
|
||||
|
||||
struct ScriptData {
|
||||
AngelScriptScript* Script = nullptr;
|
||||
AngelScripResolver* Resolver = nullptr;
|
||||
@@ -38,8 +35,7 @@ static AngelScripResolver* GetScriptResolver(PkmnLib::Battling::BattleLibrary* m
|
||||
if (_resolverCache == nullptr){
|
||||
_resolverCache = dynamic_cast<AngelScripResolver*>(PkmnLib::Battling::BattleLibrary::CreateScriptResolver());
|
||||
_resolverCache->Initialize(mainLib);
|
||||
_resolverCache->SetCreateFunction(&_testLoadFunc);
|
||||
_resolverCache->CreateScript(AngelScripResolver::ScriptCategory::Attack ,"testScript1");
|
||||
_resolverCache->CreateScript("testScript1" , _scripts["testScript1"]);
|
||||
_resolverCache->FinalizeModule();
|
||||
}
|
||||
return _resolverCache;
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
static std::unordered_map<const char*, const char*> _scripts =
|
||||
std::unordered_map<const char*, const char*>{{"testScript1", R"(
|
||||
namespace Pokemon{
|
||||
class testScript1 {
|
||||
bool testName(const Species@ s, const string &in name){ return s.Name == name; }
|
||||
bool testId(const Species@ s, uint16 id){ return s.Id == id; }
|
||||
@@ -12,13 +13,9 @@ class testScript1 {
|
||||
bool testCaptureRate(const Species@ s, uint8 rate){ return s.CaptureRate == rate; }
|
||||
bool testGetForme(const Species@ s, const Forme@ forme){ return s.GetForme("default") is forme; }
|
||||
bool testGetDefaultForme(const Species@ s, const Forme@ forme){ return s.GetDefaultForme() is forme; }
|
||||
}
|
||||
}}
|
||||
)"}};
|
||||
|
||||
static const char* _testLoadFunc(CreatureLib::Battling::ScriptResolver::ScriptCategory category, const char* name) {
|
||||
return _scripts[name];
|
||||
}
|
||||
|
||||
struct ScriptData {
|
||||
AngelScriptScript* Script;
|
||||
AngelScripResolver* Resolver;
|
||||
@@ -36,8 +33,7 @@ static AngelScripResolver* GetScriptResolver(PkmnLib::Battling::BattleLibrary* m
|
||||
if (_resolverCache == nullptr){
|
||||
_resolverCache = dynamic_cast<AngelScripResolver*>(PkmnLib::Battling::BattleLibrary::CreateScriptResolver());
|
||||
_resolverCache->Initialize(mainLib);
|
||||
_resolverCache->SetCreateFunction(&_testLoadFunc);
|
||||
_resolverCache->CreateScript(AngelScripResolver::ScriptCategory::Attack ,"testScript1");
|
||||
_resolverCache->CreateScript("testScript1" , _scripts["testScript1"]);
|
||||
_resolverCache->FinalizeModule();
|
||||
}
|
||||
return _resolverCache;
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
static std::unordered_map<const char*, const char*> _scripts =
|
||||
std::unordered_map<const char*, const char*>{{"testScript1", R"(
|
||||
namespace Pokemon{
|
||||
class testScript1 {
|
||||
bool testMaximumLevel(const StaticLibrary@ s, uint8 level){ return s.Settings.MaximalLevel == level; }
|
||||
bool testMaximumMoves(const StaticLibrary@ s, uint8 moveCount){ return s.Settings.MaximalMoves == moveCount; }
|
||||
@@ -13,13 +14,9 @@ class testScript1 {
|
||||
bool testItemLibrary(const StaticLibrary@ s, const ItemLibrary@ itemLib){ return s.ItemLibrary is itemLib; }
|
||||
bool testGrowthRateLibrary(const StaticLibrary@ s, const GrowthRateLibrary@ gl){ return s.GrowthRateLibrary is gl; }
|
||||
bool testTypeLibrary(const StaticLibrary@ s, const TypeLibrary@ tl){ return s.TypeLibrary is tl; }
|
||||
}
|
||||
}}
|
||||
)"}};
|
||||
|
||||
static const char* _testLoadFunc(CreatureLib::Battling::ScriptResolver::ScriptCategory category, const char* name) {
|
||||
return _scripts[name];
|
||||
}
|
||||
|
||||
struct ScriptData {
|
||||
AngelScriptScript* Script;
|
||||
AngelScripResolver* Resolver;
|
||||
@@ -37,8 +34,7 @@ static AngelScripResolver* GetScriptResolver(PkmnLib::Battling::BattleLibrary* m
|
||||
if (_resolverCache == nullptr){
|
||||
_resolverCache = dynamic_cast<AngelScripResolver*>(PkmnLib::Battling::BattleLibrary::CreateScriptResolver());
|
||||
_resolverCache->Initialize(mainLib);
|
||||
_resolverCache->SetCreateFunction(&_testLoadFunc);
|
||||
_resolverCache->CreateScript(AngelScripResolver::ScriptCategory::Attack ,"testScript1");
|
||||
_resolverCache->CreateScript("testScript1" , _scripts["testScript1"]);
|
||||
_resolverCache->FinalizeModule();
|
||||
}
|
||||
return _resolverCache;
|
||||
|
||||
Reference in New Issue
Block a user