Skip to content

Commit

Permalink
improve
Browse files Browse the repository at this point in the history
  • Loading branch information
beats-dh committed Mar 28, 2024
1 parent 510c6aa commit 79a0ef8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion data/XML/imbuements.xml
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@
<attribute key="item" value="22053" count="20" />
<attribute key="item" value="23507" count="15" />
</imbuement>
<imbuement name="Vibrancy" base="3" category="18" iconid="81" premium="0" storage="0">
<imbuement name="Vibrancy" base="3" category="18" iconid="81" premium="0" storage="46317">
<attribute key="description" value="deflects PvP paralysis, removes paralysis with a chance of 50%." />
<attribute key="effect" type="vibrancy" chance="50" />
<attribute key="item" value="22053" count="20" />
Expand Down
14 changes: 7 additions & 7 deletions src/creatures/players/imbuements/imbuements.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ SkillMapId skillMap = {
{ "sword", SKILL_SWORD }, { "axe", SKILL_AXE }, { "club", SKILL_CLUB }, { "dist", SKILL_DISTANCE }, { "distance", SKILL_DISTANCE }, { "fish", SKILL_FISHING }, { "shield", SKILL_SHIELD }, { "fist", SKILL_FIST }, { "magicpoints", STAT_MAGICPOINTS }, { "critical", SKILL_CRITICAL_HIT_DAMAGE }, { "lifeleech", SKILL_LIFE_LEECH_AMOUNT }, { "manaleech", SKILL_MANA_LEECH_AMOUNT }
};

std::shared_ptr<Imbuement> Imbuements::getImbuement(uint16_t id) {
std::shared_ptr<Imbuement> Imbuements::getImbuement(uint16_t id) const {
if (id == 0) {
return nullptr;
}
Expand Down Expand Up @@ -105,7 +105,7 @@ bool Imbuements::processImbuementNode(const pugi::xml_node &imbuementNode) {
}

uint16_t baseid = pugi::cast<uint32_t>(base.value());
auto groupBase = getBaseByID(baseid);
const auto &groupBase = getBaseByID(baseid);
if (groupBase == nullptr) {
g_logger().warn("Group base '{}' not exist", baseid);
return false;
Expand Down Expand Up @@ -152,7 +152,7 @@ bool Imbuements::processImbuementNode(const pugi::xml_node &imbuementNode) {
}

auto category = pugi::cast<uint16_t>(categorybase.value());
auto category_p = getCategoryByID(category);
const auto &category_p = getCategoryByID(category);
if (category_p == nullptr) {
g_logger().warn("Category imbuement {} not exist", category);
return false;
Expand Down Expand Up @@ -330,23 +330,23 @@ bool Imbuements::reload() {
return loadFromXml(true);
}

std::shared_ptr<BaseImbuement> Imbuements::getBaseByID(uint16_t id) {
std::shared_ptr<BaseImbuement> Imbuements::getBaseByID(uint16_t id) const {
auto baseImbuements = std::find_if(basesImbuement.begin(), basesImbuement.end(), [id](const auto &groupImbuement) {
return groupImbuement->id == id;
});

return baseImbuements != basesImbuement.end() ? *baseImbuements : nullptr;
}

std::shared_ptr<CategoryImbuement> Imbuements::getCategoryByID(uint16_t id) {
std::shared_ptr<CategoryImbuement> Imbuements::getCategoryByID(uint16_t id) const {
auto categoryImbuements = std::find_if(categoriesImbuement.begin(), categoriesImbuement.end(), [id](const auto &categoryImbuement) {
return categoryImbuement->id == id;
});

return categoryImbuements != categoriesImbuement.end() ? *categoryImbuements : nullptr;
}

std::vector<std::shared_ptr<Imbuement>> Imbuements::getImbuements(const std::shared_ptr<Player> &player, const std::shared_ptr<Item> &item) {
std::vector<std::shared_ptr<Imbuement>> Imbuements::getImbuements(const std::shared_ptr<Player> &player, const std::shared_ptr<Item> &item) const {
std::vector<std::shared_ptr<Imbuement>> imbuements;

for (auto &[key, value] : imbuementMap) {
Expand All @@ -364,7 +364,7 @@ std::vector<std::shared_ptr<Imbuement>> Imbuements::getImbuements(const std::sha
}

// Send only the imbuements registered on item (in items.xml) to the imbuement window
const std::shared_ptr<CategoryImbuement> categoryImbuement = getCategoryByID(imbuement->getCategory());
const std::shared_ptr<CategoryImbuement> &categoryImbuement = getCategoryByID(imbuement->getCategory());
if (!item->hasImbuementType(static_cast<ImbuementTypes_t>(categoryImbuement->id), imbuement->getBaseID())) {
continue;
}
Expand Down
8 changes: 4 additions & 4 deletions src/creatures/players/imbuements/imbuements.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ class Imbuements {
return inject<Imbuements>();
}

std::shared_ptr<Imbuement> getImbuement(uint16_t id);
std::shared_ptr<BaseImbuement> getBaseByID(uint16_t id);
std::shared_ptr<CategoryImbuement> getCategoryByID(uint16_t id);
std::shared_ptr<Imbuement> getImbuement(uint16_t id) const;
std::shared_ptr<BaseImbuement> getBaseByID(uint16_t id) const;
std::shared_ptr<CategoryImbuement> getCategoryByID(uint16_t id) const;

std::vector<std::shared_ptr<Imbuement>> getImbuements(const std::shared_ptr<Player> &player, const std::shared_ptr<Item> &item);
std::vector<std::shared_ptr<Imbuement>> getImbuements(const std::shared_ptr<Player> &player, const std::shared_ptr<Item> &item) const;

protected:
friend class Imbuement;
Expand Down

0 comments on commit 79a0ef8

Please sign in to comment.