Update to the latest CreatureLib version.
This commit is contained in:
parent
29a82a5e75
commit
48ef465c82
|
@ -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} )
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
namespace PkmnLib::Battling {
|
||||
class Battle : public CreatureLib::Battling::Battle {
|
||||
public:
|
||||
Battle(const BattleLibrary* library, const std::vector<CreatureLib::Battling::BattleParty>& parties,
|
||||
Battle(const BattleLibrary* library, const List<CreatureLib::Battling::BattleParty*>& parties,
|
||||
bool canFlee = true, uint8_t numberOfSides = 2, uint8_t creaturesPerSide = 1)
|
||||
: CreatureLib::Battling::Battle(library, parties, canFlee, numberOfSides, creaturesPerSide) {}
|
||||
};
|
||||
|
|
|
@ -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<float>(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<LearnedMove*>(attack->GetAttack());
|
||||
auto moveData = learnedMove->GetMoveData();
|
||||
if (moveData->GetCategory() == Library::MoveCategory::Physical) {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -9,7 +9,7 @@ uint32_t PkmnLib::Battling::StatCalculator::CalculateHealthStat(const Pokemon* p
|
|||
return static_cast<uint32_t>(((2 * base + iv + static_cast<uint32_t>(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<uint32_t>(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<uint32_t>
|
||||
CreatureLib::Library::StatisticSet<uint32_t>
|
||||
PkmnLib::Battling::StatCalculator::CalculateFlatStats(CreatureLib::Battling::Creature* creature) const {
|
||||
auto pkmn = dynamic_cast<Pokemon*>(creature);
|
||||
return CreatureLib::Core::StatisticSet<uint32_t>(
|
||||
return CreatureLib::Library::StatisticSet<uint32_t>(
|
||||
CalculateHealthStat(pkmn), CalculateOtherStat(pkmn, Library::Statistic::PhysicalAttack),
|
||||
CalculateOtherStat(pkmn, Library::Statistic::PhysicalDefense),
|
||||
CalculateOtherStat(pkmn, Library::Statistic::SpecialAttack),
|
||||
CalculateOtherStat(pkmn, Library::Statistic::SpecialDefense),
|
||||
CalculateOtherStat(pkmn, Library::Statistic::Speed));
|
||||
}
|
||||
CreatureLib::Core::StatisticSet<uint32_t>
|
||||
CreatureLib::Library::StatisticSet<uint32_t>
|
||||
PkmnLib::Battling::StatCalculator::CalculateBoostedStats(CreatureLib::Battling::Creature* creature) const {
|
||||
return CreatureLib::Core::StatisticSet<uint32_t>(
|
||||
return CreatureLib::Library::StatisticSet<uint32_t>(
|
||||
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<Pokemon*>(creature));
|
||||
return CalculateOtherStat(dynamic_cast<Pokemon*>(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);
|
||||
}
|
||||
|
|
|
@ -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<uint32_t>
|
||||
CreatureLib::Library::StatisticSet<uint32_t>
|
||||
CalculateFlatStats(CreatureLib::Battling::Creature* creature) const override;
|
||||
|
||||
CreatureLib::Core::StatisticSet<uint32_t>
|
||||
CreatureLib::Library::StatisticSet<uint32_t>
|
||||
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;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -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<CreatureLib::Battling::LearnedAttack*>(_attacks.size());
|
||||
for (size_t i = 0; i < attacks.size(); i++) {
|
||||
auto attacks = List<CreatureLib::Battling::LearnedAttack*>(_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);
|
||||
|
|
|
@ -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<CreatureLib::Library::Gender>(-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);
|
||||
|
||||
|
|
|
@ -10,8 +10,8 @@
|
|||
namespace PkmnLib::Battling {
|
||||
class Pokemon : public CreatureLib::Battling::Creature {
|
||||
private:
|
||||
CreatureLib::Core::StatisticSet<uint8_t> _individualValues;
|
||||
CreatureLib::Core::StatisticSet<uint8_t> _effortValues;
|
||||
CreatureLib::Library::StatisticSet<uint8_t> _individualValues;
|
||||
CreatureLib::Library::StatisticSet<uint8_t> _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<CreatureLib::Battling::LearnedAttack*> moves,
|
||||
CreatureLib::Core::StatisticSet<uint8_t> individualValues,
|
||||
CreatureLib::Core::StatisticSet<uint8_t> effortValues, uint8_t nature)
|
||||
const std::string& nickname, const CreatureLib::Library::TalentIndex& talent,
|
||||
List<CreatureLib::Battling::LearnedAttack*> moves,
|
||||
CreatureLib::Library::StatisticSet<uint8_t> individualValues,
|
||||
CreatureLib::Library::StatisticSet<uint8_t> 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<const Library::PokemonForme*>(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); }
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -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<Arbutils::CaseInsensitiveConstString> flags, uint8_t flingPower)
|
||||
std::unordered_set<uint32_t> flags, uint8_t flingPower)
|
||||
: CreatureLib::Library::Item(name, category, battleCategory, price, flags), _flingPower(flingPower) {}
|
||||
|
||||
inline uint8_t GetFlingPower() const { return _flingPower; }
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
#include "MoveData.hpp"
|
||||
#include <utility>
|
||||
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<Arbutils::CaseInsensitiveConstString> flags)
|
||||
const CreatureLib::Library::SecondaryEffect& effect,
|
||||
std::unordered_set<uint32_t> flags)
|
||||
: AttackData(name, type, static_cast<CreatureLib::Library::AttackCategory>(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<PkmnLib::Library::MoveCategory>(AttackData::GetCategory());
|
||||
|
|
|
@ -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<Arbutils::CaseInsensitiveConstString> 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<uint32_t> flags);
|
||||
|
||||
PkmnLib::Library::MoveCategory GetCategory() const;
|
||||
};
|
||||
|
|
|
@ -1,21 +1,22 @@
|
|||
#ifndef PKMNLIB_NATURE_HPP
|
||||
#define PKMNLIB_NATURE_HPP
|
||||
|
||||
#include <CreatureLib/Core/Statistic.hpp>
|
||||
#include <CreatureLib/Library/Statistic.hpp>
|
||||
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)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef PKMNLIB_NATURELIBRARY_HPP
|
||||
#define PKMNLIB_NATURELIBRARY_HPP
|
||||
|
||||
#include <CreatureLib/Core/Exceptions/CreatureException.hpp>
|
||||
#include <CreatureLib/Library/Exceptions/CreatureException.hpp>
|
||||
#include <Arbutils/Random.hpp>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include "PokemonForme.hpp"
|
||||
PkmnLib::Library::PokemonForme::PokemonForme(ConstString name, float height, float weight, uint32_t baseExperience,
|
||||
std::vector<uint8_t> types,
|
||||
CreatureLib::Core::StatisticSet<uint16_t> baseStats,
|
||||
std::vector<ConstString> talents, std::vector<ConstString> secretTalents,
|
||||
const List<uint8_t>& types,
|
||||
CreatureLib::Library::StatisticSet<uint16_t> baseStats,
|
||||
const List<ConstString>& talents, const List<ConstString>& secretTalents,
|
||||
const CreatureLib::Library::LearnableAttacks* attacks)
|
||||
: SpeciesVariant(name, height, weight, baseExperience, types, baseStats, talents, secretTalents, attacks) {}
|
||||
|
|
|
@ -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<uint8_t> types,
|
||||
CreatureLib::Core::StatisticSet<uint16_t> baseStats, std::vector<ConstString> talents,
|
||||
std::vector<ConstString> secretTalents, const CreatureLib::Library::LearnableAttacks* attacks);
|
||||
PokemonForme(ConstString name, float height, float weight, uint32_t baseExperience, const List<uint8_t>& types,
|
||||
CreatureLib::Library::StatisticSet<uint16_t> baseStats, const List<ConstString>& talents,
|
||||
const List<ConstString>& 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);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -1,19 +1,20 @@
|
|||
#ifndef PKMNLIB_STATISTIC_HPP
|
||||
#define PKMNLIB_STATISTIC_HPP
|
||||
|
||||
#include <CreatureLib/Core/Statistic.hpp>
|
||||
#include <CreatureLib/Library/Statistic.hpp>
|
||||
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;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#define PKMNLIB_ANGELSCRIPTSCRIPT_HPP
|
||||
#include <CreatureLib/Battling/ScriptHandling/Script.hpp>
|
||||
#define ANGELSCRIPT_DLL_LIBRARY_IMPORT
|
||||
#include <CreatureLib/Core/Exceptions/NotImplementedException.hpp>
|
||||
#include <CreatureLib/Library/Exceptions/NotImplementedException.hpp>
|
||||
#include <angelscript.h>
|
||||
#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);
|
||||
|
|
|
@ -2,8 +2,9 @@
|
|||
#define PKMNLIB_ANGELSCRIPTTYPEINFO_HPP
|
||||
|
||||
#define ANGELSCRIPT_DLL_LIBRARY_IMPORT
|
||||
#include <Arbutils/Collections/Dictionary.hpp>
|
||||
#include <Arbutils/ConstString.hpp>
|
||||
#include <CreatureLib/Core/Exceptions/CreatureException.hpp>
|
||||
#include <CreatureLib/Library/Exceptions/CreatureException.hpp>
|
||||
#include <angelscript.h>
|
||||
#include <cstring>
|
||||
#include <unordered_map>
|
||||
|
@ -14,7 +15,7 @@ using ConstString = Arbutils::CaseInsensitiveConstString;
|
|||
class AngelScriptTypeInfo {
|
||||
private:
|
||||
asITypeInfo* _type = nullptr;
|
||||
std::unordered_map<std::string, asIScriptFunction*> _functions;
|
||||
Arbutils::Collections::Dictionary<ConstString, asIScriptFunction*> _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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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){};
|
||||
|
|
|
@ -59,8 +59,8 @@ CScriptArray* GetTypes(const PkmnLib::Battling::Pokemon* obj) {
|
|||
asIScriptEngine* engine = ctx->GetEngine();
|
||||
asITypeInfo* t = engine->GetTypeInfoByDecl("array<uint8>");
|
||||
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)",
|
||||
|
|
|
@ -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);
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
#ifndef PKMNLIB_CONSTSTRING_HPP
|
||||
#define PKMNLIB_CONSTSTRING_HPP
|
||||
#include <Arbutils/Assert.hpp>
|
||||
#include <Arbutils/ConstString.hpp>
|
||||
#include <angelscript.h>
|
||||
class ConstStringRegister {
|
||||
public:
|
||||
static void Register(asIScriptEngine* engine);
|
||||
};
|
||||
|
||||
#endif // PKMNLIB_CONSTSTRING_HPP
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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<uint16_t>(100, 100, 100, 100, 100, 100), {"testAbility"_cnc},
|
||||
CreatureLib::Library::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100), {"testAbility"_cnc},
|
||||
{"testHiddenAbility"_cnc}, new CreatureLib::Library::LearnableAttacks(100)),
|
||||
0.5f, "testGrowthRate"_cnc, 100, 100));
|
||||
delete lib;
|
||||
|
@ -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<uint16_t>(100, 100, 100, 100, 100, 100), {"testAbility"_cnc},
|
||||
CreatureLib::Library::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100), {"testAbility"_cnc},
|
||||
{"testHiddenAbility"_cnc}, new CreatureLib::Library::LearnableAttacks(100)),
|
||||
0.5f, "testGrowthRate"_cnc, 100, 100));
|
||||
auto val = lib->Get("foo"_cnc);
|
||||
|
|
|
@ -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<uint16_t>(100, 100, 100, 100, 100, 100),
|
||||
CreatureLib::Library::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100),
|
||||
{"testAbility"_cnc}, {"testHiddenAbility"_cnc},
|
||||
new CreatureLib::Library::LearnableAttacks(100)),
|
||||
0.5f, "testGrowthRate"_cnc, 100, 100);
|
||||
|
@ -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<uint16_t>(100, 100, 100, 100, 100, 100),
|
||||
CreatureLib::Library::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100),
|
||||
{"testAbility"_cnc}, {"testHiddenAbility"_cnc},
|
||||
new CreatureLib::Library::LearnableAttacks(100)),
|
||||
0.5f, "testGrowthRate"_cnc, 100, 100);
|
||||
|
@ -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<uint16_t>(100, 100, 100, 100, 100, 100),
|
||||
CreatureLib::Library::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100),
|
||||
{"testAbility"_cnc}, {"testHiddenAbility"_cnc},
|
||||
new CreatureLib::Library::LearnableAttacks(100)),
|
||||
0.5f, "testGrowthRate"_cnc, 100, 100);
|
||||
|
@ -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<uint16_t>(100, 100, 100, 100, 100, 100),
|
||||
CreatureLib::Library::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100),
|
||||
{"testAbility"_cnc}, {"testHiddenAbility"_cnc},
|
||||
new CreatureLib::Library::LearnableAttacks(100)),
|
||||
0.5f, "testGrowthRate"_cnc, 100, 100);
|
||||
|
@ -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<uint16_t>(100, 100, 100, 100, 100, 100),
|
||||
CreatureLib::Library::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100),
|
||||
{"testAbility"_cnc}, {"testHiddenAbility"_cnc},
|
||||
new CreatureLib::Library::LearnableAttacks(100)),
|
||||
0.5f, "testGrowthRate"_cnc, 100, 100);
|
||||
|
@ -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<uint16_t>(100, 100, 100, 100, 100, 100),
|
||||
CreatureLib::Library::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100),
|
||||
{"testAbility"_cnc}, {"testHiddenAbility"_cnc},
|
||||
new CreatureLib::Library::LearnableAttacks(100)),
|
||||
0.5f, "testGrowthRate"_cnc, 100, 100);
|
||||
|
@ -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<uint16_t>(100, 100, 100, 100, 100, 100),
|
||||
CreatureLib::Library::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100),
|
||||
{"testAbility"_cnc}, {"testHiddenAbility"_cnc},
|
||||
new CreatureLib::Library::LearnableAttacks(100)),
|
||||
0.5f, "testGrowthRate"_cnc, 100, 100);
|
||||
|
@ -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<uint16_t>(100, 100, 100, 100, 100, 100),
|
||||
CreatureLib::Library::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100),
|
||||
{"testAbility"_cnc}, {"testHiddenAbility"_cnc},
|
||||
new CreatureLib::Library::LearnableAttacks(100)),
|
||||
0.5f, "testGrowthRate"_cnc, 100, 100);
|
||||
|
@ -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<uint16_t>(100, 100, 100, 100, 100, 100),
|
||||
CreatureLib::Library::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100),
|
||||
{"testAbility"_cnc}, {"testHiddenAbility"_cnc},
|
||||
new CreatureLib::Library::LearnableAttacks(100)),
|
||||
0.5f, "testGrowthRate"_cnc, 100, 100);
|
||||
|
@ -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<uint16_t>(100, 100, 100, 100, 100, 100),
|
||||
CreatureLib::Library::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100),
|
||||
{"testAbility"_cnc}, {"testHiddenAbility"_cnc},
|
||||
new CreatureLib::Library::LearnableAttacks(100)),
|
||||
0.5f, "testGrowthRate"_cnc, 100, 100);
|
||||
auto species2 = new PkmnLib::Library::PokemonSpecies(
|
||||
2, "bar"_cnc,
|
||||
new PkmnLib::Library::PokemonForme("default"_cnc, 1.0f, 1.0f, 100, {0},
|
||||
CreatureLib::Core::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100),
|
||||
CreatureLib::Library::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100),
|
||||
{"testAbility"_cnc}, {"testHiddenAbility"_cnc},
|
||||
new CreatureLib::Library::LearnableAttacks(100)),
|
||||
0.5f, "testGrowthRate"_cnc, 100, 100);
|
||||
|
|
|
@ -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<AngelScripResolver*>(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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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<AngelScriptScript*>(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<PkmnLib::Battling::Pokemon*>(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<PkmnLib::Battling::Pokemon*>(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<PkmnLib::Battling::Pokemon*>(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<PkmnLib::Battling::Pokemon*>(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<PkmnLib::Battling::Pokemon*>(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<PkmnLib::Battling::Pokemon*>(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<PkmnLib::Battling::Pokemon*>(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<PkmnLib::Battling::Pokemon*>(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<PkmnLib::Battling::Pokemon*>(mon));
|
||||
data.Context->SetArgDWord(1, i);
|
||||
|
|
|
@ -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<AngelScripResolver*>(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<AngelScriptScript*>(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<PkmnLib::Library::PokemonForme*>(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<PkmnLib::Library::PokemonForme*>(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<PkmnLib::Library::PokemonForme*>(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<PkmnLib::Library::PokemonForme*>(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<PkmnLib::Library::PokemonForme*>(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<PkmnLib::Library::PokemonForme*>(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<uint8_t>(CreatureLib::Core::Statistic::Health);
|
||||
statInt != static_cast<uint8_t>(CreatureLib::Core::Statistic::Speed); statInt++) {
|
||||
auto stat = static_cast<CreatureLib::Core::Statistic>(statInt);
|
||||
for (uint8_t statInt = static_cast<uint8_t>(CreatureLib::Library::Statistic::Health);
|
||||
statInt != static_cast<uint8_t>(CreatureLib::Library::Statistic::Speed); statInt++) {
|
||||
auto stat = static_cast<CreatureLib::Library::Statistic>(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<PkmnLib::Library::PokemonForme*>(forme));
|
||||
data.Context->SetArgDWord(1, static_cast<asDWORD>(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<PkmnLib::Library::PokemonForme*>(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
|
|
@ -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<AngelScriptScript*>(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<PkmnLib::Library::Item*>(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<PkmnLib::Library::Item*>(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<PkmnLib::Library::Item*>(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<PkmnLib::Library::Item*>(item));
|
||||
|
|
|
@ -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<AngelScriptScript*>(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<PkmnLib::Library::MoveData*>(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<PkmnLib::Library::MoveData*>(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<PkmnLib::Library::MoveData*>(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<PkmnLib::Library::MoveData*>(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<PkmnLib::Library::MoveData*>(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<PkmnLib::Library::MoveData*>(move));
|
||||
|
|
|
@ -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<AngelScriptScript*>(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<PkmnLib::Library::PokemonSpecies*>(species));
|
||||
|
|
|
@ -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<AngelScriptScript*>(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<PkmnLib::Library::PokemonLibrary*>(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<PkmnLib::Library::PokemonLibrary*>(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<PkmnLib::Library::PokemonLibrary*>(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<PkmnLib::Library::PokemonLibrary*>(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<PkmnLib::Library::PokemonLibrary*>(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<PkmnLib::Library::PokemonLibrary*>(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<PkmnLib::Library::PokemonLibrary*>(mainLib->GetStaticLib()));
|
||||
data.Context->SetArgObject(
|
||||
|
|
|
@ -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<uint16_t>(100, 100, 100, 100, 100, 100), {"testAbility"_cnc},
|
||||
CreatureLib::Library::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100), {"testAbility"_cnc},
|
||||
{"testHiddenAbility"_cnc}, new CreatureLib::Library::LearnableAttacks(100)),
|
||||
0.5f, "testGrowthRate"_cnc, 100, 100));
|
||||
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<uint16_t>(100, 100, 100, 100, 100, 100), {"testAbility"_cnc},
|
||||
CreatureLib::Library::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100), {"testAbility"_cnc},
|
||||
{"testHiddenAbility"_cnc}, new CreatureLib::Library::LearnableAttacks(100)),
|
||||
0.5f, "testGrowthRate"_cnc, 100, 100));
|
||||
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<uint16_t>(100, 100, 100, 100, 100, 100), {"testAbility"_cnc},
|
||||
CreatureLib::Library::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100), {"testAbility"_cnc},
|
||||
{"testHiddenAbility"_cnc}, new CreatureLib::Library::LearnableAttacks(100)),
|
||||
0.5f, "testGrowthRate"_cnc, 100, 100));
|
||||
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<uint16_t>(100, 100, 100, 100, 100, 100), {"testAbility"_cnc},
|
||||
CreatureLib::Library::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100), {"testAbility"_cnc},
|
||||
{"testHiddenAbility"_cnc}, new CreatureLib::Library::LearnableAttacks(100)),
|
||||
0.5f, "testGrowthRate"_cnc, 100, 100));
|
||||
|
||||
|
@ -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() {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue