refactor: remove unnecessary classes
This commit is contained in:
@ -1,45 +0,0 @@
|
||||
#pragma once
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include "../Serializers/Serializable.h"
|
||||
#include "../Enums/ChatChannelEnum.h"
|
||||
|
||||
namespace L2Bot::Domain::ValueObjects
|
||||
{
|
||||
class ChatMessage : public Serializers::Serializable
|
||||
{
|
||||
public:
|
||||
const std::vector<Serializers::Node> BuildSerializationNodes() const override
|
||||
{
|
||||
return std::vector<Serializers::Node>
|
||||
{
|
||||
{ L"objectId", std::to_wstring(m_ObjectId) },
|
||||
{ L"channel", std::to_wstring(static_cast<uint8_t>(m_Channel)) },
|
||||
{ L"name", m_Name },
|
||||
{ L"text", m_Text }
|
||||
};
|
||||
}
|
||||
|
||||
ChatMessage(
|
||||
const uint32_t objectId,
|
||||
const Enums::ChatChannelEnum channel,
|
||||
const std::wstring& name,
|
||||
const std::wstring& text
|
||||
) :
|
||||
m_ObjectId(objectId),
|
||||
m_Channel(channel),
|
||||
m_Name(name),
|
||||
m_Text(text)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
ChatMessage() = default;
|
||||
virtual ~ChatMessage() = default;
|
||||
private:
|
||||
uint32_t m_ObjectId = 0;
|
||||
Enums::ChatChannelEnum m_Channel = Enums::ChatChannelEnum::all;
|
||||
std::wstring m_Name = L"";
|
||||
std::wstring m_Text = L"";
|
||||
};
|
||||
}
|
@ -1,10 +1,13 @@
|
||||
#pragma once
|
||||
#include <cstdint>
|
||||
#include <functional>
|
||||
#include "../Serializers/Serializable.h"
|
||||
#include "../Entities/Hashable.h"
|
||||
#include "../Helpers/HashCombiner.h"
|
||||
|
||||
namespace L2Bot::Domain::ValueObjects
|
||||
{
|
||||
class ExperienceInfo : public Serializers::Serializable
|
||||
class ExperienceInfo : public Serializers::Serializable, public Entities::Hashable
|
||||
{
|
||||
public:
|
||||
const uint8_t GetLevel() const
|
||||
@ -19,9 +22,13 @@ namespace L2Bot::Domain::ValueObjects
|
||||
{
|
||||
return m_Sp;
|
||||
}
|
||||
const bool IsEqual(const ExperienceInfo* other) const
|
||||
const size_t GetHash() const override
|
||||
{
|
||||
return m_Level == other->m_Level && m_Exp == other->m_Exp && m_Sp == other->m_Sp;
|
||||
return Helpers::CombineHashes({
|
||||
std::hash<uint8_t>{}(m_Level),
|
||||
std::hash<uint32_t>{}(m_Exp),
|
||||
std::hash<uint32_t>{}(m_Sp)
|
||||
});
|
||||
}
|
||||
|
||||
const std::vector<Serializers::Node> BuildSerializationNodes() const override
|
||||
|
@ -1,10 +1,13 @@
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include <functional>
|
||||
#include "../Serializers/Serializable.h"
|
||||
#include "../Entities/Hashable.h"
|
||||
#include "../Helpers/HashCombiner.h"
|
||||
|
||||
namespace L2Bot::Domain::ValueObjects
|
||||
{
|
||||
class FullName : public Serializers::Serializable
|
||||
class FullName : public Serializers::Serializable, public Entities::Hashable
|
||||
{
|
||||
public:
|
||||
const std::wstring& GetNickname() const
|
||||
@ -15,9 +18,12 @@ namespace L2Bot::Domain::ValueObjects
|
||||
{
|
||||
return m_Title;
|
||||
}
|
||||
const bool IsEqual(const FullName* other) const
|
||||
const size_t GetHash() const override
|
||||
{
|
||||
return m_Nickname == other->m_Nickname && m_Title == other->m_Title;
|
||||
return Helpers::CombineHashes({
|
||||
std::hash<std::wstring>{}(m_Nickname),
|
||||
std::hash<std::wstring>{}(m_Title)
|
||||
});
|
||||
}
|
||||
|
||||
const std::vector<Serializers::Node> BuildSerializationNodes() const override
|
||||
|
@ -1,10 +1,13 @@
|
||||
#pragma once
|
||||
#include <cstdint>
|
||||
#include <functional>
|
||||
#include "../Serializers/Serializable.h"
|
||||
#include "../Entities/Hashable.h"
|
||||
#include "../Helpers/HashCombiner.h"
|
||||
|
||||
namespace L2Bot::Domain::ValueObjects
|
||||
{
|
||||
class InventoryInfo : public Serializers::Serializable
|
||||
class InventoryInfo : public Serializers::Serializable, public Entities::Hashable
|
||||
{
|
||||
public:
|
||||
const uint32_t GetMaxWeight() const
|
||||
@ -19,11 +22,13 @@ namespace L2Bot::Domain::ValueObjects
|
||||
{
|
||||
return m_Slots;
|
||||
}
|
||||
const bool IsEqual(const InventoryInfo* other) const
|
||||
const size_t GetHash() const override
|
||||
{
|
||||
return m_MaxWeight == other->m_MaxWeight &&
|
||||
m_Weight == other->m_Weight &&
|
||||
m_Slots == other->m_Slots;
|
||||
return Helpers::CombineHashes({
|
||||
std::hash<uint32_t>{}(m_MaxWeight),
|
||||
std::hash<uint32_t>{}(m_Weight),
|
||||
std::hash<uint16_t>{}(m_Slots)
|
||||
});
|
||||
}
|
||||
|
||||
const std::vector<Serializers::Node> BuildSerializationNodes() const override
|
||||
|
@ -1,10 +1,13 @@
|
||||
#pragma once
|
||||
#include <cstdint>
|
||||
#include <functional>
|
||||
#include "../Serializers/Serializable.h"
|
||||
#include "../Entities/Hashable.h"
|
||||
#include "../Helpers/HashCombiner.h"
|
||||
|
||||
namespace L2Bot::Domain::ValueObjects
|
||||
{
|
||||
class PermanentStats : public Serializers::Serializable
|
||||
class PermanentStats : public Serializers::Serializable, public Entities::Hashable
|
||||
{
|
||||
public:
|
||||
const uint16_t GetStr() const
|
||||
@ -31,14 +34,16 @@ namespace L2Bot::Domain::ValueObjects
|
||||
{
|
||||
return m_Wit;
|
||||
}
|
||||
const bool IsEqual(const PermanentStats* other) const
|
||||
const size_t GetHash() const override
|
||||
{
|
||||
return m_Str == other->m_Str &&
|
||||
m_Dex == other->m_Dex &&
|
||||
m_Con == other->m_Con &&
|
||||
m_Int == other->m_Int &&
|
||||
m_Men == other->m_Men &&
|
||||
m_Wit == other->m_Wit;
|
||||
return Helpers::CombineHashes({
|
||||
std::hash<uint16_t>{}(m_Str),
|
||||
std::hash<uint16_t>{}(m_Dex),
|
||||
std::hash<uint16_t>{}(m_Con),
|
||||
std::hash<uint16_t>{}(m_Int),
|
||||
std::hash<uint16_t>{}(m_Men),
|
||||
std::hash<uint16_t>{}(m_Wit)
|
||||
});
|
||||
}
|
||||
|
||||
const std::vector<Serializers::Node> BuildSerializationNodes() const override
|
||||
|
@ -1,11 +1,14 @@
|
||||
#pragma once
|
||||
#include <functional>
|
||||
#include "../Enums/RaceEnum.h"
|
||||
#include "../Enums/ClassEnum.h"
|
||||
#include "../Serializers/Serializable.h"
|
||||
#include "../Entities/Hashable.h"
|
||||
#include "../Helpers/HashCombiner.h"
|
||||
|
||||
namespace L2Bot::Domain::ValueObjects
|
||||
{
|
||||
class Phenotype : public Serializers::Serializable
|
||||
class Phenotype : public Serializers::Serializable, public Entities::Hashable
|
||||
{
|
||||
public:
|
||||
const bool IsSubClass() const
|
||||
@ -28,12 +31,14 @@ namespace L2Bot::Domain::ValueObjects
|
||||
{
|
||||
return m_ActiveClass;
|
||||
}
|
||||
const bool IsEqual(const Phenotype* other) const
|
||||
const size_t GetHash() const override
|
||||
{
|
||||
return m_Race == other->m_Race &&
|
||||
m_IsMale == other->m_IsMale &&
|
||||
m_Class == other->m_Class &&
|
||||
m_ActiveClass == other->m_ActiveClass;
|
||||
return Helpers::CombineHashes({
|
||||
std::hash<Enums::RaceEnum>{}(m_Race),
|
||||
std::hash<bool>{}(m_IsMale),
|
||||
std::hash<Enums::ClassEnum>{}(m_Class),
|
||||
std::hash<Enums::ClassEnum>{}(m_ActiveClass)
|
||||
});
|
||||
}
|
||||
|
||||
const std::vector<Serializers::Node> BuildSerializationNodes() const override
|
||||
|
@ -1,10 +1,13 @@
|
||||
#pragma once
|
||||
#include <cstdint>
|
||||
#include <functional>
|
||||
#include "../Serializers/Serializable.h"
|
||||
#include "../Entities/Hashable.h"
|
||||
#include "../Helpers/HashCombiner.h"
|
||||
|
||||
namespace L2Bot::Domain::ValueObjects
|
||||
{
|
||||
class Reputation : public Serializers::Serializable
|
||||
class Reputation : public Serializers::Serializable, public Entities::Hashable
|
||||
{
|
||||
public:
|
||||
const bool IsPlayerKiller() const
|
||||
@ -31,13 +34,15 @@ namespace L2Bot::Domain::ValueObjects
|
||||
{
|
||||
return m_EvalScore;
|
||||
}
|
||||
const bool IsEqual(const Reputation* other) const
|
||||
const size_t GetHash() const override
|
||||
{
|
||||
return m_Karma == other->m_Karma &&
|
||||
m_PkKills == other->m_PkKills &&
|
||||
m_PvpKills == other->m_PvpKills &&
|
||||
m_RecRemaining == other->m_RecRemaining &&
|
||||
m_EvalScore == other->m_EvalScore;
|
||||
return Helpers::CombineHashes({
|
||||
std::hash<uint16_t>{}(m_Karma),
|
||||
std::hash<uint16_t>{}(m_PkKills),
|
||||
std::hash<uint16_t>{}(m_PvpKills),
|
||||
std::hash<uint8_t>{}(m_RecRemaining),
|
||||
std::hash<uint8_t>{}(m_EvalScore)
|
||||
});
|
||||
}
|
||||
|
||||
const std::vector<Serializers::Node> BuildSerializationNodes() const override
|
||||
|
@ -1,10 +1,12 @@
|
||||
#pragma once
|
||||
#include "../ValueObjects/Vector3.h"
|
||||
#include "../Serializers/Serializable.h"
|
||||
#include "../Entities/Hashable.h"
|
||||
#include "../Helpers/HashCombiner.h"
|
||||
|
||||
namespace L2Bot::Domain::ValueObjects
|
||||
{
|
||||
class Transform : public Serializers::Serializable
|
||||
class Transform : public Serializers::Serializable, public Entities::Hashable
|
||||
{
|
||||
public:
|
||||
const Vector3& GetPosition() const
|
||||
@ -23,12 +25,14 @@ namespace L2Bot::Domain::ValueObjects
|
||||
{
|
||||
return m_Acceleration;
|
||||
}
|
||||
const bool IsEqual(const Transform* other) const
|
||||
const size_t GetHash() const override
|
||||
{
|
||||
return m_Position.IsEqual(&other->m_Position) &&
|
||||
m_Rotation.IsEqual(&other->m_Rotation) &&
|
||||
m_Velocity.IsEqual(&other->m_Velocity) &&
|
||||
m_Acceleration.IsEqual(&other->m_Acceleration);
|
||||
return Helpers::CombineHashes({
|
||||
m_Position.GetHash(),
|
||||
m_Rotation.GetHash(),
|
||||
m_Velocity.GetHash(),
|
||||
m_Acceleration.GetHash()
|
||||
});
|
||||
}
|
||||
const float_t GetSqrDistance(const Transform& other) const
|
||||
{
|
||||
|
@ -1,10 +1,13 @@
|
||||
#pragma once
|
||||
#include <functional>
|
||||
#include <cstdint>
|
||||
#include "../Serializers/Serializable.h"
|
||||
#include "../Entities/Hashable.h"
|
||||
#include "../Helpers/HashCombiner.h"
|
||||
|
||||
namespace L2Bot::Domain::ValueObjects
|
||||
{
|
||||
class VariableStats : public Serializers::Serializable
|
||||
class VariableStats : public Serializers::Serializable, public Entities::Hashable
|
||||
{
|
||||
public:
|
||||
const uint16_t GetAccuracy() const
|
||||
@ -43,17 +46,19 @@ namespace L2Bot::Domain::ValueObjects
|
||||
{
|
||||
return m_CastingSpeed;
|
||||
}
|
||||
const bool IsEqual(const VariableStats* other) const
|
||||
const size_t GetHash() const override
|
||||
{
|
||||
return m_Accuracy == other->m_Accuracy &&
|
||||
m_CritRate == other->m_CritRate &&
|
||||
m_PAttack == other->m_PAttack &&
|
||||
m_AttackSpeed == other->m_AttackSpeed &&
|
||||
m_PDefense == other->m_PDefense &&
|
||||
m_Evasion == other->m_Evasion &&
|
||||
m_MAttack == other->m_MAttack &&
|
||||
m_MDefense == other->m_MDefense &&
|
||||
m_CastingSpeed == other->m_CastingSpeed;
|
||||
return Helpers::CombineHashes({
|
||||
std::hash<uint16_t>{}(m_Accuracy),
|
||||
std::hash<uint16_t>{}(m_CritRate),
|
||||
std::hash<uint32_t>{}(m_PAttack),
|
||||
std::hash<uint16_t>{}(m_AttackSpeed),
|
||||
std::hash<uint32_t>{}(m_PDefense),
|
||||
std::hash<uint16_t>{}(m_Evasion),
|
||||
std::hash<uint32_t>{}(m_MAttack),
|
||||
std::hash<uint32_t>{}(m_MDefense),
|
||||
std::hash<uint16_t>{}(m_CastingSpeed)
|
||||
});
|
||||
}
|
||||
|
||||
const std::vector<Serializers::Node> BuildSerializationNodes() const override
|
||||
|
@ -1,10 +1,13 @@
|
||||
#pragma once
|
||||
#include <math.h>
|
||||
#include <functional>
|
||||
#include "../Serializers/Serializable.h"
|
||||
#include "../Entities/Hashable.h"
|
||||
#include "../Helpers/HashCombiner.h"
|
||||
|
||||
namespace L2Bot::Domain::ValueObjects
|
||||
{
|
||||
class Vector3 : public Serializers::Serializable
|
||||
class Vector3 : public Serializers::Serializable, public Entities::Hashable
|
||||
{
|
||||
public:
|
||||
const float_t GetX() const
|
||||
@ -19,12 +22,17 @@ namespace L2Bot::Domain::ValueObjects
|
||||
{
|
||||
return m_Z;
|
||||
}
|
||||
const bool IsEqual(const Vector3* other) const
|
||||
const size_t GetHash() const override
|
||||
{
|
||||
float_t epsilon = 0.0001f;
|
||||
return fabsf(m_X - other->m_X) < epsilon &&
|
||||
fabsf(m_Y - other->m_Y) < epsilon &&
|
||||
fabsf(m_Z - other->m_Z) < epsilon;
|
||||
const auto x = std::round(m_X * 10000.0f) / 10000.0f;
|
||||
const auto y = std::round(m_Y * 10000.0f) / 10000.0f;
|
||||
const auto z = std::round(m_Z * 10000.0f) / 10000.0f;
|
||||
|
||||
return Helpers::CombineHashes({
|
||||
std::hash<float_t>{}(m_X),
|
||||
std::hash<float_t>{}(m_Y),
|
||||
std::hash<float_t>{}(m_Z)
|
||||
});
|
||||
}
|
||||
const float_t GetSqrDistance(const Vector3& other) const
|
||||
{
|
||||
|
@ -1,10 +1,13 @@
|
||||
#pragma once
|
||||
#include <cstdint>
|
||||
#include <functional>
|
||||
#include "../Serializers/Serializable.h"
|
||||
#include "../Entities/Hashable.h"
|
||||
#include "../Helpers/HashCombiner.h"
|
||||
|
||||
namespace L2Bot::Domain::ValueObjects
|
||||
{
|
||||
class VitalStats : public Serializers::Serializable
|
||||
class VitalStats : public Serializers::Serializable, public Entities::Hashable
|
||||
{
|
||||
public:
|
||||
const bool IsAlive() const
|
||||
@ -35,14 +38,16 @@ namespace L2Bot::Domain::ValueObjects
|
||||
{
|
||||
return m_Cp;
|
||||
}
|
||||
const bool IsEqual(const VitalStats* other) const
|
||||
const size_t GetHash() const override
|
||||
{
|
||||
return m_MaxHp == other->m_MaxHp &&
|
||||
m_Hp == other->m_Hp &&
|
||||
m_MaxMp == other->m_MaxMp &&
|
||||
m_Mp == other->m_Mp &&
|
||||
m_MaxCp == other->m_MaxCp &&
|
||||
m_Cp == other->m_Cp;
|
||||
return Helpers::CombineHashes({
|
||||
std::hash<uint32_t>{}(m_MaxHp),
|
||||
std::hash<uint32_t>{}(m_Hp),
|
||||
std::hash<uint32_t>{}(m_MaxMp),
|
||||
std::hash<uint32_t>{}(m_Mp),
|
||||
std::hash<uint32_t>{}(m_MaxCp),
|
||||
std::hash<uint32_t>{}(m_Cp)
|
||||
});
|
||||
}
|
||||
|
||||
const std::vector<Serializers::Node> BuildSerializationNodes() const override
|
||||
|
Reference in New Issue
Block a user