feat: add vital stats to players

This commit is contained in:
k0t9i 2023-02-27 23:37:53 +04:00
parent 8eea2ded26
commit f450a7cc0e
2 changed files with 19 additions and 3 deletions

View File

@ -15,6 +15,7 @@ namespace L2Bot::Domain::Entities
WorldObject::Update(other); WorldObject::Update(other);
m_FullName = casted->m_FullName; m_FullName = casted->m_FullName;
m_Phenotype = casted->m_Phenotype; m_Phenotype = casted->m_Phenotype;
m_VitalStats = casted->m_VitalStats;
} }
void SaveState() override void SaveState() override
{ {
@ -23,6 +24,7 @@ namespace L2Bot::Domain::Entities
{ {
m_FullName, m_FullName,
m_Phenotype, m_Phenotype,
m_VitalStats,
false false
}; };
} }
@ -31,7 +33,8 @@ namespace L2Bot::Domain::Entities
const Player* casted = static_cast<const Player*>(other); const Player* casted = static_cast<const Player*>(other);
return WorldObject::IsEqual(other) && return WorldObject::IsEqual(other) &&
m_FullName.IsEqual(&casted->m_FullName) && m_FullName.IsEqual(&casted->m_FullName) &&
m_Phenotype.IsEqual(&casted->m_Phenotype); m_Phenotype.IsEqual(&casted->m_Phenotype) &&
m_VitalStats.IsEqual(&casted->m_VitalStats);
} }
const std::vector<Serializers::Node> BuildSerializationNodes() const override const std::vector<Serializers::Node> BuildSerializationNodes() const override
@ -46,6 +49,10 @@ namespace L2Bot::Domain::Entities
{ {
result.push_back({ L"phenotype", m_Phenotype.BuildSerializationNodes() }); result.push_back({ L"phenotype", m_Phenotype.BuildSerializationNodes() });
} }
if (m_PrevState.isNewState || !m_VitalStats.IsEqual(&m_PrevState.vitalStats))
{
result.push_back({ L"vitalStats", m_VitalStats.BuildSerializationNodes() });
}
return result; return result;
} }
@ -54,11 +61,13 @@ namespace L2Bot::Domain::Entities
const uint32_t id, const uint32_t id,
const ValueObjects::Transform transform, const ValueObjects::Transform transform,
const ValueObjects::FullName fullName, const ValueObjects::FullName fullName,
const ValueObjects::Phenotype phenotype const ValueObjects::Phenotype phenotype,
const ValueObjects::VitalStats vitalStats
) : ) :
WorldObject(id, transform), WorldObject(id, transform),
m_FullName(fullName), m_FullName(fullName),
m_Phenotype(phenotype) m_Phenotype(phenotype),
m_VitalStats(vitalStats)
{ {
} }
@ -70,6 +79,7 @@ namespace L2Bot::Domain::Entities
{ {
ValueObjects::FullName fullName = ValueObjects::FullName(); ValueObjects::FullName fullName = ValueObjects::FullName();
ValueObjects::Phenotype phenotype = ValueObjects::Phenotype(); ValueObjects::Phenotype phenotype = ValueObjects::Phenotype();
ValueObjects::VitalStats vitalStats = ValueObjects::VitalStats();
bool isNewState = true; bool isNewState = true;
}; };
@ -77,6 +87,7 @@ namespace L2Bot::Domain::Entities
private: private:
ValueObjects::FullName m_FullName = ValueObjects::FullName(); ValueObjects::FullName m_FullName = ValueObjects::FullName();
ValueObjects::Phenotype m_Phenotype = ValueObjects::Phenotype(); ValueObjects::Phenotype m_Phenotype = ValueObjects::Phenotype();
ValueObjects::VitalStats m_VitalStats = ValueObjects::VitalStats();
GetState m_PrevState = GetState(); GetState m_PrevState = GetState();
}; };
} }

View File

@ -35,6 +35,11 @@ namespace Interlude
item->gender == L2::Gender::MALE, item->gender == L2::Gender::MALE,
(Enums::ClassEnum)item->classId, (Enums::ClassEnum)item->classId,
(Enums::ClassEnum)item->activeClassId (Enums::ClassEnum)item->activeClassId
),
ValueObjects::VitalStats(
item->maxHp, item->hp,
item->maxMp, item->mp,
item->maxCp, item->cp
) )
); );
} }