Adds Pokemon::IsEgg function, make eggs not usable in battle.
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2021-06-19 12:44:05 +02:00
parent d779c7cbfe
commit 94de55f933
3 changed files with 33 additions and 17 deletions

View File

@@ -91,3 +91,9 @@ CreatureLib::Battling::Creature* PkmnLib::Battling::Pokemon::Clone() const {
return c;
}
bool PkmnLib::Battling::Pokemon::IsUsable() const noexcept {
if (IsEgg()) {
return false;
}
return Creature::IsUsable();
}

View File

@@ -16,6 +16,7 @@ namespace PkmnLib::Battling {
ArbUt::BorrowedPtr<const PkmnLib::Library::Nature> _nature;
std::unique_ptr<CreatureLib::Battling::BattleScript> _statusScript = nullptr;
uint8_t _friendship = 0;
bool _isEgg;
public:
Pokemon(ArbUt::BorrowedPtr<const BattleLibrary> library,
@@ -27,14 +28,15 @@ namespace PkmnLib::Battling {
const std::vector<CreatureLib::Battling::LearnedAttack*>& moves,
CreatureLib::Library::ClampedStatisticSet<uint8_t, 0, 31> individualValues,
CreatureLib::Library::ClampedStatisticSet<uint8_t, 0, 252> effortValues,
ArbUt::BorrowedPtr<const PkmnLib::Library::Nature> nature, bool allowedExperienceGain = true)
ArbUt::BorrowedPtr<const PkmnLib::Library::Nature> nature, bool allowedExperienceGain = true,
bool isEgg = false)
: CreatureLib::Battling::Creature(
library.ForceAs<const CreatureLib::Battling::BattleLibrary>(),
species.ForceAs<const CreatureLib::Library::CreatureSpecies>(),
forme.ForceAs<const CreatureLib::Library::SpeciesVariant>(), level, experience, uid, gender, coloring,
heldItem.ForceAs<const CreatureLib::Library::Item>(), nickname, talent, moves, allowedExperienceGain),
_individualValues(individualValues), _effortValues(effortValues), _nature(nature),
_friendship(species->GetBaseHappiness()) {}
_friendship(species->GetBaseHappiness()), _isEgg(isEgg) {}
const ArbUt::BorrowedPtr<const Library::PokemonForme> GetForme() const {
return _variant.ForceAs<const Library::PokemonForme>();
@@ -59,6 +61,7 @@ namespace PkmnLib::Battling {
inline void SetEffortValue(CreatureLib::Library::Statistic stat, uint8_t value) {
return _effortValues.SetStat(stat, value);
}
inline bool IsEgg() const noexcept { return _isEgg; }
inline ArbUt::BorrowedPtr<const PkmnLib::Library::PokemonSpecies> GetPokemonSpecies() const noexcept {
return _species.As<const PkmnLib::Library::PokemonSpecies>();
@@ -88,6 +91,8 @@ namespace PkmnLib::Battling {
_friendship = newValue;
}
bool IsUsable() const noexcept override;
Creature* Clone() const override;
};
}