PkmnLib/src/Battling/Battle/Battle.hpp

58 lines
2.2 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"
2021-03-07 10:12:18 +00:00
#include "../PkmnScript.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:
2022-05-14 14:50:20 +00:00
ArbUt::OptionalUniquePtr<CreatureLib::Battling::BattleScript> _weatherScript = nullptr;
2020-04-18 13:35:01 +00:00
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) {}
2020-04-18 13:35:01 +00:00
2020-12-28 14:11:06 +00:00
virtual ~Battle() = default;
bool SetWeather(const ArbUt::StringView& name);
2020-04-26 18:01:11 +00:00
void ClearWeather();
void SuppressWeather() {
2022-05-14 14:50:20 +00:00
if (_weatherScript.HasValue()) {
_weatherScript.GetValue()->Suppress();
}
}
void UnsuppressWeather() {
2022-05-14 14:50:20 +00:00
if (_weatherScript.HasValue()) {
_weatherScript.GetValue()->Unsuppress();
}
}
2020-08-17 16:23:25 +00:00
const ArbUt::StringView& GetWeatherName() noexcept {
2022-05-14 14:50:20 +00:00
if (!_weatherScript.HasValue()) {
2020-08-17 16:23:25 +00:00
return ArbUt::StringView::EmptyString();
2022-05-14 14:50:20 +00:00
}
return _weatherScript.GetValue()->GetName();
2020-08-17 16:23:25 +00:00
}
2020-04-18 13:35:01 +00:00
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);
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
}
Battle* non_null Clone() const override;
};
}
#endif // PKMNLIB_BATTLE_HPP