Battle C Interface.

This commit is contained in:
2020-04-26 20:01:11 +02:00
parent ec1685aa14
commit 718c146ebe
4 changed files with 45 additions and 26 deletions

View File

@@ -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));
}

View File

@@ -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; }