feat: add armor item
This commit is contained in:
170
L2BotCore/Domain/Entities/ArmorItem.h
Normal file
170
L2BotCore/Domain/Entities/ArmorItem.h
Normal file
@ -0,0 +1,170 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <cstdint>
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
#include "BaseItem.h"
|
||||||
|
#include "../Enums/ArmorType.h"
|
||||||
|
#include "../Enums/CrystalType.h"
|
||||||
|
|
||||||
|
namespace L2Bot::Domain::Entities
|
||||||
|
{
|
||||||
|
class ArmorItem : public BaseItem
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
void Update(const EntityInterface* other) override
|
||||||
|
{
|
||||||
|
const ArmorItem* casted = static_cast<const ArmorItem*>(other);
|
||||||
|
|
||||||
|
BaseItem::Update(other);
|
||||||
|
|
||||||
|
m_IsEquipped = casted->m_IsEquipped;
|
||||||
|
m_EnchantLevel = casted->m_EnchantLevel;
|
||||||
|
m_ArmorType = casted->m_ArmorType;
|
||||||
|
m_CrystalType = casted->m_CrystalType;
|
||||||
|
m_PDef = casted->m_PDef;
|
||||||
|
m_MDef = casted->m_MDef;
|
||||||
|
m_SetEffect = casted->m_SetEffect;
|
||||||
|
m_AddSetEffect = casted->m_AddSetEffect;
|
||||||
|
m_EnchantEffect = casted->m_EnchantEffect;
|
||||||
|
}
|
||||||
|
void SaveState() override
|
||||||
|
{
|
||||||
|
BaseItem::SaveState();
|
||||||
|
m_PrevState =
|
||||||
|
{
|
||||||
|
m_IsEquipped,
|
||||||
|
m_EnchantLevel,
|
||||||
|
m_PDef,
|
||||||
|
m_MDef,
|
||||||
|
false
|
||||||
|
};
|
||||||
|
}
|
||||||
|
const bool IsEqual(const EntityInterface* other) const override
|
||||||
|
{
|
||||||
|
const ArmorItem* casted = static_cast<const ArmorItem*>(other);
|
||||||
|
return BaseItem::IsEqual(other) &&
|
||||||
|
m_IsEquipped == casted->m_IsEquipped &&
|
||||||
|
m_EnchantLevel == casted->m_EnchantLevel &&
|
||||||
|
m_ArmorType == casted->m_ArmorType &&
|
||||||
|
m_CrystalType == casted->m_CrystalType &&
|
||||||
|
m_PDef == casted->m_PDef &&
|
||||||
|
m_MDef == casted->m_MDef &&
|
||||||
|
m_SetEffect == casted->m_SetEffect &&
|
||||||
|
m_AddSetEffect == casted->m_AddSetEffect &&
|
||||||
|
m_EnchantEffect == casted->m_EnchantEffect;
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::vector<Serializers::Node> BuildSerializationNodes() const override
|
||||||
|
{
|
||||||
|
std::vector<Serializers::Node> result = BaseItem::BuildSerializationNodes();
|
||||||
|
|
||||||
|
if (m_PrevState.isNewState)
|
||||||
|
{
|
||||||
|
result.push_back({ "armorType", std::to_string(static_cast<uint8_t>(m_ArmorType)) });
|
||||||
|
result.push_back({ "crystalType", std::to_string(static_cast<int8_t>(m_CrystalType)) });
|
||||||
|
result.push_back({ "setEffect", m_SetEffect });
|
||||||
|
result.push_back({ "addSetEffect", m_AddSetEffect });
|
||||||
|
result.push_back({ "enchantEffect", m_EnchantEffect });
|
||||||
|
}
|
||||||
|
|
||||||
|
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_PDef != m_PrevState.pDef)
|
||||||
|
{
|
||||||
|
result.push_back({ "pDef", std::to_string(m_PDef) });
|
||||||
|
}
|
||||||
|
if (m_PrevState.isNewState || m_MDef != m_PrevState.mDef)
|
||||||
|
{
|
||||||
|
result.push_back({ "mDef", std::to_string(m_MDef) });
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
ArmorItem(
|
||||||
|
const uint32_t objectId,
|
||||||
|
const uint32_t itemId,
|
||||||
|
const int32_t mana,
|
||||||
|
const std::string& name,
|
||||||
|
const std::string& iconName,
|
||||||
|
const std::string& description,
|
||||||
|
const uint16_t weight,
|
||||||
|
const bool isEquipped,
|
||||||
|
const uint16_t enchantLevel,
|
||||||
|
const Enums::ArmorType armorType,
|
||||||
|
const Enums::CrystalType crystalType,
|
||||||
|
const uint16_t pDef,
|
||||||
|
const uint16_t mDef,
|
||||||
|
const std::string& setEffect,
|
||||||
|
const std::string& addSetEffect,
|
||||||
|
const std::string& enchantEffect
|
||||||
|
) :
|
||||||
|
BaseItem
|
||||||
|
(
|
||||||
|
objectId,
|
||||||
|
itemId,
|
||||||
|
mana,
|
||||||
|
name,
|
||||||
|
iconName,
|
||||||
|
description,
|
||||||
|
weight
|
||||||
|
),
|
||||||
|
m_IsEquipped(isEquipped),
|
||||||
|
m_EnchantLevel(enchantLevel),
|
||||||
|
m_ArmorType(armorType),
|
||||||
|
m_CrystalType(crystalType),
|
||||||
|
m_PDef(pDef),
|
||||||
|
m_MDef(mDef),
|
||||||
|
m_SetEffect(setEffect),
|
||||||
|
m_AddSetEffect(addSetEffect),
|
||||||
|
m_EnchantEffect(enchantEffect)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
ArmorItem(const ArmorItem* other) :
|
||||||
|
BaseItem(other),
|
||||||
|
m_IsEquipped(other->m_IsEquipped),
|
||||||
|
m_EnchantLevel(other->m_EnchantLevel),
|
||||||
|
m_ArmorType(other->m_ArmorType),
|
||||||
|
m_CrystalType(other->m_CrystalType),
|
||||||
|
m_PDef(other->m_PDef),
|
||||||
|
m_MDef(other->m_MDef),
|
||||||
|
m_SetEffect(other->m_SetEffect),
|
||||||
|
m_AddSetEffect(other->m_AddSetEffect),
|
||||||
|
m_EnchantEffect(other->m_EnchantEffect)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
ArmorItem() = default;
|
||||||
|
virtual ~ArmorItem() = default;
|
||||||
|
|
||||||
|
private:
|
||||||
|
struct GetState
|
||||||
|
{
|
||||||
|
bool isEquipped = 0;
|
||||||
|
uint16_t enchantLevel = 0;
|
||||||
|
uint16_t pDef = 0;
|
||||||
|
uint16_t mDef = 0;
|
||||||
|
|
||||||
|
bool isNewState = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool m_IsEquipped = 0;
|
||||||
|
uint16_t m_EnchantLevel = 0;
|
||||||
|
Enums::ArmorType m_ArmorType = Enums::ArmorType::none;
|
||||||
|
Enums::CrystalType m_CrystalType = Enums::CrystalType::none;
|
||||||
|
uint16_t m_PDef = 0;
|
||||||
|
uint16_t m_MDef = 0;
|
||||||
|
std::string m_SetEffect = "";
|
||||||
|
std::string m_AddSetEffect = "";
|
||||||
|
std::string m_EnchantEffect = "";
|
||||||
|
GetState m_PrevState = GetState();
|
||||||
|
};
|
||||||
|
}
|
@ -9,44 +9,37 @@ namespace L2Bot::Domain::Entities
|
|||||||
class BaseItem : public EntityInterface
|
class BaseItem : public EntityInterface
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
const uint32_t GetId() const
|
const uint32_t GetId() const override
|
||||||
{
|
{
|
||||||
return m_ItemId;
|
return m_ObjectId;
|
||||||
}
|
}
|
||||||
void Update(const EntityInterface* other) override
|
virtual void Update(const EntityInterface* other) override
|
||||||
{
|
{
|
||||||
const BaseItem* casted = static_cast<const BaseItem*>(other);
|
const BaseItem* casted = static_cast<const BaseItem*>(other);
|
||||||
SaveState();
|
SaveState();
|
||||||
|
|
||||||
|
m_ObjectId = casted->m_ObjectId;
|
||||||
m_ItemId = casted->m_ItemId;
|
m_ItemId = casted->m_ItemId;
|
||||||
m_Amount = casted->m_Amount;
|
|
||||||
m_IsEquipped = casted->m_IsEquipped;
|
|
||||||
m_EnchantLevel = casted->m_EnchantLevel;
|
|
||||||
m_Mana = casted->m_Mana;
|
m_Mana = casted->m_Mana;
|
||||||
m_Name = casted->m_Name;
|
m_Name = casted->m_Name;
|
||||||
m_IconName = casted->m_IconName;
|
m_IconName = casted->m_IconName;
|
||||||
m_Description = casted->m_Description;
|
m_Description = casted->m_Description;
|
||||||
m_Weight = casted->m_Weight;
|
m_Weight = casted->m_Weight;
|
||||||
}
|
}
|
||||||
void SaveState() override
|
virtual void SaveState() override
|
||||||
{
|
{
|
||||||
m_PrevState =
|
m_PrevState =
|
||||||
{
|
{
|
||||||
m_Amount,
|
|
||||||
m_IsEquipped,
|
|
||||||
m_EnchantLevel,
|
|
||||||
m_Mana,
|
m_Mana,
|
||||||
m_Weight,
|
m_Weight,
|
||||||
false
|
false
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
const bool IsEqual(const EntityInterface* other) const override
|
virtual const bool IsEqual(const EntityInterface* other) const override
|
||||||
{
|
{
|
||||||
const BaseItem* casted = static_cast<const BaseItem*>(other);
|
const BaseItem* casted = static_cast<const BaseItem*>(other);
|
||||||
return m_ItemId == casted->m_ItemId &&
|
return m_ObjectId == casted->m_ObjectId &&
|
||||||
m_Amount == casted->m_Amount &&
|
m_ItemId == casted->m_ItemId &&
|
||||||
m_IsEquipped == casted->m_IsEquipped &&
|
|
||||||
m_EnchantLevel == casted->m_EnchantLevel &&
|
|
||||||
m_Mana == casted->m_Mana &&
|
m_Mana == casted->m_Mana &&
|
||||||
m_Name == casted->m_Name &&
|
m_Name == casted->m_Name &&
|
||||||
m_IconName == casted->m_IconName &&
|
m_IconName == casted->m_IconName &&
|
||||||
@ -54,10 +47,11 @@ namespace L2Bot::Domain::Entities
|
|||||||
m_Weight == casted->m_Weight;
|
m_Weight == casted->m_Weight;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector<Serializers::Node> BuildSerializationNodes() const override
|
virtual const std::vector<Serializers::Node> BuildSerializationNodes() const override
|
||||||
{
|
{
|
||||||
std::vector<Serializers::Node> result;
|
std::vector<Serializers::Node> result;
|
||||||
|
|
||||||
|
result.push_back({ "objectId", std::to_string(m_ObjectId) });
|
||||||
result.push_back({ "itemId", std::to_string(m_ItemId) });
|
result.push_back({ "itemId", std::to_string(m_ItemId) });
|
||||||
|
|
||||||
if (m_PrevState.isNewState)
|
if (m_PrevState.isNewState)
|
||||||
@ -67,18 +61,6 @@ namespace L2Bot::Domain::Entities
|
|||||||
result.push_back({ "description", m_Description });
|
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)
|
if (m_PrevState.isNewState || m_Mana != m_PrevState.mana)
|
||||||
{
|
{
|
||||||
result.push_back({ "mana", std::to_string(m_Mana) });
|
result.push_back({ "mana", std::to_string(m_Mana) });
|
||||||
@ -92,20 +74,16 @@ namespace L2Bot::Domain::Entities
|
|||||||
}
|
}
|
||||||
|
|
||||||
BaseItem(
|
BaseItem(
|
||||||
|
const uint32_t objectId,
|
||||||
const uint32_t itemId,
|
const uint32_t itemId,
|
||||||
const uint32_t amount,
|
|
||||||
const bool isEquipped,
|
|
||||||
const uint16_t enchantLevel,
|
|
||||||
const int32_t mana,
|
const int32_t mana,
|
||||||
const std::string& name,
|
const std::string& name,
|
||||||
const std::string& iconName,
|
const std::string& iconName,
|
||||||
const std::string& description,
|
const std::string& description,
|
||||||
const uint16_t weight
|
const uint16_t weight
|
||||||
) :
|
) :
|
||||||
|
m_ObjectId(objectId),
|
||||||
m_ItemId(itemId),
|
m_ItemId(itemId),
|
||||||
m_Amount(amount),
|
|
||||||
m_IsEquipped(isEquipped),
|
|
||||||
m_EnchantLevel(enchantLevel),
|
|
||||||
m_Mana(mana),
|
m_Mana(mana),
|
||||||
m_Name(name),
|
m_Name(name),
|
||||||
m_IconName(iconName),
|
m_IconName(iconName),
|
||||||
@ -115,10 +93,8 @@ namespace L2Bot::Domain::Entities
|
|||||||
}
|
}
|
||||||
|
|
||||||
BaseItem(const BaseItem* other) :
|
BaseItem(const BaseItem* other) :
|
||||||
|
m_ObjectId(other->m_ObjectId),
|
||||||
m_ItemId(other->m_ItemId),
|
m_ItemId(other->m_ItemId),
|
||||||
m_Amount(other->m_Amount),
|
|
||||||
m_IsEquipped(other->m_IsEquipped),
|
|
||||||
m_EnchantLevel(other->m_EnchantLevel),
|
|
||||||
m_Mana(other->m_Mana),
|
m_Mana(other->m_Mana),
|
||||||
m_Name(other->m_Name),
|
m_Name(other->m_Name),
|
||||||
m_IconName(other->m_IconName),
|
m_IconName(other->m_IconName),
|
||||||
@ -133,9 +109,6 @@ namespace L2Bot::Domain::Entities
|
|||||||
private:
|
private:
|
||||||
struct GetState
|
struct GetState
|
||||||
{
|
{
|
||||||
uint32_t amount = 0;
|
|
||||||
bool isEquipped = 0;
|
|
||||||
uint16_t enchantLevel = 0;
|
|
||||||
int32_t mana = -1;
|
int32_t mana = -1;
|
||||||
uint16_t weight = 0;
|
uint16_t weight = 0;
|
||||||
|
|
||||||
@ -143,10 +116,8 @@ namespace L2Bot::Domain::Entities
|
|||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
uint32_t m_ObjectId = 0;
|
||||||
uint32_t m_ItemId = 0;
|
uint32_t m_ItemId = 0;
|
||||||
uint32_t m_Amount = 0;
|
|
||||||
bool m_IsEquipped = 0;
|
|
||||||
uint16_t m_EnchantLevel = 0;
|
|
||||||
int32_t m_Mana = -1;
|
int32_t m_Mana = -1;
|
||||||
std::string m_Name = "";
|
std::string m_Name = "";
|
||||||
std::string m_IconName = "";
|
std::string m_IconName = "";
|
||||||
|
104
L2BotCore/Domain/Entities/EtcItem.h
Normal file
104
L2BotCore/Domain/Entities/EtcItem.h
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <cstdint>
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
#include "BaseItem.h"
|
||||||
|
|
||||||
|
namespace L2Bot::Domain::Entities
|
||||||
|
{
|
||||||
|
class EtcItem : public BaseItem
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
void Update(const EntityInterface* other) override
|
||||||
|
{
|
||||||
|
const EtcItem* casted = static_cast<const EtcItem*>(other);
|
||||||
|
|
||||||
|
BaseItem::Update(other);
|
||||||
|
|
||||||
|
m_Amount = casted->m_Amount;
|
||||||
|
m_IsQuest = casted->m_IsQuest;
|
||||||
|
}
|
||||||
|
void SaveState() override
|
||||||
|
{
|
||||||
|
BaseItem::SaveState();
|
||||||
|
m_PrevState =
|
||||||
|
{
|
||||||
|
m_Amount,
|
||||||
|
false
|
||||||
|
};
|
||||||
|
}
|
||||||
|
const bool IsEqual(const EntityInterface* other) const override
|
||||||
|
{
|
||||||
|
const EtcItem* casted = static_cast<const EtcItem*>(other);
|
||||||
|
return BaseItem::IsEqual(other) &&
|
||||||
|
m_IsQuest == casted->m_IsQuest &&
|
||||||
|
m_Amount == casted->m_Amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::vector<Serializers::Node> BuildSerializationNodes() const override
|
||||||
|
{
|
||||||
|
std::vector<Serializers::Node> result = BaseItem::BuildSerializationNodes();
|
||||||
|
|
||||||
|
if (m_PrevState.isNewState)
|
||||||
|
{
|
||||||
|
result.push_back({ "isQuest", std::to_string(m_IsQuest) });
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_PrevState.isNewState || m_Amount != m_PrevState.amount)
|
||||||
|
{
|
||||||
|
result.push_back({ "amount", std::to_string(m_Amount) });
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
EtcItem(
|
||||||
|
const uint32_t objectId,
|
||||||
|
const uint32_t itemId,
|
||||||
|
const int32_t mana,
|
||||||
|
const std::string& name,
|
||||||
|
const std::string& iconName,
|
||||||
|
const std::string& description,
|
||||||
|
const uint16_t weight,
|
||||||
|
const uint32_t amount,
|
||||||
|
const bool isQuest
|
||||||
|
) :
|
||||||
|
BaseItem
|
||||||
|
(
|
||||||
|
objectId,
|
||||||
|
itemId,
|
||||||
|
mana,
|
||||||
|
name,
|
||||||
|
iconName,
|
||||||
|
description,
|
||||||
|
weight
|
||||||
|
),
|
||||||
|
m_Amount(amount),
|
||||||
|
m_IsQuest(isQuest)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
EtcItem(const EtcItem* other) :
|
||||||
|
BaseItem(other),
|
||||||
|
m_Amount(other->m_Amount),
|
||||||
|
m_IsQuest(other->m_IsQuest)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
EtcItem() = default;
|
||||||
|
virtual ~EtcItem() = default;
|
||||||
|
|
||||||
|
private:
|
||||||
|
struct GetState
|
||||||
|
{
|
||||||
|
uint32_t amount = 0;
|
||||||
|
|
||||||
|
bool isNewState = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
private:
|
||||||
|
uint32_t m_Amount = 0;
|
||||||
|
bool m_IsQuest = false;
|
||||||
|
GetState m_PrevState = GetState();
|
||||||
|
};
|
||||||
|
}
|
14
L2BotCore/Domain/Enums/ArmorType.h
Normal file
14
L2BotCore/Domain/Enums/ArmorType.h
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
namespace L2Bot::Domain::Enums
|
||||||
|
{
|
||||||
|
enum class ArmorType : uint8_t
|
||||||
|
{
|
||||||
|
none = 0,
|
||||||
|
light,
|
||||||
|
heavy,
|
||||||
|
robe
|
||||||
|
};
|
||||||
|
}
|
17
L2BotCore/Domain/Enums/CrystalType.h
Normal file
17
L2BotCore/Domain/Enums/CrystalType.h
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
namespace L2Bot::Domain::Enums
|
||||||
|
{
|
||||||
|
enum class CrystalType : int8_t
|
||||||
|
{
|
||||||
|
none = -1,
|
||||||
|
ng,
|
||||||
|
d,
|
||||||
|
c,
|
||||||
|
b,
|
||||||
|
a,
|
||||||
|
s
|
||||||
|
};
|
||||||
|
}
|
@ -160,9 +160,13 @@
|
|||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="Domain\DTO\EntityState.h" />
|
<ClInclude Include="Domain\DTO\EntityState.h" />
|
||||||
|
<ClInclude Include="Domain\Entities\ArmorItem.h" />
|
||||||
<ClInclude Include="Domain\Entities\EntityInterface.h" />
|
<ClInclude Include="Domain\Entities\EntityInterface.h" />
|
||||||
<ClInclude Include="Domain\Entities\BaseItem.h" />
|
<ClInclude Include="Domain\Entities\BaseItem.h" />
|
||||||
|
<ClInclude Include="Domain\Entities\EtcItem.h" />
|
||||||
<ClInclude Include="Domain\Entities\Skill.h" />
|
<ClInclude Include="Domain\Entities\Skill.h" />
|
||||||
|
<ClInclude Include="Domain\Enums\ArmorType.h" />
|
||||||
|
<ClInclude Include="Domain\Enums\CrystalType.h" />
|
||||||
<ClInclude Include="Domain\ValueObjects\Vector3.h" />
|
<ClInclude Include="Domain\ValueObjects\Vector3.h" />
|
||||||
<ClInclude Include="Domain\Enums\SpoilStateEnum.h" />
|
<ClInclude Include="Domain\Enums\SpoilStateEnum.h" />
|
||||||
<ClInclude Include="Domain\Transports\TransportInterface.h" />
|
<ClInclude Include="Domain\Transports\TransportInterface.h" />
|
||||||
|
@ -111,6 +111,18 @@
|
|||||||
<ClInclude Include="Domain\Entities\EntityInterface.h">
|
<ClInclude Include="Domain\Entities\EntityInterface.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="Domain\Entities\EtcItem.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Domain\Entities\ArmorItem.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Domain\Enums\ArmorType.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Domain\Enums\CrystalType.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="pch.cpp">
|
<ClCompile Include="pch.cpp">
|
||||||
|
@ -4,9 +4,11 @@
|
|||||||
|
|
||||||
struct ItemData
|
struct ItemData
|
||||||
{
|
{
|
||||||
|
const uint32_t objectId = 0;
|
||||||
const uint32_t itemId = 0;
|
const uint32_t itemId = 0;
|
||||||
const uint32_t amount = 0;
|
const uint32_t amount = 0;
|
||||||
const uint16_t isEquipped = 0;
|
const uint16_t isEquipped = 0;
|
||||||
const uint16_t enchantLevel = 0;
|
const uint16_t enchantLevel = 0;
|
||||||
const int32_t mana = -1;
|
const int32_t mana = -1;
|
||||||
|
const bool isQuest = false;
|
||||||
};
|
};
|
@ -20,7 +20,7 @@ public:
|
|||||||
return m_ItemData;
|
return m_ItemData;
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemCreatedEvent(const ItemData& itemData) :
|
ItemCreatedEvent(const ItemData itemData) :
|
||||||
m_ItemData(itemData)
|
m_ItemData(itemData)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -15,13 +15,13 @@ public:
|
|||||||
return std::string(name);
|
return std::string(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
const uint32_t GetItemId() const
|
const uint32_t GetObjectId() const
|
||||||
{
|
{
|
||||||
return m_Id;
|
return m_ObjectId;
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemDeletedEvent(const uint32_t id) :
|
ItemDeletedEvent(const uint32_t objectId) :
|
||||||
m_Id(id)
|
m_ObjectId(objectId)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -30,5 +30,5 @@ public:
|
|||||||
virtual ~ItemDeletedEvent() = default;
|
virtual ~ItemDeletedEvent() = default;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const uint32_t m_Id;
|
const uint32_t m_ObjectId;
|
||||||
};
|
};
|
@ -20,7 +20,7 @@ public:
|
|||||||
return m_ItemData;
|
return m_ItemData;
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemUpdatedEvent(const ItemData& itemData) :
|
ItemUpdatedEvent(const ItemData itemData) :
|
||||||
m_ItemData(itemData)
|
m_ItemData(itemData)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -119,8 +119,8 @@ private:
|
|||||||
{
|
{
|
||||||
std::vector<Serializers::SerializableStateContainer> items
|
std::vector<Serializers::SerializableStateContainer> items
|
||||||
{
|
{
|
||||||
/*Serializers::SerializableStateContainer{m_HeroService.GetEntities(), "hero"},
|
Serializers::SerializableStateContainer{m_HeroService.GetEntities(), "hero"},
|
||||||
Serializers::SerializableStateContainer{m_DropService.GetEntities(), "drop"},
|
/*Serializers::SerializableStateContainer{m_DropService.GetEntities(), "drop"},
|
||||||
Serializers::SerializableStateContainer{m_NPCService.GetEntities(), "npc"},
|
Serializers::SerializableStateContainer{m_NPCService.GetEntities(), "npc"},
|
||||||
Serializers::SerializableStateContainer{m_PlayerService.GetEntities(), "player"},
|
Serializers::SerializableStateContainer{m_PlayerService.GetEntities(), "player"},
|
||||||
Serializers::SerializableStateContainer{m_SkillService.GetEntities(), "skill"},*/
|
Serializers::SerializableStateContainer{m_SkillService.GetEntities(), "skill"},*/
|
||||||
|
@ -6,7 +6,8 @@
|
|||||||
#include "../GameStructs/L2GameDataWrapper.h"
|
#include "../GameStructs/L2GameDataWrapper.h"
|
||||||
#include "../GameStructs/FName.h"
|
#include "../GameStructs/FName.h"
|
||||||
#include "../../../Common/Common.h"
|
#include "../../../Common/Common.h"
|
||||||
#include "Domain/Entities/BaseItem.h"
|
#include "Domain/Entities/EtcItem.h"
|
||||||
|
#include "Domain/Entities/ArmorItem.h"
|
||||||
#include "../../../DTO/ItemData.h"
|
#include "../../../DTO/ItemData.h"
|
||||||
|
|
||||||
using namespace L2Bot::Domain;
|
using namespace L2Bot::Domain;
|
||||||
@ -30,19 +31,98 @@ namespace Interlude
|
|||||||
const auto data = m_L2GameData.GetItemData(itemInfo.itemId);
|
const auto data = m_L2GameData.GetItemData(itemInfo.itemId);
|
||||||
|
|
||||||
const auto nameEntry = data ? m_FName.GetEntry(data->nameIndex) : nullptr;
|
const auto nameEntry = data ? m_FName.GetEntry(data->nameIndex) : nullptr;
|
||||||
|
const auto name = nameEntry ? ConvertFromWideChar(nameEntry->value) : "";
|
||||||
const auto iconEntry = data ? m_FName.GetEntry(data->iconNameIndex) : nullptr;
|
const auto iconEntry = data ? m_FName.GetEntry(data->iconNameIndex) : nullptr;
|
||||||
const auto description = data && data->description ? data->description : L"";
|
const auto icon = iconEntry ? ConvertFromWideChar(iconEntry->value) : "";
|
||||||
|
const auto description = data && data->description ? ConvertFromWideChar(data->description) : "";
|
||||||
|
|
||||||
return std::make_unique<Entities::BaseItem>(
|
if (data)
|
||||||
|
{
|
||||||
|
switch (data->dataType)
|
||||||
|
{
|
||||||
|
case L2::ItemDataType::ARMOR:
|
||||||
|
return CreateArmor(itemInfo, data, name, icon, description);
|
||||||
|
case L2::ItemDataType::WEAPON:
|
||||||
|
return CreateEtc(itemInfo, data, name, icon, description);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return CreateEtc(itemInfo, data, name, icon, description);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::unique_ptr<Entities::BaseItem> CreateFromPointer(const Entities::BaseItem* other) const
|
||||||
|
{
|
||||||
|
{
|
||||||
|
const auto object = dynamic_cast<const Entities::EtcItem*>(other);
|
||||||
|
if (object)
|
||||||
|
{
|
||||||
|
return std::make_unique<Entities::EtcItem>(object);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
{
|
||||||
|
const auto object = dynamic_cast<const Entities::ArmorItem*>(other);
|
||||||
|
if (object)
|
||||||
|
{
|
||||||
|
return std::make_unique<Entities::ArmorItem>(object);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::make_unique<Entities::BaseItem>(other);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::unique_ptr<Entities::BaseItem> CreateEtc(
|
||||||
|
const ItemData& itemInfo,
|
||||||
|
const FL2ItemDataBase* itemData,
|
||||||
|
const std::string& name,
|
||||||
|
const std::string& icon,
|
||||||
|
const std::string& description
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
return std::make_unique<Entities::EtcItem>(
|
||||||
|
itemInfo.objectId,
|
||||||
itemInfo.itemId,
|
itemInfo.itemId,
|
||||||
|
itemInfo.mana,
|
||||||
|
name,
|
||||||
|
icon,
|
||||||
|
description,
|
||||||
|
itemData ? itemData->weight : 0,
|
||||||
itemInfo.amount,
|
itemInfo.amount,
|
||||||
|
itemInfo.isQuest
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::unique_ptr<Entities::BaseItem> CreateArmor(
|
||||||
|
const ItemData& itemInfo,
|
||||||
|
const FL2ItemDataBase* itemData,
|
||||||
|
const std::string& name,
|
||||||
|
const std::string& icon,
|
||||||
|
const std::string& description
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
const auto casted = static_cast<const FL2ArmorItemData*>(itemData);
|
||||||
|
|
||||||
|
const auto setEffect = casted && casted->setEffect ? ConvertFromWideChar(casted->setEffect) : "";
|
||||||
|
const auto addSetEffect = casted && casted->setEffect ? ConvertFromWideChar(casted->setEffect) : "";
|
||||||
|
const auto enchantEffect = casted && casted->enchantEffect ? ConvertFromWideChar(casted->enchantEffect) : "";
|
||||||
|
|
||||||
|
return std::make_unique<Entities::ArmorItem>(
|
||||||
|
itemInfo.objectId,
|
||||||
|
itemInfo.itemId,
|
||||||
|
itemInfo.mana,
|
||||||
|
name,
|
||||||
|
icon,
|
||||||
|
description,
|
||||||
|
itemData ? itemData->weight : 0,
|
||||||
itemInfo.isEquipped > 0,
|
itemInfo.isEquipped > 0,
|
||||||
itemInfo.enchantLevel,
|
itemInfo.enchantLevel,
|
||||||
itemInfo.mana,
|
casted ? static_cast<Enums::ArmorType>(casted->armorType) : Enums::ArmorType::none,
|
||||||
nameEntry ? ConvertFromWideChar(nameEntry->value) : "",
|
casted ? static_cast<Enums::CrystalType>(casted->crystalType) : Enums::CrystalType::none,
|
||||||
iconEntry ? ConvertFromWideChar(iconEntry->value) : "",
|
casted ? casted->pDef : 0,
|
||||||
ConvertFromWideChar(description),
|
casted ? casted->mDef : 0,
|
||||||
data ? data->weight : 0
|
setEffect,
|
||||||
|
addSetEffect,
|
||||||
|
enchantEffect
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,11 +107,13 @@ namespace Interlude
|
|||||||
{
|
{
|
||||||
ItemData
|
ItemData
|
||||||
{
|
{
|
||||||
|
itemInfo.objectId,
|
||||||
itemInfo.itemId,
|
itemInfo.itemId,
|
||||||
itemInfo.amount,
|
itemInfo.amount,
|
||||||
itemInfo.isEquipped,
|
itemInfo.isEquipped,
|
||||||
itemInfo.enchantLevel,
|
itemInfo.enchantLevel,
|
||||||
itemInfo.mana,
|
itemInfo.mana,
|
||||||
|
itemInfo.type2 == L2::ItemType2::QUEST
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@ -122,11 +124,13 @@ namespace Interlude
|
|||||||
{
|
{
|
||||||
const ItemData itemData
|
const ItemData itemData
|
||||||
{
|
{
|
||||||
|
itemInfo.objectId,
|
||||||
itemInfo.itemId,
|
itemInfo.itemId,
|
||||||
itemInfo.amount,
|
itemInfo.amount,
|
||||||
itemInfo.isEquipped,
|
itemInfo.isEquipped,
|
||||||
itemInfo.enchantLevel,
|
itemInfo.enchantLevel,
|
||||||
itemInfo.mana,
|
itemInfo.mana,
|
||||||
|
itemInfo.type2 == L2::ItemType2::QUEST
|
||||||
};
|
};
|
||||||
|
|
||||||
switch (actionType)
|
switch (actionType)
|
||||||
@ -138,7 +142,7 @@ namespace Interlude
|
|||||||
EventDispatcher::GetInstance().Dispatch(ItemUpdatedEvent{ itemData });
|
EventDispatcher::GetInstance().Dispatch(ItemUpdatedEvent{ itemData });
|
||||||
break;
|
break;
|
||||||
case UpdateItemListActionType::deleted:
|
case UpdateItemListActionType::deleted:
|
||||||
EventDispatcher::GetInstance().Dispatch(ItemDeletedEvent{ itemInfo.itemId });
|
EventDispatcher::GetInstance().Dispatch(ItemDeletedEvent{ itemInfo.objectId });
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
(*__OnReceiveUpdateItemList)(This, actionType, itemInfo);
|
(*__OnReceiveUpdateItemList)(This, actionType, itemInfo);
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
#include "../../../Events/ItemCreatedEvent.h"
|
#include "../../../Events/ItemCreatedEvent.h"
|
||||||
#include "../../../Events/ItemUpdatedEvent.h"
|
#include "../../../Events/ItemUpdatedEvent.h"
|
||||||
#include "../../../Events/ItemDeletedEvent.h"
|
#include "../../../Events/ItemDeletedEvent.h"
|
||||||
|
#include "../../../Events/HeroDeletedEvent.h"
|
||||||
#include "../../../Events/EventDispatcher.h"
|
#include "../../../Events/EventDispatcher.h"
|
||||||
|
|
||||||
using namespace L2Bot::Domain;
|
using namespace L2Bot::Domain;
|
||||||
@ -30,7 +31,7 @@ namespace Interlude
|
|||||||
}
|
}
|
||||||
|
|
||||||
const auto objects = m_EntityHandler.GetEntities<Entities::BaseItem*>(itemPtrs, [this](Entities::BaseItem* item) {
|
const auto objects = m_EntityHandler.GetEntities<Entities::BaseItem*>(itemPtrs, [this](Entities::BaseItem* item) {
|
||||||
return std::make_unique<Entities::BaseItem>(item);
|
return m_Factory.CreateFromPointer(item);
|
||||||
});
|
});
|
||||||
|
|
||||||
auto result = std::vector<std::shared_ptr<DTO::EntityState>>();
|
auto result = std::vector<std::shared_ptr<DTO::EntityState>>();
|
||||||
@ -57,6 +58,18 @@ namespace Interlude
|
|||||||
EventDispatcher::GetInstance().Subscribe(ItemDeletedEvent::name, [this](const Event& evt) {
|
EventDispatcher::GetInstance().Subscribe(ItemDeletedEvent::name, [this](const Event& evt) {
|
||||||
OnItemDeleted(evt);
|
OnItemDeleted(evt);
|
||||||
});
|
});
|
||||||
|
EventDispatcher::GetInstance().Subscribe(HeroDeletedEvent::name, [this](const Event& evt) {
|
||||||
|
OnHeroDeleted(evt);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnHeroDeleted(const Event& evt)
|
||||||
|
{
|
||||||
|
std::shared_lock<std::shared_timed_mutex>(m_Mutex);
|
||||||
|
if (evt.GetName() == HeroDeletedEvent::name)
|
||||||
|
{
|
||||||
|
Reset();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnItemCreated(const Event& evt)
|
void OnItemCreated(const Event& evt)
|
||||||
@ -68,14 +81,14 @@ namespace Interlude
|
|||||||
const auto& data = casted.GetItemData();
|
const auto& data = casted.GetItemData();
|
||||||
|
|
||||||
auto item = m_Factory.Create(data);
|
auto item = m_Factory.Create(data);
|
||||||
if (m_Items.find(data.itemId) == m_Items.end())
|
if (m_Items.find(data.objectId) == m_Items.end())
|
||||||
{
|
{
|
||||||
m_Items.emplace(data.itemId, std::move(item));
|
m_Items.emplace(data.objectId, std::move(item));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// When equip/unequip accessories
|
// When equip/unequip accessories
|
||||||
m_Items[data.itemId]->Update(item.get());
|
m_Items[data.objectId]->Update(item.get());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -89,16 +102,17 @@ namespace Interlude
|
|||||||
const auto& data = casted.GetItemData();
|
const auto& data = casted.GetItemData();
|
||||||
|
|
||||||
//todo exception?
|
//todo exception?
|
||||||
if (m_Items.find(data.itemId) == m_Items.end())
|
if (m_Items.find(data.objectId) == m_Items.end())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto item = m_Factory.Create(data);
|
auto item = m_Factory.Create(data);
|
||||||
m_Items[data.itemId]->Update(item.get());
|
m_Items[data.objectId]->Update(item.get());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//todo deleted ehchant scroll
|
||||||
void OnItemDeleted(const Event& evt)
|
void OnItemDeleted(const Event& evt)
|
||||||
{
|
{
|
||||||
//fixme may be a race condition
|
//fixme may be a race condition
|
||||||
@ -107,7 +121,7 @@ namespace Interlude
|
|||||||
{
|
{
|
||||||
const auto casted = static_cast<const ItemDeletedEvent&>(evt);
|
const auto casted = static_cast<const ItemDeletedEvent&>(evt);
|
||||||
|
|
||||||
m_Items.erase(casted.GetItemId());
|
m_Items.erase(casted.GetObjectId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user