#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; uint8_t _friendship = 0; bool _isEgg; 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::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 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 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); 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; } bool IsUsable() const noexcept override; Creature* Clone() const override; }; } #endif // PKMNLIB_POKEMON_HPP