2020-02-16 16:50:16 +00:00
|
|
|
#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"
|
2020-02-16 16:50:16 +00:00
|
|
|
#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"
|
2020-02-16 16:50:16 +00:00
|
|
|
|
|
|
|
namespace PkmnLib::Battling {
|
2020-02-17 15:56:44 +00:00
|
|
|
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
|
|
|
|
2020-02-16 16:50:16 +00:00
|
|
|
public:
|
2022-03-25 18:08:42 +00:00
|
|
|
Battle(const BattleLibrary* non_null library,
|
|
|
|
const ArbUt::List<CreatureLib::Battling::BattleParty * non_null>& parties, bool canFlee = true,
|
|
|
|
u8 numberOfSides = 2, u8 creaturesPerSide = 1,
|
2020-07-26 08:50:39 +00:00
|
|
|
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;
|
|
|
|
|
2021-11-19 13:56:29 +00:00
|
|
|
bool SetWeather(const ArbUt::StringView& name);
|
2020-04-26 18:01:11 +00:00
|
|
|
void ClearWeather();
|
2021-11-19 13:56:29 +00:00
|
|
|
void SuppressWeather() {
|
2022-05-14 14:50:20 +00:00
|
|
|
if (_weatherScript.HasValue()) {
|
|
|
|
_weatherScript.GetValue()->Suppress();
|
2021-11-19 13:56:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
void UnsuppressWeather() {
|
2022-05-14 14:50:20 +00:00
|
|
|
if (_weatherScript.HasValue()) {
|
|
|
|
_weatherScript.GetValue()->Unsuppress();
|
2021-11-19 13:56:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2020-04-25 09:43:04 +00:00
|
|
|
size_t ScriptCount() const override { return CreatureLib::Battling::Battle::ScriptCount() + 1; }
|
2021-10-29 17:35:31 +00:00
|
|
|
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
|
|
|
}
|
2021-04-11 14:27:21 +00:00
|
|
|
|
2022-03-25 18:08:42 +00:00
|
|
|
Battle* non_null Clone() const override;
|
2020-02-16 16:50:16 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // PKMNLIB_BATTLE_HPP
|