File formatting.
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
686f898259
commit
c4b866cb38
|
@ -23,7 +23,7 @@ public:
|
|||
return 0; \
|
||||
} catch (const std::exception& e) { \
|
||||
ExceptionHandler::SetLastException(e); \
|
||||
return PkmnLibException; \
|
||||
return PkmnLibException; \
|
||||
}
|
||||
|
||||
#endif // PKMNLIB_CORE_HPP
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
#include "../Core.hpp"
|
||||
using namespace PkmnLib::Library;
|
||||
|
||||
export const LibrarySettings* PkmnLib_LibrarySettings_Construct(uint8_t maximalLevel, uint8_t maximalMoves, uint16_t shinyRate) {
|
||||
export const LibrarySettings* PkmnLib_LibrarySettings_Construct(uint8_t maximalLevel, uint8_t maximalMoves,
|
||||
uint16_t shinyRate) {
|
||||
return new LibrarySettings(maximalLevel, maximalMoves, shinyRate);
|
||||
}
|
||||
|
||||
|
|
|
@ -2,8 +2,9 @@
|
|||
#include "../Core.hpp"
|
||||
using namespace PkmnLib::Library;
|
||||
|
||||
export Nature* PkmnLib_Nature_Construct(CreatureLib::Library::Statistic increasedStat, CreatureLib::Library::Statistic decreasedStat,
|
||||
float increasedModifier, float decreasedModifier) {
|
||||
export Nature* PkmnLib_Nature_Construct(CreatureLib::Library::Statistic increasedStat,
|
||||
CreatureLib::Library::Statistic decreasedStat, float increasedModifier,
|
||||
float decreasedModifier) {
|
||||
return new Nature(increasedStat, decreasedStat, increasedModifier, decreasedModifier);
|
||||
}
|
||||
export void PkmnLib_Nature_Destruct(const Nature* p) { delete p; }
|
||||
|
@ -18,6 +19,6 @@ SIMPLE_GET_FUNC(Nature, GetDecreasedStat, CreatureLib::Library::Statistic)
|
|||
|
||||
#undef SIMPLE_GET_FUNC
|
||||
|
||||
export float PkmnLib_Nature_GetStatModifier(PkmnLib::Library::Nature nature, CreatureLib::Library::Statistic stat){
|
||||
export float PkmnLib_Nature_GetStatModifier(PkmnLib::Library::Nature nature, CreatureLib::Library::Statistic stat) {
|
||||
return nature.GetStatModifier(stat);
|
||||
}
|
|
@ -14,8 +14,7 @@ uint32_t PkmnLib::Battling::StatCalculator::CalculateOtherStat(const Pokemon* pk
|
|||
uint32_t iv = pkmn->GetIndividualValue(stat);
|
||||
uint32_t ev = pkmn->GetEffortValue(stat);
|
||||
uint8_t level = pkmn->GetLevel();
|
||||
uint32_t unmodified =
|
||||
static_cast<uint32_t>(((2 * base + iv + static_cast<uint32_t>(ev / 4)) * level) / 100) + 5;
|
||||
uint32_t unmodified = static_cast<uint32_t>(((2 * base + iv + static_cast<uint32_t>(ev / 4)) * level) / 100) + 5;
|
||||
return static_cast<uint32_t>(unmodified * pkmn->GetNature()->GetStatModifier(stat));
|
||||
}
|
||||
float PkmnLib::Battling::StatCalculator::GetStatBoostModifier(const CreatureLib::Battling::Creature* pkmn,
|
||||
|
@ -41,12 +40,12 @@ float PkmnLib::Battling::StatCalculator::GetStatBoostModifier(const CreatureLib:
|
|||
CreatureLib::Library::StatisticSet<uint32_t>
|
||||
PkmnLib::Battling::StatCalculator::CalculateFlatStats(CreatureLib::Battling::Creature* creature) const {
|
||||
auto pkmn = dynamic_cast<Pokemon*>(creature);
|
||||
return CreatureLib::Library::StatisticSet<uint32_t>(
|
||||
CalculateHealthStat(pkmn), CalculateOtherStat(pkmn, Library::Statistic::PhysicalAttack),
|
||||
CalculateOtherStat(pkmn, Library::Statistic::PhysicalDefense),
|
||||
CalculateOtherStat(pkmn, Library::Statistic::SpecialAttack),
|
||||
CalculateOtherStat(pkmn, Library::Statistic::SpecialDefense),
|
||||
CalculateOtherStat(pkmn, Library::Statistic::Speed));
|
||||
return CreatureLib::Library::StatisticSet<uint32_t>(CalculateHealthStat(pkmn),
|
||||
CalculateOtherStat(pkmn, Library::Statistic::PhysicalAttack),
|
||||
CalculateOtherStat(pkmn, Library::Statistic::PhysicalDefense),
|
||||
CalculateOtherStat(pkmn, Library::Statistic::SpecialAttack),
|
||||
CalculateOtherStat(pkmn, Library::Statistic::SpecialDefense),
|
||||
CalculateOtherStat(pkmn, Library::Statistic::Speed));
|
||||
}
|
||||
CreatureLib::Library::StatisticSet<uint32_t>
|
||||
PkmnLib::Battling::StatCalculator::CalculateBoostedStats(CreatureLib::Battling::Creature* creature) const {
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
#include <CreatureLib/Battling/ScriptHandling/Script.hpp>
|
||||
#include "Pokemon/Pokemon.hpp"
|
||||
|
||||
namespace PkmnLib::Battling{
|
||||
class PkmnScript : public CreatureLib::Battling::Script{
|
||||
namespace PkmnLib::Battling {
|
||||
class PkmnScript : public CreatureLib::Battling::Script {
|
||||
public:
|
||||
virtual void ModifyCriticalStage(CreatureLib::Battling::ExecutingAttack* attack,
|
||||
CreatureLib::Battling::Creature* target, uint8_t hit, uint8_t* critStage){};
|
||||
|
|
|
@ -8,6 +8,6 @@
|
|||
if (next == nullptr) \
|
||||
continue; \
|
||||
auto castNext = dynamic_cast<PkmnLib::Battling::PkmnScript*>(next); \
|
||||
castNext->hookName(__VA_ARGS__); \
|
||||
castNext->hookName(__VA_ARGS__); \
|
||||
} \
|
||||
}
|
||||
|
|
|
@ -29,7 +29,8 @@ const EvolutionData* EvolutionData::CreateTradeWithItemEvolution(const Item* ite
|
|||
return new EvolutionData(EvolutionMethod::TradeWithHeldItem,
|
||||
{new CreatureLib::Library::EffectParameter(item->GetName())}, into);
|
||||
}
|
||||
const EvolutionData* EvolutionData::CreateTradeWithSpeciesEvolution(const PokemonSpecies* traded, const PokemonSpecies* into) {
|
||||
const EvolutionData* EvolutionData::CreateTradeWithSpeciesEvolution(const PokemonSpecies* traded,
|
||||
const PokemonSpecies* into) {
|
||||
return new EvolutionData(EvolutionMethod::TradeWithSpecificPokemon,
|
||||
{new CreatureLib::Library::EffectParameter(traded->GetName())}, into);
|
||||
}
|
||||
|
|
|
@ -5,8 +5,7 @@
|
|||
namespace PkmnLib::Library {
|
||||
ENUM(EvolutionMethod, uint8_t, Level, HighFriendship, KnownMove, LocationBased, TimeBased, HoldsItem,
|
||||
IsGenderAndLevel, EvolutionItemUse, EvolutionItemUseWithGender, Trade, TradeWithHeldItem,
|
||||
TradeWithSpecificPokemon, Custom
|
||||
)
|
||||
TradeWithSpecificPokemon, Custom)
|
||||
}
|
||||
|
||||
#endif // PKMNLIB_EVOLUTIONMETHOD_HPP
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace PkmnLib::Library {
|
|||
|
||||
inline bool TryGet(const Arbutils::CaseInsensitiveConstString& name, const MoveData*& move) const {
|
||||
const CreatureLib::Library::AttackData* ptr;
|
||||
if (CreatureLib::Library::AttackLibrary::TryGet(name, ptr)){
|
||||
if (CreatureLib::Library::AttackLibrary::TryGet(name, ptr)) {
|
||||
move = dynamic_cast<const MoveData*>(ptr);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -38,8 +38,7 @@ namespace PkmnLib::Library {
|
|||
auto& map = _items.GetStdMap();
|
||||
return std::next(std::begin(map), i)->first;
|
||||
}
|
||||
inline const Arbutils::CaseInsensitiveConstString&
|
||||
GetRandomNatureName(Arbutils::Random* rand) const {
|
||||
inline const Arbutils::CaseInsensitiveConstString& GetRandomNatureName(Arbutils::Random* rand) const {
|
||||
auto i = rand->Get(_items.Count());
|
||||
auto& map = _items.GetStdMap();
|
||||
return std::next(std::begin(map), i)->first;
|
||||
|
|
|
@ -14,16 +14,14 @@ namespace PkmnLib::Library {
|
|||
const NatureLibrary* _natures;
|
||||
|
||||
public:
|
||||
~PokemonLibrary() override {
|
||||
delete _natures;
|
||||
}
|
||||
~PokemonLibrary() override { delete _natures; }
|
||||
|
||||
PokemonLibrary(PkmnLib::Library::LibrarySettings* settings, SpeciesLibrary* species, MoveLibrary* moves,
|
||||
ItemLibrary* items, CreatureLib::Library::GrowthRateLibrary* growthRates,
|
||||
CreatureLib::Library::TypeLibrary* typeLibrary, NatureLibrary* natures)
|
||||
: DataLibrary(settings, species, moves, items, growthRates, typeLibrary), _natures(natures) {}
|
||||
|
||||
const PkmnLib::Library::LibrarySettings* GetSettings() const{
|
||||
const PkmnLib::Library::LibrarySettings* GetSettings() const {
|
||||
return static_cast<const LibrarySettings*>(CreatureLib::Library::DataLibrary::GetSettings());
|
||||
}
|
||||
|
||||
|
@ -39,9 +37,7 @@ namespace PkmnLib::Library {
|
|||
return (const ItemLibrary*)(CreatureLib::Library::DataLibrary::GetItemLibrary());
|
||||
}
|
||||
|
||||
[[nodiscard]] const NatureLibrary* GetNatureLibrary() const {
|
||||
return _natures;
|
||||
}
|
||||
[[nodiscard]] const NatureLibrary* GetNatureLibrary() const { return _natures; }
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ private:
|
|||
|
||||
void RegisterTypes();
|
||||
void InitializeByteCode(asIBinaryStream* stream,
|
||||
const Dictionary<ScriptCategory, Dictionary<ConstString, const char*>>& types);
|
||||
const Dictionary<ScriptCategory, Dictionary<ConstString, const char*>>& types);
|
||||
|
||||
public:
|
||||
~AngelScriptResolver() override {
|
||||
|
@ -57,9 +57,9 @@ public:
|
|||
return _typeDatabase;
|
||||
}
|
||||
|
||||
asITypeInfo* GetBaseType(const ConstString& name){
|
||||
asITypeInfo* GetBaseType(const ConstString& name) {
|
||||
asITypeInfo* t = nullptr;
|
||||
if (!_baseTypes.TryGet(name, t)){
|
||||
if (!_baseTypes.TryGet(name, t)) {
|
||||
t = this->_engine->GetTypeInfoByDecl(name.c_str());
|
||||
_baseTypes.Insert(name, t);
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ private:
|
|||
|
||||
asIScriptObject* _obj = nullptr;
|
||||
CScriptArray* GetEffectParameters(const List<CreatureLib::Library::EffectParameter*>& ls);
|
||||
|
||||
public:
|
||||
AngelScriptScript(AngelScriptResolver* resolver, AngelScriptTypeInfo* type, asIScriptObject* obj,
|
||||
ContextPool* ctxPool)
|
||||
|
|
|
@ -82,8 +82,8 @@ public:
|
|||
SCRIPT_HOOK_FUNCTION(OnInitialize, "void OnInitialize(const array<EffectParameter@> &in parameters)");
|
||||
SCRIPT_HOOK_FUNCTION(Stack, "void Stack()");
|
||||
SCRIPT_HOOK_FUNCTION(OnRemove, "void OnRemove()");
|
||||
SCRIPT_HOOK_FUNCTION(OnBeforeTurn, "void OnBeforeTurn(BaseTurnChoice@ choice)");
|
||||
SCRIPT_HOOK_FUNCTION(ChangeAttack, "void ChangeAttack(MoveTurnChoice@ choice, constString& changedMove)");
|
||||
SCRIPT_HOOK_FUNCTION(OnBeforeTurn, "void OnBeforeTurn(BaseTurnChoice@ choice)");
|
||||
SCRIPT_HOOK_FUNCTION(ChangeAttack, "void ChangeAttack(MoveTurnChoice@ choice, constString& changedMove)");
|
||||
|
||||
SCRIPT_HOOK_FUNCTION(PreventAttack, "void PreventAttack(ExecutingMove@ attack, bool& result)");
|
||||
SCRIPT_HOOK_FUNCTION(FailAttack, "void FailAttack(ExecutingMove@ attack, bool& result)");
|
||||
|
|
|
@ -13,7 +13,7 @@ private:
|
|||
#define MEM_STEPS 256
|
||||
|
||||
public:
|
||||
MemoryByteCodeStream() : _out((uint8_t*)malloc(MEM_STEPS * sizeof(uint8_t) )), _capacity(MEM_STEPS){};
|
||||
MemoryByteCodeStream() : _out((uint8_t*)malloc(MEM_STEPS * sizeof(uint8_t))), _capacity(MEM_STEPS){};
|
||||
MemoryByteCodeStream(uint8_t* in, size_t size) : _out(in), _size(size) {}
|
||||
|
||||
uint8_t* GetOut() const { return _out; }
|
||||
|
|
|
@ -11,8 +11,8 @@ class ContextPool {
|
|||
public:
|
||||
ContextPool(asIScriptEngine* engine) : _engine(engine) {}
|
||||
|
||||
~ContextPool(){
|
||||
for (auto ctx: _pool){
|
||||
~ContextPool() {
|
||||
for (auto ctx : _pool) {
|
||||
ctx->Release();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ class RegisterBattleClass {
|
|||
static void RegisterChoiceQueue(asIScriptEngine* engine);
|
||||
static void RegisterBattle(asIScriptEngine* engine);
|
||||
static void RegisterBattleRandom(asIScriptEngine* engine);
|
||||
|
||||
public:
|
||||
static void Register(asIScriptEngine* engine);
|
||||
};
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
class RegisterBattleLibrary {
|
||||
static void RegisterDamageLibrary(asIScriptEngine* engine);
|
||||
static void RegisterLibrary(asIScriptEngine* engine);
|
||||
|
||||
public:
|
||||
static void Register(asIScriptEngine* engine);
|
||||
};
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "RegisterExecutingAttack.hpp"
|
||||
#include <CreatureLib/Battling/Models/ExecutingAttack.hpp>
|
||||
#include <Arbutils/Assert.hpp>
|
||||
#include <CreatureLib/Battling/Models/ExecutingAttack.hpp>
|
||||
|
||||
void RegisterExecutingAttack::Register(asIScriptEngine* engine) {
|
||||
RegisterHitData(engine);
|
||||
|
@ -34,20 +34,16 @@ void RegisterExecutingAttack::RegisterExecutingAttackType(asIScriptEngine* engin
|
|||
[[maybe_unused]] int r = engine->RegisterObjectType("ExecutingMove", 0, asOBJ_REF | asOBJ_NOCOUNT);
|
||||
Assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod("ExecutingMove", "HitData@ GetHitData(Pokemon@ target, uint8 hit) const",
|
||||
asMETHOD(CreatureLib::Battling::ExecutingAttack, GetHitData),
|
||||
asCALL_THISCALL);
|
||||
asMETHOD(CreatureLib::Battling::ExecutingAttack, GetHitData), asCALL_THISCALL);
|
||||
Assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod("ExecutingMove", "bool IsPokemonTarget(Pokemon@ pkmn) const",
|
||||
asMETHOD(CreatureLib::Battling::ExecutingAttack, IsCreatureTarget),
|
||||
asCALL_THISCALL);
|
||||
Assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod("ExecutingMove", "Pokemon@ get_User() const property",
|
||||
asMETHOD(CreatureLib::Battling::ExecutingAttack, GetUser),
|
||||
asCALL_THISCALL);
|
||||
asMETHOD(CreatureLib::Battling::ExecutingAttack, GetUser), asCALL_THISCALL);
|
||||
Assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod("ExecutingMove", "LearnedMove@ get_Move() const property",
|
||||
asMETHOD(CreatureLib::Battling::ExecutingAttack, GetAttack),
|
||||
asCALL_THISCALL);
|
||||
asMETHOD(CreatureLib::Battling::ExecutingAttack, GetAttack), asCALL_THISCALL);
|
||||
Assert(r >= 0);
|
||||
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
class RegisterExecutingAttack {
|
||||
static void RegisterHitData(asIScriptEngine* engine);
|
||||
static void RegisterExecutingAttackType(asIScriptEngine* engine);
|
||||
|
||||
public:
|
||||
static void Register(asIScriptEngine* engine);
|
||||
};
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#include "RegisterPokemonClass.hpp"
|
||||
#include <CreatureLib/Battling/Models/LearnedAttack.hpp>
|
||||
#include <Arbutils/Assert.hpp>
|
||||
#include <CreatureLib/Battling/Models/LearnedAttack.hpp>
|
||||
#include "../../../../../extern/angelscript_addons/scriptarray/scriptarray.h"
|
||||
#include "../../../../Battling/Pokemon/Pokemon.hpp"
|
||||
#include "../../../../Battling/PkmnDamageSource.hpp"
|
||||
#include "../../../../Battling/Pokemon/Pokemon.hpp"
|
||||
|
||||
// Hack to handle AngelScript not recognizing different sized enums on fields, and returning invalid values due to it.
|
||||
#define ENUM__SIZE_WRAPPER(name, type, func) \
|
||||
|
@ -19,13 +19,11 @@ void RegisterPokemonClass::Register(asIScriptEngine* engine) {
|
|||
void RegisterPokemonClass::RegisterDamageSource(asIScriptEngine* engine) {
|
||||
[[maybe_unused]] int r = engine->RegisterEnum("DamageSource");
|
||||
Assert(r >= 0);
|
||||
for (auto v: CreatureLib::Battling::DamageSourceHelper::GetValues()){
|
||||
r = engine->RegisterEnumValue("DamageSource", CreatureLib::Battling::DamageSourceHelper::ToString(v),
|
||||
(int)v);
|
||||
for (auto v : CreatureLib::Battling::DamageSourceHelper::GetValues()) {
|
||||
r = engine->RegisterEnumValue("DamageSource", CreatureLib::Battling::DamageSourceHelper::ToString(v), (int)v);
|
||||
}
|
||||
for (auto v: PkmnDamageSourceHelper::GetValues()){
|
||||
r = engine->RegisterEnumValue("DamageSource", PkmnDamageSourceHelper::ToString(v),
|
||||
(int)v);
|
||||
for (auto v : PkmnDamageSourceHelper::GetValues()) {
|
||||
r = engine->RegisterEnumValue("DamageSource", PkmnDamageSourceHelper::ToString(v), (int)v);
|
||||
}
|
||||
|
||||
Assert(r >= 0);
|
||||
|
@ -94,7 +92,6 @@ static bool HasHeldItem(const PkmnLib::Battling::Pokemon* obj, const ConstString
|
|||
return obj->HasHeldItem(str.GetHash());
|
||||
}
|
||||
|
||||
|
||||
void RegisterPokemonClass::RegisterPokemonType(asIScriptEngine* engine) {
|
||||
[[maybe_unused]] int r = engine->RegisterObjectType("Pokemon", 0, asOBJ_REF | asOBJ_NOCOUNT);
|
||||
Assert(r >= 0);
|
||||
|
|
|
@ -7,6 +7,7 @@ class RegisterPokemonClass {
|
|||
static void RegisterMoveLearnMethod(asIScriptEngine* engine);
|
||||
static void RegisterLearnedAttack(asIScriptEngine* engine);
|
||||
static void RegisterPokemonType(asIScriptEngine* engine);
|
||||
|
||||
public:
|
||||
static void Register(asIScriptEngine* engine);
|
||||
};
|
||||
|
|
|
@ -73,7 +73,8 @@ void RegisterTurnChoices::RegisterSwitchTurnChoice(asIScriptEngine* engine) {
|
|||
asMETHOD(CreatureLib::Battling::SwitchTurnChoice, GetUser), asCALL_THISCALL);
|
||||
Assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod("SwitchTurnChoice", "Pokemon@ get_NewPokemon() const property",
|
||||
asMETHOD(CreatureLib::Battling::SwitchTurnChoice, GetNewCreature), asCALL_THISCALL);
|
||||
asMETHOD(CreatureLib::Battling::SwitchTurnChoice, GetNewCreature),
|
||||
asCALL_THISCALL);
|
||||
Assert(r >= 0);
|
||||
|
||||
r = engine->RegisterObjectMethod(
|
||||
|
|
|
@ -7,6 +7,7 @@ class RegisterTurnChoices {
|
|||
static void RegisterBaseTurnChoice(asIScriptEngine* engine);
|
||||
static void RegisterMoveTurnChoice(asIScriptEngine* engine);
|
||||
static void RegisterSwitchTurnChoice(asIScriptEngine* engine);
|
||||
|
||||
public:
|
||||
static void Register(asIScriptEngine* engine);
|
||||
};
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
#include "ConstString.hpp"
|
||||
using ConstString = Arbutils::CaseInsensitiveConstString;
|
||||
|
||||
static void ConstructConstString(void* self) { new (self)ConstString(); }
|
||||
static void CopyConstructConstString(const ConstString& other, void* self) { new (self)ConstString(other); }
|
||||
static void DestructConstString(void* self) {
|
||||
((ConstString*)self)->~ConstString();
|
||||
}
|
||||
static void ConstructConstString(void* self) { new (self) ConstString(); }
|
||||
static void CopyConstructConstString(const ConstString& other, void* self) { new (self) ConstString(other); }
|
||||
static void DestructConstString(void* self) { ((ConstString*)self)->~ConstString(); }
|
||||
static bool ConstStringEquality(const ConstString& a, const ConstString& b) { return a == b; }
|
||||
static bool ConstStringStdStringEquality(const ConstString& a, const std::string& b) { return a == b; }
|
||||
static ConstString ImplStdStringConstStringConv(const std::string& s) { return ConstString(s); }
|
||||
|
|
|
@ -34,8 +34,8 @@ void RegisterGrowthRateTypes::RegisterGrowthRateLibrary(asIScriptEngine* engine)
|
|||
"uint8 CalculateLevel(const constString &in growthRate, uint experience) const",
|
||||
asFUNCTION(CalculateLevel), asCALL_CDECL_OBJLAST);
|
||||
assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod("GrowthRateLibrary",
|
||||
"uint CalculateExperience(const constString &in growthRate, uint8 experience) const",
|
||||
asFUNCTION(CalculateExperience), asCALL_CDECL_OBJLAST);
|
||||
r = engine->RegisterObjectMethod(
|
||||
"GrowthRateLibrary", "uint CalculateExperience(const constString &in growthRate, uint8 experience) const",
|
||||
asFUNCTION(CalculateExperience), asCALL_CDECL_OBJLAST);
|
||||
assert(r >= 0);
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
class RegisterGrowthRateTypes {
|
||||
static void RegisterGrowthRateType(asIScriptEngine* engine);
|
||||
static void RegisterGrowthRateLibrary(asIScriptEngine* engine);
|
||||
|
||||
public:
|
||||
static void Register(asIScriptEngine* engine);
|
||||
};
|
||||
|
|
|
@ -23,7 +23,8 @@ void RegisterItemTypes::RegisterItemCategoryEnum(asIScriptEngine* engine) {
|
|||
assert(r >= 0);
|
||||
r = engine->RegisterEnumValue("ItemCategory", "TM", (int)CreatureLib::Library::ItemCategory::MoveLearner);
|
||||
assert(r >= 0);
|
||||
r = engine->RegisterEnumValue("ItemCategory", "VariantChanger", (int)CreatureLib::Library::ItemCategory::VariantChanger);
|
||||
r = engine->RegisterEnumValue("ItemCategory", "VariantChanger",
|
||||
(int)CreatureLib::Library::ItemCategory::VariantChanger);
|
||||
assert(r >= 0);
|
||||
r = engine->RegisterEnumValue("ItemCategory", "KeyItem", (int)CreatureLib::Library::ItemCategory::KeyItem);
|
||||
assert(r >= 0);
|
||||
|
@ -36,13 +37,17 @@ void RegisterItemTypes::RegisterBattleItemCategoryEnum(asIScriptEngine* engine)
|
|||
assert(r >= 0);
|
||||
r = engine->RegisterEnumValue("BattleItemCategory", "None", (int)CreatureLib::Library::BattleItemCategory::None);
|
||||
assert(r >= 0);
|
||||
r = engine->RegisterEnumValue("BattleItemCategory", "Healing", (int)CreatureLib::Library::BattleItemCategory::Healing);
|
||||
r = engine->RegisterEnumValue("BattleItemCategory", "Healing",
|
||||
(int)CreatureLib::Library::BattleItemCategory::Healing);
|
||||
assert(r >= 0);
|
||||
r = engine->RegisterEnumValue("BattleItemCategory", "StatusHealing", (int)CreatureLib::Library::BattleItemCategory::StatusHealing);
|
||||
r = engine->RegisterEnumValue("BattleItemCategory", "StatusHealing",
|
||||
(int)CreatureLib::Library::BattleItemCategory::StatusHealing);
|
||||
assert(r >= 0);
|
||||
r = engine->RegisterEnumValue("BattleItemCategory", "CaptureDevice", (int)CreatureLib::Library::BattleItemCategory::CaptureDevice);
|
||||
r = engine->RegisterEnumValue("BattleItemCategory", "CaptureDevice",
|
||||
(int)CreatureLib::Library::BattleItemCategory::CaptureDevice);
|
||||
assert(r >= 0);
|
||||
r = engine->RegisterEnumValue("BattleItemCategory", "Misc", (int)CreatureLib::Library::BattleItemCategory::MiscBattleItem);
|
||||
r = engine->RegisterEnumValue("BattleItemCategory", "Misc",
|
||||
(int)CreatureLib::Library::BattleItemCategory::MiscBattleItem);
|
||||
assert(r >= 0);
|
||||
}
|
||||
|
||||
|
@ -57,7 +62,6 @@ static bool HasFlag(const PkmnLib::Library::Item* obj, const Arbutils::CaseInsen
|
|||
return obj->HasFlag(str);
|
||||
}
|
||||
|
||||
|
||||
void RegisterItemTypes::RegisterItemType(asIScriptEngine* engine) {
|
||||
[[maybe_unused]] int r = engine->RegisterObjectType("Item", 0, asOBJ_REF | asOBJ_NOCOUNT);
|
||||
assert(r >= 0);
|
||||
|
@ -73,11 +77,9 @@ void RegisterItemTypes::RegisterItemType(asIScriptEngine* engine) {
|
|||
r = engine->RegisterObjectMethod("Item", "int get_Price() const property",
|
||||
asMETHOD(PkmnLib::Library::Item, GetPrice), asCALL_THISCALL);
|
||||
assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod("Item", "bool HasFlag(const constString &in flag) const",
|
||||
asFUNCTION(HasFlag), asCALL_CDECL_OBJLAST);
|
||||
r = engine->RegisterObjectMethod("Item", "bool HasFlag(const constString &in flag) const", asFUNCTION(HasFlag),
|
||||
asCALL_CDECL_OBJLAST);
|
||||
assert(r >= 0);
|
||||
|
||||
|
||||
}
|
||||
void RegisterItemTypes::RegisterItemLibrary(asIScriptEngine* engine) {
|
||||
[[maybe_unused]] int r = engine->RegisterObjectType("ItemLibrary", 0, asOBJ_REF | asOBJ_NOCOUNT);
|
||||
|
|
|
@ -7,6 +7,7 @@ class RegisterItemTypes {
|
|||
static void RegisterBattleItemCategoryEnum(asIScriptEngine* engine);
|
||||
static void RegisterItemType(asIScriptEngine* engine);
|
||||
static void RegisterItemLibrary(asIScriptEngine* engine);
|
||||
|
||||
public:
|
||||
static void Register(asIScriptEngine* engine);
|
||||
};
|
||||
|
|
|
@ -77,8 +77,8 @@ void RegisterMoveTypes::RegisterMoveType(asIScriptEngine* engine) {
|
|||
r = engine->RegisterObjectMethod("MoveData", "int8 get_Priority() const property",
|
||||
asMETHOD(PkmnLib::Library::MoveData, GetPriority), asCALL_THISCALL);
|
||||
assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod("MoveData", "bool HasFlag(const constString &in flag) const",
|
||||
asFUNCTION(HasFlag), asCALL_CDECL_OBJLAST);
|
||||
r = engine->RegisterObjectMethod("MoveData", "bool HasFlag(const constString &in flag) const", asFUNCTION(HasFlag),
|
||||
asCALL_CDECL_OBJLAST);
|
||||
assert(r >= 0);
|
||||
}
|
||||
void RegisterMoveTypes::RegisterMoveLibrary(asIScriptEngine* engine) {
|
||||
|
|
|
@ -7,6 +7,7 @@ class RegisterMoveTypes {
|
|||
static void RegisterMoveTarget(asIScriptEngine* engine);
|
||||
static void RegisterMoveType(asIScriptEngine* engine);
|
||||
static void RegisterMoveLibrary(asIScriptEngine* engine);
|
||||
|
||||
public:
|
||||
static void Register(asIScriptEngine* engine);
|
||||
};
|
||||
|
|
|
@ -41,6 +41,4 @@ void RegisterStaticLibraryTypes::RegisterLibraryType(asIScriptEngine* engine) {
|
|||
r = engine->RegisterObjectMethod("StaticLibrary", "const TypeLibrary@ get_TypeLibrary() const property",
|
||||
asMETHOD(PkmnLib::Library::PokemonLibrary, GetTypeLibrary), asCALL_THISCALL);
|
||||
assert(r >= 0);
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
class RegisterStaticLibraryTypes {
|
||||
static void RegisterLibrarySettingsType(asIScriptEngine* engine);
|
||||
static void RegisterLibraryType(asIScriptEngine* engine);
|
||||
|
||||
public:
|
||||
static void Register(asIScriptEngine* engine);
|
||||
};
|
||||
|
|
|
@ -2,9 +2,7 @@
|
|||
#include <CreatureLib/Library/TypeLibrary.hpp>
|
||||
#include <cassert>
|
||||
|
||||
void RegisterTypeLibrary::Register(asIScriptEngine* engine) {
|
||||
RegisterTypeLibraryType(engine);
|
||||
}
|
||||
void RegisterTypeLibrary::Register(asIScriptEngine* engine) { RegisterTypeLibraryType(engine); }
|
||||
|
||||
static bool GetTypeId(const CreatureLib::Library::TypeLibrary* obj, const Arbutils::CaseInsensitiveConstString& str) {
|
||||
return obj->GetTypeId(str);
|
||||
|
@ -16,8 +14,9 @@ void RegisterTypeLibrary::RegisterTypeLibraryType(asIScriptEngine* engine) {
|
|||
r = engine->RegisterObjectMethod("TypeLibrary", "uint8 GetTypeId(const constString &in name) const",
|
||||
asFUNCTION(GetTypeId), asCALL_CDECL_OBJLAST);
|
||||
assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod("TypeLibrary", "float GetSingleEffectiveness(uint8 attacking, uint8 defensive) const",
|
||||
asMETHOD(CreatureLib::Library::TypeLibrary, GetSingleEffectiveness), asCALL_THISCALL);
|
||||
r = engine->RegisterObjectMethod(
|
||||
"TypeLibrary", "float GetSingleEffectiveness(uint8 attacking, uint8 defensive) const",
|
||||
asMETHOD(CreatureLib::Library::TypeLibrary, GetSingleEffectiveness), asCALL_THISCALL);
|
||||
assert(r >= 0);
|
||||
//TODO: Register get full effectiveness method.
|
||||
// TODO: Register get full effectiveness method.
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
class RegisterTypeLibrary {
|
||||
static void RegisterTypeLibraryType(asIScriptEngine* engine);
|
||||
|
||||
public:
|
||||
static void Register(asIScriptEngine* engine);
|
||||
};
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
#ifndef PKMNLIB_REFCAST_HPP
|
||||
#define PKMNLIB_REFCAST_HPP
|
||||
template<class A, class B>
|
||||
B* refCast(A* a)
|
||||
{
|
||||
if( !a ) return 0;
|
||||
template <class A, class B> B* refCast(A* a) {
|
||||
if (!a)
|
||||
return 0;
|
||||
B* b = dynamic_cast<B*>(a);
|
||||
return b;
|
||||
}
|
||||
|
|
|
@ -11,30 +11,29 @@ TEST_CASE("Able to build and destroy empty library", "library") {
|
|||
TEST_CASE("Able to build, destroy and insert library", "library") {
|
||||
auto lib = new PkmnLib::Library::SpeciesLibrary();
|
||||
lib->Insert("foo"_cnc,
|
||||
new PkmnLib::Library::PokemonSpecies(
|
||||
1, "foo"_cnc,
|
||||
new PkmnLib::Library::PokemonForme(
|
||||
"default"_cnc, 1.0f, 1.0f, 100, {0},
|
||||
CreatureLib::Library::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100), {"testAbility"_cnc},
|
||||
{"testHiddenAbility"_cnc}, new CreatureLib::Library::LearnableAttacks(100)),
|
||||
0.5f, "testGrowthRate"_cnc, 100, 100));
|
||||
new PkmnLib::Library::PokemonSpecies(
|
||||
1, "foo"_cnc,
|
||||
new PkmnLib::Library::PokemonForme(
|
||||
"default"_cnc, 1.0f, 1.0f, 100, {0},
|
||||
CreatureLib::Library::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100), {"testAbility"_cnc},
|
||||
{"testHiddenAbility"_cnc}, new CreatureLib::Library::LearnableAttacks(100)),
|
||||
0.5f, "testGrowthRate"_cnc, 100, 100));
|
||||
delete lib;
|
||||
}
|
||||
|
||||
TEST_CASE("Able to insert and retrieve from library", "library") {
|
||||
auto lib = new PkmnLib::Library::SpeciesLibrary();
|
||||
lib->Insert("foo"_cnc,
|
||||
new PkmnLib::Library::PokemonSpecies(
|
||||
1, "foo"_cnc,
|
||||
new PkmnLib::Library::PokemonForme(
|
||||
"default"_cnc, 1.0f, 1.0f, 100, {0},
|
||||
CreatureLib::Library::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100), {"testAbility"_cnc},
|
||||
{"testHiddenAbility"_cnc}, new CreatureLib::Library::LearnableAttacks(100)),
|
||||
0.5f, "testGrowthRate"_cnc, 100, 100));
|
||||
new PkmnLib::Library::PokemonSpecies(
|
||||
1, "foo"_cnc,
|
||||
new PkmnLib::Library::PokemonForme(
|
||||
"default"_cnc, 1.0f, 1.0f, 100, {0},
|
||||
CreatureLib::Library::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100), {"testAbility"_cnc},
|
||||
{"testHiddenAbility"_cnc}, new CreatureLib::Library::LearnableAttacks(100)),
|
||||
0.5f, "testGrowthRate"_cnc, 100, 100));
|
||||
auto val = lib->Get("foo"_cnc);
|
||||
REQUIRE(val->GetName() == "foo");
|
||||
delete lib;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
|
@ -24,7 +24,7 @@ TEST_CASE("Get Attack name from Pokemon") {
|
|||
.LearnMove(Arbutils::CaseInsensitiveConstString("testMove"),
|
||||
CreatureLib::Battling::AttackLearnMethod::Level)
|
||||
.LearnMove(Arbutils::CaseInsensitiveConstString("testMove2"),
|
||||
CreatureLib::Battling::AttackLearnMethod::Level)
|
||||
CreatureLib::Battling::AttackLearnMethod::Level)
|
||||
.Build();
|
||||
auto move = mon->GetMoves()[0];
|
||||
REQUIRE(move->GetMoveData()->GetName() == "testMove"_cnc);
|
||||
|
|
|
@ -134,9 +134,9 @@ TEST_CASE("Invoke OnInitialize script function") {
|
|||
ctx = ctxPool->RequestContext();
|
||||
script->PrepareMethod("GetStringValue"_cnc, ctx);
|
||||
REQUIRE(ctx->Execute() == asEXECUTION_FINISHED);
|
||||
// Arbutils::CaseInsensitiveConstString s;
|
||||
// s = *(Arbutils::CaseInsensitiveConstString*)ctx->GetReturnAddress();
|
||||
// REQUIRE(s == "foobar"_cnc);
|
||||
// Arbutils::CaseInsensitiveConstString s;
|
||||
// s = *(Arbutils::CaseInsensitiveConstString*)ctx->GetReturnAddress();
|
||||
// REQUIRE(s == "foobar"_cnc);
|
||||
ctxPool->ReturnContextToPool(ctx);
|
||||
|
||||
for (auto p : parameters) {
|
||||
|
|
|
@ -47,7 +47,7 @@ static AngelScriptResolver* GetScriptResolver(PkmnLib::Battling::BattleLibrary*
|
|||
if (_resolverCache == nullptr) {
|
||||
_resolverCache = dynamic_cast<AngelScriptResolver*>(PkmnLib::Battling::BattleLibrary::CreateScriptResolver());
|
||||
_resolverCache->Initialize(mainLib);
|
||||
_resolverCache->CreateScript("testScript1" , _scripts["testScript1"]);
|
||||
_resolverCache->CreateScript("testScript1", _scripts["testScript1"]);
|
||||
_resolverCache->FinalizeModule();
|
||||
}
|
||||
return _resolverCache;
|
||||
|
@ -278,9 +278,9 @@ TEST_CASE("Validate Pokemon Damage in Script") {
|
|||
auto mainLib = TestLibrary::GetLibrary();
|
||||
|
||||
auto mon = PkmnLib::Battling::CreatePokemon(mainLib, "testSpecies3"_cnc, 30)
|
||||
.WithForme("default"_cnc)
|
||||
.WithGender(CreatureLib::Library::Gender::Male)
|
||||
.Build();
|
||||
.WithForme("default"_cnc)
|
||||
.WithGender(CreatureLib::Library::Gender::Male)
|
||||
.Build();
|
||||
auto data = GetScript(mainLib, "testDamage"_cnc);
|
||||
|
||||
data.Context->SetArgObject(0, const_cast<PkmnLib::Battling::Pokemon*>(mon));
|
||||
|
@ -297,9 +297,9 @@ TEST_CASE("Validate Pokemon Heal in Script") {
|
|||
auto mainLib = TestLibrary::GetLibrary();
|
||||
|
||||
auto mon = PkmnLib::Battling::CreatePokemon(mainLib, "testSpecies3"_cnc, 30)
|
||||
.WithForme("default"_cnc)
|
||||
.WithGender(CreatureLib::Library::Gender::Male)
|
||||
.Build();
|
||||
.WithForme("default"_cnc)
|
||||
.WithGender(CreatureLib::Library::Gender::Male)
|
||||
.Build();
|
||||
mon->Damage(50, CreatureLib::Battling::DamageSource::AttackDamage);
|
||||
auto data = GetScript(mainLib, "testHeal"_cnc);
|
||||
|
||||
|
@ -316,10 +316,10 @@ TEST_CASE("Validate Pokemon GetMoves in Script") {
|
|||
auto mainLib = TestLibrary::GetLibrary();
|
||||
|
||||
auto mon = PkmnLib::Battling::CreatePokemon(mainLib, "testSpecies3"_cnc, 30)
|
||||
.WithForme("default"_cnc)
|
||||
.LearnMove("testMove"_cnc, CreatureLib::Battling::AttackLearnMethod::Level)
|
||||
.LearnMove("testMove2"_cnc, CreatureLib::Battling::AttackLearnMethod::Unknown)
|
||||
.Build();
|
||||
.WithForme("default"_cnc)
|
||||
.LearnMove("testMove"_cnc, CreatureLib::Battling::AttackLearnMethod::Level)
|
||||
.LearnMove("testMove2"_cnc, CreatureLib::Battling::AttackLearnMethod::Unknown)
|
||||
.Build();
|
||||
|
||||
for (size_t i = 0; i < mon->GetMoves().Count(); i++) {
|
||||
auto data = GetScript(mainLib, "testMove"_cnc);
|
||||
|
@ -339,9 +339,9 @@ TEST_CASE("Validate Pokemon HasHeldItem in Script") {
|
|||
auto mainLib = TestLibrary::GetLibrary();
|
||||
|
||||
auto mon = PkmnLib::Battling::CreatePokemon(mainLib, "testSpecies3"_cnc, 30)
|
||||
.WithForme("default"_cnc)
|
||||
.WithHeldItem("testItem"_cnc)
|
||||
.Build();
|
||||
.WithForme("default"_cnc)
|
||||
.WithHeldItem("testItem"_cnc)
|
||||
.Build();
|
||||
auto data = GetScript(mainLib, "testHasHeldItem"_cnc);
|
||||
|
||||
data.Context->SetArgObject(0, const_cast<PkmnLib::Battling::Pokemon*>(mon));
|
||||
|
@ -351,9 +351,7 @@ TEST_CASE("Validate Pokemon HasHeldItem in Script") {
|
|||
REQUIRE(data.Context->Execute() == asEXECUTION_FINISHED);
|
||||
REQUIRE((bool)data.Context->GetReturnDWord());
|
||||
|
||||
|
||||
delete mon;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
|
@ -32,11 +32,11 @@ struct ScriptData {
|
|||
};
|
||||
|
||||
static AngelScriptResolver* _resolverCache = nullptr;
|
||||
static AngelScriptResolver* GetScriptResolver(PkmnLib::Battling::BattleLibrary* mainLib){
|
||||
if (_resolverCache == nullptr){
|
||||
static AngelScriptResolver* GetScriptResolver(PkmnLib::Battling::BattleLibrary* mainLib) {
|
||||
if (_resolverCache == nullptr) {
|
||||
_resolverCache = dynamic_cast<AngelScriptResolver*>(PkmnLib::Battling::BattleLibrary::CreateScriptResolver());
|
||||
_resolverCache->Initialize(mainLib);
|
||||
_resolverCache->CreateScript("testScript1" , _scripts["testScript1"]);
|
||||
_resolverCache->CreateScript("testScript1", _scripts["testScript1"]);
|
||||
_resolverCache->FinalizeModule();
|
||||
}
|
||||
return _resolverCache;
|
||||
|
|
|
@ -28,11 +28,11 @@ struct ScriptData {
|
|||
};
|
||||
|
||||
static AngelScriptResolver* _resolverCache = nullptr;
|
||||
static AngelScriptResolver* GetScriptResolver(PkmnLib::Battling::BattleLibrary* mainLib){
|
||||
if (_resolverCache == nullptr){
|
||||
static AngelScriptResolver* GetScriptResolver(PkmnLib::Battling::BattleLibrary* mainLib) {
|
||||
if (_resolverCache == nullptr) {
|
||||
_resolverCache = dynamic_cast<AngelScriptResolver*>(PkmnLib::Battling::BattleLibrary::CreateScriptResolver());
|
||||
_resolverCache->Initialize(mainLib);
|
||||
_resolverCache->CreateScript("testScript1" , _scripts["testScript1"]);
|
||||
_resolverCache->CreateScript("testScript1", _scripts["testScript1"]);
|
||||
_resolverCache->FinalizeModule();
|
||||
}
|
||||
return _resolverCache;
|
||||
|
@ -72,7 +72,7 @@ TEST_CASE("Validate Item Category in Script") {
|
|||
|
||||
auto item = mainLib->GetItemLibrary()->Get("testItem"_cnc);
|
||||
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()));
|
||||
|
||||
REQUIRE(data.Context->Execute() == asEXECUTION_FINISHED);
|
||||
REQUIRE((bool)data.Context->GetReturnWord());
|
||||
|
@ -84,7 +84,7 @@ TEST_CASE("Validate Item Battle Category in Script") {
|
|||
|
||||
auto item = mainLib->GetItemLibrary()->Get("testItem"_cnc);
|
||||
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()));
|
||||
|
||||
REQUIRE(data.Context->Execute() == asEXECUTION_FINISHED);
|
||||
REQUIRE((bool)data.Context->GetReturnWord());
|
||||
|
@ -96,13 +96,10 @@ TEST_CASE("Validate Item Price in Script") {
|
|||
|
||||
auto item = mainLib->GetItemLibrary()->Get("testItem"_cnc);
|
||||
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()));
|
||||
|
||||
REQUIRE(data.Context->Execute() == asEXECUTION_FINISHED);
|
||||
REQUIRE((bool)data.Context->GetReturnWord());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
|
@ -32,11 +32,11 @@ struct ScriptData {
|
|||
};
|
||||
|
||||
static AngelScriptResolver* _resolverCache = nullptr;
|
||||
static AngelScriptResolver* GetScriptResolver(PkmnLib::Battling::BattleLibrary* mainLib){
|
||||
if (_resolverCache == nullptr){
|
||||
static AngelScriptResolver* GetScriptResolver(PkmnLib::Battling::BattleLibrary* mainLib) {
|
||||
if (_resolverCache == nullptr) {
|
||||
_resolverCache = dynamic_cast<AngelScriptResolver*>(PkmnLib::Battling::BattleLibrary::CreateScriptResolver());
|
||||
_resolverCache->Initialize(mainLib);
|
||||
_resolverCache->CreateScript("testScript1" , _scripts["testScript1"]);
|
||||
_resolverCache->CreateScript("testScript1", _scripts["testScript1"]);
|
||||
_resolverCache->FinalizeModule();
|
||||
}
|
||||
return _resolverCache;
|
||||
|
@ -157,5 +157,4 @@ TEST_CASE("Validate Move Priority in Script") {
|
|||
REQUIRE((bool)data.Context->GetReturnWord());
|
||||
}
|
||||
|
||||
|
||||
#endif
|
|
@ -30,11 +30,11 @@ struct ScriptData {
|
|||
};
|
||||
|
||||
static AngelScriptResolver* _resolverCache = nullptr;
|
||||
static AngelScriptResolver* GetScriptResolver(PkmnLib::Battling::BattleLibrary* mainLib){
|
||||
if (_resolverCache == nullptr){
|
||||
static AngelScriptResolver* GetScriptResolver(PkmnLib::Battling::BattleLibrary* mainLib) {
|
||||
if (_resolverCache == nullptr) {
|
||||
_resolverCache = dynamic_cast<AngelScriptResolver*>(PkmnLib::Battling::BattleLibrary::CreateScriptResolver());
|
||||
_resolverCache->Initialize(mainLib);
|
||||
_resolverCache->CreateScript("testScript1" , _scripts["testScript1"]);
|
||||
_resolverCache->CreateScript("testScript1", _scripts["testScript1"]);
|
||||
_resolverCache->FinalizeModule();
|
||||
}
|
||||
return _resolverCache;
|
||||
|
@ -60,8 +60,7 @@ TEST_CASE("Validate Species Name in Script") {
|
|||
auto data = GetScript(mainLib, "testName"_cnc);
|
||||
|
||||
auto species = mainLib->GetSpeciesLibrary()->Get("testSpecies2"_cnc);
|
||||
data.Context->SetArgObject(
|
||||
0, const_cast<PkmnLib::Library::PokemonSpecies*>(species));
|
||||
data.Context->SetArgObject(0, const_cast<PkmnLib::Library::PokemonSpecies*>(species));
|
||||
auto name = species->GetName();
|
||||
data.Context->SetArgAddress(1, &name);
|
||||
|
||||
|
@ -76,8 +75,7 @@ TEST_CASE("Validate Species Id in Script") {
|
|||
auto data = GetScript(mainLib, "testId"_cnc);
|
||||
|
||||
auto species = mainLib->GetSpeciesLibrary()->Get("testSpecies2"_cnc);
|
||||
data.Context->SetArgObject(
|
||||
0, const_cast<PkmnLib::Library::PokemonSpecies*>(species));
|
||||
data.Context->SetArgObject(0, const_cast<PkmnLib::Library::PokemonSpecies*>(species));
|
||||
data.Context->SetArgWord(1, species->GetId());
|
||||
|
||||
auto result = data.Context->Execute();
|
||||
|
@ -91,8 +89,7 @@ TEST_CASE("Validate Species Gender Rate in Script") {
|
|||
auto data = GetScript(mainLib, "testGenderRate"_cnc);
|
||||
|
||||
auto species = mainLib->GetSpeciesLibrary()->Get("testSpecies2"_cnc);
|
||||
data.Context->SetArgObject(
|
||||
0, const_cast<PkmnLib::Library::PokemonSpecies*>(species));
|
||||
data.Context->SetArgObject(0, const_cast<PkmnLib::Library::PokemonSpecies*>(species));
|
||||
data.Context->SetArgFloat(1, species->GetGenderRate());
|
||||
|
||||
auto result = data.Context->Execute();
|
||||
|
@ -106,8 +103,7 @@ TEST_CASE("Validate Species Capture Rate in Script") {
|
|||
auto data = GetScript(mainLib, "testCaptureRate"_cnc);
|
||||
|
||||
auto species = mainLib->GetSpeciesLibrary()->Get("testSpecies2"_cnc);
|
||||
data.Context->SetArgObject(
|
||||
0, const_cast<PkmnLib::Library::PokemonSpecies*>(species));
|
||||
data.Context->SetArgObject(0, const_cast<PkmnLib::Library::PokemonSpecies*>(species));
|
||||
data.Context->SetArgByte(1, species->GetCaptureRate());
|
||||
|
||||
auto result = data.Context->Execute();
|
||||
|
@ -121,12 +117,11 @@ TEST_CASE("Validate Species Get Forme in Script") {
|
|||
auto data = GetScript(mainLib, "testGetForme"_cnc);
|
||||
|
||||
auto species = mainLib->GetSpeciesLibrary()->Get("testSpecies2"_cnc);
|
||||
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->GetForme("default"_cnc)));
|
||||
|
||||
auto result = data.Context->Execute();
|
||||
if (result == asEXECUTION_EXCEPTION){
|
||||
if (result == asEXECUTION_EXCEPTION) {
|
||||
FAIL(data.Context->GetExceptionString());
|
||||
}
|
||||
REQUIRE(result == asEXECUTION_FINISHED);
|
||||
|
@ -148,6 +143,4 @@ TEST_CASE("Validate Species Get Default Forme in Script") {
|
|||
REQUIRE(v);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif
|
|
@ -31,11 +31,11 @@ struct ScriptData {
|
|||
};
|
||||
|
||||
static AngelScriptResolver* _resolverCache = nullptr;
|
||||
static AngelScriptResolver* GetScriptResolver(PkmnLib::Battling::BattleLibrary* mainLib){
|
||||
if (_resolverCache == nullptr){
|
||||
static AngelScriptResolver* GetScriptResolver(PkmnLib::Battling::BattleLibrary* mainLib) {
|
||||
if (_resolverCache == nullptr) {
|
||||
_resolverCache = dynamic_cast<AngelScriptResolver*>(PkmnLib::Battling::BattleLibrary::CreateScriptResolver());
|
||||
_resolverCache->Initialize(mainLib);
|
||||
_resolverCache->CreateScript("testScript1" , _scripts["testScript1"]);
|
||||
_resolverCache->CreateScript("testScript1", _scripts["testScript1"]);
|
||||
_resolverCache->FinalizeModule();
|
||||
}
|
||||
return _resolverCache;
|
||||
|
|
Loading…
Reference in New Issue