#ifndef PKMNLIB_POKEMON_HPP #define PKMNLIB_POKEMON_HPP #include #include "../../Library/Statistic.hpp" #include "../Library/BattleLibrary.hpp" #include "../PkmnScript.hpp" #include "LearnedMove.hpp" namespace PkmnLib::Battling { class Pokemon : public CreatureLib::Battling::Creature { private: CreatureLib::Library::ClampedStatisticSet _individualValues; CreatureLib::Library::ClampedStatisticSet _effortValues; ArbUt::BorrowedPtr _nature; std::unique_ptr _statusScript = nullptr; uint8_t _friendship = 0; public: Pokemon(ArbUt::BorrowedPtr library, const ArbUt::BorrowedPtr& species, const ArbUt::BorrowedPtr& forme, level_int_t level, uint32_t experience, uint32_t uid, CreatureLib::Library::Gender gender, uint8_t coloring, ArbUt::OptionalBorrowedPtr heldItem, const std::string& nickname, const CreatureLib::Library::TalentIndex& talent, const std::vector& moves, CreatureLib::Library::ClampedStatisticSet individualValues, CreatureLib::Library::ClampedStatisticSet effortValues, ArbUt::BorrowedPtr nature, bool allowedExperienceGain = true) : CreatureLib::Battling::Creature( library.ForceAs(), species.ForceAs(), forme.ForceAs(), level, experience, uid, gender, coloring, heldItem.ForceAs(), nickname, talent, moves, allowedExperienceGain), _individualValues(individualValues), _effortValues(effortValues), _nature(nature), _friendship(species->GetBaseHappiness()) {} const ArbUt::BorrowedPtr GetForme() const { return _variant.ForceAs(); } inline bool IsShiny() const noexcept { return _coloring == 1; } const ArbUt::List& GetMoves() const { return reinterpret_cast&>(_attacks); } inline const ArbUt::BorrowedPtr& GetNature() const noexcept { return _nature; } inline uint8_t GetIndividualValue(CreatureLib::Library::Statistic stat) const { return _individualValues.GetStat(stat); } inline void SetIndividualValue(CreatureLib::Library::Statistic stat, uint8_t value) { return _individualValues.SetStat(stat, value); } inline uint8_t GetEffortValue(CreatureLib::Library::Statistic stat) const { return _effortValues.GetStat(stat); } inline void SetEffortValue(CreatureLib::Library::Statistic stat, uint8_t value) { return _effortValues.SetStat(stat, value); } inline ArbUt::BorrowedPtr GetPokemonSpecies() const noexcept { return _species.As(); } 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 { uint8_t newValue; if (__builtin_add_overflow(_friendship, amount, &newValue)) { if (amount < 0) newValue = 0; else newValue = 255; } _friendship = newValue; } Creature* Clone() const override; }; } #endif // PKMNLIB_POKEMON_HPP