Battle C Interface.
This commit is contained in:
parent
ec1685aa14
commit
718c146ebe
|
@ -0,0 +1,17 @@
|
|||
#include "../../src/Battling/Battle/Battle.hpp"
|
||||
#include "../Core.hpp"
|
||||
using namespace PkmnLib::Battling;
|
||||
|
||||
export uint8_t PkmnLib_Battle_Construct(Battle*& out, const BattleLibrary* library,
|
||||
CreatureLib::Battling::BattleParty* const* parties, size_t partiesCount,
|
||||
bool canFlee, uint8_t numberOfSides, uint8_t creaturesPerSide) {
|
||||
List<CreatureLib::Battling::BattleParty*> partiesList(parties, parties + partiesCount);
|
||||
Try(out = new Battle(library, partiesList, canFlee, numberOfSides, creaturesPerSide));
|
||||
}
|
||||
|
||||
export void PkmnLib_Battle_Destruct(Battle* p) { delete p; }
|
||||
export uint8_t PkmnLib_Battle_SetWeather(Battle* p, const char* name) {
|
||||
Try(p->SetWeather(Arbutils::CaseInsensitiveConstString(name)));
|
||||
};
|
||||
export uint8_t PkmnLib_Battle_ClearWeather(Battle* p) { Try(p->ClearWeather()); };
|
||||
export const char* PkmnLib_Battle_GetWeatherName(Battle* p) { return p->GetWeatherName().c_str(); }
|
|
@ -1 +1,15 @@
|
|||
#include "Battle.hpp"
|
||||
void PkmnLib::Battling::Battle::SetWeather(const Arbutils::CaseInsensitiveConstString& name) {
|
||||
if (_weatherScript != nullptr) {
|
||||
_weatherScript->OnRemove();
|
||||
delete _weatherScript;
|
||||
}
|
||||
_weatherScript = _library->LoadScript(static_cast<ScriptCategory>(PkmnScriptCategory::Weather), name);
|
||||
_eventHook.TriggerEvent(new WeatherChangeEvent(name));
|
||||
}
|
||||
void PkmnLib::Battling::Battle::ClearWeather() {
|
||||
_weatherScript->OnRemove();
|
||||
delete _weatherScript;
|
||||
_weatherScript = nullptr;
|
||||
_eventHook.TriggerEvent(new WeatherChangeEvent(""_cnc));
|
||||
}
|
||||
|
|
|
@ -16,20 +16,8 @@ namespace PkmnLib::Battling {
|
|||
bool canFlee = true, uint8_t numberOfSides = 2, uint8_t creaturesPerSide = 1)
|
||||
: CreatureLib::Battling::Battle(library, parties, canFlee, numberOfSides, creaturesPerSide) {}
|
||||
|
||||
void SetWeather(const Arbutils::CaseInsensitiveConstString& name) {
|
||||
if (_weatherScript != nullptr) {
|
||||
_weatherScript->OnRemove();
|
||||
delete _weatherScript;
|
||||
}
|
||||
_weatherScript = _library->LoadScript(static_cast<ScriptCategory>(PkmnScriptCategory::Weather), name);
|
||||
_eventHook.TriggerEvent(new WeatherChangeEvent(name));
|
||||
}
|
||||
void ClearWeather() {
|
||||
_weatherScript->OnRemove();
|
||||
delete _weatherScript;
|
||||
_weatherScript = nullptr;
|
||||
_eventHook.TriggerEvent(new WeatherChangeEvent(""_cnc));
|
||||
}
|
||||
void SetWeather(const Arbutils::CaseInsensitiveConstString& name);
|
||||
void ClearWeather();
|
||||
const Arbutils::CaseInsensitiveConstString& GetWeatherName() noexcept { return _weatherScript->GetName(); }
|
||||
|
||||
size_t ScriptCount() const override { return CreatureLib::Battling::Battle::ScriptCount() + 1; }
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "RegisterExecutingAttack.hpp"
|
||||
#include <CreatureLib/Battling/Models/ExecutingAttack.hpp>
|
||||
#include <cassert>
|
||||
#include <Arbutils/Assert.hpp>
|
||||
|
||||
void RegisterExecutingAttack::Register(asIScriptEngine* engine) {
|
||||
RegisterHitData(engine);
|
||||
|
@ -8,46 +8,46 @@ void RegisterExecutingAttack::Register(asIScriptEngine* engine) {
|
|||
}
|
||||
void RegisterExecutingAttack::RegisterHitData(asIScriptEngine* engine) {
|
||||
[[maybe_unused]] int r = engine->RegisterObjectType("HitData", 0, asOBJ_REF | asOBJ_NOCOUNT);
|
||||
assert(r >= 0);
|
||||
Assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod("HitData", "bool get_IsCritical() const property",
|
||||
asMETHOD(CreatureLib::Battling::ExecutingAttack::HitData, IsCritical),
|
||||
asCALL_THISCALL);
|
||||
assert(r >= 0);
|
||||
Assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod("HitData", "uint8 get_BasePower() const property",
|
||||
asMETHOD(CreatureLib::Battling::ExecutingAttack::HitData, GetBasePower),
|
||||
asCALL_THISCALL);
|
||||
assert(r >= 0);
|
||||
Assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod("HitData", "float get_Effectiveness() const property",
|
||||
asMETHOD(CreatureLib::Battling::ExecutingAttack::HitData, GetEffectiveness),
|
||||
asCALL_THISCALL);
|
||||
assert(r >= 0);
|
||||
Assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod("HitData", "uint get_Damage() const property",
|
||||
asMETHOD(CreatureLib::Battling::ExecutingAttack::HitData, GetDamage),
|
||||
asCALL_THISCALL);
|
||||
assert(r >= 0);
|
||||
Assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod("HitData", "uint8 get_Type() const property",
|
||||
asMETHOD(CreatureLib::Battling::ExecutingAttack::HitData, GetType),
|
||||
asCALL_THISCALL);
|
||||
assert(r >= 0);
|
||||
Assert(r >= 0);
|
||||
}
|
||||
void RegisterExecutingAttack::RegisterExecutingAttackType(asIScriptEngine* engine) {
|
||||
[[maybe_unused]] int r = engine->RegisterObjectType("ExecutingMove", 0, asOBJ_REF | asOBJ_NOCOUNT);
|
||||
assert(r >= 0);
|
||||
Assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod("ExecutingMove", "HitData@ GetHitData(Pokemon@ target, uint8 hit) const",
|
||||
asMETHOD(CreatureLib::Battling::ExecutingAttack, GetHitData),
|
||||
asCALL_THISCALL);
|
||||
assert(r >= 0);
|
||||
Assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod("ExecutingMove", "bool IsPokemonTarget(Pokemon@ pkmn) const",
|
||||
asMETHOD(CreatureLib::Battling::ExecutingAttack, IsCreatureTarget),
|
||||
asCALL_THISCALL);
|
||||
assert(r >= 0);
|
||||
Assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod("ExecutingMove", "Pokemon@ get_User() const property",
|
||||
asMETHOD(CreatureLib::Battling::ExecutingAttack, GetUser),
|
||||
asCALL_THISCALL);
|
||||
assert(r >= 0);
|
||||
Assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod("ExecutingMove", "LearnedMove@ get_Move() const property",
|
||||
asMETHOD(CreatureLib::Battling::ExecutingAttack, GetAttack),
|
||||
asCALL_THISCALL);
|
||||
assert(r >= 0);
|
||||
Assert(r >= 0);
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue