Add project files.
This commit is contained in:
158
L2BotCore/Domain/ValueObjects/BaseItem.h
Normal file
158
L2BotCore/Domain/ValueObjects/BaseItem.h
Normal file
@ -0,0 +1,158 @@
|
||||
#pragma once
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "../DTO/BaseItem.h"
|
||||
#include "../Serializers/Serializable.h"
|
||||
#include "../Serializers/Node.h"
|
||||
|
||||
namespace L2Bot::Domain::ValueObjects
|
||||
{
|
||||
class BaseItem : public Serializers::Serializable
|
||||
{
|
||||
public:
|
||||
const uint32_t GetId() const
|
||||
{
|
||||
return m_ItemId;
|
||||
}
|
||||
void UpdateFromDTO(const DTO::BaseItem* dto)
|
||||
{
|
||||
SaveState();
|
||||
|
||||
m_ItemId = dto->itemId;
|
||||
m_Amount = dto->amount;
|
||||
m_IsEquipped = dto->isEquipped;
|
||||
m_EnchantLevel = dto->enchantLevel;
|
||||
m_Mana = dto->mana;
|
||||
m_Name = dto->name;
|
||||
m_IconName = dto->iconName;
|
||||
m_Description = dto->description;
|
||||
m_Weight = dto->weight;
|
||||
}
|
||||
void SaveState()
|
||||
{
|
||||
m_PrevState =
|
||||
{
|
||||
m_Amount,
|
||||
m_IsEquipped,
|
||||
m_EnchantLevel,
|
||||
m_Mana,
|
||||
m_Weight,
|
||||
false
|
||||
};
|
||||
}
|
||||
const static BaseItem CreateFromDTO(const DTO::BaseItem& dto)
|
||||
{
|
||||
return BaseItem(
|
||||
dto.itemId,
|
||||
dto.amount,
|
||||
dto.isEquipped,
|
||||
dto.enchantLevel,
|
||||
dto.mana,
|
||||
dto.name,
|
||||
dto.iconName,
|
||||
dto.description,
|
||||
dto.weight
|
||||
);
|
||||
}
|
||||
const bool IsEqual(const DTO::BaseItem* dto) const
|
||||
{
|
||||
return m_ItemId == dto->itemId &&
|
||||
m_Amount == dto->amount &&
|
||||
m_IsEquipped == dto->isEquipped &&
|
||||
m_EnchantLevel == dto->enchantLevel &&
|
||||
m_Mana == dto->mana &&
|
||||
m_Name == dto->name &&
|
||||
m_IconName == dto->iconName &&
|
||||
m_Description == dto->description &&
|
||||
m_Weight == dto->weight;
|
||||
}
|
||||
|
||||
const std::vector<Serializers::Node> BuildSerializationNodes() const override
|
||||
{
|
||||
std::vector<Serializers::Node> result;
|
||||
|
||||
result.push_back({ "itemId", std::to_string(m_ItemId) });
|
||||
|
||||
if (m_PrevState.isNewState)
|
||||
{
|
||||
result.push_back({ "name", m_Name });
|
||||
result.push_back({ "iconName", m_IconName });
|
||||
result.push_back({ "description", m_Description });
|
||||
}
|
||||
|
||||
if (m_PrevState.isNewState || m_Amount != m_PrevState.amount)
|
||||
{
|
||||
result.push_back({ "amount", std::to_string(m_Amount) });
|
||||
}
|
||||
if (m_PrevState.isNewState || m_IsEquipped != m_PrevState.isEquipped)
|
||||
{
|
||||
result.push_back({ "isEquipped", std::to_string(m_IsEquipped) });
|
||||
}
|
||||
if (m_PrevState.isNewState || m_EnchantLevel != m_PrevState.enchantLevel)
|
||||
{
|
||||
result.push_back({ "enchantLevel", std::to_string(m_EnchantLevel) });
|
||||
}
|
||||
if (m_PrevState.isNewState || m_Mana != m_PrevState.mana)
|
||||
{
|
||||
result.push_back({ "mana", std::to_string(m_Mana) });
|
||||
}
|
||||
if (m_PrevState.isNewState || m_Weight != m_PrevState.weight)
|
||||
{
|
||||
result.push_back({ "weight", std::to_string(m_Weight) });
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
BaseItem(
|
||||
const uint32_t itemId,
|
||||
const uint32_t amount,
|
||||
const bool isEquipped,
|
||||
const uint16_t enchantLevel,
|
||||
const int32_t mana,
|
||||
const std::string name,
|
||||
const std::string iconName,
|
||||
const std::string description,
|
||||
const uint16_t weight
|
||||
) :
|
||||
m_ItemId(itemId),
|
||||
m_Amount(amount),
|
||||
m_IsEquipped(isEquipped),
|
||||
m_EnchantLevel(enchantLevel),
|
||||
m_Mana(mana),
|
||||
m_Name(name),
|
||||
m_IconName(iconName),
|
||||
m_Description(description),
|
||||
m_Weight(weight)
|
||||
{
|
||||
}
|
||||
|
||||
BaseItem() = default;
|
||||
virtual ~BaseItem() = default;
|
||||
|
||||
private:
|
||||
struct State
|
||||
{
|
||||
uint32_t amount = 0;
|
||||
bool isEquipped = 0;
|
||||
uint16_t enchantLevel = 0;
|
||||
int32_t mana = -1;
|
||||
uint16_t weight = 0;
|
||||
|
||||
bool isNewState = true;
|
||||
};
|
||||
|
||||
private:
|
||||
uint32_t m_ItemId = 0;
|
||||
uint32_t m_Amount = 0;
|
||||
bool m_IsEquipped = 0;
|
||||
uint16_t m_EnchantLevel = 0;
|
||||
int32_t m_Mana = -1;
|
||||
std::string m_Name = "";
|
||||
std::string m_IconName = "";
|
||||
std::string m_Description = "";
|
||||
uint16_t m_Weight = 0;
|
||||
State m_PrevState = State();
|
||||
};
|
||||
}
|
55
L2BotCore/Domain/ValueObjects/ExperienceInfo.h
Normal file
55
L2BotCore/Domain/ValueObjects/ExperienceInfo.h
Normal file
@ -0,0 +1,55 @@
|
||||
#pragma once
|
||||
#include <cstdint>
|
||||
#include "../Serializers/Serializable.h"
|
||||
|
||||
namespace L2Bot::Domain::ValueObjects
|
||||
{
|
||||
class ExperienceInfo : public Serializers::Serializable
|
||||
{
|
||||
public:
|
||||
const uint8_t GetLevel() const
|
||||
{
|
||||
return m_Level;
|
||||
}
|
||||
const uint8_t GetExp() const
|
||||
{
|
||||
return m_Exp;
|
||||
}
|
||||
const uint8_t GetSp() const
|
||||
{
|
||||
return m_Sp;
|
||||
}
|
||||
const bool IsEqual(const ExperienceInfo* other) const
|
||||
{
|
||||
return m_Level == other->m_Level && m_Exp == other->m_Exp && m_Sp == other->m_Sp;
|
||||
}
|
||||
|
||||
const std::vector<Serializers::Node> BuildSerializationNodes() const override
|
||||
{
|
||||
return std::vector<Serializers::Node>
|
||||
{
|
||||
{ "level", std::to_string(m_Level) },
|
||||
{ "exp", std::to_string(m_Exp) },
|
||||
{ "sp", std::to_string(m_Sp) }
|
||||
};
|
||||
}
|
||||
|
||||
ExperienceInfo(
|
||||
const uint8_t level,
|
||||
const uint32_t exp,
|
||||
const uint32_t sp
|
||||
) :
|
||||
m_Level(level),
|
||||
m_Exp(exp),
|
||||
m_Sp(sp)
|
||||
{
|
||||
}
|
||||
|
||||
ExperienceInfo() = default;
|
||||
virtual ~ExperienceInfo() = default;
|
||||
private:
|
||||
uint8_t m_Level = 0;
|
||||
uint32_t m_Exp = 0;
|
||||
uint32_t m_Sp = 0;
|
||||
};
|
||||
}
|
47
L2BotCore/Domain/ValueObjects/FullName.h
Normal file
47
L2BotCore/Domain/ValueObjects/FullName.h
Normal file
@ -0,0 +1,47 @@
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include "../Serializers/Serializable.h"
|
||||
|
||||
namespace L2Bot::Domain::ValueObjects
|
||||
{
|
||||
class FullName : public Serializers::Serializable
|
||||
{
|
||||
public:
|
||||
const std::string& GetNickname() const
|
||||
{
|
||||
return m_Nickname;
|
||||
}
|
||||
const std::string& GetTitle() const
|
||||
{
|
||||
return m_Title;
|
||||
}
|
||||
const bool IsEqual(const FullName* other) const
|
||||
{
|
||||
return m_Nickname == other->m_Nickname && m_Title == other->m_Title;
|
||||
}
|
||||
|
||||
const std::vector<Serializers::Node> BuildSerializationNodes() const override
|
||||
{
|
||||
return std::vector<Serializers::Node>
|
||||
{
|
||||
{ "nickname", m_Nickname },
|
||||
{ "title", m_Title }
|
||||
};
|
||||
}
|
||||
|
||||
FullName(
|
||||
const std::string nickname,
|
||||
const std::string title
|
||||
) :
|
||||
m_Nickname(nickname),
|
||||
m_Title(title)
|
||||
{
|
||||
}
|
||||
|
||||
FullName() = default;
|
||||
virtual ~FullName() = default;
|
||||
private:
|
||||
std::string m_Nickname = "";
|
||||
std::string m_Title = "";
|
||||
};
|
||||
}
|
61
L2BotCore/Domain/ValueObjects/InventoryInfo.h
Normal file
61
L2BotCore/Domain/ValueObjects/InventoryInfo.h
Normal file
@ -0,0 +1,61 @@
|
||||
#pragma once
|
||||
#include <cstdint>
|
||||
#include "../Serializers/Serializable.h"
|
||||
|
||||
namespace L2Bot::Domain::ValueObjects
|
||||
{
|
||||
class InventoryInfo : public Serializers::Serializable
|
||||
{
|
||||
public:
|
||||
const bool IsOverloaded() const
|
||||
{
|
||||
return m_Weight >= m_MaxWeight;
|
||||
}
|
||||
const uint16_t GetMaxWeight() const
|
||||
{
|
||||
return m_MaxWeight;
|
||||
}
|
||||
const uint16_t GetWeight() const
|
||||
{
|
||||
return m_Weight;
|
||||
}
|
||||
const uint16_t GetSlots() const
|
||||
{
|
||||
return m_Slots;
|
||||
}
|
||||
const bool IsEqual(const InventoryInfo* other) const
|
||||
{
|
||||
return m_MaxWeight == other->m_MaxWeight &&
|
||||
m_Weight == other->m_Weight &&
|
||||
m_Slots == other->m_Slots;
|
||||
}
|
||||
|
||||
const std::vector<Serializers::Node> BuildSerializationNodes() const override
|
||||
{
|
||||
return std::vector<Serializers::Node>
|
||||
{
|
||||
{ "maxWeight", std::to_string(m_MaxWeight) },
|
||||
{ "weight", std::to_string(m_Weight) },
|
||||
{ "slots", std::to_string(m_Slots) }
|
||||
};
|
||||
}
|
||||
|
||||
InventoryInfo(
|
||||
const uint16_t maxWeight,
|
||||
const uint16_t weight,
|
||||
const uint16_t slots
|
||||
) :
|
||||
m_MaxWeight(maxWeight),
|
||||
m_Weight(weight),
|
||||
m_Slots(slots)
|
||||
{
|
||||
}
|
||||
|
||||
InventoryInfo() = default;
|
||||
virtual ~InventoryInfo() = default;
|
||||
private:
|
||||
uint16_t m_MaxWeight = 0;
|
||||
uint16_t m_Weight = 0;
|
||||
uint16_t m_Slots = 0;
|
||||
};
|
||||
}
|
85
L2BotCore/Domain/ValueObjects/PermanentStats.h
Normal file
85
L2BotCore/Domain/ValueObjects/PermanentStats.h
Normal file
@ -0,0 +1,85 @@
|
||||
#pragma once
|
||||
#include <cstdint>
|
||||
#include "../Serializers/Serializable.h"
|
||||
|
||||
namespace L2Bot::Domain::ValueObjects
|
||||
{
|
||||
class PermanentStats : public Serializers::Serializable
|
||||
{
|
||||
public:
|
||||
const uint16_t GetStr() const
|
||||
{
|
||||
return m_Str;
|
||||
}
|
||||
const uint16_t GetDex() const
|
||||
{
|
||||
return m_Dex;
|
||||
}
|
||||
const uint16_t GetCon() const
|
||||
{
|
||||
return m_Con;
|
||||
}
|
||||
const uint16_t GetInt() const
|
||||
{
|
||||
return m_Int;
|
||||
}
|
||||
const uint16_t GetMen() const
|
||||
{
|
||||
return m_Men;
|
||||
}
|
||||
const uint16_t GetWit() const
|
||||
{
|
||||
return m_Wit;
|
||||
}
|
||||
const bool IsEqual(const PermanentStats* other) const
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
const std::vector<Serializers::Node> BuildSerializationNodes() const override
|
||||
{
|
||||
return std::vector<Serializers::Node>
|
||||
{
|
||||
{ "str", std::to_string(m_Str) },
|
||||
{ "dex", std::to_string(m_Dex) },
|
||||
{ "con", std::to_string(m_Con) },
|
||||
{ "int", std::to_string(m_Int) },
|
||||
{ "men", std::to_string(m_Men) },
|
||||
{ "wit", std::to_string(m_Wit) }
|
||||
};
|
||||
}
|
||||
|
||||
PermanentStats(
|
||||
uint16_t str,
|
||||
uint16_t dex,
|
||||
uint16_t con,
|
||||
uint16_t int_,
|
||||
uint16_t men,
|
||||
uint16_t wit
|
||||
) :
|
||||
m_Str(str),
|
||||
m_Dex(dex),
|
||||
m_Con(con),
|
||||
m_Int(int_),
|
||||
m_Men(men),
|
||||
m_Wit(wit)
|
||||
{
|
||||
}
|
||||
|
||||
PermanentStats() = default;
|
||||
virtual ~PermanentStats() = default;
|
||||
|
||||
private:
|
||||
uint16_t m_Str = 0;
|
||||
uint16_t m_Dex = 0;
|
||||
uint16_t m_Con = 0;
|
||||
uint16_t m_Int = 0;
|
||||
uint16_t m_Men = 0;
|
||||
uint16_t m_Wit = 0;
|
||||
};
|
||||
}
|
72
L2BotCore/Domain/ValueObjects/Phenotype.h
Normal file
72
L2BotCore/Domain/ValueObjects/Phenotype.h
Normal file
@ -0,0 +1,72 @@
|
||||
#pragma once
|
||||
#include "../Enums/RaceEnum.h"
|
||||
#include "../Enums/ClassEnum.h"
|
||||
#include "../Serializers/Serializable.h"
|
||||
|
||||
namespace L2Bot::Domain::ValueObjects
|
||||
{
|
||||
class Phenotype : public Serializers::Serializable
|
||||
{
|
||||
public:
|
||||
const bool IsSubClass() const
|
||||
{
|
||||
return m_ActiveClass != Enums::ClassEnum::none && m_Class != m_ActiveClass;
|
||||
}
|
||||
const Enums::RaceEnum GetRace() const
|
||||
{
|
||||
return m_Race;
|
||||
}
|
||||
const bool IsMale() const
|
||||
{
|
||||
return m_IsMale;
|
||||
}
|
||||
const Enums::ClassEnum GetClass() const
|
||||
{
|
||||
return m_Class;
|
||||
}
|
||||
const Enums::ClassEnum GetActiveClass() const
|
||||
{
|
||||
return m_ActiveClass;
|
||||
}
|
||||
const bool IsEqual(const Phenotype* other) const
|
||||
{
|
||||
return m_Race == other->m_Race &&
|
||||
m_IsMale == other->m_IsMale &&
|
||||
m_Class == other->m_Class &&
|
||||
m_ActiveClass == other->m_ActiveClass;
|
||||
}
|
||||
|
||||
const std::vector<Serializers::Node> BuildSerializationNodes() const override
|
||||
{
|
||||
return std::vector<Serializers::Node>
|
||||
{
|
||||
{ "race", std::to_string(static_cast<uint8_t>(m_Race)) },
|
||||
{ "isMale", std::to_string(m_IsMale) },
|
||||
{ "class", std::to_string(static_cast<uint8_t>(m_Class)) },
|
||||
{ "activeClass", std::to_string(static_cast<uint8_t>(m_ActiveClass)) }
|
||||
};
|
||||
}
|
||||
|
||||
Phenotype(
|
||||
Enums::RaceEnum race,
|
||||
bool isMale,
|
||||
Enums::ClassEnum class_,
|
||||
Enums::ClassEnum activeClass
|
||||
) :
|
||||
m_Race(race),
|
||||
m_IsMale(isMale),
|
||||
m_Class(class_),
|
||||
m_ActiveClass(activeClass)
|
||||
{
|
||||
}
|
||||
|
||||
Phenotype() = default;
|
||||
virtual ~Phenotype() = default;
|
||||
|
||||
private:
|
||||
Enums::RaceEnum m_Race = Enums::RaceEnum::none;
|
||||
bool m_IsMale = true;
|
||||
Enums::ClassEnum m_Class = Enums::ClassEnum::none;
|
||||
Enums::ClassEnum m_ActiveClass = Enums::ClassEnum::none;
|
||||
};
|
||||
}
|
80
L2BotCore/Domain/ValueObjects/Reputation.h
Normal file
80
L2BotCore/Domain/ValueObjects/Reputation.h
Normal file
@ -0,0 +1,80 @@
|
||||
#pragma once
|
||||
#include <cstdint>
|
||||
#include "../Serializers/Serializable.h"
|
||||
|
||||
namespace L2Bot::Domain::ValueObjects
|
||||
{
|
||||
class Reputation : public Serializers::Serializable
|
||||
{
|
||||
public:
|
||||
const bool IsPlayerKiller() const
|
||||
{
|
||||
return m_Karma > 0;
|
||||
}
|
||||
const uint16_t GetKarma() const
|
||||
{
|
||||
return m_Karma;
|
||||
}
|
||||
const uint16_t GetPkKills() const
|
||||
{
|
||||
return m_PkKills;
|
||||
}
|
||||
const uint16_t GetPvpKills() const
|
||||
{
|
||||
return m_PvpKills;
|
||||
}
|
||||
const uint8_t GetRecRemaining() const
|
||||
{
|
||||
return m_RecRemaining;
|
||||
}
|
||||
const uint8_t GetEvalScore() const
|
||||
{
|
||||
return m_EvalScore;
|
||||
}
|
||||
const bool IsEqual(const Reputation* other) const
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
const std::vector<Serializers::Node> BuildSerializationNodes() const override
|
||||
{
|
||||
return std::vector<Serializers::Node>
|
||||
{
|
||||
{ "karma", std::to_string(m_Karma) },
|
||||
{ "pkKills", std::to_string(m_PkKills) },
|
||||
{ "pvpKills", std::to_string(m_PvpKills) },
|
||||
{ "recRemaining", std::to_string(m_RecRemaining) },
|
||||
{ "evalScore", std::to_string(m_EvalScore) }
|
||||
};
|
||||
}
|
||||
|
||||
Reputation(
|
||||
uint16_t karma,
|
||||
uint16_t pkKills,
|
||||
uint16_t pvpKills,
|
||||
uint8_t recRemaining,
|
||||
uint8_t evalScore
|
||||
) :
|
||||
m_Karma(karma),
|
||||
m_PkKills(pkKills),
|
||||
m_PvpKills(pvpKills),
|
||||
m_RecRemaining(recRemaining),
|
||||
m_EvalScore(evalScore)
|
||||
{
|
||||
}
|
||||
|
||||
Reputation() = default;
|
||||
virtual ~Reputation() = default;
|
||||
|
||||
private:
|
||||
uint16_t m_Karma = 0;
|
||||
uint16_t m_PkKills = 0;
|
||||
uint16_t m_PvpKills = 0;
|
||||
uint8_t m_RecRemaining = 0;
|
||||
uint8_t m_EvalScore = 0;
|
||||
};
|
||||
}
|
188
L2BotCore/Domain/ValueObjects/Skill.h
Normal file
188
L2BotCore/Domain/ValueObjects/Skill.h
Normal file
@ -0,0 +1,188 @@
|
||||
#pragma once
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "../DTO/Skill.h"
|
||||
#include "../Serializers/Serializable.h"
|
||||
#include "../Serializers/Node.h"
|
||||
|
||||
namespace L2Bot::Domain::ValueObjects
|
||||
{
|
||||
class Skill : public Serializers::Serializable
|
||||
{
|
||||
public:
|
||||
const uint32_t GetId() const
|
||||
{
|
||||
return m_SkillId;
|
||||
}
|
||||
const bool IsReadyToUse() const
|
||||
{
|
||||
return !m_IsCasting && !m_IsReloading;
|
||||
}
|
||||
void UpdateFromDTO(const DTO::Skill* dto)
|
||||
{
|
||||
SaveState();
|
||||
|
||||
m_SkillId = dto->skillId;
|
||||
m_Level = dto->level;
|
||||
m_IsActive = dto->isActive;
|
||||
m_Cost = dto->cost;
|
||||
m_Range = dto->range;
|
||||
m_Name = dto->name;
|
||||
m_Description = dto->description;
|
||||
m_IconName = dto->iconName;
|
||||
m_IsToggled = dto->isToggled;
|
||||
m_IsCasting = dto->isCasting;
|
||||
m_IsReloading = dto->isReloading;
|
||||
}
|
||||
void SaveState()
|
||||
{
|
||||
m_PrevState =
|
||||
{
|
||||
m_Cost,
|
||||
m_Range,
|
||||
m_Description,
|
||||
m_IsToggled,
|
||||
m_IsCasting,
|
||||
m_IsReloading,
|
||||
IsReadyToUse(),
|
||||
false
|
||||
};
|
||||
}
|
||||
const static Skill CreateFromDTO(const DTO::Skill& dto)
|
||||
{
|
||||
return Skill(
|
||||
dto.skillId,
|
||||
dto.level,
|
||||
dto.isActive,
|
||||
dto.cost,
|
||||
dto.range,
|
||||
dto.name,
|
||||
dto.description,
|
||||
dto.iconName,
|
||||
dto.isToggled,
|
||||
dto.isCasting,
|
||||
dto.isReloading
|
||||
);
|
||||
}
|
||||
const bool IsEqual(const DTO::Skill* dto) const
|
||||
{
|
||||
return m_SkillId == dto->skillId &&
|
||||
m_Level == dto->level &&
|
||||
m_IsActive == dto->isActive &&
|
||||
m_Cost == dto->cost &&
|
||||
m_Range == dto->range &&
|
||||
m_Name == dto->name &&
|
||||
m_Description == dto->description &&
|
||||
m_IconName == dto->iconName &&
|
||||
m_IsToggled == dto->isToggled &&
|
||||
m_IsCasting == dto->isCasting &&
|
||||
m_IsReloading == dto->isReloading;
|
||||
}
|
||||
|
||||
const std::vector<Serializers::Node> BuildSerializationNodes() const override
|
||||
{
|
||||
std::vector<Serializers::Node> result;
|
||||
|
||||
result.push_back({ "skillId", std::to_string(m_SkillId) });
|
||||
result.push_back({ "level", std::to_string(m_Level) });
|
||||
|
||||
if (m_PrevState.isNewState)
|
||||
{
|
||||
result.push_back({ "isActive", std::to_string(m_IsActive) });
|
||||
result.push_back({ "name", m_Name });
|
||||
result.push_back({ "iconName", m_IconName });
|
||||
}
|
||||
|
||||
if (m_PrevState.isNewState || m_Description != m_PrevState.description)
|
||||
{
|
||||
result.push_back({ "description", m_Description });
|
||||
}
|
||||
if (m_PrevState.isNewState || m_Cost != m_PrevState.cost)
|
||||
{
|
||||
result.push_back({ "cost", std::to_string(m_Cost) });
|
||||
}
|
||||
if (m_PrevState.isNewState || m_Range != m_PrevState.range)
|
||||
{
|
||||
result.push_back({ "range", std::to_string(m_Range) });
|
||||
}
|
||||
if (m_PrevState.isNewState || m_IsToggled != m_PrevState.isToggled)
|
||||
{
|
||||
result.push_back({ "isToggled", std::to_string(m_IsToggled) });
|
||||
}
|
||||
if (m_PrevState.isNewState || m_IsCasting != m_PrevState.isCasting)
|
||||
{
|
||||
result.push_back({ "isCasting", std::to_string(m_IsCasting) });
|
||||
}
|
||||
if (m_PrevState.isNewState || m_IsReloading != m_PrevState.isReloading)
|
||||
{
|
||||
result.push_back({ "isReloading", std::to_string(m_IsReloading) });
|
||||
}
|
||||
if (m_PrevState.isNewState || IsReadyToUse() != m_PrevState.isReadyToUse)
|
||||
{
|
||||
result.push_back({ "isReadyToUse", std::to_string(IsReadyToUse()) });
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
Skill(
|
||||
const uint32_t skillId,
|
||||
const uint8_t level,
|
||||
const bool isActive,
|
||||
const uint8_t cost,
|
||||
const int16_t range,
|
||||
const std::string& name,
|
||||
const std::string& description,
|
||||
const std::string& iconName,
|
||||
const bool isToggled,
|
||||
const bool isCasting,
|
||||
const bool isReloading
|
||||
) :
|
||||
m_SkillId(skillId),
|
||||
m_Level(level),
|
||||
m_IsActive(isActive),
|
||||
m_Cost(cost),
|
||||
m_Range(range),
|
||||
m_Name(name),
|
||||
m_Description(description),
|
||||
m_IconName(iconName),
|
||||
m_IsToggled(isToggled),
|
||||
m_IsCasting(isCasting),
|
||||
m_IsReloading(isReloading)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Skill() = default;
|
||||
virtual ~Skill() = default;
|
||||
|
||||
private:
|
||||
struct State
|
||||
{
|
||||
uint8_t cost = 0;
|
||||
int16_t range = 0;
|
||||
std::string description = "";
|
||||
bool isToggled = false;
|
||||
bool isCasting = false;
|
||||
bool isReloading = false;
|
||||
bool isReadyToUse = true;
|
||||
|
||||
bool isNewState = true;
|
||||
};
|
||||
|
||||
private:
|
||||
uint32_t m_SkillId = 0;
|
||||
uint8_t m_Level = 0;
|
||||
bool m_IsActive = false;
|
||||
uint8_t m_Cost = 0;
|
||||
int16_t m_Range = 0;
|
||||
std::string m_Name = "";
|
||||
std::string m_Description = "";
|
||||
std::string m_IconName = "";
|
||||
bool m_IsToggled = false;
|
||||
bool m_IsCasting = false;
|
||||
bool m_IsReloading = false;
|
||||
State m_PrevState = State();
|
||||
};
|
||||
}
|
74
L2BotCore/Domain/ValueObjects/Transform.h
Normal file
74
L2BotCore/Domain/ValueObjects/Transform.h
Normal file
@ -0,0 +1,74 @@
|
||||
#pragma once
|
||||
#include "../ValueObjects/Vector3.h"
|
||||
#include "../Serializers/Serializable.h"
|
||||
|
||||
namespace L2Bot::Domain::ValueObjects
|
||||
{
|
||||
class Transform : public Serializers::Serializable
|
||||
{
|
||||
public:
|
||||
const Vector3& GetPosition() const
|
||||
{
|
||||
return m_Position;
|
||||
}
|
||||
const Vector3& GetRotation() const
|
||||
{
|
||||
return m_Rotation;
|
||||
}
|
||||
const Vector3& GetVelocity() const
|
||||
{
|
||||
return m_Velocity;
|
||||
}
|
||||
const Vector3& GetAcceleration() const
|
||||
{
|
||||
return m_Acceleration;
|
||||
}
|
||||
const bool IsEqual(const Transform* other) const
|
||||
{
|
||||
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);
|
||||
}
|
||||
const float_t GetSqrDistance(const Transform& other) const
|
||||
{
|
||||
return m_Position.GetSqrDistance(other.m_Position);
|
||||
}
|
||||
const float_t GetHorizontalSqrDistance(const Transform& other) const
|
||||
{
|
||||
return m_Position.GetHorizontalSqrDistance(other.m_Position);
|
||||
}
|
||||
|
||||
const std::vector<Serializers::Node> BuildSerializationNodes() const override
|
||||
{
|
||||
return std::vector<Serializers::Node>
|
||||
{
|
||||
{ "position", m_Position.BuildSerializationNodes() },
|
||||
{ "rotation", m_Rotation.BuildSerializationNodes() },
|
||||
{ "velocity", m_Velocity.BuildSerializationNodes() },
|
||||
{ "acceleration", m_Acceleration.BuildSerializationNodes() }
|
||||
};
|
||||
}
|
||||
|
||||
Transform(
|
||||
const Vector3 position,
|
||||
const Vector3 rotation,
|
||||
const Vector3 velocity,
|
||||
const Vector3 acceleration
|
||||
) :
|
||||
m_Position(position),
|
||||
m_Rotation(rotation),
|
||||
m_Velocity(velocity),
|
||||
m_Acceleration(acceleration)
|
||||
{
|
||||
}
|
||||
|
||||
Transform() = default;
|
||||
virtual ~Transform() = default;
|
||||
private:
|
||||
Vector3 m_Position = Vector3();
|
||||
Vector3 m_Rotation = Vector3();
|
||||
Vector3 m_Velocity = Vector3();
|
||||
Vector3 m_Acceleration = Vector3();
|
||||
};
|
||||
}
|
112
L2BotCore/Domain/ValueObjects/VariableStats.h
Normal file
112
L2BotCore/Domain/ValueObjects/VariableStats.h
Normal file
@ -0,0 +1,112 @@
|
||||
#pragma once
|
||||
#include <cstdint>
|
||||
#include "../Serializers/Serializable.h"
|
||||
|
||||
namespace L2Bot::Domain::ValueObjects
|
||||
{
|
||||
class VariableStats : public Serializers::Serializable
|
||||
{
|
||||
public:
|
||||
const uint16_t GetAccuracy() const
|
||||
{
|
||||
return m_Accuracy;
|
||||
}
|
||||
const uint16_t GetCritRate() const
|
||||
{
|
||||
return m_CritRate;
|
||||
}
|
||||
const uint16_t GetPAttack() const
|
||||
{
|
||||
return m_PAttack;
|
||||
}
|
||||
const uint16_t GetAttackSpeed() const
|
||||
{
|
||||
return m_AttackSpeed;
|
||||
}
|
||||
const uint16_t GetPDefense() const
|
||||
{
|
||||
return m_PDefense;
|
||||
}
|
||||
const uint16_t GetEvasion() const
|
||||
{
|
||||
return m_Evasion;
|
||||
}
|
||||
const uint16_t GetMAttack() const
|
||||
{
|
||||
return m_MAttack;
|
||||
}
|
||||
const uint16_t GetMDefense() const
|
||||
{
|
||||
return m_MDefense;
|
||||
}
|
||||
const uint16_t GetCastingSpeed() const
|
||||
{
|
||||
return m_CastingSpeed;
|
||||
}
|
||||
const bool IsEqual(const VariableStats* other) const
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
const std::vector<Serializers::Node> BuildSerializationNodes() const override
|
||||
{
|
||||
return std::vector<Serializers::Node>
|
||||
{
|
||||
{ "accuracy", std::to_string(m_Accuracy) },
|
||||
{ "critRate", std::to_string(m_CritRate) },
|
||||
{ "pAttack", std::to_string(m_PAttack) },
|
||||
{ "attackSpeed", std::to_string(m_AttackSpeed) },
|
||||
{ "pDefense", std::to_string(m_PDefense) },
|
||||
{ "evasion", std::to_string(m_Evasion) },
|
||||
{ "mAttack", std::to_string(m_MAttack) },
|
||||
{ "mDefense", std::to_string(m_MDefense) },
|
||||
{ "castingSpeed", std::to_string(m_CastingSpeed) }
|
||||
};
|
||||
}
|
||||
|
||||
VariableStats(
|
||||
uint16_t accuracy,
|
||||
uint16_t critRate,
|
||||
uint16_t pAttack,
|
||||
uint16_t attackSpeed,
|
||||
uint16_t pDefense,
|
||||
uint16_t evasion,
|
||||
uint16_t mAttack,
|
||||
uint16_t mDefense,
|
||||
uint16_t castingSpeed
|
||||
) :
|
||||
m_Accuracy(accuracy),
|
||||
m_CritRate(critRate),
|
||||
m_PAttack(pAttack),
|
||||
m_AttackSpeed(attackSpeed),
|
||||
m_PDefense(pDefense),
|
||||
m_Evasion(evasion),
|
||||
m_MAttack(mAttack),
|
||||
m_MDefense(mDefense),
|
||||
m_CastingSpeed(castingSpeed)
|
||||
{
|
||||
}
|
||||
|
||||
VariableStats() = default;
|
||||
virtual ~VariableStats() = default;
|
||||
|
||||
private:
|
||||
uint16_t m_Accuracy = 0;
|
||||
uint16_t m_CritRate = 0;
|
||||
uint16_t m_PAttack = 0;
|
||||
uint16_t m_AttackSpeed = 0;
|
||||
uint16_t m_PDefense = 0;
|
||||
uint16_t m_Evasion = 0;
|
||||
uint16_t m_MAttack = 0;
|
||||
uint16_t m_MDefense = 0;
|
||||
uint16_t m_CastingSpeed = 0;
|
||||
};
|
||||
}
|
64
L2BotCore/Domain/ValueObjects/Vector3.h
Normal file
64
L2BotCore/Domain/ValueObjects/Vector3.h
Normal file
@ -0,0 +1,64 @@
|
||||
#pragma once
|
||||
#include <math.h>
|
||||
#include "../Serializers/Serializable.h"
|
||||
|
||||
namespace L2Bot::Domain::ValueObjects
|
||||
{
|
||||
class Vector3 : public Serializers::Serializable
|
||||
{
|
||||
public:
|
||||
const float_t GetX() const
|
||||
{
|
||||
return m_X;
|
||||
}
|
||||
const float_t GetY() const
|
||||
{
|
||||
return m_Y;
|
||||
}
|
||||
const float_t GetZ() const
|
||||
{
|
||||
return m_Z;
|
||||
}
|
||||
const bool IsEqual(const Vector3* other) const
|
||||
{
|
||||
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 float_t GetSqrDistance(const Vector3& other) const
|
||||
{
|
||||
return (m_X - other.m_X) * (m_X - other.m_X) +
|
||||
(m_Y - other.m_Y) * (m_Y - other.m_Y) +
|
||||
(m_Z - other.m_Z) * (m_Z - other.m_Z);
|
||||
}
|
||||
const float_t GetHorizontalSqrDistance(const Vector3& other) const
|
||||
{
|
||||
return (m_X - other.m_X) * (m_X - other.m_X) +
|
||||
(m_Y - other.m_Y) * (m_Y - other.m_Y);
|
||||
}
|
||||
|
||||
const std::vector<Serializers::Node> BuildSerializationNodes() const override
|
||||
{
|
||||
return std::vector<Serializers::Node>
|
||||
{
|
||||
{ "x", std::to_string(m_X) },
|
||||
{ "y", std::to_string(m_Y) },
|
||||
{ "z", std::to_string(m_Z) }
|
||||
};
|
||||
}
|
||||
|
||||
Vector3(const float_t x, const float_t y, const float_t z) :
|
||||
m_X(x), m_Y(y), m_Z(z)
|
||||
{
|
||||
}
|
||||
|
||||
Vector3() = default;
|
||||
virtual ~Vector3() = default;
|
||||
|
||||
private:
|
||||
float_t m_X = 0;
|
||||
float_t m_Y = 0;
|
||||
float_t m_Z = 0;
|
||||
};
|
||||
}
|
89
L2BotCore/Domain/ValueObjects/VitalStats.h
Normal file
89
L2BotCore/Domain/ValueObjects/VitalStats.h
Normal file
@ -0,0 +1,89 @@
|
||||
#pragma once
|
||||
#include <cstdint>
|
||||
#include "../Serializers/Serializable.h"
|
||||
|
||||
namespace L2Bot::Domain::ValueObjects
|
||||
{
|
||||
class VitalStats : public Serializers::Serializable
|
||||
{
|
||||
public:
|
||||
const bool IsAlive() const
|
||||
{
|
||||
return m_MaxHp <= 0 || m_Hp > 0;
|
||||
}
|
||||
const uint32_t GetMaxHp() const
|
||||
{
|
||||
return m_MaxHp;
|
||||
}
|
||||
const uint32_t GetHp() const
|
||||
{
|
||||
return m_Hp;
|
||||
}
|
||||
const uint32_t GetMaxMp() const
|
||||
{
|
||||
return m_MaxMp;
|
||||
}
|
||||
const uint32_t GetMp() const
|
||||
{
|
||||
return m_Mp;
|
||||
}
|
||||
const uint32_t GetMaxCp() const
|
||||
{
|
||||
return m_MaxCp;
|
||||
}
|
||||
const uint32_t GetCp() const
|
||||
{
|
||||
return m_Cp;
|
||||
}
|
||||
const bool IsEqual(const VitalStats* other) const
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
const std::vector<Serializers::Node> BuildSerializationNodes() const override
|
||||
{
|
||||
return std::vector<Serializers::Node>
|
||||
{
|
||||
{ "maxHp", std::to_string(m_MaxHp) },
|
||||
{ "hp", std::to_string(m_Hp) },
|
||||
{ "maxMp", std::to_string(m_MaxMp) },
|
||||
{ "mp", std::to_string(m_Mp) },
|
||||
{ "maxCp", std::to_string(m_MaxCp) },
|
||||
{ "cp", std::to_string(m_Cp) }
|
||||
};
|
||||
}
|
||||
|
||||
VitalStats(
|
||||
uint32_t maxHp,
|
||||
uint32_t hp,
|
||||
uint32_t maxMp,
|
||||
uint32_t mp,
|
||||
uint32_t maxCp,
|
||||
uint32_t cp
|
||||
) :
|
||||
m_MaxHp(maxHp),
|
||||
m_Hp(hp),
|
||||
m_MaxMp(maxMp),
|
||||
m_Mp(mp),
|
||||
m_MaxCp(maxCp),
|
||||
m_Cp(cp)
|
||||
{
|
||||
}
|
||||
|
||||
VitalStats() = default;
|
||||
virtual ~VitalStats() = default;
|
||||
|
||||
private:
|
||||
uint32_t m_MaxHp = 0;
|
||||
uint32_t m_Hp = 0;
|
||||
uint32_t m_MaxMp = 0;
|
||||
uint32_t m_Mp = 0;
|
||||
uint32_t m_MaxCp = 0;
|
||||
uint32_t m_Cp = 0;
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user