Implements Weather
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2020-04-18 15:35:01 +02:00
parent caa353191d
commit c6d31e09a1
3 changed files with 67 additions and 24 deletions

View File

@@ -3,13 +3,36 @@
#include <CreatureLib/Battling/Models/Battle.hpp>
#include "../Library/BattleLibrary.hpp"
#include "../PkmnScriptCategory.hpp"
namespace PkmnLib::Battling {
class Battle : public CreatureLib::Battling::Battle {
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) {}
void SetWeather(const Arbutils::CaseInsensitiveConstString& name) {
if (_weatherScript != nullptr) {
_weatherScript->OnRemove();
delete _weatherScript;
}
_weatherScript = _library->LoadScript(static_cast<ScriptCategory>(PkmnScriptCategory::Weather), name);
}
void ClearWeather() {
_weatherScript->OnRemove();
delete _weatherScript;
_weatherScript = nullptr;
}
const Arbutils::CaseInsensitiveConstString& GetWeatherName() noexcept { return _weatherScript->GetName(); }
void GetActiveScripts(List<CreatureLib::Battling::ScriptWrapper>& scripts) override {
CreatureLib::Battling::Battle::GetActiveScripts(scripts);
scripts.Append(CreatureLib::Battling::ScriptWrapper(&_weatherScript));
}
};
}

View File

@@ -0,0 +1,8 @@
#ifndef PKMNLIB_PKMNSCRIPTCATEGORY_HPP
#define PKMNLIB_PKMNSCRIPTCATEGORY_HPP
#include <Arbutils/Enum.hpp>
#include <CreatureLib/Battling/ScriptHandling/ScriptCategory.hpp>
ENUM_WITH_START_VALUE(PkmnScriptCategory, uint8_t, ((uint8_t)ScriptCategoryHelper::Highest()) + 1, Weather)
#endif // PKMNLIB_PKMNSCRIPTCATEGORY_HPP