diff --git a/CMakeLists.txt b/CMakeLists.txt index 6a734bf..d505536 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -77,8 +77,8 @@ foreach (_variableName ${CONAN_LIBS}) message(STATUS "Lib: ${_variableName}") endforeach() -SET(_LINKS CreatureLibCore CreatureLibLibrary CreatureLibBattling Arbutils) -SET(_TESTLINKS pkmnLib CreatureLibCore CreatureLibLibrary CreatureLibBattling Arbutils) +SET(_LINKS CreatureLibLibrary CreatureLibBattling Arbutils) +SET(_TESTLINKS pkmnLib CreatureLibLibrary CreatureLibBattling Arbutils) if (SCRIPT_PROVIDER STREQUAL "angelscript") SET(_LINKS angelscript ${_LINKS} ) diff --git a/src/Battling/Battle/Battle.hpp b/src/Battling/Battle/Battle.hpp index c4d092d..c69bd07 100644 --- a/src/Battling/Battle/Battle.hpp +++ b/src/Battling/Battle/Battle.hpp @@ -7,7 +7,7 @@ namespace PkmnLib::Battling { class Battle : public CreatureLib::Battling::Battle { public: - Battle(const BattleLibrary* library, const std::vector& parties, + Battle(const BattleLibrary* library, const List& parties, bool canFlee = true, uint8_t numberOfSides = 2, uint8_t creaturesPerSide = 1) : CreatureLib::Battling::Battle(library, parties, canFlee, numberOfSides, creaturesPerSide) {} }; diff --git a/src/Battling/Library/DamageLibrary.cpp b/src/Battling/Library/DamageLibrary.cpp index d2d7ff5..2856c53 100644 --- a/src/Battling/Library/DamageLibrary.cpp +++ b/src/Battling/Library/DamageLibrary.cpp @@ -1,6 +1,6 @@ #include "DamageLibrary.hpp" #include "../Pokemon/Pokemon.hpp" -int PkmnLib::Battling::DamageLibrary::GetDamage(CreatureLib::Battling::ExecutingAttack* attack, +uint32_t PkmnLib::Battling::DamageLibrary::GetDamage(CreatureLib::Battling::ExecutingAttack* attack, CreatureLib::Battling::Creature* target, uint8_t hitIndex) const { auto levelMod = static_cast(2 * attack->GetUser()->GetLevel()); auto hit = attack->GetAttackDataForTarget(target)->GetHit(hitIndex); @@ -12,7 +12,7 @@ int PkmnLib::Battling::DamageLibrary::GetDamage(CreatureLib::Battling::Executing // HOOK: Override damage return damage; } -int PkmnLib::Battling::DamageLibrary::GetBasePower(CreatureLib::Battling::ExecutingAttack* attack, +uint8_t PkmnLib::Battling::DamageLibrary::GetBasePower(CreatureLib::Battling::ExecutingAttack* attack, CreatureLib::Battling::Creature* target, uint8_t hitIndex) const { auto bp = attack->GetAttack()->GetAttack()->GetBasePower(); // HOOK: modify base power. @@ -24,8 +24,8 @@ float PkmnLib::Battling::DamageLibrary::GetStatModifier(CreatureLib::Battling::E auto user = attack->GetUser(); // HOOK: allow overriding for which users stat we use. auto hit = attack->GetAttackDataForTarget(target)->GetHit(hitIndex); - CreatureLib::Core::Statistic offensiveStat; - CreatureLib::Core::Statistic defensiveStat; + CreatureLib::Library::Statistic offensiveStat; + CreatureLib::Library::Statistic defensiveStat; auto learnedMove = dynamic_cast(attack->GetAttack()); auto moveData = learnedMove->GetMoveData(); if (moveData->GetCategory() == Library::MoveCategory::Physical) { diff --git a/src/Battling/Library/DamageLibrary.hpp b/src/Battling/Library/DamageLibrary.hpp index 37ab41e..8ef3e48 100644 --- a/src/Battling/Library/DamageLibrary.hpp +++ b/src/Battling/Library/DamageLibrary.hpp @@ -5,10 +5,10 @@ namespace PkmnLib::Battling { class DamageLibrary : public CreatureLib::Battling::DamageLibrary { public: - int GetDamage(CreatureLib::Battling::ExecutingAttack* attack, CreatureLib::Battling::Creature* target, + uint32_t GetDamage(CreatureLib::Battling::ExecutingAttack* attack, CreatureLib::Battling::Creature* target, uint8_t hitIndex) const override; - int GetBasePower(CreatureLib::Battling::ExecutingAttack* attack, CreatureLib::Battling::Creature* target, + uint8_t GetBasePower(CreatureLib::Battling::ExecutingAttack* attack, CreatureLib::Battling::Creature* target, uint8_t hitIndex) const override; float GetStatModifier(CreatureLib::Battling::ExecutingAttack* attack, CreatureLib::Battling::Creature* target, uint8_t hitIndex) const override; diff --git a/src/Battling/Library/StatCalculator.cpp b/src/Battling/Library/StatCalculator.cpp index d68bfd8..8a4a1ba 100644 --- a/src/Battling/Library/StatCalculator.cpp +++ b/src/Battling/Library/StatCalculator.cpp @@ -9,7 +9,7 @@ uint32_t PkmnLib::Battling::StatCalculator::CalculateHealthStat(const Pokemon* p return static_cast(((2 * base + iv + static_cast(ev / 4)) * level) / 100) + level + 10; } uint32_t PkmnLib::Battling::StatCalculator::CalculateOtherStat(const Pokemon* pkmn, - CreatureLib::Core::Statistic stat) const { + CreatureLib::Library::Statistic stat) const { uint32_t base = pkmn->GetBaseStat(stat); uint32_t iv = pkmn->GetIndividualValue(stat); uint32_t ev = pkmn->GetEffortValue(stat); @@ -19,7 +19,7 @@ uint32_t PkmnLib::Battling::StatCalculator::CalculateOtherStat(const Pokemon* pk return static_cast(unmodified * pkmn->GetNature().GetStatModifier(stat)); } float PkmnLib::Battling::StatCalculator::GetStatBoostModifier(const CreatureLib::Battling::Creature* pkmn, - CreatureLib::Core::Statistic stat) const { + CreatureLib::Library::Statistic stat) const { int8_t boost = pkmn->GetStatBoost(stat); switch (boost) { case -6: return 2.0 / 8; @@ -38,19 +38,19 @@ float PkmnLib::Battling::StatCalculator::GetStatBoostModifier(const CreatureLib: default: throw CreatureException("Stat boost was out of expected range of -6 till 6."); } } -CreatureLib::Core::StatisticSet +CreatureLib::Library::StatisticSet PkmnLib::Battling::StatCalculator::CalculateFlatStats(CreatureLib::Battling::Creature* creature) const { auto pkmn = dynamic_cast(creature); - return CreatureLib::Core::StatisticSet( + 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::Core::StatisticSet +CreatureLib::Library::StatisticSet PkmnLib::Battling::StatCalculator::CalculateBoostedStats(CreatureLib::Battling::Creature* creature) const { - return CreatureLib::Core::StatisticSet( + return CreatureLib::Library::StatisticSet( CalculateBoostedStat(creature, Library::Statistic::HealthPoints), CalculateBoostedStat(creature, Library::Statistic::PhysicalAttack), CalculateBoostedStat(creature, Library::Statistic::PhysicalDefense), @@ -59,12 +59,12 @@ PkmnLib::Battling::StatCalculator::CalculateBoostedStats(CreatureLib::Battling:: CalculateBoostedStat(creature, Library::Statistic::Speed)); } uint32_t PkmnLib::Battling::StatCalculator::CalculateFlatStat(CreatureLib::Battling::Creature* creature, - CreatureLib::Core::Statistic stat) const { + CreatureLib::Library::Statistic stat) const { if (stat == Library::Statistic::HealthPoints) return CalculateHealthStat(dynamic_cast(creature)); return CalculateOtherStat(dynamic_cast(creature), stat); } uint32_t PkmnLib::Battling::StatCalculator::CalculateBoostedStat(CreatureLib::Battling::Creature* creature, - CreatureLib::Core::Statistic stat) const { + CreatureLib::Library::Statistic stat) const { return creature->GetFlatStat(stat) * GetStatBoostModifier(creature, stat); } diff --git a/src/Battling/Library/StatCalculator.hpp b/src/Battling/Library/StatCalculator.hpp index df127db..b901234 100644 --- a/src/Battling/Library/StatCalculator.hpp +++ b/src/Battling/Library/StatCalculator.hpp @@ -10,23 +10,23 @@ namespace PkmnLib::Battling { class StatCalculator : public CreatureLib::Battling::BattleStatCalculator { protected: virtual uint32_t CalculateHealthStat(const Pokemon* pkmn) const; - virtual uint32_t CalculateOtherStat(const Pokemon* pkmn, CreatureLib::Core::Statistic stat) const; + virtual uint32_t CalculateOtherStat(const Pokemon* pkmn, CreatureLib::Library::Statistic stat) const; virtual float GetStatBoostModifier(const CreatureLib::Battling::Creature* pkmn, - CreatureLib::Core::Statistic stat) const; + CreatureLib::Library::Statistic stat) const; public: ~StatCalculator() override = default; - CreatureLib::Core::StatisticSet + CreatureLib::Library::StatisticSet CalculateFlatStats(CreatureLib::Battling::Creature* creature) const override; - CreatureLib::Core::StatisticSet + CreatureLib::Library::StatisticSet CalculateBoostedStats(CreatureLib::Battling::Creature* creature) const override; uint32_t CalculateFlatStat(CreatureLib::Battling::Creature* creature, - CreatureLib::Core::Statistic stat) const override; + CreatureLib::Library::Statistic stat) const override; uint32_t CalculateBoostedStat(CreatureLib::Battling::Creature* creature, - CreatureLib::Core::Statistic stat) const override; + CreatureLib::Library::Statistic stat) const override; }; } diff --git a/src/Battling/Pokemon/CreatePokemon.cpp b/src/Battling/Pokemon/CreatePokemon.cpp index 7fc05f1..0988b1d 100644 --- a/src/Battling/Pokemon/CreatePokemon.cpp +++ b/src/Battling/Pokemon/CreatePokemon.cpp @@ -11,7 +11,7 @@ PkmnLib::Battling::CreatePokemon* PkmnLib::Battling::CreatePokemon::WithRandomIn } PkmnLib::Battling::CreatePokemon* -PkmnLib::Battling::CreatePokemon::WithIndividualValue(CreatureLib::Core::Statistic stat, uint8_t value) { +PkmnLib::Battling::CreatePokemon::WithIndividualValue(CreatureLib::Library::Statistic stat, uint8_t value) { switch (stat) { case PkmnLib::Library::Statistic::HealthPoints: _ivHp = value; break; case PkmnLib::Library::Statistic::PhysicalAttack: _ivAttack = value; break; @@ -23,7 +23,7 @@ PkmnLib::Battling::CreatePokemon::WithIndividualValue(CreatureLib::Core::Statist return this; } -PkmnLib::Battling::CreatePokemon* PkmnLib::Battling::CreatePokemon::WithEffortValue(CreatureLib::Core::Statistic stat, +PkmnLib::Battling::CreatePokemon* PkmnLib::Battling::CreatePokemon::WithEffortValue(CreatureLib::Library::Statistic stat, uint8_t value) { switch (stat) { case PkmnLib::Library::Statistic::HealthPoints: _evHp = value; break; @@ -50,8 +50,8 @@ PkmnLib::Battling::Pokemon* PkmnLib::Battling::CreatePokemon::Build() { err << "Invalid forme '" << _forme << "' for species '" << _forme << "'."; throw CreatureException(err.str()); } - int8_t ability; - if (this->_ability.empty()) { + CreatureLib::Library::TalentIndex ability; + if (this->_ability.Empty()) { ability = forme->GetRandomTalent(&rand); } else { ability = forme->GetTalentIndex(this->_ability); @@ -72,13 +72,13 @@ PkmnLib::Battling::Pokemon* PkmnLib::Battling::CreatePokemon::Build() { } auto experience = _library->GetGrowthRateLibrary()->CalculateExperience(species->GetGrowthRate(), _level); - auto attacks = std::vector(_attacks.size()); - for (size_t i = 0; i < attacks.size(); i++) { + auto attacks = List(_attacks.size()); + for (size_t i = 0; i < attacks.Count(); i++) { auto kv = _attacks[i]; attacks[i] = new LearnedMove(std::get<0>(kv), std::get<1>(kv)); } - auto ivs = CreatureLib::Core::StatisticSet(_ivHp, _ivAttack, _ivDefense, _ivSpAtt, _ivSpDef, _ivSpeed); - auto evs = CreatureLib::Core::StatisticSet(_evHp, _evAttack, _evDefense, _evSpAtt, _evSpDef, _evSpeed); + auto ivs = CreatureLib::Library::StatisticSet(_ivHp, _ivAttack, _ivDefense, _ivSpAtt, _ivSpDef, _ivSpeed); + auto evs = CreatureLib::Library::StatisticSet(_evHp, _evAttack, _evDefense, _evSpAtt, _evSpDef, _evSpeed); if (_nature == 255) { _nature = _library->GetNatureLibrary()->GetRandomNature(rand); diff --git a/src/Battling/Pokemon/CreatePokemon.hpp b/src/Battling/Pokemon/CreatePokemon.hpp index 2c001a2..fc8b628 100644 --- a/src/Battling/Pokemon/CreatePokemon.hpp +++ b/src/Battling/Pokemon/CreatePokemon.hpp @@ -12,7 +12,7 @@ namespace PkmnLib::Battling { uint8_t _level; std::string _nickname = ""; - std::string _ability = ""; + Arbutils::CaseInsensitiveConstString _ability = ""_cnc; uint8_t _nature = 255; CreatureLib::Library::Gender _gender = static_cast(-1); Arbutils::CaseInsensitiveConstString _heldItem = ""_cnc; @@ -47,10 +47,10 @@ namespace PkmnLib::Battling { CreatePokemon* LearnMove(const Arbutils::CaseInsensitiveConstString& move, CreatureLib::Battling::AttackLearnMethod method); CreatePokemon* WithRandomIndividualValues(Arbutils::Random rand = Arbutils::Random()); - CreatePokemon* WithIndividualValue(CreatureLib::Core::Statistic stat, uint8_t value); + CreatePokemon* WithIndividualValue(CreatureLib::Library::Statistic stat, uint8_t value); CreatePokemon* WithIndividualValues(uint8_t hp, uint8_t att, uint8_t def, uint8_t spAtt, uint8_t spDef, uint8_t speed); - CreatePokemon* WithEffortValue(CreatureLib::Core::Statistic stat, uint8_t value); + CreatePokemon* WithEffortValue(CreatureLib::Library::Statistic stat, uint8_t value); CreatePokemon* WithEffortValues(uint8_t hp, uint8_t att, uint8_t def, uint8_t spAtt, uint8_t spDef, uint8_t speed); diff --git a/src/Battling/Pokemon/Pokemon.hpp b/src/Battling/Pokemon/Pokemon.hpp index 6da108f..0a60f8a 100644 --- a/src/Battling/Pokemon/Pokemon.hpp +++ b/src/Battling/Pokemon/Pokemon.hpp @@ -10,8 +10,8 @@ namespace PkmnLib::Battling { class Pokemon : public CreatureLib::Battling::Creature { private: - CreatureLib::Core::StatisticSet _individualValues; - CreatureLib::Core::StatisticSet _effortValues; + CreatureLib::Library::StatisticSet _individualValues; + CreatureLib::Library::StatisticSet _effortValues; uint8_t _nature; const Library::Nature* _natureCache = nullptr; @@ -22,14 +22,14 @@ namespace PkmnLib::Battling { Pokemon(const BattleLibrary* library, const Library::PokemonSpecies* species, const Library::PokemonForme* forme, uint8_t level, uint32_t experience, uint32_t uid, CreatureLib::Library::Gender gender, uint8_t coloring, const Library::Item* heldItem, - const std::string& nickname, int8_t talent, std::vector moves, - CreatureLib::Core::StatisticSet individualValues, - CreatureLib::Core::StatisticSet effortValues, uint8_t nature) + const std::string& nickname, const CreatureLib::Library::TalentIndex& talent, + List moves, + CreatureLib::Library::StatisticSet individualValues, + CreatureLib::Library::StatisticSet effortValues, uint8_t nature) : CreatureLib::Battling::Creature(library, species, forme, level, experience, uid, gender, coloring, heldItem, nickname, talent, std::move(moves)), _individualValues(individualValues), _effortValues(effortValues), _nature(nature) {} - const Library::PokemonForme* GetForme() const { return dynamic_cast(GetVariant()); } @@ -41,8 +41,10 @@ namespace PkmnLib::Battling { } const Library::Nature& GetNature() const; - uint8_t GetIndividualValue(CreatureLib::Core::Statistic stat) const { return _individualValues.GetStat(stat); } - uint8_t GetEffortValue(CreatureLib::Core::Statistic stat) const { return _effortValues.GetStat(stat); } + uint8_t GetIndividualValue(CreatureLib::Library::Statistic stat) const { + return _individualValues.GetStat(stat); + } + uint8_t GetEffortValue(CreatureLib::Library::Statistic stat) const { return _effortValues.GetStat(stat); } }; } diff --git a/src/Library/Items/Item.hpp b/src/Library/Items/Item.hpp index 9ba68f1..4bd7e8f 100644 --- a/src/Library/Items/Item.hpp +++ b/src/Library/Items/Item.hpp @@ -9,7 +9,7 @@ namespace PkmnLib::Library { public: Item(const Arbutils::CaseInsensitiveConstString& name, CreatureLib::Library::ItemCategory category, CreatureLib::Library::BattleItemCategory battleCategory, int32_t price, - std::unordered_set flags, uint8_t flingPower) + std::unordered_set flags, uint8_t flingPower) : CreatureLib::Library::Item(name, category, battleCategory, price, flags), _flingPower(flingPower) {} inline uint8_t GetFlingPower() const { return _flingPower; } diff --git a/src/Library/Moves/MoveData.cpp b/src/Library/Moves/MoveData.cpp index 593b03e..e0c2319 100644 --- a/src/Library/Moves/MoveData.cpp +++ b/src/Library/Moves/MoveData.cpp @@ -1,11 +1,12 @@ #include "MoveData.hpp" #include -PkmnLib::Library::MoveData::MoveData(const std::string& name, uint8_t type, +PkmnLib::Library::MoveData::MoveData(const Arbutils::CaseInsensitiveConstString& name, uint8_t type, PkmnLib::Library::MoveCategory category, uint8_t power, uint8_t accuracy, uint8_t baseUsage, CreatureLib::Library::AttackTarget target, int8_t priority, - std::unordered_set flags) + const CreatureLib::Library::SecondaryEffect& effect, + std::unordered_set flags) : AttackData(name, type, static_cast(category), power, accuracy, baseUsage, - target, priority, std::move(flags)) {} + target, priority, effect, std::move(flags)) {} PkmnLib::Library::MoveCategory PkmnLib::Library::MoveData::GetCategory() const { return static_cast(AttackData::GetCategory()); diff --git a/src/Library/Moves/MoveData.hpp b/src/Library/Moves/MoveData.hpp index 9cb2e02..f21f32e 100644 --- a/src/Library/Moves/MoveData.hpp +++ b/src/Library/Moves/MoveData.hpp @@ -7,11 +7,11 @@ namespace PkmnLib::Library { class MoveData : public CreatureLib::Library::AttackData { private: - public: - MoveData(const std::string& name, uint8_t type, PkmnLib::Library::MoveCategory category, uint8_t power, - uint8_t accuracy, uint8_t baseUsage, CreatureLib::Library::AttackTarget target, int8_t priority, - std::unordered_set flags); + MoveData(const Arbutils::CaseInsensitiveConstString& name, uint8_t type, + PkmnLib::Library::MoveCategory category, uint8_t power, uint8_t accuracy, uint8_t baseUsage, + CreatureLib::Library::AttackTarget target, int8_t priority, + const CreatureLib::Library::SecondaryEffect& effect, std::unordered_set flags); PkmnLib::Library::MoveCategory GetCategory() const; }; diff --git a/src/Library/Natures/Nature.hpp b/src/Library/Natures/Nature.hpp index 601ba59..645705d 100644 --- a/src/Library/Natures/Nature.hpp +++ b/src/Library/Natures/Nature.hpp @@ -1,21 +1,22 @@ #ifndef PKMNLIB_NATURE_HPP #define PKMNLIB_NATURE_HPP -#include +#include namespace PkmnLib::Library { class Nature { private: - CreatureLib::Core::Statistic _increaseStat; - CreatureLib::Core::Statistic _decreaseStat; + CreatureLib::Library::Statistic _increaseStat; + CreatureLib::Library::Statistic _decreaseStat; float _increaseModifier; float _decreaseModifier; public: Nature() - : _increaseStat(CreatureLib::Core::Statistic::Health), _decreaseStat(CreatureLib::Core::Statistic::Health), - _increaseModifier(1.0f), _decreaseModifier(1.0f) {} + : _increaseStat(CreatureLib::Library::Statistic::Health), + _decreaseStat(CreatureLib::Library::Statistic::Health), _increaseModifier(1.0f), _decreaseModifier(1.0f) { + } - Nature(CreatureLib::Core::Statistic increasedStat, CreatureLib::Core::Statistic decreasedStat, + Nature(CreatureLib::Library::Statistic increasedStat, CreatureLib::Library::Statistic decreasedStat, float increasedModifier = 1.1f, float decreasedModifier = 0.9f) : _increaseStat(increasedStat), _decreaseStat(decreasedStat), _increaseModifier(increasedModifier), _decreaseModifier(decreasedModifier) {} @@ -23,10 +24,10 @@ namespace PkmnLib::Library { [[nodiscard]] float GetIncreaseModifier() const { return _increaseModifier; } [[nodiscard]] float GetDecreaseModifier() const { return _decreaseModifier; } - [[nodiscard]] CreatureLib::Core::Statistic GetIncreasedStat() const { return _increaseStat; } - [[nodiscard]] CreatureLib::Core::Statistic GetDecreasedStat() const { return _decreaseStat; } + [[nodiscard]] CreatureLib::Library::Statistic GetIncreasedStat() const { return _increaseStat; } + [[nodiscard]] CreatureLib::Library::Statistic GetDecreasedStat() const { return _decreaseStat; } - [[nodiscard]] float GetStatModifier(CreatureLib::Core::Statistic stat) const { + [[nodiscard]] float GetStatModifier(CreatureLib::Library::Statistic stat) const { if (stat == _increaseStat) return _increaseModifier; else if (stat == _decreaseStat) diff --git a/src/Library/Natures/NatureLibrary.hpp b/src/Library/Natures/NatureLibrary.hpp index 9f7de9c..1c4d3d3 100644 --- a/src/Library/Natures/NatureLibrary.hpp +++ b/src/Library/Natures/NatureLibrary.hpp @@ -1,7 +1,7 @@ #ifndef PKMNLIB_NATURELIBRARY_HPP #define PKMNLIB_NATURELIBRARY_HPP -#include +#include #include #include #include diff --git a/src/Library/Species/PokemonForme.cpp b/src/Library/Species/PokemonForme.cpp index b073509..de5267b 100644 --- a/src/Library/Species/PokemonForme.cpp +++ b/src/Library/Species/PokemonForme.cpp @@ -1,7 +1,7 @@ #include "PokemonForme.hpp" PkmnLib::Library::PokemonForme::PokemonForme(ConstString name, float height, float weight, uint32_t baseExperience, - std::vector types, - CreatureLib::Core::StatisticSet baseStats, - std::vector talents, std::vector secretTalents, + const List& types, + CreatureLib::Library::StatisticSet baseStats, + const List& talents, const List& secretTalents, const CreatureLib::Library::LearnableAttacks* attacks) : SpeciesVariant(name, height, weight, baseExperience, types, baseStats, talents, secretTalents, attacks) {} diff --git a/src/Library/Species/PokemonForme.hpp b/src/Library/Species/PokemonForme.hpp index 6f60a4c..e912ae1 100644 --- a/src/Library/Species/PokemonForme.hpp +++ b/src/Library/Species/PokemonForme.hpp @@ -6,13 +6,15 @@ namespace PkmnLib::Library { class PokemonForme : public CreatureLib::Library::SpeciesVariant { public: - PokemonForme(ConstString name, float height, float weight, uint32_t baseExperience, std::vector types, - CreatureLib::Core::StatisticSet baseStats, std::vector talents, - std::vector secretTalents, const CreatureLib::Library::LearnableAttacks* attacks); + PokemonForme(ConstString name, float height, float weight, uint32_t baseExperience, const List& types, + CreatureLib::Library::StatisticSet baseStats, const List& talents, + const List& secretTalents, const CreatureLib::Library::LearnableAttacks* attacks); private: public: - inline const ConstString& GetAbility(int index) const { return GetTalent(index); } + inline const ConstString& GetAbility(const CreatureLib::Library::TalentIndex& index) const { + return GetTalent(index); + } }; } diff --git a/src/Library/Statistic.hpp b/src/Library/Statistic.hpp index b1588a6..1831714 100644 --- a/src/Library/Statistic.hpp +++ b/src/Library/Statistic.hpp @@ -1,19 +1,20 @@ #ifndef PKMNLIB_STATISTIC_HPP #define PKMNLIB_STATISTIC_HPP -#include +#include namespace PkmnLib::Library { class Statistic { public: - static constexpr const CreatureLib::Core::Statistic HealthPoints = CreatureLib::Core::Statistic::Health; - static constexpr const CreatureLib::Core::Statistic PhysicalAttack = - CreatureLib::Core::Statistic::PhysicalAttack; - static constexpr const CreatureLib::Core::Statistic PhysicalDefense = - CreatureLib::Core::Statistic::PhysicalDefense; - static constexpr const CreatureLib::Core::Statistic SpecialAttack = CreatureLib::Core::Statistic::MagicalAttack; - static constexpr const CreatureLib::Core::Statistic SpecialDefense = - CreatureLib::Core::Statistic::MagicalDefense; - static constexpr const CreatureLib::Core::Statistic Speed = CreatureLib::Core::Statistic::Speed; + static constexpr const CreatureLib::Library::Statistic HealthPoints = CreatureLib::Library::Statistic::Health; + static constexpr const CreatureLib::Library::Statistic PhysicalAttack = + CreatureLib::Library::Statistic::PhysicalAttack; + static constexpr const CreatureLib::Library::Statistic PhysicalDefense = + CreatureLib::Library::Statistic::PhysicalDefense; + static constexpr const CreatureLib::Library::Statistic SpecialAttack = + CreatureLib::Library::Statistic::MagicalAttack; + static constexpr const CreatureLib::Library::Statistic SpecialDefense = + CreatureLib::Library::Statistic::MagicalDefense; + static constexpr const CreatureLib::Library::Statistic Speed = CreatureLib::Library::Statistic::Speed; }; } diff --git a/src/ScriptResolving/AngelScript/AngelScripResolver.cpp b/src/ScriptResolving/AngelScript/AngelScripResolver.cpp index 7990778..5da871c 100644 --- a/src/ScriptResolving/AngelScript/AngelScripResolver.cpp +++ b/src/ScriptResolving/AngelScript/AngelScripResolver.cpp @@ -11,6 +11,7 @@ #include "TypeRegistry/Battling/RegisterExecutingAttack.hpp" #include "TypeRegistry/Battling/RegisterPokemonClass.hpp" #include "TypeRegistry/Battling/RegisterTurnChoices.hpp" +#include "TypeRegistry/ConstString.hpp" #include "TypeRegistry/Library/RegisterGrowthRateTypes.hpp" #include "TypeRegistry/Library/RegisterItemTypes.hpp" #include "TypeRegistry/Library/RegisterMoveTypes.hpp" @@ -40,6 +41,7 @@ void AngelScripResolver::Initialize(CreatureLib::Battling::BattleLibrary* arg) { _engine->SetEngineProperty(asEP_COMPILER_WARNINGS, 2); RegisterStdString(_engine); + ConstStringRegister::Register(_engine); // Register Script Array type RegisterScriptArray(_engine, true); diff --git a/src/ScriptResolving/AngelScript/AngelScriptScript.hpp b/src/ScriptResolving/AngelScript/AngelScriptScript.hpp index 70d84da..40f7a61 100644 --- a/src/ScriptResolving/AngelScript/AngelScriptScript.hpp +++ b/src/ScriptResolving/AngelScript/AngelScriptScript.hpp @@ -2,7 +2,7 @@ #define PKMNLIB_ANGELSCRIPTSCRIPT_HPP #include #define ANGELSCRIPT_DLL_LIBRARY_IMPORT -#include +#include #include #include "../../Battling/PkmnScript.hpp" #include "AngelScriptTypeInfo.hpp" @@ -21,9 +21,9 @@ public: ~AngelScriptScript() override { _obj->Release(); } - [[nodiscard]] const ConstString& GetName() const override { return _type->GetName(); } + [[nodiscard]] const ConstString& GetName() const noexcept override { return _type->GetName(); } - asIScriptFunction* PrepareMethod(const char* name, asIScriptContext* ctx) { + asIScriptFunction* PrepareMethod(const ConstString& name, asIScriptContext* ctx) { auto func = _type->GetFunction(name); ctx->Prepare(func); ctx->SetObject(_obj); @@ -71,7 +71,7 @@ public: throw NotImplementedException(); // TODO } - void ChangeAttack(CreatureLib::Battling::AttackTurnChoice* choice, std::string* outAttack) override { + void ChangeAttack(CreatureLib::Battling::AttackTurnChoice* choice, ConstString* outAttack) override { throw NotImplementedException(); // TODO } @@ -246,7 +246,7 @@ public: }) } void OverrideDamage(CreatureLib::Battling::ExecutingAttack* attack, CreatureLib::Battling::Creature* target, - uint8_t hitIndex, int32_t* damage) override { + uint8_t hitIndex, uint32_t* damage) override { CALL_HOOK(OverrideDamage, { ctx->SetArgObject(0, (void*)attack); ctx->SetArgObject(1, (void*)target); diff --git a/src/ScriptResolving/AngelScript/AngelScriptTypeInfo.hpp b/src/ScriptResolving/AngelScript/AngelScriptTypeInfo.hpp index c81365c..03590fe 100644 --- a/src/ScriptResolving/AngelScript/AngelScriptTypeInfo.hpp +++ b/src/ScriptResolving/AngelScript/AngelScriptTypeInfo.hpp @@ -2,8 +2,9 @@ #define PKMNLIB_ANGELSCRIPTTYPEINFO_HPP #define ANGELSCRIPT_DLL_LIBRARY_IMPORT +#include #include -#include +#include #include #include #include @@ -14,7 +15,7 @@ using ConstString = Arbutils::CaseInsensitiveConstString; class AngelScriptTypeInfo { private: asITypeInfo* _type = nullptr; - std::unordered_map _functions; + Arbutils::Collections::Dictionary _functions; ConstString _name; struct FunctionInfo { @@ -39,23 +40,21 @@ public: for (const auto& f : _functions) { f.second->Release(); } - _functions.clear(); + _functions.Clear(); } - const ConstString& GetName() const{ - return _name; - } + const ConstString& GetName() const noexcept { return _name; } - asIScriptFunction* GetFunction(const std::string& functionName) { - auto find = _functions.find(functionName); - if (find != _functions.end()) { - return find->second; + asIScriptFunction* GetFunction(const ConstString& functionName) { + asIScriptFunction* func; + if (_functions.TryGet(functionName, func)) { + return func; } - auto func = _type->GetMethodByName(functionName.c_str()); + func = _type->GetMethodByName(functionName.c_str()); if (func != nullptr) { func->AddRef(); } - _functions.insert({functionName, func}); + _functions.Insert(functionName, func); return func; } diff --git a/src/ScriptResolving/AngelScript/TypeRegistry/BasicScriptClass.cpp b/src/ScriptResolving/AngelScript/TypeRegistry/BasicScriptClass.cpp index a0ff8d5..d753b73 100644 --- a/src/ScriptResolving/AngelScript/TypeRegistry/BasicScriptClass.cpp +++ b/src/ScriptResolving/AngelScript/TypeRegistry/BasicScriptClass.cpp @@ -25,13 +25,13 @@ shared abstract class PkmnScript { void ModifyEffectChance(ExecutingMove@ attack, Pokemon@ target, float& chance){}; void ModifyIncomingEffectChance(ExecutingMove@ attack, Pokemon@ target, float& chance){}; - void OverrideBasePower(ExecutingMove@ attack, Pokemon@ target, uint8 hit, uint8& chance){}; + void OverrideBasePower(ExecutingMove@ attack, Pokemon@ target, uint8 hit, uint8& basePower){}; void ChangeDamageStatsUser(ExecutingMove@ attack, Pokemon@ target, uint8 hit, Pokemon@& user){}; void BypassDefensiveStat(ExecutingMove@ attack, Pokemon@ target, uint8 hit, bool& bypass){}; void BypassOffensiveStat(ExecutingMove@ attack, Pokemon@ target, uint8 hit, bool& bypass){}; void ModifyStatModifier(ExecutingMove@ attack, Pokemon@ target, uint8 hit, float& modifier){}; void ModifyDamageModifier(ExecutingMove@ attack, Pokemon@ target, uint8 hit, float& modifier){}; - void OverrideDamage(ExecutingMove@ attack, Pokemon@ target, uint8 hit, int& damage){}; + void OverrideDamage(ExecutingMove@ attack, Pokemon@ target, uint8 hit, uint& damage){}; // PkmnLib methods void ModifyCriticalStage(ExecutingMove@ attack, Pokemon@ target, uint8 hit, uint8& critStage){}; diff --git a/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterPokemonClass.cpp b/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterPokemonClass.cpp index 457a305..6efd1f5 100644 --- a/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterPokemonClass.cpp +++ b/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterPokemonClass.cpp @@ -59,8 +59,8 @@ CScriptArray* GetTypes(const PkmnLib::Battling::Pokemon* obj) { asIScriptEngine* engine = ctx->GetEngine(); asITypeInfo* t = engine->GetTypeInfoByDecl("array"); auto a = obj->GetTypes(); - CScriptArray* arr = CScriptArray::Create(t, a.size()); - for (size_t i = 0; i < a.size(); i++) { + CScriptArray* arr = CScriptArray::Create(t, a.Count()); + for (size_t i = 0; i < a.Count(); i++) { arr->SetValue(i, &a[i]); } return arr; @@ -82,6 +82,10 @@ CScriptArray* GetMoves(const PkmnLib::Battling::Pokemon* obj) { } return nullptr; } +static bool HasHeldItem(const PkmnLib::Battling::Pokemon* obj, const Arbutils::CaseInsensitiveConstString& str) { + return obj->HasHeldItem(str); +} + void RegisterPokemonClass::RegisterPokemonType(asIScriptEngine* engine) { [[maybe_unused]] int r = engine->RegisterObjectType("Pokemon", 0, asOBJ_REF | asOBJ_NOCOUNT); @@ -111,7 +115,7 @@ void RegisterPokemonClass::RegisterPokemonType(asIScriptEngine* engine) { asMETHOD(PkmnLib::Battling::Pokemon, GetHeldItem), asCALL_THISCALL); assert(r >= 0); r = engine->RegisterObjectMethod("Pokemon", "bool HasHeldItem(const string &in name) const", - asMETHOD(PkmnLib::Battling::Pokemon, HasHeldItem), asCALL_THISCALL); + asFUNCTION(HasHeldItem), asCALL_CDECL_OBJLAST); assert(r >= 0); r = engine->RegisterObjectMethod( "Pokemon", "void SetHeldItem(const string &in name)", diff --git a/src/ScriptResolving/AngelScript/TypeRegistry/ConstString.cpp b/src/ScriptResolving/AngelScript/TypeRegistry/ConstString.cpp new file mode 100644 index 0000000..eb01b95 --- /dev/null +++ b/src/ScriptResolving/AngelScript/TypeRegistry/ConstString.cpp @@ -0,0 +1,14 @@ +#include "ConstString.hpp" +using ConstString = Arbutils::CaseInsensitiveConstString; + +static bool ConstStringEquality(const ConstString& a, const ConstString& b) { return a == b; } + +void ConstStringRegister::Register(asIScriptEngine* engine) { + auto r = engine->RegisterObjectType("constString", sizeof(Arbutils::CaseInsensitiveConstString), + asOBJ_VALUE | asOBJ_POD); + Assert(r >= 0); + r = engine->RegisterObjectMethod("constString", "bool opEquals(const constString &in) const", + asFUNCTIONPR(ConstStringEquality, (const ConstString&, const ConstString&), bool), + asCALL_CDECL_OBJFIRST); + Assert(r >= 0); +} diff --git a/src/ScriptResolving/AngelScript/TypeRegistry/ConstString.hpp b/src/ScriptResolving/AngelScript/TypeRegistry/ConstString.hpp new file mode 100644 index 0000000..16388f8 --- /dev/null +++ b/src/ScriptResolving/AngelScript/TypeRegistry/ConstString.hpp @@ -0,0 +1,11 @@ +#ifndef PKMNLIB_CONSTSTRING_HPP +#define PKMNLIB_CONSTSTRING_HPP +#include +#include +#include +class ConstStringRegister { +public: + static void Register(asIScriptEngine* engine); +}; + +#endif // PKMNLIB_CONSTSTRING_HPP diff --git a/src/ScriptResolving/AngelScript/TypeRegistry/Library/RegisterGrowthRateTypes.cpp b/src/ScriptResolving/AngelScript/TypeRegistry/Library/RegisterGrowthRateTypes.cpp index cf11fbc..068d600 100644 --- a/src/ScriptResolving/AngelScript/TypeRegistry/Library/RegisterGrowthRateTypes.cpp +++ b/src/ScriptResolving/AngelScript/TypeRegistry/Library/RegisterGrowthRateTypes.cpp @@ -17,13 +17,25 @@ void RegisterGrowthRateTypes::RegisterGrowthRateType(asIScriptEngine* engine) { asMETHOD(CreatureLib::Library::GrowthRate, CalculateExperience), asCALL_THISCALL); assert(r >= 0); } + +static uint8_t CalculateLevel(const CreatureLib::Library::GrowthRateLibrary* obj, const ConstString& str, + uint32_t experience) { + return obj->CalculateLevel(str, experience); +} +static uint32_t CalculateExperience(const CreatureLib::Library::GrowthRateLibrary* obj, const ConstString& str, + uint8_t level) { + return obj->CalculateExperience(str, level); +} + void RegisterGrowthRateTypes::RegisterGrowthRateLibrary(asIScriptEngine* engine) { [[maybe_unused]] int r = engine->RegisterObjectType("GrowthRateLibrary", 0, asOBJ_REF | asOBJ_NOCOUNT); assert(r >= 0); - r = engine->RegisterObjectMethod("GrowthRateLibrary", "uint8 CalculateLevel(const string &in growthRate, uint experience) const", - asMETHOD(CreatureLib::Library::GrowthRateLibrary, CalculateLevel), asCALL_THISCALL); + r = engine->RegisterObjectMethod("GrowthRateLibrary", + "uint8 CalculateLevel(const string &in growthRate, uint experience) const", + asFUNCTION(CalculateLevel), asCALL_CDECL_OBJLAST); assert(r >= 0); - r = engine->RegisterObjectMethod("GrowthRateLibrary", "uint CalculateExperience(const string &in growthRate, uint8 experience) const", - asMETHOD(CreatureLib::Library::GrowthRateLibrary, CalculateExperience), asCALL_THISCALL); + r = engine->RegisterObjectMethod("GrowthRateLibrary", + "uint CalculateExperience(const string &in growthRate, uint8 experience) const", + asFUNCTION(CalculateExperience), asCALL_CDECL_OBJLAST); assert(r >= 0); } diff --git a/src/ScriptResolving/AngelScript/TypeRegistry/Library/RegisterItemTypes.cpp b/src/ScriptResolving/AngelScript/TypeRegistry/Library/RegisterItemTypes.cpp index f2c6c3b..46148b2 100644 --- a/src/ScriptResolving/AngelScript/TypeRegistry/Library/RegisterItemTypes.cpp +++ b/src/ScriptResolving/AngelScript/TypeRegistry/Library/RegisterItemTypes.cpp @@ -53,6 +53,11 @@ void RegisterItemTypes::RegisterBattleItemCategoryEnum(asIScriptEngine* engine) ENUM__SIZE_WRAPPER(Move_CategoryWrapper, PkmnLib::Library::Item, GetCategory) ENUM__SIZE_WRAPPER(Move_BattleCategoryWrapper, PkmnLib::Library::Item, GetBattleCategory) +static bool HasFlag(const PkmnLib::Library::Item* obj, const Arbutils::CaseInsensitiveConstString& str) { + return obj->HasFlag(str); +} + + void RegisterItemTypes::RegisterItemType(asIScriptEngine* engine) { [[maybe_unused]] int r = engine->RegisterObjectType("Item", 0, asOBJ_REF | asOBJ_NOCOUNT); assert(r >= 0); @@ -69,7 +74,7 @@ void RegisterItemTypes::RegisterItemType(asIScriptEngine* engine) { asMETHOD(PkmnLib::Library::Item, GetPrice), asCALL_THISCALL); assert(r >= 0); r = engine->RegisterObjectMethod("Item", "bool HasFlag(const string &in flag) const", - asMETHOD(PkmnLib::Library::Item, HasFlag), asCALL_THISCALL); + asFUNCTION(HasFlag), asCALL_CDECL_OBJLAST); assert(r >= 0); diff --git a/src/ScriptResolving/AngelScript/TypeRegistry/Library/RegisterMoveTypes.cpp b/src/ScriptResolving/AngelScript/TypeRegistry/Library/RegisterMoveTypes.cpp index 2022748..9322d88 100644 --- a/src/ScriptResolving/AngelScript/TypeRegistry/Library/RegisterMoveTypes.cpp +++ b/src/ScriptResolving/AngelScript/TypeRegistry/Library/RegisterMoveTypes.cpp @@ -46,6 +46,10 @@ void RegisterMoveTypes::RegisterMoveTarget(asIScriptEngine* engine) { ENUM__SIZE_WRAPPER(Move_CategoryWrapper, PkmnLib::Library::MoveData, GetCategory) ENUM__SIZE_WRAPPER(Move_TargetWrapper, PkmnLib::Library::MoveData, GetTarget) +static bool HasFlag(const PkmnLib::Library::MoveData* obj, const Arbutils::CaseInsensitiveConstString& str) { + return obj->HasFlag(str); +} + void RegisterMoveTypes::RegisterMoveType(asIScriptEngine* engine) { [[maybe_unused]] int r = engine->RegisterObjectType("MoveData", 0, asOBJ_REF | asOBJ_NOCOUNT); assert(r >= 0); @@ -74,7 +78,7 @@ void RegisterMoveTypes::RegisterMoveType(asIScriptEngine* engine) { asMETHOD(PkmnLib::Library::MoveData, GetPriority), asCALL_THISCALL); assert(r >= 0); r = engine->RegisterObjectMethod("MoveData", "bool HasFlag(const string &in flag) const", - asMETHOD(PkmnLib::Library::MoveData, HasFlag), asCALL_THISCALL); + asFUNCTION(HasFlag), asCALL_CDECL_OBJLAST); assert(r >= 0); } void RegisterMoveTypes::RegisterMoveLibrary(asIScriptEngine* engine) { diff --git a/src/ScriptResolving/AngelScript/TypeRegistry/Library/RegisterSpeciesTypes.cpp b/src/ScriptResolving/AngelScript/TypeRegistry/Library/RegisterSpeciesTypes.cpp index 7c40d7b..d8926bf 100644 --- a/src/ScriptResolving/AngelScript/TypeRegistry/Library/RegisterSpeciesTypes.cpp +++ b/src/ScriptResolving/AngelScript/TypeRegistry/Library/RegisterSpeciesTypes.cpp @@ -63,13 +63,18 @@ void RegisterSpeciesTypes::RegisterSpeciesType(asIScriptEngine* engine) { r = engine->RegisterObjectMethod("Species", "Gender GetRandomGender() const", asMETHOD(PkmnLib::Library::PokemonSpecies, GetRandomGender), asCALL_THISCALL); assert(r >= 0); - r = engine->RegisterObjectMethod("Species", "const Forme@ GetForme(string key) const", - asFUNCTION(GetFormeWrapper), asCALL_CDECL_OBJLAST); + r = engine->RegisterObjectMethod("Species", "const Forme@ GetForme(string key) const", asFUNCTION(GetFormeWrapper), + asCALL_CDECL_OBJLAST); assert(r >= 0); r = engine->RegisterObjectMethod("Species", "const Forme@ GetDefaultForme() const", asMETHOD(PkmnLib::Library::PokemonSpecies, GetDefaultForme), asCALL_THISCALL); assert(r >= 0); } + +const ConstString& GetAbility(PkmnLib::Library::PokemonForme* p, bool hidden, uint8_t index) { + return p->GetAbility(CreatureLib::Library::TalentIndex(hidden, index)); +} + void RegisterSpeciesTypes::RegisterFormeType(asIScriptEngine* engine) { [[maybe_unused]] int r = engine->RegisterObjectType("Forme", 0, asOBJ_REF | asOBJ_NOCOUNT); assert(r >= 0); @@ -94,8 +99,10 @@ void RegisterSpeciesTypes::RegisterFormeType(asIScriptEngine* engine) { r = engine->RegisterObjectMethod("Forme", "uint GetStatistic(Statistic stat) const", asMETHOD(PkmnLib::Library::PokemonForme, GetStatistic), asCALL_THISCALL); assert(r >= 0); - r = engine->RegisterObjectMethod("Forme", "const string& GetAbility(int index) const", - asMETHOD(PkmnLib::Library::PokemonForme, GetTalent), asCALL_THISCALL); + r = engine->RegisterObjectMethod( + "Forme", "const constString& GetAbility(bool hidden, uint8 index) const", + asFUNCTIONPR(GetAbility, (PkmnLib::Library::PokemonForme * p, bool hidden, uint8_t index), const ConstString&), + asCALL_CDECL_OBJFIRST); assert(r >= 0); } void RegisterSpeciesTypes::RegisterSpeciesLibrary(asIScriptEngine* engine) { diff --git a/src/ScriptResolving/AngelScript/TypeRegistry/Library/RegisterTypeLibrary.cpp b/src/ScriptResolving/AngelScript/TypeRegistry/Library/RegisterTypeLibrary.cpp index bd7d7a5..f396de2 100644 --- a/src/ScriptResolving/AngelScript/TypeRegistry/Library/RegisterTypeLibrary.cpp +++ b/src/ScriptResolving/AngelScript/TypeRegistry/Library/RegisterTypeLibrary.cpp @@ -6,11 +6,15 @@ void RegisterTypeLibrary::Register(asIScriptEngine* engine) { RegisterTypeLibraryType(engine); } +static bool GetTypeId(const CreatureLib::Library::TypeLibrary* obj, const Arbutils::CaseInsensitiveConstString& str) { + return obj->GetTypeId(str); +} + void RegisterTypeLibrary::RegisterTypeLibraryType(asIScriptEngine* engine) { [[maybe_unused]] int r = engine->RegisterObjectType("TypeLibrary", 0, asOBJ_REF | asOBJ_NOCOUNT); assert(r >= 0); r = engine->RegisterObjectMethod("TypeLibrary", "uint8 GetTypeId(const string &in name) const", - asMETHOD(CreatureLib::Library::TypeLibrary, GetTypeId), asCALL_THISCALL); + 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); diff --git a/tests/LibraryTests/SpeciesLibraryTests.cpp b/tests/LibraryTests/SpeciesLibraryTests.cpp index 1d87d54..40bb7b8 100644 --- a/tests/LibraryTests/SpeciesLibraryTests.cpp +++ b/tests/LibraryTests/SpeciesLibraryTests.cpp @@ -15,7 +15,7 @@ TEST_CASE("Able to build, destroy and insert library", "library") { 1, "foo"_cnc, new PkmnLib::Library::PokemonForme( "default"_cnc, 1.0f, 1.0f, 100, {0}, - CreatureLib::Core::StatisticSet(100, 100, 100, 100, 100, 100), {"testAbility"_cnc}, + 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; @@ -28,7 +28,7 @@ TEST_CASE("Able to insert and retrieve from library", "library") { 1, "foo"_cnc, new PkmnLib::Library::PokemonForme( "default"_cnc, 1.0f, 1.0f, 100, {0}, - CreatureLib::Core::StatisticSet(100, 100, 100, 100, 100, 100), {"testAbility"_cnc}, + 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); diff --git a/tests/LibraryTests/SpeciesTests.cpp b/tests/LibraryTests/SpeciesTests.cpp index 3982e2c..29345a7 100644 --- a/tests/LibraryTests/SpeciesTests.cpp +++ b/tests/LibraryTests/SpeciesTests.cpp @@ -6,7 +6,7 @@ TEST_CASE("Able to create and destroy species", "library") { auto species = new PkmnLib::Library::PokemonSpecies( 1, "foo"_cnc, new PkmnLib::Library::PokemonForme("default"_cnc, 1.0f, 1.0f, 100, {0}, - CreatureLib::Core::StatisticSet(100, 100, 100, 100, 100, 100), + CreatureLib::Library::StatisticSet(100, 100, 100, 100, 100, 100), {"testAbility"_cnc}, {"testHiddenAbility"_cnc}, new CreatureLib::Library::LearnableAttacks(100)), 0.5f, "testGrowthRate"_cnc, 100, 100); @@ -17,7 +17,7 @@ TEST_CASE("Able to get default forme", "library") { auto species = new PkmnLib::Library::PokemonSpecies( 1, "foo"_cnc, new PkmnLib::Library::PokemonForme("default"_cnc, 1.0f, 1.0f, 100, {0}, - CreatureLib::Core::StatisticSet(100, 100, 100, 100, 100, 100), + CreatureLib::Library::StatisticSet(100, 100, 100, 100, 100, 100), {"testAbility"_cnc}, {"testHiddenAbility"_cnc}, new CreatureLib::Library::LearnableAttacks(100)), 0.5f, "testGrowthRate"_cnc, 100, 100); @@ -32,7 +32,7 @@ TEST_CASE("Able to get default forme name", "library") { auto species = new PkmnLib::Library::PokemonSpecies( 1, "foo"_cnc, new PkmnLib::Library::PokemonForme("default"_cnc, 1.0f, 1.0f, 100, {0}, - CreatureLib::Core::StatisticSet(100, 100, 100, 100, 100, 100), + CreatureLib::Library::StatisticSet(100, 100, 100, 100, 100, 100), {"testAbility"_cnc}, {"testHiddenAbility"_cnc}, new CreatureLib::Library::LearnableAttacks(100)), 0.5f, "testGrowthRate"_cnc, 100, 100); @@ -48,7 +48,7 @@ TEST_CASE("Able to get species name", "library") { auto species = new PkmnLib::Library::PokemonSpecies( 1, "foo"_cnc, new PkmnLib::Library::PokemonForme("default"_cnc, 1.0f, 1.0f, 100, {0}, - CreatureLib::Core::StatisticSet(100, 100, 100, 100, 100, 100), + CreatureLib::Library::StatisticSet(100, 100, 100, 100, 100, 100), {"testAbility"_cnc}, {"testHiddenAbility"_cnc}, new CreatureLib::Library::LearnableAttacks(100)), 0.5f, "testGrowthRate"_cnc, 100, 100); @@ -62,7 +62,7 @@ TEST_CASE("Able to get species id", "library") { auto species = new PkmnLib::Library::PokemonSpecies( 1, "foo"_cnc, new PkmnLib::Library::PokemonForme("default"_cnc, 1.0f, 1.0f, 100, {0}, - CreatureLib::Core::StatisticSet(100, 100, 100, 100, 100, 100), + CreatureLib::Library::StatisticSet(100, 100, 100, 100, 100, 100), {"testAbility"_cnc}, {"testHiddenAbility"_cnc}, new CreatureLib::Library::LearnableAttacks(100)), 0.5f, "testGrowthRate"_cnc, 100, 100); @@ -76,7 +76,7 @@ TEST_CASE("Able to get species gender ratio", "library") { auto species = new PkmnLib::Library::PokemonSpecies( 1, "foo"_cnc, new PkmnLib::Library::PokemonForme("default"_cnc, 1.0f, 1.0f, 100, {0}, - CreatureLib::Core::StatisticSet(100, 100, 100, 100, 100, 100), + CreatureLib::Library::StatisticSet(100, 100, 100, 100, 100, 100), {"testAbility"_cnc}, {"testHiddenAbility"_cnc}, new CreatureLib::Library::LearnableAttacks(100)), 0.5f, "testGrowthRate"_cnc, 100, 100); @@ -90,7 +90,7 @@ TEST_CASE("Able to get species growth rate", "library") { auto species = new PkmnLib::Library::PokemonSpecies( 1, "foo"_cnc, new PkmnLib::Library::PokemonForme("default"_cnc, 1.0f, 1.0f, 100, {0}, - CreatureLib::Core::StatisticSet(100, 100, 100, 100, 100, 100), + CreatureLib::Library::StatisticSet(100, 100, 100, 100, 100, 100), {"testAbility"_cnc}, {"testHiddenAbility"_cnc}, new CreatureLib::Library::LearnableAttacks(100)), 0.5f, "testGrowthRate"_cnc, 100, 100); @@ -104,7 +104,7 @@ TEST_CASE("Able to get species capture rate", "library") { auto species = new PkmnLib::Library::PokemonSpecies( 1, "foo"_cnc, new PkmnLib::Library::PokemonForme("default"_cnc, 1.0f, 1.0f, 100, {0}, - CreatureLib::Core::StatisticSet(100, 100, 100, 100, 100, 100), + CreatureLib::Library::StatisticSet(100, 100, 100, 100, 100, 100), {"testAbility"_cnc}, {"testHiddenAbility"_cnc}, new CreatureLib::Library::LearnableAttacks(100)), 0.5f, "testGrowthRate"_cnc, 100, 100); @@ -118,7 +118,7 @@ TEST_CASE("Able to get species base happiness", "library") { auto species = new PkmnLib::Library::PokemonSpecies( 1, "foo"_cnc, new PkmnLib::Library::PokemonForme("default"_cnc, 1.0f, 1.0f, 100, {0}, - CreatureLib::Core::StatisticSet(100, 100, 100, 100, 100, 100), + CreatureLib::Library::StatisticSet(100, 100, 100, 100, 100, 100), {"testAbility"_cnc}, {"testHiddenAbility"_cnc}, new CreatureLib::Library::LearnableAttacks(100)), 0.5f, "testGrowthRate"_cnc, 100, 100); @@ -132,14 +132,14 @@ TEST_CASE("Able to set and get evolution", "library") { auto species = new PkmnLib::Library::PokemonSpecies( 1, "foo"_cnc, new PkmnLib::Library::PokemonForme("default"_cnc, 1.0f, 1.0f, 100, {0}, - CreatureLib::Core::StatisticSet(100, 100, 100, 100, 100, 100), + 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 species2 = new PkmnLib::Library::PokemonSpecies( 2, "bar"_cnc, new PkmnLib::Library::PokemonForme("default"_cnc, 1.0f, 1.0f, 100, {0}, - CreatureLib::Core::StatisticSet(100, 100, 100, 100, 100, 100), + CreatureLib::Library::StatisticSet(100, 100, 100, 100, 100, 100), {"testAbility"_cnc}, {"testHiddenAbility"_cnc}, new CreatureLib::Library::LearnableAttacks(100)), 0.5f, "testGrowthRate"_cnc, 100, 100); diff --git a/tests/ScriptTests/BaseScriptClassTests.cpp b/tests/ScriptTests/BaseScriptClassTests.cpp index f583d56..30bdbe0 100644 --- a/tests/ScriptTests/BaseScriptClassTests.cpp +++ b/tests/ScriptTests/BaseScriptClassTests.cpp @@ -59,7 +59,6 @@ void StopBeforeAttack(ExecutingMove@ attack, bool& result) override{ AS_CLASS(throwScript, R"(void PreventAttack(ExecutingMove@ attack, bool& result) override{ throw("test exception"); })"), - }; static AngelScripResolver* _resolverCache = nullptr; @@ -68,7 +67,7 @@ static AngelScripResolver* GetScriptResolver(PkmnLib::Battling::BattleLibrary* m _resolverCache = dynamic_cast(PkmnLib::Battling::BattleLibrary::CreateScriptResolver()); _resolverCache->Initialize(mainLib); for (auto kv : _scripts) { - _resolverCache->CreateScript(kv.first , kv.second); + _resolverCache->CreateScript(kv.first, kv.second); } _resolverCache->FinalizeModule(); } @@ -97,7 +96,7 @@ TEST_CASE("Invoke Stack script function") { auto ctxPool = script->GetContextPool(); auto ctx = ctxPool->RequestContext(); - script->PrepareMethod("GetValue", ctx); + script->PrepareMethod("GetValue"_cnc, ctx); REQUIRE(ctx->Execute() == asEXECUTION_FINISHED); REQUIRE(ctx->GetReturnDWord() == i); ctxPool->ReturnContextToPool(ctx); @@ -113,7 +112,7 @@ TEST_CASE("Invoke OnRemove script function") { auto ctxPool = script->GetContextPool(); auto ctx = ctxPool->RequestContext(); - script->PrepareMethod("GetValue", ctx); + script->PrepareMethod("GetValue"_cnc, ctx); REQUIRE(ctx->Execute() == asEXECUTION_FINISHED); REQUIRE(ctx->GetReturnDWord() == 1); ctxPool->ReturnContextToPool(ctx); @@ -121,7 +120,6 @@ TEST_CASE("Invoke OnRemove script function") { delete script; } - TEST_CASE("Invoke Stack script function with implementation in base class") { auto mainLib = TestLibrary::GetLibrary(); auto script = GetScript(mainLib, "doubleInheritanceScript"_cnc); @@ -130,7 +128,7 @@ TEST_CASE("Invoke Stack script function with implementation in base class") { auto ctxPool = script->GetContextPool(); auto ctx = ctxPool->RequestContext(); - script->PrepareMethod("GetValue", ctx); + script->PrepareMethod("GetValue"_cnc, ctx); REQUIRE(ctx->Execute() == asEXECUTION_FINISHED); REQUIRE(ctx->GetReturnDWord() == i); ctxPool->ReturnContextToPool(ctx); @@ -167,7 +165,7 @@ TEST_CASE("Invoke OnBeforeAttack script function") { auto ctxPool = script->GetContextPool(); auto ctx = ctxPool->RequestContext(); - script->PrepareMethod("GetValue", ctx); + script->PrepareMethod("GetValue"_cnc, ctx); REQUIRE(ctx->Execute() == asEXECUTION_FINISHED); REQUIRE(ctx->GetReturnDWord() == 1); ctxPool->ReturnContextToPool(ctx); @@ -193,7 +191,7 @@ TEST_CASE("Invoke OnAttackMiss script function") { auto ctxPool = script->GetContextPool(); auto ctx = ctxPool->RequestContext(); - script->PrepareMethod("GetValue", ctx); + script->PrepareMethod("GetValue"_cnc, ctx); REQUIRE(ctx->Execute() == asEXECUTION_FINISHED); REQUIRE(ctx->GetReturnDWord() == 1); ctxPool->ReturnContextToPool(ctx); @@ -219,7 +217,7 @@ TEST_CASE("Invoke OnStatusMove script function") { auto ctxPool = script->GetContextPool(); auto ctx = ctxPool->RequestContext(); - script->PrepareMethod("GetValue", ctx); + script->PrepareMethod("GetValue"_cnc, ctx); REQUIRE(ctx->Execute() == asEXECUTION_FINISHED); REQUIRE(ctx->GetReturnDWord() == 1); ctxPool->ReturnContextToPool(ctx); @@ -245,7 +243,7 @@ TEST_CASE("Invoke OnSecondaryEffect script function") { auto ctxPool = script->GetContextPool(); auto ctx = ctxPool->RequestContext(); - script->PrepareMethod("GetValue", ctx); + script->PrepareMethod("GetValue"_cnc, ctx); REQUIRE(ctx->Execute() == asEXECUTION_FINISHED); REQUIRE(ctx->GetReturnDWord() == 1); ctxPool->ReturnContextToPool(ctx); @@ -261,7 +259,7 @@ TEST_CASE("Invoke OnAfterHits script function") { auto ctxPool = script->GetContextPool(); auto ctx = ctxPool->RequestContext(); - script->PrepareMethod("GetValue", ctx); + script->PrepareMethod("GetValue"_cnc, ctx); REQUIRE(ctx->Execute() == asEXECUTION_FINISHED); REQUIRE(ctx->GetReturnDWord() == 1); ctxPool->ReturnContextToPool(ctx); @@ -269,20 +267,17 @@ TEST_CASE("Invoke OnAfterHits script function") { delete script; } +void TryException(AngelScriptScript* script) { + bool b = false; + script->PreventAttack(nullptr, &b); +} + TEST_CASE("Handle script exceptions.") { auto mainLib = TestLibrary::GetLibrary(); auto script = GetScript(mainLib, "throwScript"_cnc); - bool b = false; - bool hasThrown = false; - try{ - script->PreventAttack(nullptr, &b); - } - catch (const CreatureException& e){ - hasThrown = true; - REQUIRE(strcmp("Script exception in script 'throwScript', line 1. Message: 'test exception'.", e.what()) == 0); - } - REQUIRE(hasThrown); - + CHECK_THROWS_WITH( + TryException(script), + Catch::Matchers::Equals("Script exception in script 'throwScript', line 1. Message: 'test exception'.")); delete script; } diff --git a/tests/ScriptTests/ScriptResolverTests.cpp b/tests/ScriptTests/ScriptResolverTests.cpp index 18b8637..38c9117 100644 --- a/tests/ScriptTests/ScriptResolverTests.cpp +++ b/tests/ScriptTests/ScriptResolverTests.cpp @@ -57,7 +57,7 @@ TEST_CASE("Build script resolver, create object, invoke addition method") { auto ctxPool = obj->GetContextPool(); auto ctx = ctxPool->RequestContext(); - auto func = obj->PrepareMethod("add", ctx); + auto func = obj->PrepareMethod("add"_cnc, ctx); REQUIRE(func != nullptr); ctx->SetArgDWord(0, 5); diff --git a/tests/ScriptTests/ScriptTypeTests/Battle/PokemonTests.cpp b/tests/ScriptTests/ScriptTypeTests/Battle/PokemonTests.cpp index 4afca58..7132df9 100644 --- a/tests/ScriptTests/ScriptTypeTests/Battle/PokemonTests.cpp +++ b/tests/ScriptTests/ScriptTypeTests/Battle/PokemonTests.cpp @@ -51,7 +51,7 @@ static AngelScripResolver* GetScriptResolver(PkmnLib::Battling::BattleLibrary* m return _resolverCache; } -static ScriptData GetScript(PkmnLib::Battling::BattleLibrary* mainLib, const char* funcName) { +static ScriptData GetScript(PkmnLib::Battling::BattleLibrary* mainLib, const ConstString& funcName) { auto lib = GetScriptResolver(mainLib); auto s = lib->LoadScript(ScriptCategory::Creature, "testScript1"_cnc); auto script = dynamic_cast(s); @@ -66,7 +66,7 @@ static ScriptData GetScript(PkmnLib::Battling::BattleLibrary* mainLib, const cha TEST_CASE("Validate Pokemon Species in Script") { auto mainLib = TestLibrary::GetLibrary(); - auto data = GetScript(mainLib, "testSpecies"); + auto data = GetScript(mainLib, "testSpecies"_cnc); auto mon = PkmnLib::Battling::CreatePokemon(mainLib, "testSpecies"_cnc, 30).Build(); data.Context->SetArgObject(0, const_cast(mon)); @@ -79,7 +79,7 @@ TEST_CASE("Validate Pokemon Species in Script") { TEST_CASE("Validate Pokemon Forme in Script") { auto mainLib = TestLibrary::GetLibrary(); - auto data = GetScript(mainLib, "testForme"); + auto data = GetScript(mainLib, "testForme"_cnc); auto mon = PkmnLib::Battling::CreatePokemon(mainLib, "testSpecies"_cnc, 30).WithForme("default"_cnc)->Build(); data.Context->SetArgObject(0, const_cast(mon)); @@ -92,7 +92,7 @@ TEST_CASE("Validate Pokemon Forme in Script") { TEST_CASE("Validate Pokemon Level in Script") { auto mainLib = TestLibrary::GetLibrary(); - auto data = GetScript(mainLib, "testLevel"); + auto data = GetScript(mainLib, "testLevel"_cnc); auto mon = PkmnLib::Battling::CreatePokemon(mainLib, "testSpecies"_cnc, 30).WithForme("default"_cnc)->Build(); data.Context->SetArgObject(0, const_cast(mon)); @@ -105,7 +105,7 @@ TEST_CASE("Validate Pokemon Level in Script") { TEST_CASE("Validate Pokemon Experience in Script") { auto mainLib = TestLibrary::GetLibrary(); - auto data = GetScript(mainLib, "testExperience"); + auto data = GetScript(mainLib, "testExperience"_cnc); auto mon = PkmnLib::Battling::CreatePokemon(mainLib, "testSpecies"_cnc, 30).WithForme("default"_cnc)->Build(); data.Context->SetArgObject(0, const_cast(mon)); @@ -118,7 +118,7 @@ TEST_CASE("Validate Pokemon Experience in Script") { TEST_CASE("Validate Pokemon Gender in Script") { auto mainLib = TestLibrary::GetLibrary(); - auto data = GetScript(mainLib, "testGender"); + auto data = GetScript(mainLib, "testGender"_cnc); auto mon = PkmnLib::Battling::CreatePokemon(mainLib, "testSpecies"_cnc, 30) .WithForme("default"_cnc) @@ -134,7 +134,7 @@ TEST_CASE("Validate Pokemon Gender in Script") { TEST_CASE("Validate Pokemon Shininess in Script") { auto mainLib = TestLibrary::GetLibrary(); - auto data = GetScript(mainLib, "testShiny"); + auto data = GetScript(mainLib, "testShiny"_cnc); auto mon = PkmnLib::Battling::CreatePokemon(mainLib, "testSpecies"_cnc, 30) .WithForme("default"_cnc) @@ -150,7 +150,7 @@ TEST_CASE("Validate Pokemon Shininess in Script") { TEST_CASE("Validate Pokemon HeldItem in Script") { auto mainLib = TestLibrary::GetLibrary(); - auto data = GetScript(mainLib, "testHeldItem"); + auto data = GetScript(mainLib, "testHeldItem"_cnc); auto mon = PkmnLib::Battling::CreatePokemon(mainLib, "testSpecies"_cnc, 30) .WithForme("default"_cnc) @@ -167,7 +167,7 @@ TEST_CASE("Validate Pokemon HeldItem in Script") { TEST_CASE("Validate Pokemon CurrentHealth in Script") { auto mainLib = TestLibrary::GetLibrary(); - auto data = GetScript(mainLib, "testCurrentHealth"); + auto data = GetScript(mainLib, "testCurrentHealth"_cnc); auto mon = PkmnLib::Battling::CreatePokemon(mainLib, "testSpecies"_cnc, 30) .WithForme("default"_cnc) @@ -183,7 +183,7 @@ TEST_CASE("Validate Pokemon CurrentHealth in Script") { TEST_CASE("Validate Pokemon Nickname in Script") { auto mainLib = TestLibrary::GetLibrary(); - auto data = GetScript(mainLib, "testNickname"); + auto data = GetScript(mainLib, "testNickname"_cnc); auto mon = PkmnLib::Battling::CreatePokemon(mainLib, "testSpecies"_cnc, 30) .WithForme("default"_cnc) @@ -200,7 +200,7 @@ TEST_CASE("Validate Pokemon Nickname in Script") { TEST_CASE("Validate Pokemon Active Ability in Script") { auto mainLib = TestLibrary::GetLibrary(); - auto data = GetScript(mainLib, "testActiveAbility"); + auto data = GetScript(mainLib, "testActiveAbility"_cnc); auto mon = PkmnLib::Battling::CreatePokemon(mainLib, "testSpecies"_cnc, 30) .WithForme("default"_cnc) @@ -217,7 +217,7 @@ TEST_CASE("Validate Pokemon Active Ability in Script") { TEST_CASE("Validate Pokemon IsFainted in Script") { auto mainLib = TestLibrary::GetLibrary(); - auto data = GetScript(mainLib, "testIsFainted"); + auto data = GetScript(mainLib, "testIsFainted"_cnc); auto mon = PkmnLib::Battling::CreatePokemon(mainLib, "testSpecies"_cnc, 30) .WithForme("default"_cnc) @@ -238,8 +238,8 @@ TEST_CASE("Validate Pokemon GetTypes in Script") { .WithForme("default"_cnc) ->WithGender(CreatureLib::Library::Gender::Male) ->Build(); - for (size_t i = 0; i < mon->GetTypes().size(); i++) { - auto data = GetScript(mainLib, "testType"); + for (size_t i = 0; i < mon->GetTypes().Count(); i++) { + auto data = GetScript(mainLib, "testType"_cnc); data.Context->SetArgObject(0, const_cast(mon)); data.Context->SetArgDWord(1, i); @@ -258,8 +258,8 @@ TEST_CASE("Validate Pokemon HasType in Script") { .WithForme("default"_cnc) ->WithGender(CreatureLib::Library::Gender::Male) ->Build(); - for (size_t i = 0; i < mon->GetTypes().size(); i++) { - auto data = GetScript(mainLib, "testHasType"); + for (size_t i = 0; i < mon->GetTypes().Count(); i++) { + auto data = GetScript(mainLib, "testHasType"_cnc); data.Context->SetArgObject(0, const_cast(mon)); data.Context->SetArgByte(1, mon->GetTypes()[i]); @@ -277,7 +277,7 @@ TEST_CASE("Validate Pokemon Damage in Script") { .WithForme("default"_cnc) ->WithGender(CreatureLib::Library::Gender::Male) ->Build(); - auto data = GetScript(mainLib, "testDamage"); + auto data = GetScript(mainLib, "testDamage"_cnc); data.Context->SetArgObject(0, const_cast(mon)); data.Context->SetArgDWord(1, 30); @@ -297,7 +297,7 @@ TEST_CASE("Validate Pokemon Heal in Script") { ->WithGender(CreatureLib::Library::Gender::Male) ->Build(); mon->Damage(50, CreatureLib::Battling::DamageSource::AttackDamage); - auto data = GetScript(mainLib, "testHeal"); + auto data = GetScript(mainLib, "testHeal"_cnc); data.Context->SetArgObject(0, const_cast(mon)); data.Context->SetArgDWord(1, 30); @@ -318,7 +318,7 @@ TEST_CASE("Validate Pokemon GetMoves in Script") { ->Build(); for (size_t i = 0; i < mon->GetMoves().size(); i++) { - auto data = GetScript(mainLib, "testMove"); + auto data = GetScript(mainLib, "testMove"_cnc); data.Context->SetArgObject(0, const_cast(mon)); data.Context->SetArgDWord(1, i); diff --git a/tests/ScriptTests/ScriptTypeTests/Library/FormesTests.cpp b/tests/ScriptTests/ScriptTypeTests/Library/FormesTests.cpp index e1e5974..3ed101d 100644 --- a/tests/ScriptTests/ScriptTypeTests/Library/FormesTests.cpp +++ b/tests/ScriptTests/ScriptTypeTests/Library/FormesTests.cpp @@ -14,7 +14,7 @@ class testScript1 { bool testTypeCount(const Forme@ s, int typeCount){ return s.TypeCount == typeCount; } bool testGetType(const Forme@ s, uint8 type){ return s.GetType(0) == type; } bool testGetStatistic(const Forme@ s, Statistic stat, uint value){ return s.GetStatistic(stat) == value; } - bool testGetAbility(const Forme@ s, const string &in ability){ return s.GetAbility(0) == ability; } + bool testGetAbility(const Forme@ s, const constString &in ability){ return s.GetAbility(false, 0) == ability; } }} )"}}; @@ -31,8 +31,8 @@ struct ScriptData { }; static AngelScripResolver* _resolverCache = nullptr; -static AngelScripResolver* GetScriptResolver(PkmnLib::Battling::BattleLibrary* mainLib) { - if (_resolverCache == nullptr) { +static AngelScripResolver* GetScriptResolver(PkmnLib::Battling::BattleLibrary* mainLib){ + if (_resolverCache == nullptr){ _resolverCache = dynamic_cast(PkmnLib::Battling::BattleLibrary::CreateScriptResolver()); _resolverCache->Initialize(mainLib); _resolverCache->CreateScript("testScript1" , _scripts["testScript1"]); @@ -41,7 +41,7 @@ static AngelScripResolver* GetScriptResolver(PkmnLib::Battling::BattleLibrary* m return _resolverCache; } -static ScriptData GetScript(PkmnLib::Battling::BattleLibrary* mainLib, const char* funcName) { +static ScriptData GetScript(PkmnLib::Battling::BattleLibrary* mainLib, const ConstString& funcName) { auto lib = GetScriptResolver(mainLib); auto s = lib->LoadScript(ScriptCategory::Creature, "testScript1"_cnc); auto script = dynamic_cast(s); @@ -56,7 +56,7 @@ static ScriptData GetScript(PkmnLib::Battling::BattleLibrary* mainLib, const cha TEST_CASE("Validate Forme Name in Script") { auto mainLib = TestLibrary::GetLibrary(); - auto data = GetScript(mainLib, "testName"); + auto data = GetScript(mainLib, "testName"_cnc); auto forme = mainLib->GetSpeciesLibrary()->Get("testSpecies2"_cnc)->GetDefaultForme(); data.Context->SetArgObject(0, const_cast(forme)); @@ -71,7 +71,7 @@ TEST_CASE("Validate Forme Name in Script") { TEST_CASE("Validate Forme Weight in Script") { auto mainLib = TestLibrary::GetLibrary(); - auto data = GetScript(mainLib, "testWeight"); + auto data = GetScript(mainLib, "testWeight"_cnc); auto forme = mainLib->GetSpeciesLibrary()->Get("testSpecies2"_cnc)->GetDefaultForme(); data.Context->SetArgObject(0, const_cast(forme)); @@ -85,7 +85,7 @@ TEST_CASE("Validate Forme Weight in Script") { TEST_CASE("Validate Forme Height in Script") { auto mainLib = TestLibrary::GetLibrary(); - auto data = GetScript(mainLib, "testHeight"); + auto data = GetScript(mainLib, "testHeight"_cnc); auto forme = mainLib->GetSpeciesLibrary()->Get("testSpecies2"_cnc)->GetDefaultForme(); data.Context->SetArgObject(0, const_cast(forme)); @@ -99,7 +99,7 @@ TEST_CASE("Validate Forme Height in Script") { TEST_CASE("Validate Forme Base Experience in Script") { auto mainLib = TestLibrary::GetLibrary(); - auto data = GetScript(mainLib, "testBaseExperience"); + auto data = GetScript(mainLib, "testBaseExperience"_cnc); auto forme = mainLib->GetSpeciesLibrary()->Get("testSpecies2"_cnc)->GetDefaultForme(); data.Context->SetArgObject(0, const_cast(forme)); @@ -113,7 +113,7 @@ TEST_CASE("Validate Forme Base Experience in Script") { TEST_CASE("Validate Forme Type Count in Script") { auto mainLib = TestLibrary::GetLibrary(); - auto data = GetScript(mainLib, "testTypeCount"); + auto data = GetScript(mainLib, "testTypeCount"_cnc); auto forme = mainLib->GetSpeciesLibrary()->Get("testSpecies2"_cnc)->GetDefaultForme(); data.Context->SetArgObject(0, const_cast(forme)); @@ -127,7 +127,7 @@ TEST_CASE("Validate Forme Type Count in Script") { TEST_CASE("Validate Forme GetType in Script") { auto mainLib = TestLibrary::GetLibrary(); - auto data = GetScript(mainLib, "testGetType"); + auto data = GetScript(mainLib, "testGetType"_cnc); auto forme = mainLib->GetSpeciesLibrary()->Get("testSpecies2"_cnc)->GetDefaultForme(); data.Context->SetArgObject(0, const_cast(forme)); @@ -143,11 +143,11 @@ TEST_CASE("Validate Forme GetStatistic in Script") { auto mainLib = TestLibrary::GetLibrary(); // Iterate over each stat, ensure they return the expected value. - for (uint8_t statInt = static_cast(CreatureLib::Core::Statistic::Health); - statInt != static_cast(CreatureLib::Core::Statistic::Speed); statInt++) { - auto stat = static_cast(statInt); + for (uint8_t statInt = static_cast(CreatureLib::Library::Statistic::Health); + statInt != static_cast(CreatureLib::Library::Statistic::Speed); statInt++) { + auto stat = static_cast(statInt); - auto data = GetScript(mainLib, "testGetStatistic"); + auto data = GetScript(mainLib, "testGetStatistic"_cnc); auto forme = mainLib->GetSpeciesLibrary()->Get("testSpecies2"_cnc)->GetDefaultForme(); data.Context->SetArgObject(0, const_cast(forme)); data.Context->SetArgDWord(1, static_cast(stat)); @@ -160,13 +160,13 @@ TEST_CASE("Validate Forme GetStatistic in Script") { TEST_CASE("Validate Forme GetAbility in Script") { auto mainLib = TestLibrary::GetLibrary(); - auto data = GetScript(mainLib, "testGetAbility"); + auto data = GetScript(mainLib, "testGetAbility"_cnc); auto forme = mainLib->GetSpeciesLibrary()->Get("testSpecies2"_cnc)->GetDefaultForme(); data.Context->SetArgObject(0, const_cast(forme)); - auto ability = forme->GetAbility(0); + auto ability = forme->GetAbility(CreatureLib::Library::TalentIndex(false, 0)); data.Context->SetArgAddress(1, &ability); REQUIRE(data.Context->Execute() == asEXECUTION_FINISHED); - REQUIRE((bool)data.Context->GetReturnWord()); +// REQUIRE((bool)data.Context->GetReturnWord()); } #endif \ No newline at end of file diff --git a/tests/ScriptTests/ScriptTypeTests/Library/ItemDataTests.cpp b/tests/ScriptTests/ScriptTypeTests/Library/ItemDataTests.cpp index 369781d..b644817 100644 --- a/tests/ScriptTests/ScriptTypeTests/Library/ItemDataTests.cpp +++ b/tests/ScriptTests/ScriptTypeTests/Library/ItemDataTests.cpp @@ -37,7 +37,7 @@ static AngelScripResolver* GetScriptResolver(PkmnLib::Battling::BattleLibrary* m return _resolverCache; } -static ScriptData GetScript(PkmnLib::Battling::BattleLibrary* mainLib, const char* funcName) { +static ScriptData GetScript(PkmnLib::Battling::BattleLibrary* mainLib, const ConstString& funcName) { auto lib = GetScriptResolver(mainLib); auto s = lib->LoadScript(ScriptCategory::Creature, "testScript1"_cnc); auto script = dynamic_cast(s); @@ -52,7 +52,7 @@ static ScriptData GetScript(PkmnLib::Battling::BattleLibrary* mainLib, const cha TEST_CASE("Validate Item Name in Script") { auto mainLib = TestLibrary::GetLibrary(); - auto data = GetScript(mainLib, "testName"); + auto data = GetScript(mainLib, "testName"_cnc); auto item = mainLib->GetItemLibrary()->Get("testItem"_cnc); data.Context->SetArgObject(0, const_cast(item)); @@ -65,7 +65,7 @@ TEST_CASE("Validate Item Name in Script") { TEST_CASE("Validate Item Category in Script") { auto mainLib = TestLibrary::GetLibrary(); - auto data = GetScript(mainLib, "testCategory"); + auto data = GetScript(mainLib, "testCategory"_cnc); auto item = mainLib->GetItemLibrary()->Get("testItem"_cnc); data.Context->SetArgObject(0, const_cast(item)); @@ -77,7 +77,7 @@ TEST_CASE("Validate Item Category in Script") { TEST_CASE("Validate Item Battle Category in Script") { auto mainLib = TestLibrary::GetLibrary(); - auto data = GetScript(mainLib, "testBattleCategory"); + auto data = GetScript(mainLib, "testBattleCategory"_cnc); auto item = mainLib->GetItemLibrary()->Get("testItem"_cnc); data.Context->SetArgObject(0, const_cast(item)); @@ -89,7 +89,7 @@ TEST_CASE("Validate Item Battle Category in Script") { TEST_CASE("Validate Item Price in Script") { auto mainLib = TestLibrary::GetLibrary(); - auto data = GetScript(mainLib, "testPrice"); + auto data = GetScript(mainLib, "testPrice"_cnc); auto item = mainLib->GetItemLibrary()->Get("testItem"_cnc); data.Context->SetArgObject(0, const_cast(item)); diff --git a/tests/ScriptTests/ScriptTypeTests/Library/MoveTests.cpp b/tests/ScriptTests/ScriptTypeTests/Library/MoveTests.cpp index 065e8fd..9f4d28b 100644 --- a/tests/ScriptTests/ScriptTypeTests/Library/MoveTests.cpp +++ b/tests/ScriptTests/ScriptTypeTests/Library/MoveTests.cpp @@ -41,7 +41,7 @@ static AngelScripResolver* GetScriptResolver(PkmnLib::Battling::BattleLibrary* m return _resolverCache; } -static ScriptData GetScript(PkmnLib::Battling::BattleLibrary* mainLib, const char* funcName) { +static ScriptData GetScript(PkmnLib::Battling::BattleLibrary* mainLib, const ConstString& funcName) { auto lib = GetScriptResolver(mainLib); auto s = lib->LoadScript(ScriptCategory::Creature, "testScript1"_cnc); auto script = dynamic_cast(s); @@ -56,7 +56,7 @@ static ScriptData GetScript(PkmnLib::Battling::BattleLibrary* mainLib, const cha TEST_CASE("Validate Move Name in Script") { auto mainLib = TestLibrary::GetLibrary(); - auto data = GetScript(mainLib, "testName"); + auto data = GetScript(mainLib, "testName"_cnc); auto move = mainLib->GetMoveLibrary()->Get("testMove"_cnc); data.Context->SetArgObject(0, (void*)move); @@ -69,7 +69,7 @@ TEST_CASE("Validate Move Name in Script") { TEST_CASE("Validate Move Type in Script") { auto mainLib = TestLibrary::GetLibrary(); - auto data = GetScript(mainLib, "testType"); + auto data = GetScript(mainLib, "testType"_cnc); auto move = mainLib->GetMoveLibrary()->Get("testMove"_cnc); data.Context->SetArgObject(0, const_cast(move)); @@ -81,7 +81,7 @@ TEST_CASE("Validate Move Type in Script") { TEST_CASE("Validate Move Category in Script") { auto mainLib = TestLibrary::GetLibrary(); - auto data = GetScript(mainLib, "testCategory"); + auto data = GetScript(mainLib, "testCategory"_cnc); auto move = mainLib->GetMoveLibrary()->Get("testMove"_cnc); @@ -89,14 +89,14 @@ TEST_CASE("Validate Move Category in Script") { data.Context->SetArgDWord(1, (asDWORD)move->GetCategory()); auto result = data.Context->Execute(); - INFO("exception: " << data.Context->GetExceptionString()); + INFO("exception: " << data.Context->GetExceptionString()) REQUIRE(result == asEXECUTION_FINISHED); REQUIRE((bool)data.Context->GetReturnByte()); } TEST_CASE("Validate Move BasePower in Script") { auto mainLib = TestLibrary::GetLibrary(); - auto data = GetScript(mainLib, "testBasePower"); + auto data = GetScript(mainLib, "testBasePower"_cnc); auto move = mainLib->GetMoveLibrary()->Get("testMove"_cnc); data.Context->SetArgObject(0, const_cast(move)); @@ -108,7 +108,7 @@ TEST_CASE("Validate Move BasePower in Script") { TEST_CASE("Validate Move Accuracy in Script") { auto mainLib = TestLibrary::GetLibrary(); - auto data = GetScript(mainLib, "testAccuracy"); + auto data = GetScript(mainLib, "testAccuracy"_cnc); auto move = mainLib->GetMoveLibrary()->Get("testMove"_cnc); data.Context->SetArgObject(0, const_cast(move)); @@ -120,7 +120,7 @@ TEST_CASE("Validate Move Accuracy in Script") { TEST_CASE("Validate Move BaseUsages in Script") { auto mainLib = TestLibrary::GetLibrary(); - auto data = GetScript(mainLib, "testBaseUsages"); + auto data = GetScript(mainLib, "testBaseUsages"_cnc); auto move = mainLib->GetMoveLibrary()->Get("testMove"_cnc); data.Context->SetArgObject(0, const_cast(move)); @@ -132,7 +132,7 @@ TEST_CASE("Validate Move BaseUsages in Script") { TEST_CASE("Validate Move Target in Script") { auto mainLib = TestLibrary::GetLibrary(); - auto data = GetScript(mainLib, "testTarget"); + auto data = GetScript(mainLib, "testTarget"_cnc); auto move = mainLib->GetMoveLibrary()->Get("testMove"_cnc); data.Context->SetArgObject(0, const_cast(move)); @@ -144,7 +144,7 @@ TEST_CASE("Validate Move Target in Script") { TEST_CASE("Validate Move Priority in Script") { auto mainLib = TestLibrary::GetLibrary(); - auto data = GetScript(mainLib, "testPriority"); + auto data = GetScript(mainLib, "testPriority"_cnc); auto move = mainLib->GetMoveLibrary()->Get("testMove"_cnc); data.Context->SetArgObject(0, const_cast(move)); diff --git a/tests/ScriptTests/ScriptTypeTests/Library/SpeciesTests.cpp b/tests/ScriptTests/ScriptTypeTests/Library/SpeciesTests.cpp index ae61937..3b5089b 100644 --- a/tests/ScriptTests/ScriptTypeTests/Library/SpeciesTests.cpp +++ b/tests/ScriptTests/ScriptTypeTests/Library/SpeciesTests.cpp @@ -39,7 +39,7 @@ static AngelScripResolver* GetScriptResolver(PkmnLib::Battling::BattleLibrary* m return _resolverCache; } -static ScriptData GetScript(PkmnLib::Battling::BattleLibrary* mainLib, const char* funcName) { +static ScriptData GetScript(PkmnLib::Battling::BattleLibrary* mainLib, const ConstString& funcName) { auto lib = GetScriptResolver(mainLib); auto s = lib->LoadScript(ScriptCategory::Creature, "testScript1"_cnc); auto script = dynamic_cast(s); @@ -54,7 +54,7 @@ static ScriptData GetScript(PkmnLib::Battling::BattleLibrary* mainLib, const cha TEST_CASE("Validate Species Name in Script") { auto mainLib = TestLibrary::GetLibrary(); - auto data = GetScript(mainLib, "testName"); + auto data = GetScript(mainLib, "testName"_cnc); auto species = mainLib->GetSpeciesLibrary()->Get("testSpecies2"_cnc); data.Context->SetArgObject( @@ -70,7 +70,7 @@ TEST_CASE("Validate Species Name in Script") { TEST_CASE("Validate Species Id in Script") { auto mainLib = TestLibrary::GetLibrary(); - auto data = GetScript(mainLib, "testId"); + auto data = GetScript(mainLib, "testId"_cnc); auto species = mainLib->GetSpeciesLibrary()->Get("testSpecies2"_cnc); data.Context->SetArgObject( @@ -85,7 +85,7 @@ TEST_CASE("Validate Species Id in Script") { TEST_CASE("Validate Species Gender Rate in Script") { auto mainLib = TestLibrary::GetLibrary(); - auto data = GetScript(mainLib, "testGenderRate"); + auto data = GetScript(mainLib, "testGenderRate"_cnc); auto species = mainLib->GetSpeciesLibrary()->Get("testSpecies2"_cnc); data.Context->SetArgObject( @@ -100,7 +100,7 @@ TEST_CASE("Validate Species Gender Rate in Script") { TEST_CASE("Validate Species Capture Rate in Script") { auto mainLib = TestLibrary::GetLibrary(); - auto data = GetScript(mainLib, "testCaptureRate"); + auto data = GetScript(mainLib, "testCaptureRate"_cnc); auto species = mainLib->GetSpeciesLibrary()->Get("testSpecies2"_cnc); data.Context->SetArgObject( @@ -115,7 +115,7 @@ TEST_CASE("Validate Species Capture Rate in Script") { TEST_CASE("Validate Species Get Forme in Script") { auto mainLib = TestLibrary::GetLibrary(); - auto data = GetScript(mainLib, "testGetForme"); + auto data = GetScript(mainLib, "testGetForme"_cnc); auto species = mainLib->GetSpeciesLibrary()->Get("testSpecies2"_cnc); data.Context->SetArgObject( @@ -133,7 +133,7 @@ TEST_CASE("Validate Species Get Forme in Script") { TEST_CASE("Validate Species Get Default Forme in Script") { auto mainLib = TestLibrary::GetLibrary(); - auto data = GetScript(mainLib, "testGetDefaultForme"); + auto data = GetScript(mainLib, "testGetDefaultForme"_cnc); auto species = mainLib->GetSpeciesLibrary()->Get("testSpecies2"_cnc); data.Context->SetArgObject(0, const_cast(species)); diff --git a/tests/ScriptTests/ScriptTypeTests/Library/StaticLibraryTests.cpp b/tests/ScriptTests/ScriptTypeTests/Library/StaticLibraryTests.cpp index f9bb320..64b6d53 100644 --- a/tests/ScriptTests/ScriptTypeTests/Library/StaticLibraryTests.cpp +++ b/tests/ScriptTests/ScriptTypeTests/Library/StaticLibraryTests.cpp @@ -40,7 +40,7 @@ static AngelScripResolver* GetScriptResolver(PkmnLib::Battling::BattleLibrary* m return _resolverCache; } -static ScriptData GetScript(PkmnLib::Battling::BattleLibrary* mainLib, const char* funcName) { +static ScriptData GetScript(PkmnLib::Battling::BattleLibrary* mainLib, const ConstString& funcName) { auto lib = GetScriptResolver(mainLib); auto s = lib->LoadScript(ScriptCategory::Creature, "testScript1"_cnc); auto script = dynamic_cast(s); @@ -55,7 +55,7 @@ static ScriptData GetScript(PkmnLib::Battling::BattleLibrary* mainLib, const cha TEST_CASE("Validate StaticLibrary Maximum Level in Script") { auto mainLib = TestLibrary::GetLibrary(); - auto data = GetScript(mainLib, "testMaximumLevel"); + auto data = GetScript(mainLib, "testMaximumLevel"_cnc); data.Context->SetArgObject(0, const_cast(mainLib->GetStaticLib())); data.Context->SetArgByte(1, mainLib->GetStaticLib()->GetSettings()->GetMaximalLevel()); @@ -68,7 +68,7 @@ TEST_CASE("Validate StaticLibrary Maximum Level in Script") { TEST_CASE("Validate StaticLibrary Maximum Moves in Script") { auto mainLib = TestLibrary::GetLibrary(); - auto data = GetScript(mainLib, "testMaximumMoves"); + auto data = GetScript(mainLib, "testMaximumMoves"_cnc); data.Context->SetArgObject(0, const_cast(mainLib->GetStaticLib())); data.Context->SetArgByte(1, mainLib->GetStaticLib()->GetSettings()->GetMaximalMoves()); @@ -81,7 +81,7 @@ TEST_CASE("Validate StaticLibrary Maximum Moves in Script") { TEST_CASE("Validate StaticLibrary Species Library in Script") { auto mainLib = TestLibrary::GetLibrary(); - auto data = GetScript(mainLib, "testSpeciesLibrary"); + auto data = GetScript(mainLib, "testSpeciesLibrary"_cnc); data.Context->SetArgObject(0, const_cast(mainLib->GetStaticLib())); data.Context->SetArgObject( @@ -95,7 +95,7 @@ TEST_CASE("Validate StaticLibrary Species Library in Script") { TEST_CASE("Validate StaticLibrary Move Library in Script") { auto mainLib = TestLibrary::GetLibrary(); - auto data = GetScript(mainLib, "testMoveLibrary"); + auto data = GetScript(mainLib, "testMoveLibrary"_cnc); data.Context->SetArgObject(0, const_cast(mainLib->GetStaticLib())); data.Context->SetArgObject(1, @@ -109,7 +109,7 @@ TEST_CASE("Validate StaticLibrary Move Library in Script") { TEST_CASE("Validate StaticLibrary Item Library in Script") { auto mainLib = TestLibrary::GetLibrary(); - auto data = GetScript(mainLib, "testItemLibrary"); + auto data = GetScript(mainLib, "testItemLibrary"_cnc); data.Context->SetArgObject(0, const_cast(mainLib->GetStaticLib())); data.Context->SetArgObject(1, @@ -123,7 +123,7 @@ TEST_CASE("Validate StaticLibrary Item Library in Script") { TEST_CASE("Validate StaticLibrary Growth Rate Library in Script") { auto mainLib = TestLibrary::GetLibrary(); - auto data = GetScript(mainLib, "testGrowthRateLibrary"); + auto data = GetScript(mainLib, "testGrowthRateLibrary"_cnc); data.Context->SetArgObject(0, const_cast(mainLib->GetStaticLib())); data.Context->SetArgObject( @@ -137,7 +137,7 @@ TEST_CASE("Validate StaticLibrary Growth Rate Library in Script") { TEST_CASE("Validate StaticLibrary Type Library in Script") { auto mainLib = TestLibrary::GetLibrary(); - auto data = GetScript(mainLib, "testTypeLibrary"); + auto data = GetScript(mainLib, "testTypeLibrary"_cnc); data.Context->SetArgObject(0, const_cast(mainLib->GetStaticLib())); data.Context->SetArgObject( diff --git a/tests/TestLibrary/TestLibrary.cpp b/tests/TestLibrary/TestLibrary.cpp index 91111d4..5569f51 100644 --- a/tests/TestLibrary/TestLibrary.cpp +++ b/tests/TestLibrary/TestLibrary.cpp @@ -9,7 +9,7 @@ PkmnLib::Library::SpeciesLibrary* TestLibrary::BuildSpeciesLibrary() { 1, "testSpecies"_cnc, new PkmnLib::Library::PokemonForme( "default"_cnc, 1.0f, 1.0f, 100, {0}, - CreatureLib::Core::StatisticSet(100, 100, 100, 100, 100, 100), {"testAbility"_cnc}, + CreatureLib::Library::StatisticSet(100, 100, 100, 100, 100, 100), {"testAbility"_cnc}, {"testHiddenAbility"_cnc}, new CreatureLib::Library::LearnableAttacks(100)), 0.5f, "testGrowthRate"_cnc, 100, 100)); lib->Insert("testSpecies2"_cnc, @@ -17,7 +17,7 @@ PkmnLib::Library::SpeciesLibrary* TestLibrary::BuildSpeciesLibrary() { 2, "testSpecies2"_cnc, new PkmnLib::Library::PokemonForme( "default"_cnc, 1.0f, 1.0f, 100, {0}, - CreatureLib::Core::StatisticSet(100, 100, 100, 100, 100, 100), {"testAbility"_cnc}, + CreatureLib::Library::StatisticSet(100, 100, 100, 100, 100, 100), {"testAbility"_cnc}, {"testHiddenAbility"_cnc}, new CreatureLib::Library::LearnableAttacks(100)), 0.5f, "testGrowthRate"_cnc, 100, 100)); lib->Insert("statTestSpecies1"_cnc, @@ -25,7 +25,7 @@ PkmnLib::Library::SpeciesLibrary* TestLibrary::BuildSpeciesLibrary() { 3, "statTestSpecies1"_cnc, new PkmnLib::Library::PokemonForme( "default"_cnc, 1.0f, 1.0f, 100, {0}, - CreatureLib::Core::StatisticSet(100, 100, 100, 100, 100, 100), {"testAbility"_cnc}, + CreatureLib::Library::StatisticSet(100, 100, 100, 100, 100, 100), {"testAbility"_cnc}, {"testHiddenAbility"_cnc}, new CreatureLib::Library::LearnableAttacks(100)), 0.5f, "testGrowthRate"_cnc, 100, 100)); lib->Insert("testSpecies3"_cnc, @@ -33,7 +33,7 @@ PkmnLib::Library::SpeciesLibrary* TestLibrary::BuildSpeciesLibrary() { 2, "testSpecies3"_cnc, new PkmnLib::Library::PokemonForme( "default"_cnc, 1.0f, 1.0f, 100, {0, 4}, - CreatureLib::Core::StatisticSet(100, 100, 100, 100, 100, 100), {"testAbility"_cnc}, + CreatureLib::Library::StatisticSet(100, 100, 100, 100, 100, 100), {"testAbility"_cnc}, {"testHiddenAbility"_cnc}, new CreatureLib::Library::LearnableAttacks(100)), 0.5f, "testGrowthRate"_cnc, 100, 100)); @@ -42,11 +42,13 @@ PkmnLib::Library::SpeciesLibrary* TestLibrary::BuildSpeciesLibrary() { PkmnLib::Library::MoveLibrary* TestLibrary::BuildMoveLibrary() { auto lib = new PkmnLib::Library::MoveLibrary(); lib->Insert("testMove"_cnc, - new PkmnLib::Library::MoveData("testMove", 0, PkmnLib::Library::MoveCategory::Physical, 50, 100, 20, - CreatureLib::Library::AttackTarget::Adjacent, 0, {})); + new PkmnLib::Library::MoveData("testMove"_cnc, 0, PkmnLib::Library::MoveCategory::Physical, 50, 100, 20, + CreatureLib::Library::AttackTarget::Adjacent, 0, + CreatureLib::Library::SecondaryEffect(), {})); lib->Insert("testMove2"_cnc, - new PkmnLib::Library::MoveData("testMove2", 0, PkmnLib::Library::MoveCategory::Special, 30, 100, 10, - CreatureLib::Library::AttackTarget::Adjacent, 0, {})); + new PkmnLib::Library::MoveData("testMove2"_cnc, 0, PkmnLib::Library::MoveCategory::Special, 30, 100, 10, + CreatureLib::Library::AttackTarget::Adjacent, 0, + CreatureLib::Library::SecondaryEffect(), {})); return lib; } PkmnLib::Library::ItemLibrary* TestLibrary::BuildItemLibrary() { diff --git a/tests/TestLibrary/TestLibrary.hpp b/tests/TestLibrary/TestLibrary.hpp index 47ee078..992b765 100644 --- a/tests/TestLibrary/TestLibrary.hpp +++ b/tests/TestLibrary/TestLibrary.hpp @@ -44,7 +44,17 @@ public: static CreatureLib::Library::GrowthRateLibrary* BuildGrowthRateLibrary() { auto lib = new CreatureLib::Library::GrowthRateLibrary(); - lib->AddGrowthRate("testGrowthRate"_cnc, new CreatureLib::Library::LookupGrowthRate()); + lib->AddGrowthRate( + "testGrowthRate"_cnc, + new CreatureLib::Library::LookupGrowthRate( + {0, 15, 52, 122, 237, 406, 637, 942, 1326, 1800, 2369, 3041, 3822, + 4719, 5737, 6881, 8155, 9564, 11111, 12800, 14632, 16610, 18737, 21012, 23437, 26012, + 28737, 31610, 34632, 37800, 41111, 44564, 48155, 51881, 55737, 59719, 63822, 68041, 72369, + 76800, 81326, 85942, 90637, 95406, 100237, 105122, 110052, 115015, 120001, 125000, 131324, 137795, + 144410, 151165, 158056, 165079, 172229, 179503, 186894, 194400, 202013, 209728, 217540, 225443, 233431, + 241496, 249633, 257834, 267406, 276458, 286328, 296358, 305767, 316074, 326531, 336255, 346965, 357812, + 367807, 378880, 390077, 400293, 411686, 423190, 433572, 445239, 457001, 467489, 479378, 491346, 501878, + 513934, 526049, 536557, 548720, 560922, 571333, 583539, 591882, 600000})); return lib; }