Moved Creature types to creature itself, instead of using the variant types.
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:
@@ -1,5 +1,6 @@
|
||||
#include "TurnHandler.hpp"
|
||||
#include <Arbutils/Assert.hpp>
|
||||
#include <unordered_set>
|
||||
#include "../../Library/Exceptions/NotImplementedException.hpp"
|
||||
#include "../ScriptHandling/ScriptMacros.hpp"
|
||||
#include "ResolveTarget.hpp"
|
||||
|
||||
@@ -25,6 +25,9 @@ Battling::Creature::Creature(ArbUt::BorrowedPtr<const BattleLibrary> library,
|
||||
if (_nickname.empty()) {
|
||||
_nickname = species->GetName().std_str();
|
||||
}
|
||||
for (auto t : _variant->GetTypes()) {
|
||||
_types.insert(t);
|
||||
}
|
||||
}
|
||||
|
||||
void Battling::Creature::ChangeLevelBy(int8_t amount) {
|
||||
@@ -146,14 +149,10 @@ void Battling::Creature::OverrideActiveTalent(const ConstString& talent) {
|
||||
_activeTalent.reset(this->_library->LoadScript(ScriptCategory::Talent, talent));
|
||||
}
|
||||
|
||||
const ArbUt::List<uint8_t>& Battling::Creature::GetTypes() const noexcept {
|
||||
// HOOK: override types.
|
||||
return this->_variant->GetTypes();
|
||||
}
|
||||
const std::unordered_set<uint8_t>& Battling::Creature::GetTypes() const noexcept { return _types; }
|
||||
|
||||
bool Battling::Creature::HasType(uint8_t type) const noexcept {
|
||||
auto t = GetTypes();
|
||||
return std::find(t.begin(), t.end(), type) != t.end();
|
||||
return std::find(_types.begin(), _types.end(), type) != _types.end();
|
||||
}
|
||||
|
||||
size_t Battling::Creature::ScriptCount() const {
|
||||
|
||||
@@ -59,6 +59,8 @@ namespace CreatureLib::Battling {
|
||||
std::unique_ptr<Script> _status = nullptr;
|
||||
ScriptSet _volatile = {};
|
||||
|
||||
std::unordered_set<uint8_t> _types;
|
||||
|
||||
private:
|
||||
void OnFaint();
|
||||
|
||||
@@ -109,7 +111,7 @@ namespace CreatureLib::Battling {
|
||||
const ArbUt::CaseInsensitiveConstString& GetActiveTalent() const;
|
||||
|
||||
[[nodiscard]] bool IsFainted() const noexcept;
|
||||
[[nodiscard]] const ArbUt::List<uint8_t>& GetTypes() const noexcept;
|
||||
[[nodiscard]] const std::unordered_set<uint8_t>& GetTypes() const noexcept;
|
||||
[[nodiscard]] bool HasType(uint8_t type) const noexcept;
|
||||
|
||||
uint32_t GetMaxHealth() const noexcept { return _boostedStats.GetHealth(); }
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
using namespace CreatureLib::Library;
|
||||
|
||||
float TypeLibrary::GetEffectiveness(uint8_t attacking, const ArbUt::List<uint8_t>& defensive) const {
|
||||
float TypeLibrary::GetEffectiveness(uint8_t attacking, const std::unordered_set<uint8_t>& defensive) const {
|
||||
return std::accumulate(
|
||||
defensive.begin(), defensive.end(), (float)1,
|
||||
[this, attacking](float init, uint8_t defense) { return init * GetSingleEffectiveness(attacking, defense); });
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include <Arbutils/Collections/Dictionary.hpp>
|
||||
#include <Arbutils/Collections/List.hpp>
|
||||
#include <Arbutils/ConstString.hpp>
|
||||
#include <unordered_map>
|
||||
#include <unordered_set>
|
||||
#include <vector>
|
||||
|
||||
namespace CreatureLib::Library {
|
||||
@@ -18,7 +18,7 @@ namespace CreatureLib::Library {
|
||||
uint8_t GetTypeId(const ArbUt::CaseInsensitiveConstString& s) const;
|
||||
uint8_t GetTypeId(uint32_t s) const;
|
||||
[[nodiscard]] float GetSingleEffectiveness(uint8_t attacking, uint8_t defensive) const;
|
||||
[[nodiscard]] float GetEffectiveness(uint8_t attacking, const ArbUt::List<uint8_t>& defensive) const;
|
||||
[[nodiscard]] float GetEffectiveness(uint8_t attacking, const std::unordered_set<uint8_t>& defensive) const;
|
||||
|
||||
uint8_t RegisterType(const ArbUt::CaseInsensitiveConstString& typeName);
|
||||
uint8_t RegisterType(uint32_t typeHash);
|
||||
|
||||
Reference in New Issue
Block a user