Update to new CreatureLib version, updated libraries in accordance.
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Deukhoofd 2020-02-15 19:04:06 +01:00
parent 4ee791c6cb
commit 45662cb29b
Signed by: Deukhoofd
GPG Key ID: ADF2E9256009EDCE
14 changed files with 68 additions and 75 deletions

View File

@ -44,7 +44,7 @@ class PkmnLibConan(ConanFile):
self.options["AngelScript"].link_std_statically = True self.options["AngelScript"].link_std_statically = True
def requirements(self): def requirements(self):
self.requires("CreatureLib/a6f91faba45b39b716510b4348e3f747eab9bb2d@creaturelib/master") self.requires("CreatureLib/d6ea16b467c23ad532b548007df4ec52d58265b3@creaturelib/master")
if self.options.script_handler == "angelscript": if self.options.script_handler == "angelscript":
self.requires("AngelScript/2.34@AngelScript/Deukhoofd") self.requires("AngelScript/2.34@AngelScript/Deukhoofd")
else: else:

View File

@ -40,7 +40,7 @@ PkmnLib::Battling::CreatePokemon* PkmnLib::Battling::CreatePokemon::WithEffortVa
PkmnLib::Battling::Pokemon* PkmnLib::Battling::CreatePokemon::Build() { PkmnLib::Battling::Pokemon* PkmnLib::Battling::CreatePokemon::Build() {
auto rand = CreatureLib::Core::Random(); auto rand = CreatureLib::Core::Random();
const PkmnLib::Library::PokemonSpecies* species = nullptr; const PkmnLib::Library::PokemonSpecies* species = nullptr;
if (!this->_library->GetSpeciesLibrary()->TryGetPkmnSpecies(this->_species, species)) { if (!this->_library->GetSpeciesLibrary()->TryGet(this->_species.c_str(), species)) {
std::stringstream err; std::stringstream err;
err << "Invalid species '" << _species << "'."; err << "Invalid species '" << _species << "'.";
throw CreatureException(err.str()); throw CreatureException(err.str());
@ -67,7 +67,7 @@ PkmnLib::Battling::Pokemon* PkmnLib::Battling::CreatePokemon::Build() {
} }
const Library::Item* heldItem = nullptr; const Library::Item* heldItem = nullptr;
if (!this->_heldItem.empty()) { if (!this->_heldItem.empty()) {
if (!_library->GetItemLibrary()->TryGetItem(this->_heldItem, heldItem)) { if (!_library->GetItemLibrary()->TryGet(this->_heldItem.c_str(), heldItem)) {
throw CreatureException("Unknown Item: " + this->_heldItem); throw CreatureException("Unknown Item: " + this->_heldItem);
} }
} }
@ -143,7 +143,7 @@ PkmnLib::Battling::CreatePokemon* PkmnLib::Battling::CreatePokemon::WithHeldItem
PkmnLib::Battling::CreatePokemon* PkmnLib::Battling::CreatePokemon*
PkmnLib::Battling::CreatePokemon::LearnMove(const std::string& moveName, CreatureLib::Battling::AttackLearnMethod method) { PkmnLib::Battling::CreatePokemon::LearnMove(const std::string& moveName, CreatureLib::Battling::AttackLearnMethod method) {
const PkmnLib::Library::MoveData* move; const PkmnLib::Library::MoveData* move;
if (!_library->GetMoveLibrary()->TryGetMove(moveName, move)){ if (!_library->GetMoveLibrary()->TryGet(moveName.c_str(), move)){
throw CreatureException("Invalid Move given: " + moveName); throw CreatureException("Invalid Move given: " + moveName);
} }
if (_attacks.size() >= _library->GetSettings()->GetMaximalMoves()){ if (_attacks.size() >= _library->GetSettings()->GetMaximalMoves()){

View File

@ -6,15 +6,17 @@
namespace PkmnLib::Library { namespace PkmnLib::Library {
class ItemLibrary : public CreatureLib::Library::ItemLibrary { class ItemLibrary : public CreatureLib::Library::ItemLibrary {
public: public:
inline bool TryGetItem(const std::string& name, const Item*& item) const { inline bool TryGet(const char* name, const Item*& item) const{
return CreatureLib::Library::ItemLibrary::TryGetItem(name, (const CreatureLib::Library::Item*&)item); return CreatureLib::Library::ItemLibrary::TryGet(name, (const CreatureLib::Library::Item*&)item);
} }
const Item* GetItem(const std::string& name) const {
return reinterpret_cast<const Item*>(CreatureLib::Library::ItemLibrary::GetItem(name)); inline const Item* Get(const char* name) const{
return reinterpret_cast<const Item*>(CreatureLib::Library::ItemLibrary::Get(name));
} }
const Item* operator[](const std::string& name) const { return GetItem(name); } const Item* operator[](const char* name) const { return Get(name); }
void LoadItem(const std::string& name, const Item* item) {
CreatureLib::Library::ItemLibrary::LoadItem(name, item); void Insert(const char* name, const Item* item) {
CreatureLib::Library::ItemLibrary::Insert(name, item);
} }
}; };
} }

View File

@ -8,22 +8,13 @@ namespace PkmnLib::Library {
public: public:
MoveLibrary(size_t initialCapacity = 32) : CreatureLib::Library::AttackLibrary(initialCapacity) {} MoveLibrary(size_t initialCapacity = 32) : CreatureLib::Library::AttackLibrary(initialCapacity) {}
virtual const MoveData* operator[](const std::string& name) const { return GetAttack(name); } virtual const MoveData* operator[](const char* name) const { return Get(name); }
inline bool TryGetMove(const std::string& name, const MoveData*& move) const{ inline bool TryGet(const char* name, const MoveData*& move) const {
return TryGetAttack(name, (const CreatureLib::Library::AttackData*&)move); return CreatureLib::Library::AttackLibrary::TryGet(name, (const CreatureLib::Library::AttackData*&)move);
} }
const MoveData* GetMove(const std::string& name) const { return GetAttack(name); } const MoveData* Get(const char* name) const {
return dynamic_cast<const MoveData*>(CreatureLib::Library::AttackLibrary::Get(name));
const MoveData* GetAttack(const std::string& name) const {
return reinterpret_cast<const MoveData*>(CreatureLib::Library::AttackLibrary::GetAttack(name));
}
void LoadAttack(const std::string& name, const MoveData* attack) {
CreatureLib::Library::AttackLibrary::LoadAttack(name, attack);
}
void LoadMove(const std::string& name, const MoveData* attack) {
CreatureLib::Library::AttackLibrary::LoadAttack(name, attack);
} }
}; };
} }

View File

@ -7,19 +7,19 @@
namespace PkmnLib::Library { namespace PkmnLib::Library {
class SpeciesLibrary : public CreatureLib::Library::SpeciesLibrary { class SpeciesLibrary : public CreatureLib::Library::SpeciesLibrary {
public: public:
inline bool TryGet(const char* name, const PokemonSpecies*& outSpecies) const {
inline bool TryGetPkmnSpecies(const std::string& name, const PokemonSpecies*& outSpecies) const{ return CreatureLib::Library::SpeciesLibrary::TryGet(
return TryGetSpecies(name, (const CreatureLib::Library::CreatureSpecies*&)outSpecies); name, (const CreatureLib::Library::CreatureSpecies*&)outSpecies);
} }
inline const PokemonSpecies* GetPkmnSpecies(const std::string& name) const { inline const PokemonSpecies* Get(const char* name) const {
return dynamic_cast<const PokemonSpecies*>(CreatureLib::Library::SpeciesLibrary::GetSpecies(name)); return dynamic_cast<const PokemonSpecies*>(CreatureLib::Library::SpeciesLibrary::Get(name));
} }
const PokemonSpecies* operator[](const std::string& name) const { return GetPkmnSpecies(name); } const PokemonSpecies* operator[](const char* name) const { return Get(name); }
void LoadSpecies(const std::string& name, const PokemonSpecies* species){ void Insert(const char* name, const PokemonSpecies* species) {
CreatureLib::Library::SpeciesLibrary::LoadSpecies(name, species); CreatureLib::Library::SpeciesLibrary::Insert(name, species);
} }
}; };
} }

View File

@ -77,7 +77,7 @@ void RegisterItemTypes::RegisterItemType(asIScriptEngine* engine) {
void RegisterItemTypes::RegisterItemLibrary(asIScriptEngine* engine) { void RegisterItemTypes::RegisterItemLibrary(asIScriptEngine* engine) {
[[maybe_unused]] int r = engine->RegisterObjectType("ItemLibrary", 0, asOBJ_REF | asOBJ_NOCOUNT); [[maybe_unused]] int r = engine->RegisterObjectType("ItemLibrary", 0, asOBJ_REF | asOBJ_NOCOUNT);
assert(r >= 0); assert(r >= 0);
r = engine->RegisterObjectMethod("ItemLibrary", "const Item@ GetItem(const string &in name) const", r = engine->RegisterObjectMethod("ItemLibrary", "const Item@ Get(const string &in name) const",
asMETHOD(PkmnLib::Library::ItemLibrary, GetItem), asCALL_THISCALL); asMETHOD(PkmnLib::Library::ItemLibrary, Get), asCALL_THISCALL);
assert(r >= 0); assert(r >= 0);
} }

View File

@ -80,8 +80,8 @@ void RegisterMoveTypes::RegisterMoveType(asIScriptEngine* engine) {
void RegisterMoveTypes::RegisterMoveLibrary(asIScriptEngine* engine) { void RegisterMoveTypes::RegisterMoveLibrary(asIScriptEngine* engine) {
[[maybe_unused]] int r = engine->RegisterObjectType("MoveLibrary", 0, asOBJ_REF | asOBJ_NOCOUNT); [[maybe_unused]] int r = engine->RegisterObjectType("MoveLibrary", 0, asOBJ_REF | asOBJ_NOCOUNT);
assert(r >= 0); assert(r >= 0);
r = engine->RegisterObjectMethod("MoveLibrary", "const MoveData@ GetMove(const string &in name) const", r = engine->RegisterObjectMethod("MoveLibrary", "const MoveData@ Get(const string &in name) const",
asMETHOD(PkmnLib::Library::MoveLibrary, GetMove), asCALL_THISCALL); asMETHOD(PkmnLib::Library::MoveLibrary, Get), asCALL_THISCALL);
assert(r >= 0); assert(r >= 0);
} }

View File

@ -99,7 +99,7 @@ void RegisterSpeciesTypes::RegisterFormeType(asIScriptEngine* engine) {
void RegisterSpeciesTypes::RegisterSpeciesLibrary(asIScriptEngine* engine) { void RegisterSpeciesTypes::RegisterSpeciesLibrary(asIScriptEngine* engine) {
[[maybe_unused]] int r = engine->RegisterObjectType("SpeciesLibrary", 0, asOBJ_REF | asOBJ_NOCOUNT); [[maybe_unused]] int r = engine->RegisterObjectType("SpeciesLibrary", 0, asOBJ_REF | asOBJ_NOCOUNT);
assert(r >= 0); assert(r >= 0);
r = engine->RegisterObjectMethod("SpeciesLibrary", "const Species@ GetSpecies(const string &in name) const", r = engine->RegisterObjectMethod("SpeciesLibrary", "const Species@ Get(const string &in name) const",
asMETHOD(PkmnLib::Library::SpeciesLibrary, GetPkmnSpecies), asCALL_THISCALL); asMETHOD(PkmnLib::Library::SpeciesLibrary, Get), asCALL_THISCALL);
assert(r >= 0); assert(r >= 0);
} }

View File

@ -10,7 +10,7 @@ TEST_CASE("Able to build and destroy empty library", "library") {
TEST_CASE("Able to build, destroy and insert library", "library") { TEST_CASE("Able to build, destroy and insert library", "library") {
auto lib = new PkmnLib::Library::SpeciesLibrary(); auto lib = new PkmnLib::Library::SpeciesLibrary();
lib->LoadSpecies("foo", lib->Insert("foo",
new PkmnLib::Library::PokemonSpecies( new PkmnLib::Library::PokemonSpecies(
1, "foo", 1, "foo",
new PkmnLib::Library::PokemonForme( new PkmnLib::Library::PokemonForme(
@ -23,7 +23,7 @@ TEST_CASE("Able to build, destroy and insert library", "library") {
TEST_CASE("Able to insert and retrieve from library", "library") { TEST_CASE("Able to insert and retrieve from library", "library") {
auto lib = new PkmnLib::Library::SpeciesLibrary(); auto lib = new PkmnLib::Library::SpeciesLibrary();
lib->LoadSpecies("foo", lib->Insert("foo",
new PkmnLib::Library::PokemonSpecies( new PkmnLib::Library::PokemonSpecies(
1, "foo", 1, "foo",
new PkmnLib::Library::PokemonForme( new PkmnLib::Library::PokemonForme(
@ -31,7 +31,7 @@ TEST_CASE("Able to insert and retrieve from library", "library") {
CreatureLib::Core::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100), {"testAbility"}, CreatureLib::Core::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100), {"testAbility"},
{"testHiddenAbility"}, new CreatureLib::Library::LearnableAttacks(100)), {"testHiddenAbility"}, new CreatureLib::Library::LearnableAttacks(100)),
0.5f, "testGrowthRate", 100, 100)); 0.5f, "testGrowthRate", 100, 100));
auto val = lib->GetPkmnSpecies("foo"); auto val = lib->Get("foo");
REQUIRE(val->GetName() == "foo"); REQUIRE(val->GetName() == "foo");
delete lib; delete lib;
} }

View File

@ -62,7 +62,7 @@ TEST_CASE("Validate Forme Name in Script") {
auto mainLib = TestLibrary::GetLibrary(); auto mainLib = TestLibrary::GetLibrary();
auto data = GetScript(mainLib, "testName"); auto data = GetScript(mainLib, "testName");
auto forme = mainLib->GetSpeciesLibrary()->GetPkmnSpecies("testSpecies2")->GetDefaultForme(); auto forme = mainLib->GetSpeciesLibrary()->Get("testSpecies2")->GetDefaultForme();
data.Context->SetArgObject(0, const_cast<PkmnLib::Library::PokemonForme*>(forme)); data.Context->SetArgObject(0, const_cast<PkmnLib::Library::PokemonForme*>(forme));
auto name = forme->GetName(); auto name = forme->GetName();
data.Context->SetArgAddress(1, &name); data.Context->SetArgAddress(1, &name);
@ -77,7 +77,7 @@ TEST_CASE("Validate Forme Weight in Script") {
auto mainLib = TestLibrary::GetLibrary(); auto mainLib = TestLibrary::GetLibrary();
auto data = GetScript(mainLib, "testWeight"); auto data = GetScript(mainLib, "testWeight");
auto forme = mainLib->GetSpeciesLibrary()->GetPkmnSpecies("testSpecies2")->GetDefaultForme(); auto forme = mainLib->GetSpeciesLibrary()->Get("testSpecies2")->GetDefaultForme();
data.Context->SetArgObject(0, const_cast<PkmnLib::Library::PokemonForme*>(forme)); data.Context->SetArgObject(0, const_cast<PkmnLib::Library::PokemonForme*>(forme));
data.Context->SetArgFloat(1, forme->GetWeight()); data.Context->SetArgFloat(1, forme->GetWeight());
@ -91,7 +91,7 @@ TEST_CASE("Validate Forme Height in Script") {
auto mainLib = TestLibrary::GetLibrary(); auto mainLib = TestLibrary::GetLibrary();
auto data = GetScript(mainLib, "testHeight"); auto data = GetScript(mainLib, "testHeight");
auto forme = mainLib->GetSpeciesLibrary()->GetPkmnSpecies("testSpecies2")->GetDefaultForme(); auto forme = mainLib->GetSpeciesLibrary()->Get("testSpecies2")->GetDefaultForme();
data.Context->SetArgObject(0, const_cast<PkmnLib::Library::PokemonForme*>(forme)); data.Context->SetArgObject(0, const_cast<PkmnLib::Library::PokemonForme*>(forme));
data.Context->SetArgFloat(1, forme->GetHeight()); data.Context->SetArgFloat(1, forme->GetHeight());
@ -105,7 +105,7 @@ TEST_CASE("Validate Forme Base Experience in Script") {
auto mainLib = TestLibrary::GetLibrary(); auto mainLib = TestLibrary::GetLibrary();
auto data = GetScript(mainLib, "testBaseExperience"); auto data = GetScript(mainLib, "testBaseExperience");
auto forme = mainLib->GetSpeciesLibrary()->GetPkmnSpecies("testSpecies2")->GetDefaultForme(); auto forme = mainLib->GetSpeciesLibrary()->Get("testSpecies2")->GetDefaultForme();
data.Context->SetArgObject(0, const_cast<PkmnLib::Library::PokemonForme*>(forme)); data.Context->SetArgObject(0, const_cast<PkmnLib::Library::PokemonForme*>(forme));
data.Context->SetArgDWord(1, forme->GetBaseExperience()); data.Context->SetArgDWord(1, forme->GetBaseExperience());
@ -119,7 +119,7 @@ TEST_CASE("Validate Forme Type Count in Script") {
auto mainLib = TestLibrary::GetLibrary(); auto mainLib = TestLibrary::GetLibrary();
auto data = GetScript(mainLib, "testTypeCount"); auto data = GetScript(mainLib, "testTypeCount");
auto forme = mainLib->GetSpeciesLibrary()->GetPkmnSpecies("testSpecies2")->GetDefaultForme(); auto forme = mainLib->GetSpeciesLibrary()->Get("testSpecies2")->GetDefaultForme();
data.Context->SetArgObject(0, const_cast<PkmnLib::Library::PokemonForme*>(forme)); data.Context->SetArgObject(0, const_cast<PkmnLib::Library::PokemonForme*>(forme));
data.Context->SetArgDWord(1, forme->GetTypeCount()); data.Context->SetArgDWord(1, forme->GetTypeCount());
@ -133,7 +133,7 @@ TEST_CASE("Validate Forme GetType in Script") {
auto mainLib = TestLibrary::GetLibrary(); auto mainLib = TestLibrary::GetLibrary();
auto data = GetScript(mainLib, "testGetType"); auto data = GetScript(mainLib, "testGetType");
auto forme = mainLib->GetSpeciesLibrary()->GetPkmnSpecies("testSpecies2")->GetDefaultForme(); auto forme = mainLib->GetSpeciesLibrary()->Get("testSpecies2")->GetDefaultForme();
data.Context->SetArgObject(0, const_cast<PkmnLib::Library::PokemonForme*>(forme)); data.Context->SetArgObject(0, const_cast<PkmnLib::Library::PokemonForme*>(forme));
data.Context->SetArgByte(1, forme->GetType(0)); data.Context->SetArgByte(1, forme->GetType(0));
@ -152,7 +152,7 @@ TEST_CASE("Validate Forme GetStatistic in Script") {
auto stat = static_cast<CreatureLib::Core::Statistic>(statInt); auto stat = static_cast<CreatureLib::Core::Statistic>(statInt);
auto data = GetScript(mainLib, "testGetStatistic"); auto data = GetScript(mainLib, "testGetStatistic");
auto forme = mainLib->GetSpeciesLibrary()->GetPkmnSpecies("testSpecies2")->GetDefaultForme(); auto forme = mainLib->GetSpeciesLibrary()->Get("testSpecies2")->GetDefaultForme();
data.Context->SetArgObject(0, const_cast<PkmnLib::Library::PokemonForme*>(forme)); data.Context->SetArgObject(0, const_cast<PkmnLib::Library::PokemonForme*>(forme));
data.Context->SetArgDWord(1, static_cast<asDWORD>(stat)); data.Context->SetArgDWord(1, static_cast<asDWORD>(stat));
data.Context->SetArgDWord(2, forme->GetStatistic(stat)); data.Context->SetArgDWord(2, forme->GetStatistic(stat));
@ -165,7 +165,7 @@ TEST_CASE("Validate Forme GetAbility in Script") {
auto mainLib = TestLibrary::GetLibrary(); auto mainLib = TestLibrary::GetLibrary();
auto data = GetScript(mainLib, "testGetAbility"); auto data = GetScript(mainLib, "testGetAbility");
auto forme = mainLib->GetSpeciesLibrary()->GetPkmnSpecies("testSpecies2")->GetDefaultForme(); auto forme = mainLib->GetSpeciesLibrary()->Get("testSpecies2")->GetDefaultForme();
data.Context->SetArgObject(0, const_cast<PkmnLib::Library::PokemonForme*>(forme)); data.Context->SetArgObject(0, const_cast<PkmnLib::Library::PokemonForme*>(forme));
auto ability = forme->GetAbility(0); auto ability = forme->GetAbility(0);
data.Context->SetArgAddress(1, &ability); data.Context->SetArgAddress(1, &ability);

View File

@ -58,7 +58,7 @@ TEST_CASE("Validate Item Name in Script") {
auto mainLib = TestLibrary::GetLibrary(); auto mainLib = TestLibrary::GetLibrary();
auto data = GetScript(mainLib, "testName"); auto data = GetScript(mainLib, "testName");
auto item = mainLib->GetItemLibrary()->GetItem("testItem"); auto item = mainLib->GetItemLibrary()->Get("testItem");
data.Context->SetArgObject(0, const_cast<PkmnLib::Library::Item*>(item)); data.Context->SetArgObject(0, const_cast<PkmnLib::Library::Item*>(item));
auto name = item->GetName(); auto name = item->GetName();
data.Context->SetArgAddress(1, &name); data.Context->SetArgAddress(1, &name);
@ -71,7 +71,7 @@ TEST_CASE("Validate Item Category in Script") {
auto mainLib = TestLibrary::GetLibrary(); auto mainLib = TestLibrary::GetLibrary();
auto data = GetScript(mainLib, "testCategory"); auto data = GetScript(mainLib, "testCategory");
auto item = mainLib->GetItemLibrary()->GetItem("testItem"); auto item = mainLib->GetItemLibrary()->Get("testItem");
data.Context->SetArgObject(0, const_cast<PkmnLib::Library::Item*>(item)); data.Context->SetArgObject(0, const_cast<PkmnLib::Library::Item*>(item));
data.Context->SetArgDWord(1, static_cast<int32_t >(item->GetCategory())); data.Context->SetArgDWord(1, static_cast<int32_t >(item->GetCategory()));
@ -83,7 +83,7 @@ TEST_CASE("Validate Item Battle Category in Script") {
auto mainLib = TestLibrary::GetLibrary(); auto mainLib = TestLibrary::GetLibrary();
auto data = GetScript(mainLib, "testBattleCategory"); auto data = GetScript(mainLib, "testBattleCategory");
auto item = mainLib->GetItemLibrary()->GetItem("testItem"); auto item = mainLib->GetItemLibrary()->Get("testItem");
data.Context->SetArgObject(0, const_cast<PkmnLib::Library::Item*>(item)); data.Context->SetArgObject(0, const_cast<PkmnLib::Library::Item*>(item));
data.Context->SetArgDWord(1, static_cast<int32_t >(item->GetBattleCategory())); data.Context->SetArgDWord(1, static_cast<int32_t >(item->GetBattleCategory()));
@ -95,7 +95,7 @@ TEST_CASE("Validate Item Price in Script") {
auto mainLib = TestLibrary::GetLibrary(); auto mainLib = TestLibrary::GetLibrary();
auto data = GetScript(mainLib, "testPrice"); auto data = GetScript(mainLib, "testPrice");
auto item = mainLib->GetItemLibrary()->GetItem("testItem"); auto item = mainLib->GetItemLibrary()->Get("testItem");
data.Context->SetArgObject(0, const_cast<PkmnLib::Library::Item*>(item)); data.Context->SetArgObject(0, const_cast<PkmnLib::Library::Item*>(item));
data.Context->SetArgDWord(1, static_cast<int32_t >(item->GetPrice())); data.Context->SetArgDWord(1, static_cast<int32_t >(item->GetPrice()));

View File

@ -62,7 +62,7 @@ TEST_CASE("Validate Move Name in Script") {
auto mainLib = TestLibrary::GetLibrary(); auto mainLib = TestLibrary::GetLibrary();
auto data = GetScript(mainLib, "testName"); auto data = GetScript(mainLib, "testName");
auto move = mainLib->GetMoveLibrary()->GetAttack("testMove"); auto move = mainLib->GetMoveLibrary()->Get("testMove");
data.Context->SetArgObject(0, (void*)move); data.Context->SetArgObject(0, (void*)move);
auto name = move->GetName(); auto name = move->GetName();
data.Context->SetArgAddress(1, &name); data.Context->SetArgAddress(1, &name);
@ -75,7 +75,7 @@ TEST_CASE("Validate Move Type in Script") {
auto mainLib = TestLibrary::GetLibrary(); auto mainLib = TestLibrary::GetLibrary();
auto data = GetScript(mainLib, "testType"); auto data = GetScript(mainLib, "testType");
auto move = mainLib->GetMoveLibrary()->GetAttack("testMove"); auto move = mainLib->GetMoveLibrary()->Get("testMove");
data.Context->SetArgObject(0, const_cast<PkmnLib::Library::MoveData*>(move)); data.Context->SetArgObject(0, const_cast<PkmnLib::Library::MoveData*>(move));
data.Context->SetArgByte(1, move->GetType()); data.Context->SetArgByte(1, move->GetType());
@ -87,7 +87,7 @@ TEST_CASE("Validate Move Category in Script") {
auto mainLib = TestLibrary::GetLibrary(); auto mainLib = TestLibrary::GetLibrary();
auto data = GetScript(mainLib, "testCategory"); auto data = GetScript(mainLib, "testCategory");
auto move = mainLib->GetMoveLibrary()->GetAttack("testMove"); auto move = mainLib->GetMoveLibrary()->Get("testMove");
data.Context->SetArgObject(0, const_cast<PkmnLib::Library::MoveData*>(move)); data.Context->SetArgObject(0, const_cast<PkmnLib::Library::MoveData*>(move));
data.Context->SetArgDWord(1, (asDWORD)move->GetCategory()); data.Context->SetArgDWord(1, (asDWORD)move->GetCategory());
@ -102,7 +102,7 @@ TEST_CASE("Validate Move BasePower in Script") {
auto mainLib = TestLibrary::GetLibrary(); auto mainLib = TestLibrary::GetLibrary();
auto data = GetScript(mainLib, "testBasePower"); auto data = GetScript(mainLib, "testBasePower");
auto move = mainLib->GetMoveLibrary()->GetAttack("testMove"); auto move = mainLib->GetMoveLibrary()->Get("testMove");
data.Context->SetArgObject(0, const_cast<PkmnLib::Library::MoveData*>(move)); data.Context->SetArgObject(0, const_cast<PkmnLib::Library::MoveData*>(move));
data.Context->SetArgByte(1, move->GetBasePower()); data.Context->SetArgByte(1, move->GetBasePower());
@ -114,7 +114,7 @@ TEST_CASE("Validate Move Accuracy in Script") {
auto mainLib = TestLibrary::GetLibrary(); auto mainLib = TestLibrary::GetLibrary();
auto data = GetScript(mainLib, "testAccuracy"); auto data = GetScript(mainLib, "testAccuracy");
auto move = mainLib->GetMoveLibrary()->GetAttack("testMove"); auto move = mainLib->GetMoveLibrary()->Get("testMove");
data.Context->SetArgObject(0, const_cast<PkmnLib::Library::MoveData*>(move)); data.Context->SetArgObject(0, const_cast<PkmnLib::Library::MoveData*>(move));
data.Context->SetArgByte(1, move->GetAccuracy()); data.Context->SetArgByte(1, move->GetAccuracy());
@ -126,7 +126,7 @@ TEST_CASE("Validate Move BaseUsages in Script") {
auto mainLib = TestLibrary::GetLibrary(); auto mainLib = TestLibrary::GetLibrary();
auto data = GetScript(mainLib, "testBaseUsages"); auto data = GetScript(mainLib, "testBaseUsages");
auto move = mainLib->GetMoveLibrary()->GetAttack("testMove"); auto move = mainLib->GetMoveLibrary()->Get("testMove");
data.Context->SetArgObject(0, const_cast<PkmnLib::Library::MoveData*>(move)); data.Context->SetArgObject(0, const_cast<PkmnLib::Library::MoveData*>(move));
data.Context->SetArgByte(1, move->GetBaseUsages()); data.Context->SetArgByte(1, move->GetBaseUsages());
@ -138,7 +138,7 @@ TEST_CASE("Validate Move Target in Script") {
auto mainLib = TestLibrary::GetLibrary(); auto mainLib = TestLibrary::GetLibrary();
auto data = GetScript(mainLib, "testTarget"); auto data = GetScript(mainLib, "testTarget");
auto move = mainLib->GetMoveLibrary()->GetAttack("testMove"); auto move = mainLib->GetMoveLibrary()->Get("testMove");
data.Context->SetArgObject(0, const_cast<PkmnLib::Library::MoveData*>(move)); data.Context->SetArgObject(0, const_cast<PkmnLib::Library::MoveData*>(move));
data.Context->SetArgDWord(1, (uint32_t)move->GetTarget()); data.Context->SetArgDWord(1, (uint32_t)move->GetTarget());
@ -150,7 +150,7 @@ TEST_CASE("Validate Move Priority in Script") {
auto mainLib = TestLibrary::GetLibrary(); auto mainLib = TestLibrary::GetLibrary();
auto data = GetScript(mainLib, "testPriority"); auto data = GetScript(mainLib, "testPriority");
auto move = mainLib->GetMoveLibrary()->GetAttack("testMove"); auto move = mainLib->GetMoveLibrary()->Get("testMove");
data.Context->SetArgObject(0, const_cast<PkmnLib::Library::MoveData*>(move)); data.Context->SetArgObject(0, const_cast<PkmnLib::Library::MoveData*>(move));
data.Context->SetArgByte(1, move->GetPriority()); data.Context->SetArgByte(1, move->GetPriority());

View File

@ -60,7 +60,7 @@ TEST_CASE("Validate Species Name in Script") {
auto mainLib = TestLibrary::GetLibrary(); auto mainLib = TestLibrary::GetLibrary();
auto data = GetScript(mainLib, "testName"); auto data = GetScript(mainLib, "testName");
auto species = mainLib->GetSpeciesLibrary()->GetPkmnSpecies("testSpecies2"); auto species = mainLib->GetSpeciesLibrary()->Get("testSpecies2");
data.Context->SetArgObject( data.Context->SetArgObject(
0, const_cast<PkmnLib::Library::PokemonSpecies*>(species)); 0, const_cast<PkmnLib::Library::PokemonSpecies*>(species));
auto name = species->GetName(); auto name = species->GetName();
@ -76,7 +76,7 @@ TEST_CASE("Validate Species Id in Script") {
auto mainLib = TestLibrary::GetLibrary(); auto mainLib = TestLibrary::GetLibrary();
auto data = GetScript(mainLib, "testId"); auto data = GetScript(mainLib, "testId");
auto species = mainLib->GetSpeciesLibrary()->GetPkmnSpecies("testSpecies2"); auto species = mainLib->GetSpeciesLibrary()->Get("testSpecies2");
data.Context->SetArgObject( data.Context->SetArgObject(
0, const_cast<PkmnLib::Library::PokemonSpecies*>(species)); 0, const_cast<PkmnLib::Library::PokemonSpecies*>(species));
data.Context->SetArgWord(1, species->GetId()); data.Context->SetArgWord(1, species->GetId());
@ -91,7 +91,7 @@ TEST_CASE("Validate Species Gender Rate in Script") {
auto mainLib = TestLibrary::GetLibrary(); auto mainLib = TestLibrary::GetLibrary();
auto data = GetScript(mainLib, "testGenderRate"); auto data = GetScript(mainLib, "testGenderRate");
auto species = mainLib->GetSpeciesLibrary()->GetPkmnSpecies("testSpecies2"); auto species = mainLib->GetSpeciesLibrary()->Get("testSpecies2");
data.Context->SetArgObject( data.Context->SetArgObject(
0, const_cast<PkmnLib::Library::PokemonSpecies*>(species)); 0, const_cast<PkmnLib::Library::PokemonSpecies*>(species));
data.Context->SetArgFloat(1, species->GetGenderRate()); data.Context->SetArgFloat(1, species->GetGenderRate());
@ -106,7 +106,7 @@ TEST_CASE("Validate Species Capture Rate in Script") {
auto mainLib = TestLibrary::GetLibrary(); auto mainLib = TestLibrary::GetLibrary();
auto data = GetScript(mainLib, "testCaptureRate"); auto data = GetScript(mainLib, "testCaptureRate");
auto species = mainLib->GetSpeciesLibrary()->GetPkmnSpecies("testSpecies2"); auto species = mainLib->GetSpeciesLibrary()->Get("testSpecies2");
data.Context->SetArgObject( data.Context->SetArgObject(
0, const_cast<PkmnLib::Library::PokemonSpecies*>(species)); 0, const_cast<PkmnLib::Library::PokemonSpecies*>(species));
data.Context->SetArgByte(1, species->GetCaptureRate()); data.Context->SetArgByte(1, species->GetCaptureRate());
@ -121,7 +121,7 @@ TEST_CASE("Validate Species Get Forme in Script") {
auto mainLib = TestLibrary::GetLibrary(); auto mainLib = TestLibrary::GetLibrary();
auto data = GetScript(mainLib, "testGetForme"); auto data = GetScript(mainLib, "testGetForme");
auto species = mainLib->GetSpeciesLibrary()->GetPkmnSpecies("testSpecies2"); auto species = mainLib->GetSpeciesLibrary()->Get("testSpecies2");
data.Context->SetArgObject( data.Context->SetArgObject(
0, const_cast<PkmnLib::Library::PokemonSpecies*>(species)); 0, const_cast<PkmnLib::Library::PokemonSpecies*>(species));
data.Context->SetArgObject(1, const_cast<PkmnLib::Library::PokemonForme*>(species->GetForme("default"))); data.Context->SetArgObject(1, const_cast<PkmnLib::Library::PokemonForme*>(species->GetForme("default")));
@ -136,7 +136,7 @@ TEST_CASE("Validate Species Get Default Forme in Script") {
auto mainLib = TestLibrary::GetLibrary(); auto mainLib = TestLibrary::GetLibrary();
auto data = GetScript(mainLib, "testGetDefaultForme"); auto data = GetScript(mainLib, "testGetDefaultForme");
auto species = mainLib->GetSpeciesLibrary()->GetPkmnSpecies("testSpecies2"); auto species = mainLib->GetSpeciesLibrary()->Get("testSpecies2");
data.Context->SetArgObject(0, const_cast<PkmnLib::Library::PokemonSpecies*>(species)); data.Context->SetArgObject(0, const_cast<PkmnLib::Library::PokemonSpecies*>(species));
data.Context->SetArgObject(1, const_cast<PkmnLib::Library::PokemonForme*>(species->GetDefaultForme())); data.Context->SetArgObject(1, const_cast<PkmnLib::Library::PokemonForme*>(species->GetDefaultForme()));

View File

@ -2,7 +2,7 @@
PkmnLib::Battling::BattleLibrary* TestLibrary::_library = nullptr; PkmnLib::Battling::BattleLibrary* TestLibrary::_library = nullptr;
PkmnLib::Library::SpeciesLibrary* TestLibrary::BuildSpeciesLibrary() { PkmnLib::Library::SpeciesLibrary* TestLibrary::BuildSpeciesLibrary() {
auto lib = new PkmnLib::Library::SpeciesLibrary(); auto lib = new PkmnLib::Library::SpeciesLibrary();
lib->LoadSpecies("testSpecies", lib->Insert("testSpecies",
new PkmnLib::Library::PokemonSpecies( new PkmnLib::Library::PokemonSpecies(
1, "testSpecies", 1, "testSpecies",
new PkmnLib::Library::PokemonForme( new PkmnLib::Library::PokemonForme(
@ -10,7 +10,7 @@ PkmnLib::Library::SpeciesLibrary* TestLibrary::BuildSpeciesLibrary() {
CreatureLib::Core::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100), {"testAbility"}, CreatureLib::Core::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100), {"testAbility"},
{"testHiddenAbility"}, new CreatureLib::Library::LearnableAttacks(100)), {"testHiddenAbility"}, new CreatureLib::Library::LearnableAttacks(100)),
0.5f, "testGrowthRate", 100, 100)); 0.5f, "testGrowthRate", 100, 100));
lib->LoadSpecies("testSpecies2", lib->Insert("testSpecies2",
new PkmnLib::Library::PokemonSpecies( new PkmnLib::Library::PokemonSpecies(
2, "testSpecies2", 2, "testSpecies2",
new PkmnLib::Library::PokemonForme( new PkmnLib::Library::PokemonForme(
@ -18,7 +18,7 @@ PkmnLib::Library::SpeciesLibrary* TestLibrary::BuildSpeciesLibrary() {
CreatureLib::Core::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100), {"testAbility"}, CreatureLib::Core::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100), {"testAbility"},
{"testHiddenAbility"}, new CreatureLib::Library::LearnableAttacks(100)), {"testHiddenAbility"}, new CreatureLib::Library::LearnableAttacks(100)),
0.5f, "testGrowthRate", 100, 100)); 0.5f, "testGrowthRate", 100, 100));
lib->LoadSpecies("statTestSpecies1", lib->Insert("statTestSpecies1",
new PkmnLib::Library::PokemonSpecies( new PkmnLib::Library::PokemonSpecies(
3, "statTestSpecies1", 3, "statTestSpecies1",
new PkmnLib::Library::PokemonForme( new PkmnLib::Library::PokemonForme(
@ -26,7 +26,7 @@ PkmnLib::Library::SpeciesLibrary* TestLibrary::BuildSpeciesLibrary() {
CreatureLib::Core::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100), {"testAbility"}, CreatureLib::Core::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100), {"testAbility"},
{"testHiddenAbility"}, new CreatureLib::Library::LearnableAttacks(100)), {"testHiddenAbility"}, new CreatureLib::Library::LearnableAttacks(100)),
0.5f, "testGrowthRate", 100, 100)); 0.5f, "testGrowthRate", 100, 100));
lib->LoadSpecies("testSpecies3", lib->Insert("testSpecies3",
new PkmnLib::Library::PokemonSpecies( new PkmnLib::Library::PokemonSpecies(
2, "testSpecies3", 2, "testSpecies3",
new PkmnLib::Library::PokemonForme( new PkmnLib::Library::PokemonForme(
@ -40,17 +40,17 @@ PkmnLib::Library::SpeciesLibrary* TestLibrary::BuildSpeciesLibrary() {
} }
PkmnLib::Library::MoveLibrary* TestLibrary::BuildMoveLibrary() { PkmnLib::Library::MoveLibrary* TestLibrary::BuildMoveLibrary() {
auto lib = new PkmnLib::Library::MoveLibrary(); auto lib = new PkmnLib::Library::MoveLibrary();
lib->LoadMove("testMove", lib->Insert("testMove",
new PkmnLib::Library::MoveData("testMove", 0, PkmnLib::Library::MoveCategory::Physical, 50, 100, 20, new PkmnLib::Library::MoveData("testMove", 0, PkmnLib::Library::MoveCategory::Physical, 50, 100, 20,
CreatureLib::Library::AttackTarget::Adjacent, 0, {})); CreatureLib::Library::AttackTarget::Adjacent, 0, {}));
lib->LoadMove("testMove2", lib->Insert("testMove2",
new PkmnLib::Library::MoveData("testMove2", 0, PkmnLib::Library::MoveCategory::Special, 30, 100, 10, new PkmnLib::Library::MoveData("testMove2", 0, PkmnLib::Library::MoveCategory::Special, 30, 100, 10,
CreatureLib::Library::AttackTarget::Adjacent, 0, {})); CreatureLib::Library::AttackTarget::Adjacent, 0, {}));
return lib; return lib;
} }
PkmnLib::Library::ItemLibrary* TestLibrary::BuildItemLibrary() { PkmnLib::Library::ItemLibrary* TestLibrary::BuildItemLibrary() {
auto lib = new PkmnLib::Library::ItemLibrary(); auto lib = new PkmnLib::Library::ItemLibrary();
lib->LoadItem("testItem", new PkmnLib::Library::Item("testItem", CreatureLib::Library::ItemCategory::MiscItem, lib->Insert("testItem", new PkmnLib::Library::Item("testItem", CreatureLib::Library::ItemCategory::MiscItem,
CreatureLib::Library::BattleItemCategory::None, 0, {}, 0)); CreatureLib::Library::BattleItemCategory::None, 0, {}, 0));
return lib; return lib;
} }