#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; u8 _friendship = 0; bool _isEgg; public: Pokemon(ArbUt::BorrowedPtr library, const ArbUt::BorrowedPtr& species, const ArbUt::BorrowedPtr& forme, level_int_t level, u32 experience, u32 uid, CreatureLib::Library::Gender gender, u8 coloring, ArbUt::OptionalBorrowedPtr heldItem, const std::optional& nickname, const CreatureLib::Library::TalentIndex& talent, const std::vector& moves, CreatureLib::Library::ClampedStatisticSet individualValues, CreatureLib::Library::ClampedStatisticSet effortValues, ArbUt::BorrowedPtr nature, bool allowedExperienceGain = true, bool isEgg = false) : 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()), _isEgg(isEgg) {} 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 u8 GetIndividualValue(CreatureLib::Library::Statistic stat) const { return _individualValues.GetStat(stat); } inline void SetIndividualValue(CreatureLib::Library::Statistic stat, u8 value) { return _individualValues.SetStat(stat, value); } inline u8 GetEffortValue(CreatureLib::Library::Statistic stat) const { return _effortValues.GetStat(stat); } inline void SetEffortValue(CreatureLib::Library::Statistic stat, u8 value) { return _effortValues.SetStat(stat, value); } inline bool IsEgg() const noexcept { return _isEgg; } inline void SetIsEgg(bool value) noexcept { _isEgg = value; } inline ArbUt::BorrowedPtr GetPokemonSpecies() const noexcept { return _species.As(); } void Evolve(ArbUt::BorrowedPtr mon, ArbUt::BorrowedPtr forme); u8 GetFriendship() const noexcept { return _friendship; } void SetFriendship(u8 value) noexcept { _friendship = value; } void ChangeFriendship(i8 amount) noexcept { u8 newValue; if (__builtin_add_overflow(_friendship, amount, &newValue)) { if (amount < 0) newValue = 0; else newValue = 255; } _friendship = newValue; } bool IsUsable() const noexcept override; Creature* non_null Clone() const override; }; } #endif // PKMNLIB_POKEMON_HPP