Remove status handling, as its already in CreatureLib
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Deukhoofd 2021-07-09 15:37:44 +02:00
parent 2e2dfbaf1d
commit b5ea856443
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
6 changed files with 2 additions and 65 deletions

View File

@ -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); }

View File

@ -2,6 +2,6 @@
#define PKMNLIB_PKMNEVENTKIND_HPP
#include <CreatureLib/Battling/EventHooks/EventDataKind.hpp>
ENUM_WITH_START_VALUE(PkmnEventDataKind, uint8_t, 128, WeatherChange, StatusChange)
ENUM_WITH_START_VALUE(PkmnEventDataKind, uint8_t, 128, WeatherChange)
#endif // PKMNLIB_PKMNEVENTKIND_HPP

View File

@ -1,26 +0,0 @@
#ifndef PKMNLIB_STATUSCHANGEEVENT_HPP
#define PKMNLIB_STATUSCHANGEEVENT_HPP
#include <CreatureLib/Battling/EventHooks/Events/EventData.hpp>
#include "../Pokemon/Pokemon.hpp"
#include "PkmnEventKind.hpp"
namespace PkmnLib::Battling {
class StatusChangeEvent final : public CreatureLib::Battling::EventData {
ArbUt::BorrowedPtr<Pokemon> _pokemon;
ArbUt::StringView _statusName;
public:
explicit StatusChangeEvent(const ArbUt::BorrowedPtr<Pokemon>& pkmn, const ArbUt::StringView& name)
: _pokemon(pkmn), _statusName(name) {}
[[nodiscard]] CreatureLib::Battling::EventDataKind GetKind() const noexcept override {
return static_cast<CreatureLib::Battling::EventDataKind>(PkmnEventDataKind::StatusChange);
}
const ArbUt::BorrowedPtr<Pokemon>& GetPokemon() const noexcept { return _pokemon; }
const ArbUt::StringView& GetStatusName() const noexcept { return _statusName; }
};
}
#endif // PKMNLIB_STATUSCHANGEEVENT_HPP

View File

@ -2,6 +2,6 @@
#define PKMNLIB_PKMNSCRIPTCATEGORY_HPP
#include <CreatureLib/Battling/ScriptHandling/ScriptCategory.hpp>
ENUM_WITH_START_VALUE(PkmnScriptCategory, uint8_t, 128, Weather, Status)
ENUM_WITH_START_VALUE(PkmnScriptCategory, uint8_t, 128, Weather)
#endif // PKMNLIB_PKMNSCRIPTCATEGORY_HPP

View File

@ -1,6 +1,5 @@
#include "Pokemon.hpp"
#include <CreatureLib/Battling/Models/Battle.hpp>
#include "../EventHooks/StatusChangeEvent.hpp"
#include "../PkmnScriptCategory.hpp"
void PkmnLib::Battling::Pokemon::Evolve(ArbUt::BorrowedPtr<const Library::PokemonSpecies> mon,
@ -28,26 +27,6 @@ void PkmnLib::Battling::Pokemon::Evolve(ArbUt::BorrowedPtr<const Library::Pokemo
// TODO: Event hook
}
void PkmnLib::Battling::Pokemon::SetStatus(const ArbUt::StringView& name) {
if (_statusScript != nullptr) {
_statusScript->OnRemove();
}
_statusScript = std::unique_ptr<CreatureLib::Battling::BattleScript>(
_library->LoadScript(static_cast<ScriptCategory>(PkmnScriptCategory::Status), name));
if (_battleData.Battle.HasValue()) {
_battleData.Battle.GetValue()->TriggerEventListener<StatusChangeEvent>(this, name);
}
}
void PkmnLib::Battling::Pokemon::ClearStatus() {
if (_statusScript == nullptr)
return;
_statusScript->OnRemove();
_statusScript = nullptr;
if (_battleData.Battle.HasValue()) {
_battleData.Battle.GetValue()->TriggerEventListener<StatusChangeEvent>(this, ""_cnc);
}
}
CreatureLib::Battling::Creature* PkmnLib::Battling::Pokemon::Clone() const {
auto moves = std::vector<CreatureLib::Battling::LearnedAttack*>(_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<u8>(_types);
if (_statusScript != nullptr) {
c->_statusScript = std::unique_ptr<PkmnScript::BattleScript>(_statusScript->Clone());
}
c->_friendship = _friendship;
c->RecalculateFlatStats();

View File

@ -14,7 +14,6 @@ namespace PkmnLib::Battling {
CreatureLib::Library::ClampedStatisticSet<uint8_t, 0, 252> _effortValues;
ArbUt::BorrowedPtr<const PkmnLib::Library::Nature> _nature;
std::unique_ptr<CreatureLib::Battling::BattleScript> _statusScript = nullptr;
uint8_t _friendship = 0;
bool _isEgg;
@ -71,14 +70,6 @@ namespace PkmnLib::Battling {
void Evolve(ArbUt::BorrowedPtr<const Library::PokemonSpecies> mon,
ArbUt::BorrowedPtr<const Library::PokemonForme> 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 {