Use vector instead of set for types.
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
Signed-off-by: Deukhoofd <Deukhoofd@gmail.com>
This commit is contained in:
parent
de8b5de7b4
commit
1dc3aafd33
|
@ -56,6 +56,8 @@ BORROWED_GET_FUNC(Creature, GetBattleSide, BattleSide*);
|
||||||
SIMPLE_GET_FUNC(Creature, IsOnBattleField, bool);
|
SIMPLE_GET_FUNC(Creature, IsOnBattleField, bool);
|
||||||
export const char* CreatureLib_Creature_GetNickname(Creature* p) { return p->GetNickname().data(); }
|
export const char* CreatureLib_Creature_GetNickname(Creature* p) { return p->GetNickname().data(); }
|
||||||
export bool CreatureLib_Creature_HasType(Creature* p, uint8_t type) { return p->HasType(type); }
|
export bool CreatureLib_Creature_HasType(Creature* p, uint8_t type) { return p->HasType(type); }
|
||||||
|
export size_t CreatureLib_Creature_GetTypeCount(Creature* p) { return p->GetTypes().size(); }
|
||||||
|
export const uint8_t* CreatureLib_Creature_GetTypes(Creature* p) { return p->GetTypes().data(); }
|
||||||
SIMPLE_GET_FUNC(Creature, GetMaxHealth, uint32_t);
|
SIMPLE_GET_FUNC(Creature, GetMaxHealth, uint32_t);
|
||||||
export uint8_t CreatureLib_Creature_ChangeLevelBy(Creature* p, int8_t level) { Try(p->ChangeLevelBy(level);) }
|
export uint8_t CreatureLib_Creature_ChangeLevelBy(Creature* p, int8_t level) { Try(p->ChangeLevelBy(level);) }
|
||||||
export uint8_t CreatureLib_Creature_Damage(Creature* p, uint32_t damage, DamageSource source) {
|
export uint8_t CreatureLib_Creature_Damage(Creature* p, uint32_t damage, DamageSource source) {
|
||||||
|
|
|
@ -27,7 +27,7 @@ export uint8_t CreatureLib_TypeLibrary_GetSingleEffectiveness(float& out, TypeLi
|
||||||
|
|
||||||
export uint8_t CreatureLib_TypeLibrary_GetEffectiveness(float& out, TypeLibrary* p, uint8_t attacking,
|
export uint8_t CreatureLib_TypeLibrary_GetEffectiveness(float& out, TypeLibrary* p, uint8_t attacking,
|
||||||
uint8_t defensive[], size_t defensiveCount) {
|
uint8_t defensive[], size_t defensiveCount) {
|
||||||
Try(out = p->GetEffectiveness(attacking, std::unordered_set<uint8_t>(defensive, defensive + defensiveCount));)
|
Try(out = p->GetEffectiveness(attacking, std::vector<uint8_t>(defensive, defensive + defensiveCount));)
|
||||||
}
|
}
|
||||||
export uint8_t CreatureLib_TypeLibrary_GetTypeName(const char*& out, TypeLibrary* p, uint8_t type) {
|
export uint8_t CreatureLib_TypeLibrary_GetTypeName(const char*& out, TypeLibrary* p, uint8_t type) {
|
||||||
Try(out = p->GetTypeName(type).c_str();)
|
Try(out = p->GetTypeName(type).c_str();)
|
||||||
|
|
|
@ -26,7 +26,7 @@ class CreatureLibConan(ConanFile):
|
||||||
self.output.info("Linking C libraries statically")
|
self.output.info("Linking C libraries statically")
|
||||||
cmake.definitions["STATICC"] = "ON"
|
cmake.definitions["STATICC"] = "ON"
|
||||||
self.output.info("Using level size of: %s" % self.options.level_size)
|
self.output.info("Using level size of: %s" % self.options.level_size)
|
||||||
cmake.definitions["LEVEL_SIZE"] = self.options.level_size;
|
cmake.definitions["LEVEL_SIZE"] = self.options.level_size
|
||||||
|
|
||||||
cmake.configure()
|
cmake.configure()
|
||||||
cmake.build()
|
cmake.build()
|
||||||
|
|
|
@ -23,7 +23,7 @@ namespace CreatureLib::Battling {
|
||||||
|
|
||||||
_activeTalent = std::unique_ptr<Script>(_library->LoadScript(ScriptCategory::Talent, GetActiveTalent()));
|
_activeTalent = std::unique_ptr<Script>(_library->LoadScript(ScriptCategory::Talent, GetActiveTalent()));
|
||||||
for (auto t : _variant->GetTypes()) {
|
for (auto t : _variant->GetTypes()) {
|
||||||
_types.insert(t);
|
_types.push_back(t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ namespace CreatureLib::Battling {
|
||||||
// Set the types to the new variant.
|
// Set the types to the new variant.
|
||||||
_types.clear();
|
_types.clear();
|
||||||
for (auto t : variant->GetTypes()) {
|
for (auto t : variant->GetTypes()) {
|
||||||
_types.insert(t);
|
_types.push_back(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Grab the new active talent.
|
// Grab the new active talent.
|
||||||
|
@ -215,7 +215,7 @@ namespace CreatureLib::Battling {
|
||||||
_overridenTalentName = talent;
|
_overridenTalentName = talent;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::unordered_set<uint8_t>& Creature::GetTypes() const noexcept { return _types; }
|
const std::vector<uint8_t>& Creature::GetTypes() const noexcept { return _types; }
|
||||||
|
|
||||||
bool Creature::HasType(uint8_t type) const noexcept {
|
bool Creature::HasType(uint8_t type) const noexcept {
|
||||||
return std::find(_types.begin(), _types.end(), type) != _types.end();
|
return std::find(_types.begin(), _types.end(), type) != _types.end();
|
||||||
|
|
|
@ -57,7 +57,7 @@ namespace CreatureLib::Battling {
|
||||||
std::unique_ptr<Script> _status = nullptr;
|
std::unique_ptr<Script> _status = nullptr;
|
||||||
ScriptSet _volatile = {};
|
ScriptSet _volatile = {};
|
||||||
|
|
||||||
std::unordered_set<uint8_t> _types;
|
std::vector<uint8_t> _types;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void OnFaint();
|
void OnFaint();
|
||||||
|
@ -115,7 +115,7 @@ namespace CreatureLib::Battling {
|
||||||
const ArbUt::StringView& GetActiveTalent() const;
|
const ArbUt::StringView& GetActiveTalent() const;
|
||||||
|
|
||||||
[[nodiscard]] bool IsFainted() const noexcept;
|
[[nodiscard]] bool IsFainted() const noexcept;
|
||||||
[[nodiscard]] const std::unordered_set<uint8_t>& GetTypes() const noexcept;
|
[[nodiscard]] const std::vector<uint8_t>& GetTypes() const noexcept;
|
||||||
[[nodiscard]] bool HasType(uint8_t type) const noexcept;
|
[[nodiscard]] bool HasType(uint8_t type) const noexcept;
|
||||||
|
|
||||||
uint32_t GetMaxHealth() const noexcept { return _boostedStats.GetHealth(); }
|
uint32_t GetMaxHealth() const noexcept { return _boostedStats.GetHealth(); }
|
||||||
|
|
|
@ -21,8 +21,7 @@ namespace CreatureLib::Library {
|
||||||
<< (uint32_t)defensive);
|
<< (uint32_t)defensive);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
[[nodiscard]] inline float GetEffectiveness(uint8_t attacking,
|
[[nodiscard]] inline float GetEffectiveness(uint8_t attacking, const std::vector<uint8_t>& defensive) const {
|
||||||
const std::unordered_set<uint8_t>& defensive) const {
|
|
||||||
return std::accumulate(defensive.begin(), defensive.end(), (float)1,
|
return std::accumulate(defensive.begin(), defensive.end(), (float)1,
|
||||||
[this, attacking](float init, uint8_t defense) {
|
[this, attacking](float init, uint8_t defense) {
|
||||||
return init * GetSingleEffectiveness(attacking, defense);
|
return init * GetSingleEffectiveness(attacking, defense);
|
||||||
|
|
Loading…
Reference in New Issue