2020-01-02 17:02:40 +00:00
|
|
|
#ifndef PKMNLIB_POKEMON_HPP
|
|
|
|
#define PKMNLIB_POKEMON_HPP
|
|
|
|
|
2020-02-08 18:22:29 +00:00
|
|
|
#include <CreatureLib/Battling/Models/Creature.hpp>
|
2020-01-02 17:02:40 +00:00
|
|
|
#include <utility>
|
2020-01-05 14:18:30 +00:00
|
|
|
#include "../../Library/Statistic.hpp"
|
2020-01-02 17:02:40 +00:00
|
|
|
#include "../Library/BattleLibrary.hpp"
|
|
|
|
#include "LearnedMove.hpp"
|
|
|
|
|
|
|
|
namespace PkmnLib::Battling {
|
|
|
|
class Pokemon : public CreatureLib::Battling::Creature {
|
|
|
|
private:
|
2020-08-08 15:52:57 +00:00
|
|
|
CreatureLib::Library::ClampedStatisticSet<uint8_t, 0, 31> _individualValues;
|
|
|
|
CreatureLib::Library::ClampedStatisticSet<uint8_t, 0, 252> _effortValues;
|
2020-01-02 17:02:40 +00:00
|
|
|
|
2020-06-02 18:37:21 +00:00
|
|
|
ArbUt::BorrowedPtr<const PkmnLib::Library::Nature> _nature;
|
2020-08-08 10:01:05 +00:00
|
|
|
std::unique_ptr<CreatureLib::Battling::Script> _statusScript = nullptr;
|
2020-08-08 15:52:57 +00:00
|
|
|
uint8_t _friendship = 0;
|
2020-01-02 19:26:01 +00:00
|
|
|
|
2020-01-02 17:02:40 +00:00
|
|
|
public:
|
2020-06-02 18:37:21 +00:00
|
|
|
Pokemon(ArbUt::BorrowedPtr<const BattleLibrary> library,
|
|
|
|
const ArbUt::BorrowedPtr<const Library::PokemonSpecies>& species,
|
2020-05-27 15:26:25 +00:00
|
|
|
const ArbUt::BorrowedPtr<const Library::PokemonForme>& forme, uint8_t level, uint32_t experience,
|
|
|
|
uint32_t uid, CreatureLib::Library::Gender gender, uint8_t coloring,
|
2020-07-26 08:50:52 +00:00
|
|
|
ArbUt::BorrowedPtr<const Library::Item> heldItem, const std::string& nickname,
|
2020-05-27 15:26:25 +00:00
|
|
|
const CreatureLib::Library::TalentIndex& talent,
|
2020-06-02 18:37:21 +00:00
|
|
|
const std::vector<CreatureLib::Battling::LearnedAttack*>& moves,
|
2020-08-08 15:52:57 +00:00
|
|
|
CreatureLib::Library::ClampedStatisticSet<uint8_t, 0, 31> individualValues,
|
|
|
|
CreatureLib::Library::ClampedStatisticSet<uint8_t, 0, 252> effortValues,
|
2020-06-02 18:37:21 +00:00
|
|
|
ArbUt::BorrowedPtr<const PkmnLib::Library::Nature> nature, bool allowedExperienceGain = true)
|
|
|
|
: CreatureLib::Battling::Creature(library.ForceAs<const CreatureLib::Battling::BattleLibrary>(),
|
|
|
|
species.ForceAs<const CreatureLib::Library::CreatureSpecies>(),
|
2020-05-27 15:26:25 +00:00
|
|
|
forme.As<const CreatureLib::Library::SpeciesVariant>(), level, experience,
|
|
|
|
uid, gender, coloring, heldItem.As<const CreatureLib::Library::Item>(),
|
|
|
|
nickname, talent, moves, allowedExperienceGain),
|
2020-08-08 15:52:57 +00:00
|
|
|
_individualValues(individualValues), _effortValues(effortValues), _nature(nature),
|
|
|
|
_friendship(species->GetBaseHappiness()) {}
|
2020-01-02 19:26:01 +00:00
|
|
|
|
2020-05-27 15:26:25 +00:00
|
|
|
const ArbUt::BorrowedPtr<const Library::PokemonForme> GetForme() const {
|
|
|
|
return _variant.As<const Library::PokemonForme>();
|
2020-01-05 14:18:30 +00:00
|
|
|
}
|
2020-01-26 14:18:04 +00:00
|
|
|
|
2020-04-18 11:43:05 +00:00
|
|
|
inline bool IsShiny() const noexcept { return _coloring == 1; }
|
2020-02-02 12:57:41 +00:00
|
|
|
|
2020-05-27 15:26:25 +00:00
|
|
|
const ArbUt::List<LearnedMove*>& GetMoves() const {
|
|
|
|
return reinterpret_cast<const ArbUt::List<LearnedMove*>&>(_attacks);
|
2020-02-01 15:56:09 +00:00
|
|
|
}
|
|
|
|
|
2020-06-02 18:37:21 +00:00
|
|
|
inline const ArbUt::BorrowedPtr<const PkmnLib::Library::Nature>& GetNature() const noexcept { return _nature; }
|
2020-04-18 11:43:05 +00:00
|
|
|
inline uint8_t GetIndividualValue(CreatureLib::Library::Statistic stat) const {
|
2020-04-06 18:03:44 +00:00
|
|
|
return _individualValues.GetStat(stat);
|
|
|
|
}
|
2020-08-08 15:52:57 +00:00
|
|
|
inline void SetIndividualValue(CreatureLib::Library::Statistic stat, uint8_t value) {
|
|
|
|
return _individualValues.SetStat(stat, value);
|
|
|
|
}
|
2020-04-18 11:43:05 +00:00
|
|
|
inline uint8_t GetEffortValue(CreatureLib::Library::Statistic stat) const {
|
|
|
|
return _effortValues.GetStat(stat);
|
|
|
|
}
|
2020-08-08 15:52:57 +00:00
|
|
|
inline void SetEffortValue(CreatureLib::Library::Statistic stat, uint8_t value) {
|
|
|
|
return _effortValues.SetStat(stat, value);
|
|
|
|
}
|
2020-05-20 14:05:52 +00:00
|
|
|
|
2020-05-27 15:26:25 +00:00
|
|
|
inline ArbUt::BorrowedPtr<const PkmnLib::Library::PokemonSpecies> GetPokemonSpecies() const noexcept {
|
|
|
|
return _species.As<const PkmnLib::Library::PokemonSpecies>();
|
2020-05-20 14:05:52 +00:00
|
|
|
}
|
2020-06-10 10:33:51 +00:00
|
|
|
|
|
|
|
void Evolve(ArbUt::BorrowedPtr<const Library::PokemonSpecies> mon,
|
|
|
|
ArbUt::BorrowedPtr<const Library::PokemonForme> forme);
|
2020-08-08 10:01:05 +00:00
|
|
|
|
|
|
|
void SetStatus(const ArbUt::StringView& name);
|
|
|
|
void ClearStatus();
|
|
|
|
const ArbUt::StringView& GetStatusName() noexcept {
|
|
|
|
if (_statusScript == nullptr)
|
2020-08-08 10:35:57 +00:00
|
|
|
return ArbUt::StringView::EmptyString();
|
2020-08-08 10:01:05 +00:00
|
|
|
return _statusScript->GetName();
|
|
|
|
}
|
2020-08-08 15:52:57 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
2020-01-02 17:02:40 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // PKMNLIB_POKEMON_HPP
|