From c4b866cb38acab5287a386f37ae8ce772a3fca5e Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Tue, 28 Apr 2020 14:48:56 +0200 Subject: [PATCH] File formatting. --- CInterface/Core.hpp | 2 +- CInterface/Library/LibrarySettings.cpp | 3 +- CInterface/Library/Nature.cpp | 7 +++-- src/Battling/Library/StatCalculator.cpp | 15 +++++----- src/Battling/PkmnScript.hpp | 4 +-- src/Battling/PkmnScriptHook.hpp | 2 +- src/Library/Evolutions/EvolutionData.cpp | 3 +- src/Library/Evolutions/EvolutionMethod.hpp | 3 +- src/Library/Moves/MoveLibrary.hpp | 2 +- src/Library/Natures/NatureLibrary.hpp | 3 +- src/Library/PokemonLibrary.hpp | 10 ++----- .../AngelScript/AngelScriptResolver.hpp | 6 ++-- .../AngelScript/AngelScriptScript.hpp | 1 + .../AngelScript/AngelScriptTypeInfo.hpp | 4 +-- .../ByteCodeHandling/MemoryByteCodeStream.hpp | 2 +- .../AngelScript/ContextPool.hpp | 4 +-- .../Battling/RegisterBattleClass.hpp | 1 + .../Battling/RegisterBattleLibrary.hpp | 1 + .../Battling/RegisterExecutingAttack.cpp | 12 +++----- .../Battling/RegisterExecutingAttack.hpp | 1 + .../Battling/RegisterPokemonClass.cpp | 15 ++++------ .../Battling/RegisterPokemonClass.hpp | 1 + .../Battling/RegisterTurnChoices.cpp | 3 +- .../Battling/RegisterTurnChoices.hpp | 1 + .../AngelScript/TypeRegistry/ConstString.cpp | 8 ++--- .../Library/RegisterGrowthRateTypes.cpp | 6 ++-- .../Library/RegisterGrowthRateTypes.hpp | 1 + .../Library/RegisterItemTypes.cpp | 22 +++++++------- .../Library/RegisterItemTypes.hpp | 1 + .../Library/RegisterMoveTypes.cpp | 4 +-- .../Library/RegisterMoveTypes.hpp | 1 + .../Library/RegisterStaticLibraryTypes.cpp | 2 -- .../Library/RegisterStaticLibraryTypes.hpp | 1 + .../Library/RegisterTypeLibrary.cpp | 11 ++++--- .../Library/RegisterTypeLibrary.hpp | 1 + .../AngelScript/TypeRegistry/RefCast.hpp | 7 ++--- tests/LibraryTests/SpeciesLibraryTests.cpp | 29 +++++++++--------- tests/PokemonTests/BasicPokemonTests.cpp | 2 +- tests/ScriptTests/BaseScriptClassTests.cpp | 6 ++-- .../ScriptTypeTests/Battle/PokemonTests.cpp | 30 +++++++++---------- .../ScriptTypeTests/Library/FormesTests.cpp | 6 ++-- .../ScriptTypeTests/Library/ItemDataTests.cpp | 15 ++++------ .../ScriptTypeTests/Library/MoveTests.cpp | 7 ++--- .../ScriptTypeTests/Library/SpeciesTests.cpp | 25 ++++++---------- .../Library/StaticLibraryTests.cpp | 6 ++-- 45 files changed, 140 insertions(+), 157 deletions(-) diff --git a/CInterface/Core.hpp b/CInterface/Core.hpp index 2ff53d9..ee85466 100644 --- a/CInterface/Core.hpp +++ b/CInterface/Core.hpp @@ -23,7 +23,7 @@ public: return 0; \ } catch (const std::exception& e) { \ ExceptionHandler::SetLastException(e); \ - return PkmnLibException; \ + return PkmnLibException; \ } #endif // PKMNLIB_CORE_HPP diff --git a/CInterface/Library/LibrarySettings.cpp b/CInterface/Library/LibrarySettings.cpp index bf76761..3ffb1f7 100644 --- a/CInterface/Library/LibrarySettings.cpp +++ b/CInterface/Library/LibrarySettings.cpp @@ -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); } diff --git a/CInterface/Library/Nature.cpp b/CInterface/Library/Nature.cpp index f73d5bd..81687e2 100644 --- a/CInterface/Library/Nature.cpp +++ b/CInterface/Library/Nature.cpp @@ -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); } \ No newline at end of file diff --git a/src/Battling/Library/StatCalculator.cpp b/src/Battling/Library/StatCalculator.cpp index 27147a8..717f148 100644 --- a/src/Battling/Library/StatCalculator.cpp +++ b/src/Battling/Library/StatCalculator.cpp @@ -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(((2 * base + iv + static_cast(ev / 4)) * level) / 100) + 5; + uint32_t unmodified = static_cast(((2 * base + iv + static_cast(ev / 4)) * level) / 100) + 5; return static_cast(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 PkmnLib::Battling::StatCalculator::CalculateFlatStats(CreatureLib::Battling::Creature* creature) const { auto pkmn = dynamic_cast(creature); - return CreatureLib::Library::StatisticSet( - 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(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 PkmnLib::Battling::StatCalculator::CalculateBoostedStats(CreatureLib::Battling::Creature* creature) const { diff --git a/src/Battling/PkmnScript.hpp b/src/Battling/PkmnScript.hpp index b4bdc9c..a2785cd 100644 --- a/src/Battling/PkmnScript.hpp +++ b/src/Battling/PkmnScript.hpp @@ -3,8 +3,8 @@ #include #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){}; diff --git a/src/Battling/PkmnScriptHook.hpp b/src/Battling/PkmnScriptHook.hpp index 3e6831d..7efed7f 100644 --- a/src/Battling/PkmnScriptHook.hpp +++ b/src/Battling/PkmnScriptHook.hpp @@ -8,6 +8,6 @@ if (next == nullptr) \ continue; \ auto castNext = dynamic_cast(next); \ - castNext->hookName(__VA_ARGS__); \ + castNext->hookName(__VA_ARGS__); \ } \ } diff --git a/src/Library/Evolutions/EvolutionData.cpp b/src/Library/Evolutions/EvolutionData.cpp index 9c8e3ff..536c9a6 100644 --- a/src/Library/Evolutions/EvolutionData.cpp +++ b/src/Library/Evolutions/EvolutionData.cpp @@ -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); } diff --git a/src/Library/Evolutions/EvolutionMethod.hpp b/src/Library/Evolutions/EvolutionMethod.hpp index 2330f26..30abbe1 100644 --- a/src/Library/Evolutions/EvolutionMethod.hpp +++ b/src/Library/Evolutions/EvolutionMethod.hpp @@ -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 diff --git a/src/Library/Moves/MoveLibrary.hpp b/src/Library/Moves/MoveLibrary.hpp index ece12d3..63af8b2 100644 --- a/src/Library/Moves/MoveLibrary.hpp +++ b/src/Library/Moves/MoveLibrary.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(ptr); return true; } diff --git a/src/Library/Natures/NatureLibrary.hpp b/src/Library/Natures/NatureLibrary.hpp index 1a55cc9..83b23e5 100644 --- a/src/Library/Natures/NatureLibrary.hpp +++ b/src/Library/Natures/NatureLibrary.hpp @@ -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; diff --git a/src/Library/PokemonLibrary.hpp b/src/Library/PokemonLibrary.hpp index 5ef89c8..a62f58b 100644 --- a/src/Library/PokemonLibrary.hpp +++ b/src/Library/PokemonLibrary.hpp @@ -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(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; } }; } diff --git a/src/ScriptResolving/AngelScript/AngelScriptResolver.hpp b/src/ScriptResolving/AngelScript/AngelScriptResolver.hpp index bb5aae1..b02432e 100644 --- a/src/ScriptResolving/AngelScript/AngelScriptResolver.hpp +++ b/src/ScriptResolving/AngelScript/AngelScriptResolver.hpp @@ -26,7 +26,7 @@ private: void RegisterTypes(); void InitializeByteCode(asIBinaryStream* stream, - const Dictionary>& types); + const Dictionary>& 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); } diff --git a/src/ScriptResolving/AngelScript/AngelScriptScript.hpp b/src/ScriptResolving/AngelScript/AngelScriptScript.hpp index bb3d4e5..3ea4357 100644 --- a/src/ScriptResolving/AngelScript/AngelScriptScript.hpp +++ b/src/ScriptResolving/AngelScript/AngelScriptScript.hpp @@ -19,6 +19,7 @@ private: asIScriptObject* _obj = nullptr; CScriptArray* GetEffectParameters(const List& ls); + public: AngelScriptScript(AngelScriptResolver* resolver, AngelScriptTypeInfo* type, asIScriptObject* obj, ContextPool* ctxPool) diff --git a/src/ScriptResolving/AngelScript/AngelScriptTypeInfo.hpp b/src/ScriptResolving/AngelScript/AngelScriptTypeInfo.hpp index 37dcd38..09781a6 100644 --- a/src/ScriptResolving/AngelScript/AngelScriptTypeInfo.hpp +++ b/src/ScriptResolving/AngelScript/AngelScriptTypeInfo.hpp @@ -82,8 +82,8 @@ public: SCRIPT_HOOK_FUNCTION(OnInitialize, "void OnInitialize(const array &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)"); diff --git a/src/ScriptResolving/AngelScript/ByteCodeHandling/MemoryByteCodeStream.hpp b/src/ScriptResolving/AngelScript/ByteCodeHandling/MemoryByteCodeStream.hpp index e4b892c..30c08e4 100644 --- a/src/ScriptResolving/AngelScript/ByteCodeHandling/MemoryByteCodeStream.hpp +++ b/src/ScriptResolving/AngelScript/ByteCodeHandling/MemoryByteCodeStream.hpp @@ -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; } diff --git a/src/ScriptResolving/AngelScript/ContextPool.hpp b/src/ScriptResolving/AngelScript/ContextPool.hpp index 993c6d0..3653aee 100644 --- a/src/ScriptResolving/AngelScript/ContextPool.hpp +++ b/src/ScriptResolving/AngelScript/ContextPool.hpp @@ -11,8 +11,8 @@ class ContextPool { public: ContextPool(asIScriptEngine* engine) : _engine(engine) {} - ~ContextPool(){ - for (auto ctx: _pool){ + ~ContextPool() { + for (auto ctx : _pool) { ctx->Release(); } } diff --git a/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterBattleClass.hpp b/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterBattleClass.hpp index 54d5050..bfa991e 100644 --- a/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterBattleClass.hpp +++ b/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterBattleClass.hpp @@ -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); }; diff --git a/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterBattleLibrary.hpp b/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterBattleLibrary.hpp index a2baf0f..a8c0759 100644 --- a/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterBattleLibrary.hpp +++ b/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterBattleLibrary.hpp @@ -5,6 +5,7 @@ class RegisterBattleLibrary { static void RegisterDamageLibrary(asIScriptEngine* engine); static void RegisterLibrary(asIScriptEngine* engine); + public: static void Register(asIScriptEngine* engine); }; diff --git a/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterExecutingAttack.cpp b/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterExecutingAttack.cpp index 2df352f..b6aacde 100644 --- a/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterExecutingAttack.cpp +++ b/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterExecutingAttack.cpp @@ -1,6 +1,6 @@ #include "RegisterExecutingAttack.hpp" -#include #include +#include 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); - } diff --git a/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterExecutingAttack.hpp b/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterExecutingAttack.hpp index 90409f8..3099730 100644 --- a/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterExecutingAttack.hpp +++ b/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterExecutingAttack.hpp @@ -6,6 +6,7 @@ class RegisterExecutingAttack { static void RegisterHitData(asIScriptEngine* engine); static void RegisterExecutingAttackType(asIScriptEngine* engine); + public: static void Register(asIScriptEngine* engine); }; diff --git a/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterPokemonClass.cpp b/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterPokemonClass.cpp index ab0a35c..fbf44a0 100644 --- a/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterPokemonClass.cpp +++ b/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterPokemonClass.cpp @@ -1,9 +1,9 @@ #include "RegisterPokemonClass.hpp" -#include #include +#include #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); diff --git a/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterPokemonClass.hpp b/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterPokemonClass.hpp index 691659f..c6b1607 100644 --- a/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterPokemonClass.hpp +++ b/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterPokemonClass.hpp @@ -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); }; diff --git a/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterTurnChoices.cpp b/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterTurnChoices.cpp index f10e92e..d49a74d 100644 --- a/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterTurnChoices.cpp +++ b/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterTurnChoices.cpp @@ -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( diff --git a/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterTurnChoices.hpp b/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterTurnChoices.hpp index f4e7ebb..1fa69f0 100644 --- a/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterTurnChoices.hpp +++ b/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterTurnChoices.hpp @@ -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); }; diff --git a/src/ScriptResolving/AngelScript/TypeRegistry/ConstString.cpp b/src/ScriptResolving/AngelScript/TypeRegistry/ConstString.cpp index 7acefe4..d152308 100644 --- a/src/ScriptResolving/AngelScript/TypeRegistry/ConstString.cpp +++ b/src/ScriptResolving/AngelScript/TypeRegistry/ConstString.cpp @@ -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); } diff --git a/src/ScriptResolving/AngelScript/TypeRegistry/Library/RegisterGrowthRateTypes.cpp b/src/ScriptResolving/AngelScript/TypeRegistry/Library/RegisterGrowthRateTypes.cpp index f5c87bd..e497c07 100644 --- a/src/ScriptResolving/AngelScript/TypeRegistry/Library/RegisterGrowthRateTypes.cpp +++ b/src/ScriptResolving/AngelScript/TypeRegistry/Library/RegisterGrowthRateTypes.cpp @@ -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); } diff --git a/src/ScriptResolving/AngelScript/TypeRegistry/Library/RegisterGrowthRateTypes.hpp b/src/ScriptResolving/AngelScript/TypeRegistry/Library/RegisterGrowthRateTypes.hpp index 50509d0..097233f 100644 --- a/src/ScriptResolving/AngelScript/TypeRegistry/Library/RegisterGrowthRateTypes.hpp +++ b/src/ScriptResolving/AngelScript/TypeRegistry/Library/RegisterGrowthRateTypes.hpp @@ -5,6 +5,7 @@ class RegisterGrowthRateTypes { static void RegisterGrowthRateType(asIScriptEngine* engine); static void RegisterGrowthRateLibrary(asIScriptEngine* engine); + public: static void Register(asIScriptEngine* engine); }; diff --git a/src/ScriptResolving/AngelScript/TypeRegistry/Library/RegisterItemTypes.cpp b/src/ScriptResolving/AngelScript/TypeRegistry/Library/RegisterItemTypes.cpp index c40503a..6c9760b 100644 --- a/src/ScriptResolving/AngelScript/TypeRegistry/Library/RegisterItemTypes.cpp +++ b/src/ScriptResolving/AngelScript/TypeRegistry/Library/RegisterItemTypes.cpp @@ -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); diff --git a/src/ScriptResolving/AngelScript/TypeRegistry/Library/RegisterItemTypes.hpp b/src/ScriptResolving/AngelScript/TypeRegistry/Library/RegisterItemTypes.hpp index e3cb62d..d98aa6b 100644 --- a/src/ScriptResolving/AngelScript/TypeRegistry/Library/RegisterItemTypes.hpp +++ b/src/ScriptResolving/AngelScript/TypeRegistry/Library/RegisterItemTypes.hpp @@ -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); }; diff --git a/src/ScriptResolving/AngelScript/TypeRegistry/Library/RegisterMoveTypes.cpp b/src/ScriptResolving/AngelScript/TypeRegistry/Library/RegisterMoveTypes.cpp index c01d466..2cd966f 100644 --- a/src/ScriptResolving/AngelScript/TypeRegistry/Library/RegisterMoveTypes.cpp +++ b/src/ScriptResolving/AngelScript/TypeRegistry/Library/RegisterMoveTypes.cpp @@ -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) { diff --git a/src/ScriptResolving/AngelScript/TypeRegistry/Library/RegisterMoveTypes.hpp b/src/ScriptResolving/AngelScript/TypeRegistry/Library/RegisterMoveTypes.hpp index 75e0eaf..2e11fff 100644 --- a/src/ScriptResolving/AngelScript/TypeRegistry/Library/RegisterMoveTypes.hpp +++ b/src/ScriptResolving/AngelScript/TypeRegistry/Library/RegisterMoveTypes.hpp @@ -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); }; diff --git a/src/ScriptResolving/AngelScript/TypeRegistry/Library/RegisterStaticLibraryTypes.cpp b/src/ScriptResolving/AngelScript/TypeRegistry/Library/RegisterStaticLibraryTypes.cpp index 7935f64..efca0e8 100644 --- a/src/ScriptResolving/AngelScript/TypeRegistry/Library/RegisterStaticLibraryTypes.cpp +++ b/src/ScriptResolving/AngelScript/TypeRegistry/Library/RegisterStaticLibraryTypes.cpp @@ -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); - - } diff --git a/src/ScriptResolving/AngelScript/TypeRegistry/Library/RegisterStaticLibraryTypes.hpp b/src/ScriptResolving/AngelScript/TypeRegistry/Library/RegisterStaticLibraryTypes.hpp index 8354334..52431f2 100644 --- a/src/ScriptResolving/AngelScript/TypeRegistry/Library/RegisterStaticLibraryTypes.hpp +++ b/src/ScriptResolving/AngelScript/TypeRegistry/Library/RegisterStaticLibraryTypes.hpp @@ -5,6 +5,7 @@ class RegisterStaticLibraryTypes { static void RegisterLibrarySettingsType(asIScriptEngine* engine); static void RegisterLibraryType(asIScriptEngine* engine); + public: static void Register(asIScriptEngine* engine); }; diff --git a/src/ScriptResolving/AngelScript/TypeRegistry/Library/RegisterTypeLibrary.cpp b/src/ScriptResolving/AngelScript/TypeRegistry/Library/RegisterTypeLibrary.cpp index ba72dae..32d6a02 100644 --- a/src/ScriptResolving/AngelScript/TypeRegistry/Library/RegisterTypeLibrary.cpp +++ b/src/ScriptResolving/AngelScript/TypeRegistry/Library/RegisterTypeLibrary.cpp @@ -2,9 +2,7 @@ #include #include -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. } diff --git a/src/ScriptResolving/AngelScript/TypeRegistry/Library/RegisterTypeLibrary.hpp b/src/ScriptResolving/AngelScript/TypeRegistry/Library/RegisterTypeLibrary.hpp index e25ddba..7cd88bd 100644 --- a/src/ScriptResolving/AngelScript/TypeRegistry/Library/RegisterTypeLibrary.hpp +++ b/src/ScriptResolving/AngelScript/TypeRegistry/Library/RegisterTypeLibrary.hpp @@ -4,6 +4,7 @@ class RegisterTypeLibrary { static void RegisterTypeLibraryType(asIScriptEngine* engine); + public: static void Register(asIScriptEngine* engine); }; diff --git a/src/ScriptResolving/AngelScript/TypeRegistry/RefCast.hpp b/src/ScriptResolving/AngelScript/TypeRegistry/RefCast.hpp index b38b884..885bb69 100644 --- a/src/ScriptResolving/AngelScript/TypeRegistry/RefCast.hpp +++ b/src/ScriptResolving/AngelScript/TypeRegistry/RefCast.hpp @@ -1,9 +1,8 @@ #ifndef PKMNLIB_REFCAST_HPP #define PKMNLIB_REFCAST_HPP -template -B* refCast(A* a) -{ - if( !a ) return 0; +template B* refCast(A* a) { + if (!a) + return 0; B* b = dynamic_cast(a); return b; } diff --git a/tests/LibraryTests/SpeciesLibraryTests.cpp b/tests/LibraryTests/SpeciesLibraryTests.cpp index 40bb7b8..4048519 100644 --- a/tests/LibraryTests/SpeciesLibraryTests.cpp +++ b/tests/LibraryTests/SpeciesLibraryTests.cpp @@ -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(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(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(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(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 \ No newline at end of file diff --git a/tests/PokemonTests/BasicPokemonTests.cpp b/tests/PokemonTests/BasicPokemonTests.cpp index 48ae5a9..29aaf77 100644 --- a/tests/PokemonTests/BasicPokemonTests.cpp +++ b/tests/PokemonTests/BasicPokemonTests.cpp @@ -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); diff --git a/tests/ScriptTests/BaseScriptClassTests.cpp b/tests/ScriptTests/BaseScriptClassTests.cpp index 3e8a67b..c1cad68 100644 --- a/tests/ScriptTests/BaseScriptClassTests.cpp +++ b/tests/ScriptTests/BaseScriptClassTests.cpp @@ -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) { diff --git a/tests/ScriptTests/ScriptTypeTests/Battle/PokemonTests.cpp b/tests/ScriptTests/ScriptTypeTests/Battle/PokemonTests.cpp index 6aef354..0546677 100644 --- a/tests/ScriptTests/ScriptTypeTests/Battle/PokemonTests.cpp +++ b/tests/ScriptTests/ScriptTypeTests/Battle/PokemonTests.cpp @@ -47,7 +47,7 @@ static AngelScriptResolver* GetScriptResolver(PkmnLib::Battling::BattleLibrary* if (_resolverCache == nullptr) { _resolverCache = dynamic_cast(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(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(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 \ No newline at end of file diff --git a/tests/ScriptTests/ScriptTypeTests/Library/FormesTests.cpp b/tests/ScriptTests/ScriptTypeTests/Library/FormesTests.cpp index b23b00f..3ba9ded 100644 --- a/tests/ScriptTests/ScriptTypeTests/Library/FormesTests.cpp +++ b/tests/ScriptTests/ScriptTypeTests/Library/FormesTests.cpp @@ -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(PkmnLib::Battling::BattleLibrary::CreateScriptResolver()); _resolverCache->Initialize(mainLib); - _resolverCache->CreateScript("testScript1" , _scripts["testScript1"]); + _resolverCache->CreateScript("testScript1", _scripts["testScript1"]); _resolverCache->FinalizeModule(); } return _resolverCache; diff --git a/tests/ScriptTests/ScriptTypeTests/Library/ItemDataTests.cpp b/tests/ScriptTests/ScriptTypeTests/Library/ItemDataTests.cpp index 3fc6a39..a0f3887 100644 --- a/tests/ScriptTests/ScriptTypeTests/Library/ItemDataTests.cpp +++ b/tests/ScriptTests/ScriptTypeTests/Library/ItemDataTests.cpp @@ -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(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(item)); - data.Context->SetArgDWord(1, static_cast(item->GetCategory())); + data.Context->SetArgDWord(1, static_cast(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(item)); - data.Context->SetArgDWord(1, static_cast(item->GetBattleCategory())); + data.Context->SetArgDWord(1, static_cast(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(item)); - data.Context->SetArgDWord(1, static_cast(item->GetPrice())); + data.Context->SetArgDWord(1, static_cast(item->GetPrice())); REQUIRE(data.Context->Execute() == asEXECUTION_FINISHED); REQUIRE((bool)data.Context->GetReturnWord()); } - - - #endif \ No newline at end of file diff --git a/tests/ScriptTests/ScriptTypeTests/Library/MoveTests.cpp b/tests/ScriptTests/ScriptTypeTests/Library/MoveTests.cpp index 397deb3..7f421a2 100644 --- a/tests/ScriptTests/ScriptTypeTests/Library/MoveTests.cpp +++ b/tests/ScriptTests/ScriptTypeTests/Library/MoveTests.cpp @@ -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(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 \ No newline at end of file diff --git a/tests/ScriptTests/ScriptTypeTests/Library/SpeciesTests.cpp b/tests/ScriptTests/ScriptTypeTests/Library/SpeciesTests.cpp index bdec5a3..2f65e11 100644 --- a/tests/ScriptTests/ScriptTypeTests/Library/SpeciesTests.cpp +++ b/tests/ScriptTests/ScriptTypeTests/Library/SpeciesTests.cpp @@ -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(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(species)); + data.Context->SetArgObject(0, const_cast(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(species)); + data.Context->SetArgObject(0, const_cast(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(species)); + data.Context->SetArgObject(0, const_cast(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(species)); + data.Context->SetArgObject(0, const_cast(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(species)); + data.Context->SetArgObject(0, const_cast(species)); data.Context->SetArgObject(1, const_cast(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 \ No newline at end of file diff --git a/tests/ScriptTests/ScriptTypeTests/Library/StaticLibraryTests.cpp b/tests/ScriptTests/ScriptTypeTests/Library/StaticLibraryTests.cpp index 52220fa..b2c0184 100644 --- a/tests/ScriptTests/ScriptTypeTests/Library/StaticLibraryTests.cpp +++ b/tests/ScriptTests/ScriptTypeTests/Library/StaticLibraryTests.cpp @@ -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(PkmnLib::Battling::BattleLibrary::CreateScriptResolver()); _resolverCache->Initialize(mainLib); - _resolverCache->CreateScript("testScript1" , _scripts["testScript1"]); + _resolverCache->CreateScript("testScript1", _scripts["testScript1"]); _resolverCache->FinalizeModule(); } return _resolverCache;