File formatting.
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
686f898259
commit
c4b866cb38
|
@ -2,7 +2,8 @@
|
|||
#include "../Core.hpp"
|
||||
using namespace PkmnLib::Library;
|
||||
|
||||
export const LibrarySettings* PkmnLib_LibrarySettings_Construct(uint8_t maximalLevel, uint8_t maximalMoves, uint16_t shinyRate) {
|
||||
export const LibrarySettings* PkmnLib_LibrarySettings_Construct(uint8_t maximalLevel, uint8_t maximalMoves,
|
||||
uint16_t shinyRate) {
|
||||
return new LibrarySettings(maximalLevel, maximalMoves, shinyRate);
|
||||
}
|
||||
|
||||
|
|
|
@ -2,8 +2,9 @@
|
|||
#include "../Core.hpp"
|
||||
using namespace PkmnLib::Library;
|
||||
|
||||
export Nature* PkmnLib_Nature_Construct(CreatureLib::Library::Statistic increasedStat, CreatureLib::Library::Statistic decreasedStat,
|
||||
float increasedModifier, float decreasedModifier) {
|
||||
export Nature* PkmnLib_Nature_Construct(CreatureLib::Library::Statistic increasedStat,
|
||||
CreatureLib::Library::Statistic decreasedStat, float increasedModifier,
|
||||
float decreasedModifier) {
|
||||
return new Nature(increasedStat, decreasedStat, increasedModifier, decreasedModifier);
|
||||
}
|
||||
export void PkmnLib_Nature_Destruct(const Nature* p) { delete p; }
|
||||
|
|
|
@ -14,8 +14,7 @@ uint32_t PkmnLib::Battling::StatCalculator::CalculateOtherStat(const Pokemon* pk
|
|||
uint32_t iv = pkmn->GetIndividualValue(stat);
|
||||
uint32_t ev = pkmn->GetEffortValue(stat);
|
||||
uint8_t level = pkmn->GetLevel();
|
||||
uint32_t unmodified =
|
||||
static_cast<uint32_t>(((2 * base + iv + static_cast<uint32_t>(ev / 4)) * level) / 100) + 5;
|
||||
uint32_t unmodified = static_cast<uint32_t>(((2 * base + iv + static_cast<uint32_t>(ev / 4)) * level) / 100) + 5;
|
||||
return static_cast<uint32_t>(unmodified * pkmn->GetNature()->GetStatModifier(stat));
|
||||
}
|
||||
float PkmnLib::Battling::StatCalculator::GetStatBoostModifier(const CreatureLib::Battling::Creature* pkmn,
|
||||
|
@ -41,8 +40,8 @@ float PkmnLib::Battling::StatCalculator::GetStatBoostModifier(const CreatureLib:
|
|||
CreatureLib::Library::StatisticSet<uint32_t>
|
||||
PkmnLib::Battling::StatCalculator::CalculateFlatStats(CreatureLib::Battling::Creature* creature) const {
|
||||
auto pkmn = dynamic_cast<Pokemon*>(creature);
|
||||
return CreatureLib::Library::StatisticSet<uint32_t>(
|
||||
CalculateHealthStat(pkmn), CalculateOtherStat(pkmn, Library::Statistic::PhysicalAttack),
|
||||
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),
|
||||
|
|
|
@ -29,7 +29,8 @@ const EvolutionData* EvolutionData::CreateTradeWithItemEvolution(const Item* ite
|
|||
return new EvolutionData(EvolutionMethod::TradeWithHeldItem,
|
||||
{new CreatureLib::Library::EffectParameter(item->GetName())}, into);
|
||||
}
|
||||
const EvolutionData* EvolutionData::CreateTradeWithSpeciesEvolution(const PokemonSpecies* traded, const PokemonSpecies* into) {
|
||||
const EvolutionData* EvolutionData::CreateTradeWithSpeciesEvolution(const PokemonSpecies* traded,
|
||||
const PokemonSpecies* into) {
|
||||
return new EvolutionData(EvolutionMethod::TradeWithSpecificPokemon,
|
||||
{new CreatureLib::Library::EffectParameter(traded->GetName())}, into);
|
||||
}
|
||||
|
|
|
@ -5,8 +5,7 @@
|
|||
namespace PkmnLib::Library {
|
||||
ENUM(EvolutionMethod, uint8_t, Level, HighFriendship, KnownMove, LocationBased, TimeBased, HoldsItem,
|
||||
IsGenderAndLevel, EvolutionItemUse, EvolutionItemUseWithGender, Trade, TradeWithHeldItem,
|
||||
TradeWithSpecificPokemon, Custom
|
||||
)
|
||||
TradeWithSpecificPokemon, Custom)
|
||||
}
|
||||
|
||||
#endif // PKMNLIB_EVOLUTIONMETHOD_HPP
|
||||
|
|
|
@ -38,8 +38,7 @@ namespace PkmnLib::Library {
|
|||
auto& map = _items.GetStdMap();
|
||||
return std::next(std::begin(map), i)->first;
|
||||
}
|
||||
inline const Arbutils::CaseInsensitiveConstString&
|
||||
GetRandomNatureName(Arbutils::Random* rand) const {
|
||||
inline const Arbutils::CaseInsensitiveConstString& GetRandomNatureName(Arbutils::Random* rand) const {
|
||||
auto i = rand->Get(_items.Count());
|
||||
auto& map = _items.GetStdMap();
|
||||
return std::next(std::begin(map), i)->first;
|
||||
|
|
|
@ -14,9 +14,7 @@ namespace PkmnLib::Library {
|
|||
const NatureLibrary* _natures;
|
||||
|
||||
public:
|
||||
~PokemonLibrary() override {
|
||||
delete _natures;
|
||||
}
|
||||
~PokemonLibrary() override { delete _natures; }
|
||||
|
||||
PokemonLibrary(PkmnLib::Library::LibrarySettings* settings, SpeciesLibrary* species, MoveLibrary* moves,
|
||||
ItemLibrary* items, CreatureLib::Library::GrowthRateLibrary* growthRates,
|
||||
|
@ -39,9 +37,7 @@ namespace PkmnLib::Library {
|
|||
return (const ItemLibrary*)(CreatureLib::Library::DataLibrary::GetItemLibrary());
|
||||
}
|
||||
|
||||
[[nodiscard]] const NatureLibrary* GetNatureLibrary() const {
|
||||
return _natures;
|
||||
}
|
||||
[[nodiscard]] const NatureLibrary* GetNatureLibrary() const { return _natures; }
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@ private:
|
|||
|
||||
asIScriptObject* _obj = nullptr;
|
||||
CScriptArray* GetEffectParameters(const List<CreatureLib::Library::EffectParameter*>& ls);
|
||||
|
||||
public:
|
||||
AngelScriptScript(AngelScriptResolver* resolver, AngelScriptTypeInfo* type, asIScriptObject* obj,
|
||||
ContextPool* ctxPool)
|
||||
|
|
|
@ -6,6 +6,7 @@ class RegisterBattleClass {
|
|||
static void RegisterChoiceQueue(asIScriptEngine* engine);
|
||||
static void RegisterBattle(asIScriptEngine* engine);
|
||||
static void RegisterBattleRandom(asIScriptEngine* engine);
|
||||
|
||||
public:
|
||||
static void Register(asIScriptEngine* engine);
|
||||
};
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
class RegisterBattleLibrary {
|
||||
static void RegisterDamageLibrary(asIScriptEngine* engine);
|
||||
static void RegisterLibrary(asIScriptEngine* engine);
|
||||
|
||||
public:
|
||||
static void Register(asIScriptEngine* engine);
|
||||
};
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "RegisterExecutingAttack.hpp"
|
||||
#include <CreatureLib/Battling/Models/ExecutingAttack.hpp>
|
||||
#include <Arbutils/Assert.hpp>
|
||||
#include <CreatureLib/Battling/Models/ExecutingAttack.hpp>
|
||||
|
||||
void RegisterExecutingAttack::Register(asIScriptEngine* engine) {
|
||||
RegisterHitData(engine);
|
||||
|
@ -34,20 +34,16 @@ void RegisterExecutingAttack::RegisterExecutingAttackType(asIScriptEngine* engin
|
|||
[[maybe_unused]] int r = engine->RegisterObjectType("ExecutingMove", 0, asOBJ_REF | asOBJ_NOCOUNT);
|
||||
Assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod("ExecutingMove", "HitData@ GetHitData(Pokemon@ target, uint8 hit) const",
|
||||
asMETHOD(CreatureLib::Battling::ExecutingAttack, GetHitData),
|
||||
asCALL_THISCALL);
|
||||
asMETHOD(CreatureLib::Battling::ExecutingAttack, GetHitData), asCALL_THISCALL);
|
||||
Assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod("ExecutingMove", "bool IsPokemonTarget(Pokemon@ pkmn) const",
|
||||
asMETHOD(CreatureLib::Battling::ExecutingAttack, IsCreatureTarget),
|
||||
asCALL_THISCALL);
|
||||
Assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod("ExecutingMove", "Pokemon@ get_User() const property",
|
||||
asMETHOD(CreatureLib::Battling::ExecutingAttack, GetUser),
|
||||
asCALL_THISCALL);
|
||||
asMETHOD(CreatureLib::Battling::ExecutingAttack, GetUser), asCALL_THISCALL);
|
||||
Assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod("ExecutingMove", "LearnedMove@ get_Move() const property",
|
||||
asMETHOD(CreatureLib::Battling::ExecutingAttack, GetAttack),
|
||||
asCALL_THISCALL);
|
||||
asMETHOD(CreatureLib::Battling::ExecutingAttack, GetAttack), asCALL_THISCALL);
|
||||
Assert(r >= 0);
|
||||
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
class RegisterExecutingAttack {
|
||||
static void RegisterHitData(asIScriptEngine* engine);
|
||||
static void RegisterExecutingAttackType(asIScriptEngine* engine);
|
||||
|
||||
public:
|
||||
static void Register(asIScriptEngine* engine);
|
||||
};
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#include "RegisterPokemonClass.hpp"
|
||||
#include <CreatureLib/Battling/Models/LearnedAttack.hpp>
|
||||
#include <Arbutils/Assert.hpp>
|
||||
#include <CreatureLib/Battling/Models/LearnedAttack.hpp>
|
||||
#include "../../../../../extern/angelscript_addons/scriptarray/scriptarray.h"
|
||||
#include "../../../../Battling/Pokemon/Pokemon.hpp"
|
||||
#include "../../../../Battling/PkmnDamageSource.hpp"
|
||||
#include "../../../../Battling/Pokemon/Pokemon.hpp"
|
||||
|
||||
// Hack to handle AngelScript not recognizing different sized enums on fields, and returning invalid values due to it.
|
||||
#define ENUM__SIZE_WRAPPER(name, type, func) \
|
||||
|
@ -20,12 +20,10 @@ void RegisterPokemonClass::RegisterDamageSource(asIScriptEngine* engine) {
|
|||
[[maybe_unused]] int r = engine->RegisterEnum("DamageSource");
|
||||
Assert(r >= 0);
|
||||
for (auto v : CreatureLib::Battling::DamageSourceHelper::GetValues()) {
|
||||
r = engine->RegisterEnumValue("DamageSource", CreatureLib::Battling::DamageSourceHelper::ToString(v),
|
||||
(int)v);
|
||||
r = engine->RegisterEnumValue("DamageSource", CreatureLib::Battling::DamageSourceHelper::ToString(v), (int)v);
|
||||
}
|
||||
for (auto v : PkmnDamageSourceHelper::GetValues()) {
|
||||
r = engine->RegisterEnumValue("DamageSource", PkmnDamageSourceHelper::ToString(v),
|
||||
(int)v);
|
||||
r = engine->RegisterEnumValue("DamageSource", PkmnDamageSourceHelper::ToString(v), (int)v);
|
||||
}
|
||||
|
||||
Assert(r >= 0);
|
||||
|
@ -94,7 +92,6 @@ static bool HasHeldItem(const PkmnLib::Battling::Pokemon* obj, const ConstString
|
|||
return obj->HasHeldItem(str.GetHash());
|
||||
}
|
||||
|
||||
|
||||
void RegisterPokemonClass::RegisterPokemonType(asIScriptEngine* engine) {
|
||||
[[maybe_unused]] int r = engine->RegisterObjectType("Pokemon", 0, asOBJ_REF | asOBJ_NOCOUNT);
|
||||
Assert(r >= 0);
|
||||
|
|
|
@ -7,6 +7,7 @@ class RegisterPokemonClass {
|
|||
static void RegisterMoveLearnMethod(asIScriptEngine* engine);
|
||||
static void RegisterLearnedAttack(asIScriptEngine* engine);
|
||||
static void RegisterPokemonType(asIScriptEngine* engine);
|
||||
|
||||
public:
|
||||
static void Register(asIScriptEngine* engine);
|
||||
};
|
||||
|
|
|
@ -73,7 +73,8 @@ void RegisterTurnChoices::RegisterSwitchTurnChoice(asIScriptEngine* engine) {
|
|||
asMETHOD(CreatureLib::Battling::SwitchTurnChoice, GetUser), asCALL_THISCALL);
|
||||
Assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod("SwitchTurnChoice", "Pokemon@ get_NewPokemon() const property",
|
||||
asMETHOD(CreatureLib::Battling::SwitchTurnChoice, GetNewCreature), asCALL_THISCALL);
|
||||
asMETHOD(CreatureLib::Battling::SwitchTurnChoice, GetNewCreature),
|
||||
asCALL_THISCALL);
|
||||
Assert(r >= 0);
|
||||
|
||||
r = engine->RegisterObjectMethod(
|
||||
|
|
|
@ -7,6 +7,7 @@ class RegisterTurnChoices {
|
|||
static void RegisterBaseTurnChoice(asIScriptEngine* engine);
|
||||
static void RegisterMoveTurnChoice(asIScriptEngine* engine);
|
||||
static void RegisterSwitchTurnChoice(asIScriptEngine* engine);
|
||||
|
||||
public:
|
||||
static void Register(asIScriptEngine* engine);
|
||||
};
|
||||
|
|
|
@ -3,9 +3,7 @@ using ConstString = Arbutils::CaseInsensitiveConstString;
|
|||
|
||||
static void ConstructConstString(void* self) { new (self) ConstString(); }
|
||||
static void CopyConstructConstString(const ConstString& other, void* self) { new (self) ConstString(other); }
|
||||
static void DestructConstString(void* self) {
|
||||
((ConstString*)self)->~ConstString();
|
||||
}
|
||||
static void DestructConstString(void* self) { ((ConstString*)self)->~ConstString(); }
|
||||
static bool ConstStringEquality(const ConstString& a, const ConstString& b) { return a == b; }
|
||||
static bool ConstStringStdStringEquality(const ConstString& a, const std::string& b) { return a == b; }
|
||||
static ConstString ImplStdStringConstStringConv(const std::string& s) { return ConstString(s); }
|
||||
|
|
|
@ -34,8 +34,8 @@ void RegisterGrowthRateTypes::RegisterGrowthRateLibrary(asIScriptEngine* engine)
|
|||
"uint8 CalculateLevel(const constString &in growthRate, uint experience) const",
|
||||
asFUNCTION(CalculateLevel), asCALL_CDECL_OBJLAST);
|
||||
assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod("GrowthRateLibrary",
|
||||
"uint CalculateExperience(const constString &in growthRate, uint8 experience) const",
|
||||
r = engine->RegisterObjectMethod(
|
||||
"GrowthRateLibrary", "uint CalculateExperience(const constString &in growthRate, uint8 experience) const",
|
||||
asFUNCTION(CalculateExperience), asCALL_CDECL_OBJLAST);
|
||||
assert(r >= 0);
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
class RegisterGrowthRateTypes {
|
||||
static void RegisterGrowthRateType(asIScriptEngine* engine);
|
||||
static void RegisterGrowthRateLibrary(asIScriptEngine* engine);
|
||||
|
||||
public:
|
||||
static void Register(asIScriptEngine* engine);
|
||||
};
|
||||
|
|
|
@ -23,7 +23,8 @@ void RegisterItemTypes::RegisterItemCategoryEnum(asIScriptEngine* engine) {
|
|||
assert(r >= 0);
|
||||
r = engine->RegisterEnumValue("ItemCategory", "TM", (int)CreatureLib::Library::ItemCategory::MoveLearner);
|
||||
assert(r >= 0);
|
||||
r = engine->RegisterEnumValue("ItemCategory", "VariantChanger", (int)CreatureLib::Library::ItemCategory::VariantChanger);
|
||||
r = engine->RegisterEnumValue("ItemCategory", "VariantChanger",
|
||||
(int)CreatureLib::Library::ItemCategory::VariantChanger);
|
||||
assert(r >= 0);
|
||||
r = engine->RegisterEnumValue("ItemCategory", "KeyItem", (int)CreatureLib::Library::ItemCategory::KeyItem);
|
||||
assert(r >= 0);
|
||||
|
@ -36,13 +37,17 @@ void RegisterItemTypes::RegisterBattleItemCategoryEnum(asIScriptEngine* engine)
|
|||
assert(r >= 0);
|
||||
r = engine->RegisterEnumValue("BattleItemCategory", "None", (int)CreatureLib::Library::BattleItemCategory::None);
|
||||
assert(r >= 0);
|
||||
r = engine->RegisterEnumValue("BattleItemCategory", "Healing", (int)CreatureLib::Library::BattleItemCategory::Healing);
|
||||
r = engine->RegisterEnumValue("BattleItemCategory", "Healing",
|
||||
(int)CreatureLib::Library::BattleItemCategory::Healing);
|
||||
assert(r >= 0);
|
||||
r = engine->RegisterEnumValue("BattleItemCategory", "StatusHealing", (int)CreatureLib::Library::BattleItemCategory::StatusHealing);
|
||||
r = engine->RegisterEnumValue("BattleItemCategory", "StatusHealing",
|
||||
(int)CreatureLib::Library::BattleItemCategory::StatusHealing);
|
||||
assert(r >= 0);
|
||||
r = engine->RegisterEnumValue("BattleItemCategory", "CaptureDevice", (int)CreatureLib::Library::BattleItemCategory::CaptureDevice);
|
||||
r = engine->RegisterEnumValue("BattleItemCategory", "CaptureDevice",
|
||||
(int)CreatureLib::Library::BattleItemCategory::CaptureDevice);
|
||||
assert(r >= 0);
|
||||
r = engine->RegisterEnumValue("BattleItemCategory", "Misc", (int)CreatureLib::Library::BattleItemCategory::MiscBattleItem);
|
||||
r = engine->RegisterEnumValue("BattleItemCategory", "Misc",
|
||||
(int)CreatureLib::Library::BattleItemCategory::MiscBattleItem);
|
||||
assert(r >= 0);
|
||||
}
|
||||
|
||||
|
@ -57,7 +62,6 @@ static bool HasFlag(const PkmnLib::Library::Item* obj, const Arbutils::CaseInsen
|
|||
return obj->HasFlag(str);
|
||||
}
|
||||
|
||||
|
||||
void RegisterItemTypes::RegisterItemType(asIScriptEngine* engine) {
|
||||
[[maybe_unused]] int r = engine->RegisterObjectType("Item", 0, asOBJ_REF | asOBJ_NOCOUNT);
|
||||
assert(r >= 0);
|
||||
|
@ -73,11 +77,9 @@ void RegisterItemTypes::RegisterItemType(asIScriptEngine* engine) {
|
|||
r = engine->RegisterObjectMethod("Item", "int get_Price() const property",
|
||||
asMETHOD(PkmnLib::Library::Item, GetPrice), asCALL_THISCALL);
|
||||
assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod("Item", "bool HasFlag(const constString &in flag) const",
|
||||
asFUNCTION(HasFlag), asCALL_CDECL_OBJLAST);
|
||||
r = engine->RegisterObjectMethod("Item", "bool HasFlag(const constString &in flag) const", asFUNCTION(HasFlag),
|
||||
asCALL_CDECL_OBJLAST);
|
||||
assert(r >= 0);
|
||||
|
||||
|
||||
}
|
||||
void RegisterItemTypes::RegisterItemLibrary(asIScriptEngine* engine) {
|
||||
[[maybe_unused]] int r = engine->RegisterObjectType("ItemLibrary", 0, asOBJ_REF | asOBJ_NOCOUNT);
|
||||
|
|
|
@ -7,6 +7,7 @@ class RegisterItemTypes {
|
|||
static void RegisterBattleItemCategoryEnum(asIScriptEngine* engine);
|
||||
static void RegisterItemType(asIScriptEngine* engine);
|
||||
static void RegisterItemLibrary(asIScriptEngine* engine);
|
||||
|
||||
public:
|
||||
static void Register(asIScriptEngine* engine);
|
||||
};
|
||||
|
|
|
@ -77,8 +77,8 @@ void RegisterMoveTypes::RegisterMoveType(asIScriptEngine* engine) {
|
|||
r = engine->RegisterObjectMethod("MoveData", "int8 get_Priority() const property",
|
||||
asMETHOD(PkmnLib::Library::MoveData, GetPriority), asCALL_THISCALL);
|
||||
assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod("MoveData", "bool HasFlag(const constString &in flag) const",
|
||||
asFUNCTION(HasFlag), asCALL_CDECL_OBJLAST);
|
||||
r = engine->RegisterObjectMethod("MoveData", "bool HasFlag(const constString &in flag) const", asFUNCTION(HasFlag),
|
||||
asCALL_CDECL_OBJLAST);
|
||||
assert(r >= 0);
|
||||
}
|
||||
void RegisterMoveTypes::RegisterMoveLibrary(asIScriptEngine* engine) {
|
||||
|
|
|
@ -7,6 +7,7 @@ class RegisterMoveTypes {
|
|||
static void RegisterMoveTarget(asIScriptEngine* engine);
|
||||
static void RegisterMoveType(asIScriptEngine* engine);
|
||||
static void RegisterMoveLibrary(asIScriptEngine* engine);
|
||||
|
||||
public:
|
||||
static void Register(asIScriptEngine* engine);
|
||||
};
|
||||
|
|
|
@ -41,6 +41,4 @@ void RegisterStaticLibraryTypes::RegisterLibraryType(asIScriptEngine* engine) {
|
|||
r = engine->RegisterObjectMethod("StaticLibrary", "const TypeLibrary@ get_TypeLibrary() const property",
|
||||
asMETHOD(PkmnLib::Library::PokemonLibrary, GetTypeLibrary), asCALL_THISCALL);
|
||||
assert(r >= 0);
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
class RegisterStaticLibraryTypes {
|
||||
static void RegisterLibrarySettingsType(asIScriptEngine* engine);
|
||||
static void RegisterLibraryType(asIScriptEngine* engine);
|
||||
|
||||
public:
|
||||
static void Register(asIScriptEngine* engine);
|
||||
};
|
||||
|
|
|
@ -2,9 +2,7 @@
|
|||
#include <CreatureLib/Library/TypeLibrary.hpp>
|
||||
#include <cassert>
|
||||
|
||||
void RegisterTypeLibrary::Register(asIScriptEngine* engine) {
|
||||
RegisterTypeLibraryType(engine);
|
||||
}
|
||||
void RegisterTypeLibrary::Register(asIScriptEngine* engine) { RegisterTypeLibraryType(engine); }
|
||||
|
||||
static bool GetTypeId(const CreatureLib::Library::TypeLibrary* obj, const Arbutils::CaseInsensitiveConstString& str) {
|
||||
return obj->GetTypeId(str);
|
||||
|
@ -16,7 +14,8 @@ void RegisterTypeLibrary::RegisterTypeLibraryType(asIScriptEngine* engine) {
|
|||
r = engine->RegisterObjectMethod("TypeLibrary", "uint8 GetTypeId(const constString &in name) const",
|
||||
asFUNCTION(GetTypeId), asCALL_CDECL_OBJLAST);
|
||||
assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod("TypeLibrary", "float GetSingleEffectiveness(uint8 attacking, uint8 defensive) const",
|
||||
r = engine->RegisterObjectMethod(
|
||||
"TypeLibrary", "float GetSingleEffectiveness(uint8 attacking, uint8 defensive) const",
|
||||
asMETHOD(CreatureLib::Library::TypeLibrary, GetSingleEffectiveness), asCALL_THISCALL);
|
||||
assert(r >= 0);
|
||||
// TODO: Register get full effectiveness method.
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
class RegisterTypeLibrary {
|
||||
static void RegisterTypeLibraryType(asIScriptEngine* engine);
|
||||
|
||||
public:
|
||||
static void Register(asIScriptEngine* engine);
|
||||
};
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
#ifndef PKMNLIB_REFCAST_HPP
|
||||
#define PKMNLIB_REFCAST_HPP
|
||||
template<class A, class B>
|
||||
B* refCast(A* a)
|
||||
{
|
||||
if( !a ) return 0;
|
||||
template <class A, class B> B* refCast(A* a) {
|
||||
if (!a)
|
||||
return 0;
|
||||
B* b = dynamic_cast<B*>(a);
|
||||
return b;
|
||||
}
|
||||
|
|
|
@ -36,5 +36,4 @@ TEST_CASE("Able to insert and retrieve from library", "library") {
|
|||
delete lib;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
|
@ -351,9 +351,7 @@ TEST_CASE("Validate Pokemon HasHeldItem in Script") {
|
|||
REQUIRE(data.Context->Execute() == asEXECUTION_FINISHED);
|
||||
REQUIRE((bool)data.Context->GetReturnDWord());
|
||||
|
||||
|
||||
delete mon;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
|
@ -102,7 +102,4 @@ TEST_CASE("Validate Item Price in Script") {
|
|||
REQUIRE((bool)data.Context->GetReturnWord());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
|
@ -157,5 +157,4 @@ TEST_CASE("Validate Move Priority in Script") {
|
|||
REQUIRE((bool)data.Context->GetReturnWord());
|
||||
}
|
||||
|
||||
|
||||
#endif
|
|
@ -60,8 +60,7 @@ TEST_CASE("Validate Species Name in Script") {
|
|||
auto data = GetScript(mainLib, "testName"_cnc);
|
||||
|
||||
auto species = mainLib->GetSpeciesLibrary()->Get("testSpecies2"_cnc);
|
||||
data.Context->SetArgObject(
|
||||
0, const_cast<PkmnLib::Library::PokemonSpecies*>(species));
|
||||
data.Context->SetArgObject(0, const_cast<PkmnLib::Library::PokemonSpecies*>(species));
|
||||
auto name = species->GetName();
|
||||
data.Context->SetArgAddress(1, &name);
|
||||
|
||||
|
@ -76,8 +75,7 @@ TEST_CASE("Validate Species Id in Script") {
|
|||
auto data = GetScript(mainLib, "testId"_cnc);
|
||||
|
||||
auto species = mainLib->GetSpeciesLibrary()->Get("testSpecies2"_cnc);
|
||||
data.Context->SetArgObject(
|
||||
0, const_cast<PkmnLib::Library::PokemonSpecies*>(species));
|
||||
data.Context->SetArgObject(0, const_cast<PkmnLib::Library::PokemonSpecies*>(species));
|
||||
data.Context->SetArgWord(1, species->GetId());
|
||||
|
||||
auto result = data.Context->Execute();
|
||||
|
@ -91,8 +89,7 @@ TEST_CASE("Validate Species Gender Rate in Script") {
|
|||
auto data = GetScript(mainLib, "testGenderRate"_cnc);
|
||||
|
||||
auto species = mainLib->GetSpeciesLibrary()->Get("testSpecies2"_cnc);
|
||||
data.Context->SetArgObject(
|
||||
0, const_cast<PkmnLib::Library::PokemonSpecies*>(species));
|
||||
data.Context->SetArgObject(0, const_cast<PkmnLib::Library::PokemonSpecies*>(species));
|
||||
data.Context->SetArgFloat(1, species->GetGenderRate());
|
||||
|
||||
auto result = data.Context->Execute();
|
||||
|
@ -106,8 +103,7 @@ TEST_CASE("Validate Species Capture Rate in Script") {
|
|||
auto data = GetScript(mainLib, "testCaptureRate"_cnc);
|
||||
|
||||
auto species = mainLib->GetSpeciesLibrary()->Get("testSpecies2"_cnc);
|
||||
data.Context->SetArgObject(
|
||||
0, const_cast<PkmnLib::Library::PokemonSpecies*>(species));
|
||||
data.Context->SetArgObject(0, const_cast<PkmnLib::Library::PokemonSpecies*>(species));
|
||||
data.Context->SetArgByte(1, species->GetCaptureRate());
|
||||
|
||||
auto result = data.Context->Execute();
|
||||
|
@ -121,8 +117,7 @@ TEST_CASE("Validate Species Get Forme in Script") {
|
|||
auto data = GetScript(mainLib, "testGetForme"_cnc);
|
||||
|
||||
auto species = mainLib->GetSpeciesLibrary()->Get("testSpecies2"_cnc);
|
||||
data.Context->SetArgObject(
|
||||
0, const_cast<PkmnLib::Library::PokemonSpecies*>(species));
|
||||
data.Context->SetArgObject(0, const_cast<PkmnLib::Library::PokemonSpecies*>(species));
|
||||
data.Context->SetArgObject(1, const_cast<PkmnLib::Library::PokemonForme*>(species->GetForme("default"_cnc)));
|
||||
|
||||
auto result = data.Context->Execute();
|
||||
|
@ -148,6 +143,4 @@ TEST_CASE("Validate Species Get Default Forme in Script") {
|
|||
REQUIRE(v);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue