Update to latest CreatureLib
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2022-05-14 16:50:20 +02:00
parent 50c58a9fd3
commit cf34563a56
22 changed files with 58 additions and 54 deletions

View File

@@ -10,7 +10,7 @@
namespace PkmnLib::Battling {
class Battle : public CreatureLib::Battling::Battle {
private:
std::unique_ptr<CreatureLib::Battling::BattleScript> _weatherScript = nullptr;
ArbUt::OptionalUniquePtr<CreatureLib::Battling::BattleScript> _weatherScript = nullptr;
public:
Battle(const BattleLibrary* non_null library,
@@ -26,20 +26,21 @@ namespace PkmnLib::Battling {
bool SetWeather(const ArbUt::StringView& name);
void ClearWeather();
void SuppressWeather() {
if (_weatherScript != nullptr) {
_weatherScript->Suppress();
if (_weatherScript.HasValue()) {
_weatherScript.GetValue()->Suppress();
}
}
void UnsuppressWeather() {
if (_weatherScript != nullptr) {
_weatherScript->Unsuppress();
if (_weatherScript.HasValue()) {
_weatherScript.GetValue()->Unsuppress();
}
}
const ArbUt::StringView& GetWeatherName() noexcept {
if (_weatherScript == nullptr)
if (!_weatherScript.HasValue()) {
return ArbUt::StringView::EmptyString();
return _weatherScript->GetName();
}
return _weatherScript.GetValue()->GetName();
}
size_t ScriptCount() const override { return CreatureLib::Battling::Battle::ScriptCount() + 1; }