Change types on Creature to List instead of vector
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -34,7 +34,7 @@ namespace CreatureLib::Battling {
|
||||
.TakeOwnership();
|
||||
}
|
||||
for (auto t : _variant->GetTypes()) {
|
||||
_types.push_back(t);
|
||||
_types.Append(t);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,9 +75,9 @@ namespace CreatureLib::Battling {
|
||||
_variant = variant;
|
||||
|
||||
// Set the types to the new variant.
|
||||
_types.clear();
|
||||
_types.Clear();
|
||||
for (auto t : variant->GetTypes()) {
|
||||
_types.push_back(t);
|
||||
_types.Append(t);
|
||||
}
|
||||
|
||||
_weight = variant->GetWeight();
|
||||
@@ -136,9 +136,9 @@ namespace CreatureLib::Battling {
|
||||
ResetActiveScripts();
|
||||
_weight = _variant->GetWeight();
|
||||
_height = _variant->GetHeight();
|
||||
_types.clear();
|
||||
_types.Clear();
|
||||
for (auto t : _variant->GetTypes()) {
|
||||
_types.push_back(t);
|
||||
_types.Append(t);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -273,17 +273,11 @@ namespace CreatureLib::Battling {
|
||||
_overridenTalent = _library->GetStaticLib()->GetTalentLibrary()->Get(talent);
|
||||
}
|
||||
|
||||
const std::vector<u8>& Creature::GetTypes() const noexcept { return _types; }
|
||||
|
||||
bool Creature::HasType(u8 type) const noexcept {
|
||||
return std::find(_types.begin(), _types.end(), type) != _types.end();
|
||||
}
|
||||
|
||||
void Creature::SetType(u8 index, u8 type) noexcept {
|
||||
if (_types.size() > index) {
|
||||
if (_types.Count() > index) {
|
||||
_types[index] = type;
|
||||
} else {
|
||||
_types.push_back(type);
|
||||
_types.Append(type);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -474,7 +468,7 @@ namespace CreatureLib::Battling {
|
||||
c->_status = _status.GetValue()->Clone(c);
|
||||
}
|
||||
_volatile.Clone(c, c->_volatile);
|
||||
c->_types = std::vector<u8>(_types);
|
||||
c->_types = ArbUt::List<u8>(_types);
|
||||
c->RecalculateFlatStats();
|
||||
|
||||
return c;
|
||||
|
||||
@@ -64,7 +64,7 @@ namespace CreatureLib::Battling {
|
||||
ArbUt::OptionalUniquePtr<BattleScript> _status = nullptr;
|
||||
ScriptSet _volatile = {};
|
||||
|
||||
std::vector<u8> _types = {};
|
||||
ArbUt::List<u8> _types = {};
|
||||
|
||||
ArbUt::OptionalBorrowedPtr<const Library::Item> _heldItem;
|
||||
ArbUt::OptionalUniquePtr<BattleScript> _heldItemTriggerScript = nullptr;
|
||||
@@ -153,8 +153,8 @@ namespace CreatureLib::Battling {
|
||||
/// Are we allowed to use this creature in a battle?
|
||||
[[nodiscard]] virtual bool IsUsable() const noexcept;
|
||||
[[nodiscard]] bool IsFainted() const noexcept;
|
||||
[[nodiscard]] const std::vector<u8>& GetTypes() const noexcept;
|
||||
[[nodiscard]] bool HasType(u8 type) const noexcept;
|
||||
[[nodiscard]] inline const ArbUt::List<u8>& GetTypes() const noexcept { return _types; }
|
||||
[[nodiscard]] inline bool HasType(u8 type) const noexcept { return _types.Contains(type); }
|
||||
void SetType(u8 index, u8 type) noexcept;
|
||||
|
||||
u32 GetMaxHealth() const noexcept { return _boostedStats.GetHealth(); }
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace CreatureLib::Library {
|
||||
(u32)defensive);
|
||||
}
|
||||
}
|
||||
[[nodiscard]] inline float GetEffectiveness(u8 attacking, const std::vector<u8>& defensive) const {
|
||||
[[nodiscard]] inline float GetEffectiveness(u8 attacking, const ArbUt::List<u8>& defensive) const {
|
||||
return std::accumulate(defensive.begin(), defensive.end(), (float)1,
|
||||
[this, attacking](float init, u8 defense) {
|
||||
return init * GetSingleEffectiveness(attacking, defense);
|
||||
|
||||
Reference in New Issue
Block a user