Large cleanup of type registration, added new "NativeArray" (or narray in angelscript) type that simply holds a pointer to a native list, to prevent copies we don't need
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
@@ -147,8 +147,8 @@ TEST_CASE("Able to set and get evolution") {
|
||||
auto evo = evolutions[0];
|
||||
CHECK(evo->GetMethod() == PkmnLib::Library::EvolutionMethod::Level);
|
||||
CHECK(evo->GetNewSpecies() == species2);
|
||||
INFO(CreatureLib::Library::EffectParameterTypeHelper::ToString(evo->GetData(0)->GetType()));
|
||||
CHECK(evo->GetData(0)->AsInt() == 16);
|
||||
INFO(CreatureLib::Library::EffectParameterTypeHelper::ToString(evo->GetDataAt(0)->GetType()));
|
||||
CHECK(evo->GetDataAt(0)->AsInt() == 16);
|
||||
|
||||
delete species;
|
||||
delete species2;
|
||||
|
||||
@@ -14,7 +14,7 @@ static std::unordered_map<const char*, const char*> _scripts = std::unordered_ma
|
||||
bool boolValue = false;
|
||||
int64 intValue = 0;
|
||||
constString stringValue;
|
||||
void OnInitialize(const array<EffectParameter@> &in parameters) override {
|
||||
void OnInitialize(const narray<EffectParameter@>@ parameters) override {
|
||||
boolValue = parameters[0].AsBool();
|
||||
intValue = parameters[1].AsInt();
|
||||
stringValue = parameters[2].AsString();
|
||||
|
||||
@@ -19,7 +19,7 @@ class testScript1 : PkmnScript {
|
||||
}
|
||||
}
|
||||
|
||||
void OnInitialize(const array<EffectParameter@> &in parameters) override{ }
|
||||
void OnInitialize(const narray<EffectParameter@>@ parameters) override{ }
|
||||
}
|
||||
}
|
||||
)"}};
|
||||
|
||||
@@ -12,6 +12,10 @@ namespace Pokemon{
|
||||
[Pokemon effect=testScript1]
|
||||
class testScript1 : PkmnScript {
|
||||
bool testGetPokemonIndex(BattleSide@ b, const Pokemon@ pokemon){ return b.GetPokemonIndex(pokemon) == 0; }
|
||||
|
||||
bool testGetSides(BattleSide@ a, BattleSide@ b, Battle@ battle) {
|
||||
return battle.Sides.At(0) is a;
|
||||
}
|
||||
}}
|
||||
)"}};
|
||||
|
||||
@@ -59,25 +63,38 @@ TEST_CASE("Validate Battle Side GetPokemonIndex") {
|
||||
auto mon = PkmnLib::Battling::CreatePokemon(mainLib, "testSpecies"_cnc, 30).Build();
|
||||
auto mon2 = PkmnLib::Battling::CreatePokemon(mainLib, "testSpecies"_cnc, 30).Build();
|
||||
|
||||
auto userParty = new CreatureLib::Battling::CreatureParty({mon});
|
||||
auto targetParty = new CreatureLib::Battling::CreatureParty({mon2});
|
||||
auto battle = new PkmnLib::Battling::Battle(
|
||||
auto userParty = CreatureLib::Battling::CreatureParty({mon});
|
||||
auto targetParty = CreatureLib::Battling::CreatureParty({mon2});
|
||||
auto battle = PkmnLib::Battling::Battle(
|
||||
mainLib, {
|
||||
new CreatureLib::Battling::BattleParty(userParty, {CreatureLib::Battling::CreatureIndex(0, 0)}),
|
||||
new CreatureLib::Battling::BattleParty(targetParty, {CreatureLib::Battling::CreatureIndex(1, 0)}),
|
||||
new CreatureLib::Battling::BattleParty(&userParty, {CreatureLib::Battling::CreatureIndex(0, 0)}),
|
||||
new CreatureLib::Battling::BattleParty(&targetParty, {CreatureLib::Battling::CreatureIndex(1, 0)}),
|
||||
});
|
||||
|
||||
battle->SwitchCreature(0, 0, mon);
|
||||
battle->SwitchCreature(1, 0, mon2);
|
||||
battle.SwitchCreature(0, 0, mon);
|
||||
battle.SwitchCreature(1, 0, mon2);
|
||||
|
||||
auto data = GetScript(mainLib, "testGetPokemonIndex"_cnc);
|
||||
data.Context->SetArgObject(0, battle->GetSides()[0]);
|
||||
data.Context->SetArgObject(0, battle.GetSides()[0]);
|
||||
data.Context->SetArgObject(1, mon);
|
||||
|
||||
REQUIRE(data.Context->Execute() == asEXECUTION_FINISHED);
|
||||
REQUIRE((bool)data.Context->GetReturnWord());
|
||||
delete mon;
|
||||
delete mon2;
|
||||
}
|
||||
|
||||
TEST_CASE("Validate Battle GetBattleSides") {
|
||||
auto mainLib = TestLibrary::GetLibrary();
|
||||
auto battle = new PkmnLib::Battling::Battle(mainLib, {});
|
||||
|
||||
auto data = GetScript(mainLib, "testGetSides"_cnc);
|
||||
data.Context->SetArgObject(0, battle->GetSides()[0].GetRaw());
|
||||
data.Context->SetArgObject(1, battle->GetSides()[1].GetRaw());
|
||||
data.Context->SetArgObject(2, battle);
|
||||
|
||||
REQUIRE(data.Context->Execute() == asEXECUTION_FINISHED);
|
||||
REQUIRE((bool)data.Context->GetReturnWord());
|
||||
|
||||
delete battle;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -24,7 +24,7 @@ class testScript1 : PkmnScript {
|
||||
bool testHasType(Pokemon@ p, uint8 type){ return p.HasType(type); }
|
||||
void testDamage(Pokemon@ p, uint32 damage, DamageSource source){ p.Damage(damage, source); }
|
||||
void testHeal(Pokemon@ p, uint32 amount){ p.Heal(amount); }
|
||||
bool testMove(Pokemon@ p, uint index, LearnedMove@ move){ return p.GetMoves()[index] is move; }
|
||||
bool testMove(Pokemon@ p, uint index, LearnedMove@ move){ return p.Moves[index] is move; }
|
||||
bool testHasHeldItem(Pokemon@ p, const constString &in item){ return p.HasHeldItem(item); }
|
||||
void testSetHeldItem(Pokemon@ p, const constString &in item){ p.SetHeldItem(item); }
|
||||
void testSetHeldItem2(Pokemon@ p){ p.SetHeldItem("testItem"); }
|
||||
|
||||
Reference in New Issue
Block a user