From b5ea856443e369ea76544c3515a681f4241b8466 Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Fri, 9 Jul 2021 15:37:44 +0200 Subject: [PATCH] Remove status handling, as its already in CreatureLib --- CInterface/Battling/Pokemon.cpp | 4 --- src/Battling/EventHooks/PkmnEventKind.hpp | 2 +- src/Battling/EventHooks/StatusChangeEvent.hpp | 26 ------------------- src/Battling/PkmnScriptCategory.hpp | 2 +- src/Battling/Pokemon/Pokemon.cpp | 24 ----------------- src/Battling/Pokemon/Pokemon.hpp | 9 ------- 6 files changed, 2 insertions(+), 65 deletions(-) delete mode 100644 src/Battling/EventHooks/StatusChangeEvent.hpp diff --git a/CInterface/Battling/Pokemon.cpp b/CInterface/Battling/Pokemon.cpp index c23c9e9..519e741 100644 --- a/CInterface/Battling/Pokemon.cpp +++ b/CInterface/Battling/Pokemon.cpp @@ -46,10 +46,6 @@ export void PkmnLib_Pokemon_SetEffortValue(Pokemon* p, CreatureLib::Library::Sta p->SetEffortValue(stat, value); } -export u8 PkmnLib_Pokemon_SetStatus(Pokemon* p, const char* name) { Try(p->SetStatus(ArbUt::StringView(name))); }; -export u8 PkmnLib_Pokemon_ClearStatus(Pokemon* p) { Try(p->ClearStatus()); }; -export const char* PkmnLib_Pokemon_GetStatusName(Pokemon* p) { return p->GetStatusName().c_str(); } - SIMPLE_GET_FUNC(Pokemon, GetFriendship, uint8_t) export void PkmnLib_Pokemon_SetFriendship(Pokemon* p, u8 value) { p->SetFriendship(value); } export void PkmnLib_Pokemon_ChangeFriendship(Pokemon* p, i8 amount) { p->ChangeFriendship(amount); } diff --git a/src/Battling/EventHooks/PkmnEventKind.hpp b/src/Battling/EventHooks/PkmnEventKind.hpp index 6b2926a..153845a 100644 --- a/src/Battling/EventHooks/PkmnEventKind.hpp +++ b/src/Battling/EventHooks/PkmnEventKind.hpp @@ -2,6 +2,6 @@ #define PKMNLIB_PKMNEVENTKIND_HPP #include -ENUM_WITH_START_VALUE(PkmnEventDataKind, uint8_t, 128, WeatherChange, StatusChange) +ENUM_WITH_START_VALUE(PkmnEventDataKind, uint8_t, 128, WeatherChange) #endif // PKMNLIB_PKMNEVENTKIND_HPP diff --git a/src/Battling/EventHooks/StatusChangeEvent.hpp b/src/Battling/EventHooks/StatusChangeEvent.hpp deleted file mode 100644 index ebf41d8..0000000 --- a/src/Battling/EventHooks/StatusChangeEvent.hpp +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef PKMNLIB_STATUSCHANGEEVENT_HPP -#define PKMNLIB_STATUSCHANGEEVENT_HPP - -#include -#include "../Pokemon/Pokemon.hpp" -#include "PkmnEventKind.hpp" - -namespace PkmnLib::Battling { - class StatusChangeEvent final : public CreatureLib::Battling::EventData { - ArbUt::BorrowedPtr _pokemon; - ArbUt::StringView _statusName; - - public: - explicit StatusChangeEvent(const ArbUt::BorrowedPtr& pkmn, const ArbUt::StringView& name) - : _pokemon(pkmn), _statusName(name) {} - - [[nodiscard]] CreatureLib::Battling::EventDataKind GetKind() const noexcept override { - return static_cast(PkmnEventDataKind::StatusChange); - } - - const ArbUt::BorrowedPtr& GetPokemon() const noexcept { return _pokemon; } - const ArbUt::StringView& GetStatusName() const noexcept { return _statusName; } - }; -} - -#endif // PKMNLIB_STATUSCHANGEEVENT_HPP diff --git a/src/Battling/PkmnScriptCategory.hpp b/src/Battling/PkmnScriptCategory.hpp index dcf0452..85491c4 100644 --- a/src/Battling/PkmnScriptCategory.hpp +++ b/src/Battling/PkmnScriptCategory.hpp @@ -2,6 +2,6 @@ #define PKMNLIB_PKMNSCRIPTCATEGORY_HPP #include -ENUM_WITH_START_VALUE(PkmnScriptCategory, uint8_t, 128, Weather, Status) +ENUM_WITH_START_VALUE(PkmnScriptCategory, uint8_t, 128, Weather) #endif // PKMNLIB_PKMNSCRIPTCATEGORY_HPP diff --git a/src/Battling/Pokemon/Pokemon.cpp b/src/Battling/Pokemon/Pokemon.cpp index 8d7d4f8..8e10a5f 100644 --- a/src/Battling/Pokemon/Pokemon.cpp +++ b/src/Battling/Pokemon/Pokemon.cpp @@ -1,6 +1,5 @@ #include "Pokemon.hpp" #include -#include "../EventHooks/StatusChangeEvent.hpp" #include "../PkmnScriptCategory.hpp" void PkmnLib::Battling::Pokemon::Evolve(ArbUt::BorrowedPtr mon, @@ -28,26 +27,6 @@ void PkmnLib::Battling::Pokemon::Evolve(ArbUt::BorrowedPtrOnRemove(); - } - _statusScript = std::unique_ptr( - _library->LoadScript(static_cast(PkmnScriptCategory::Status), name)); - if (_battleData.Battle.HasValue()) { - _battleData.Battle.GetValue()->TriggerEventListener(this, name); - } -} -void PkmnLib::Battling::Pokemon::ClearStatus() { - if (_statusScript == nullptr) - return; - _statusScript->OnRemove(); - _statusScript = nullptr; - if (_battleData.Battle.HasValue()) { - _battleData.Battle.GetValue()->TriggerEventListener(this, ""_cnc); - } -} - CreatureLib::Battling::Creature* PkmnLib::Battling::Pokemon::Clone() const { auto moves = std::vector(_attacks.Count()); auto i = 0; @@ -83,9 +62,6 @@ CreatureLib::Battling::Creature* PkmnLib::Battling::Pokemon::Clone() const { } _volatile.Clone(c->_volatile); c->_types = std::vector(_types); - if (_statusScript != nullptr) { - c->_statusScript = std::unique_ptr(_statusScript->Clone()); - } c->_friendship = _friendship; c->RecalculateFlatStats(); diff --git a/src/Battling/Pokemon/Pokemon.hpp b/src/Battling/Pokemon/Pokemon.hpp index d142064..cb17fd1 100644 --- a/src/Battling/Pokemon/Pokemon.hpp +++ b/src/Battling/Pokemon/Pokemon.hpp @@ -14,7 +14,6 @@ namespace PkmnLib::Battling { CreatureLib::Library::ClampedStatisticSet _effortValues; ArbUt::BorrowedPtr _nature; - std::unique_ptr _statusScript = nullptr; uint8_t _friendship = 0; bool _isEgg; @@ -71,14 +70,6 @@ namespace PkmnLib::Battling { void Evolve(ArbUt::BorrowedPtr mon, ArbUt::BorrowedPtr forme); - void SetStatus(const ArbUt::StringView& name); - void ClearStatus(); - const ArbUt::StringView& GetStatusName() noexcept { - if (_statusScript == nullptr) - return ArbUt::StringView::EmptyString(); - return _statusScript->GetName(); - } - uint8_t GetFriendship() const noexcept { return _friendship; } void SetFriendship(uint8_t value) noexcept { _friendship = value; } void ChangeFriendship(int8_t amount) noexcept {