Allow changing creature types
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Deukhoofd 2022-03-12 12:37:26 +01:00
parent a015a3fc62
commit 6e9844b343
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
2 changed files with 13 additions and 0 deletions

View File

@ -134,6 +134,10 @@ namespace CreatureLib::Battling {
ResetActiveScripts();
_weight = _variant->GetWeight();
_height = _variant->GetHeight();
_types.clear();
for (auto t : _variant->GetTypes()) {
_types.push_back(t);
}
}
void Battling::Creature::SetOnBattleField(bool value) {
@ -273,6 +277,14 @@ namespace CreatureLib::Battling {
return std::find(_types.begin(), _types.end(), type) != _types.end();
}
void Creature::SetType(u8 index, u8 type) noexcept {
if (_types.size() > index) {
_types[index] = type;
} else {
_types.push_back(type);
}
}
size_t Creature::ScriptCount() const {
auto c = 3;
if (_battleData.Side.HasValue()) {

View File

@ -156,6 +156,7 @@ namespace CreatureLib::Battling {
[[nodiscard]] bool IsFainted() const noexcept;
[[nodiscard]] const std::vector<uint8_t>& GetTypes() const noexcept;
[[nodiscard]] bool HasType(uint8_t type) const noexcept;
void SetType(u8 index, u8 type) noexcept;
uint32_t GetMaxHealth() const noexcept { return _boostedStats.GetHealth(); }
void ChangeLevelBy(int8_t amount);