PkmnLib/src/Battling/Battle/Battle.hpp

57 lines
2.2 KiB
C++

#ifndef PKMNLIB_BATTLE_HPP
#define PKMNLIB_BATTLE_HPP
#include <CreatureLib/Battling/Models/Battle.hpp>
#include "../EventHooks/WeatherChangeEvent.hpp"
#include "../Library/BattleLibrary.hpp"
#include "../PkmnScript.hpp"
#include "../PkmnScriptCategory.hpp"
namespace PkmnLib::Battling {
class Battle : public CreatureLib::Battling::Battle {
private:
std::unique_ptr<CreatureLib::Battling::BattleScript> _weatherScript = nullptr;
public:
Battle(const BattleLibrary* non_null library,
const ArbUt::List<CreatureLib::Battling::BattleParty * non_null>& parties, bool canFlee = true,
u8 numberOfSides = 2, u8 creaturesPerSide = 1,
uint_fast32_t randomSeed = std::chrono::duration_cast<std::chrono::milliseconds>(
std::chrono::system_clock::now().time_since_epoch())
.count())
: CreatureLib::Battling::Battle(library, parties, canFlee, numberOfSides, creaturesPerSide, randomSeed) {}
virtual ~Battle() = default;
bool SetWeather(const ArbUt::StringView& name);
void ClearWeather();
void SuppressWeather() {
if (_weatherScript != nullptr) {
_weatherScript->Suppress();
}
}
void UnsuppressWeather() {
if (_weatherScript != nullptr) {
_weatherScript->Unsuppress();
}
}
const ArbUt::StringView& GetWeatherName() noexcept {
if (_weatherScript == nullptr)
return ArbUt::StringView::EmptyString();
return _weatherScript->GetName();
}
size_t ScriptCount() const override { return CreatureLib::Battling::Battle::ScriptCount() + 1; }
void GetOwnScripts(ArbUt::List<CreatureLib::Battling::ScriptWrapper>& scripts) override {
CreatureLib::Battling::Battle::GetOwnScripts(scripts);
scripts.Append(CreatureLib::Battling::ScriptWrapper(
CreatureLib::Battling::ScriptWrapper::FromScript(&_weatherScript)));
}
Battle* non_null Clone() const override;
};
}
#endif // PKMNLIB_BATTLE_HPP