PkmnLib/src/Battling/Battle/Battle.hpp

45 lines
1.9 KiB
C++
Raw Normal View History

#ifndef PKMNLIB_BATTLE_HPP
#define PKMNLIB_BATTLE_HPP
#include <CreatureLib/Battling/Models/Battle.hpp>
2020-04-18 14:21:38 +00:00
#include "../EventHooks/WeatherChangeEvent.hpp"
#include "../Library/BattleLibrary.hpp"
2020-04-18 13:35:01 +00:00
#include "../PkmnScriptCategory.hpp"
namespace PkmnLib::Battling {
class Battle : public CreatureLib::Battling::Battle {
2020-04-18 13:35:01 +00:00
private:
CreatureLib::Battling::Script* _weatherScript = nullptr;
public:
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) {}
2020-04-18 13:35:01 +00:00
void SetWeather(const Arbutils::CaseInsensitiveConstString& name) {
if (_weatherScript != nullptr) {
_weatherScript->OnRemove();
delete _weatherScript;
}
_weatherScript = _library->LoadScript(static_cast<ScriptCategory>(PkmnScriptCategory::Weather), name);
2020-04-18 14:21:38 +00:00
_eventHook.TriggerEvent(new WeatherChangeEvent(name));
2020-04-18 13:35:01 +00:00
}
void ClearWeather() {
_weatherScript->OnRemove();
delete _weatherScript;
_weatherScript = nullptr;
2020-04-18 14:21:38 +00:00
_eventHook.TriggerEvent(new WeatherChangeEvent(""_cnc));
2020-04-18 13:35:01 +00:00
}
const Arbutils::CaseInsensitiveConstString& GetWeatherName() noexcept { return _weatherScript->GetName(); }
size_t ScriptCount() const override { return CreatureLib::Battling::Battle::ScriptCount() + 1; }
2020-04-18 13:35:01 +00:00
void GetActiveScripts(List<CreatureLib::Battling::ScriptWrapper>& scripts) override {
CreatureLib::Battling::Battle::GetActiveScripts(scripts);
2020-04-23 21:31:17 +00:00
scripts.Append(CreatureLib::Battling::ScriptWrapper(
CreatureLib::Battling::ScriptWrapper::FromScript(&_weatherScript)));
2020-04-18 13:35:01 +00:00
}
};
}
#endif // PKMNLIB_BATTLE_HPP