fix: update all skill on skill created event

This commit is contained in:
k0t9i 2023-02-01 00:15:20 +04:00
parent 123037cf23
commit 823241ef32
2 changed files with 18 additions and 13 deletions

View File

@ -34,10 +34,6 @@ namespace L2Bot::Domain::Entities
{ {
m_IsToggled = isToggled; m_IsToggled = isToggled;
} }
void UpdateLevel(const uint8_t level)
{
m_Level = level;
}
void Update(const EntityInterface* other) override void Update(const EntityInterface* other) override
{ {
@ -60,6 +56,8 @@ namespace L2Bot::Domain::Entities
{ {
m_PrevState = m_PrevState =
{ {
m_Name,
m_IconName,
m_Cost, m_Cost,
m_Range, m_Range,
m_Description, m_Description,
@ -96,10 +94,16 @@ namespace L2Bot::Domain::Entities
if (m_PrevState.isNewState) if (m_PrevState.isNewState)
{ {
result.push_back({ L"isActive", std::to_wstring(m_IsActive) }); result.push_back({ L"isActive", std::to_wstring(m_IsActive) });
result.push_back({ L"name", m_Name });
result.push_back({ L"iconName", m_IconName });
} }
if (m_PrevState.isNewState || m_Name != m_PrevState.name)
{
result.push_back({ L"name", m_Name });
}
if (m_PrevState.isNewState || m_IconName != m_PrevState.iconName)
{
result.push_back({ L"iconName", m_IconName });
}
if (m_PrevState.isNewState || m_Description != m_PrevState.description) if (m_PrevState.isNewState || m_Description != m_PrevState.description)
{ {
result.push_back({ L"description", m_Description }); result.push_back({ L"description", m_Description });
@ -181,6 +185,8 @@ namespace L2Bot::Domain::Entities
private: private:
struct GetState struct GetState
{ {
std::wstring name = L"";
std::wstring iconName = L"";
uint8_t cost = 0; uint8_t cost = 0;
int16_t range = 0; int16_t range = 0;
std::wstring description = L""; std::wstring description = L"";

View File

@ -134,19 +134,18 @@ namespace Interlude
const auto skillInfo = casted.GetSkillInfo(); const auto skillInfo = casted.GetSkillInfo();
const auto skillId = skillInfo[2]; const auto skillId = skillInfo[2];
auto skill = m_Factory.Create(
skillInfo[2],
skillInfo[1],
skillInfo[0]
);
if (m_Skills.find(skillId) == m_Skills.end()) if (m_Skills.find(skillId) == m_Skills.end())
{ {
auto skill = m_Factory.Create(
skillInfo[2],
skillInfo[1],
skillInfo[0]
);
m_Skills.emplace(skill->GetId(), std::move(skill)); m_Skills.emplace(skill->GetId(), std::move(skill));
} }
else else
{ {
m_Skills[skillId]->UpdateLevel(skillInfo[1]); m_Skills[skillId] = std::move(skill);
} }
m_NewSkills[skillId] = skillId; m_NewSkills[skillId] = skillId;
} }