Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: cyclopedia description #1923

Merged
merged 8 commits into from
Dec 29, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 27 additions & 24 deletions src/items/item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1291,7 +1291,7 @@ Item::getDescriptions(const ItemType &it, std::shared_ptr<Item> item /*= nullptr

if (it.abilities->speed) {
ss.str("");
ss << std::showpos << (it.abilities->speed >> 1) << std::noshowpos;
ss << std::showpos << it.abilities->speed << std::noshowpos;
descriptions.emplace_back("Speed", ss.str());
}

Expand Down Expand Up @@ -1606,7 +1606,7 @@ Item::getDescriptions(const ItemType &it, std::shared_ptr<Item> item /*= nullptr
ss.str("");
bool skillBoost = false;
if (it.abilities->speed) {
ss << std::showpos << "speed " << (it.abilities->speed >> 1) << std::noshowpos;
ss << std::showpos << "speed " << it.abilities->speed << std::noshowpos;
skillBoost = true;
}

Expand Down Expand Up @@ -1653,14 +1653,11 @@ Item::getDescriptions(const ItemType &it, std::shared_ptr<Item> item /*= nullptr
ss << it.abilities->skills[i];
}
ss << '%' << std::noshowpos;

skillBoost = true;
}

if (it.abilities->stats[STAT_MAGICPOINTS]) {
ss.str("");
ss << std::showpos << it.abilities->stats[STAT_MAGICPOINTS] << std::noshowpos;
descriptions.emplace_back("Magic Level", ss.str());
if (skillBoost) {
descriptions.emplace_back("Skill Boost", ss.str());
}

for (uint8_t i = 1; i <= 11; i++) {
Expand Down Expand Up @@ -1692,12 +1689,6 @@ Item::getDescriptions(const ItemType &it, std::shared_ptr<Item> item /*= nullptr
descriptions.emplace_back("Damage Reflection", ss.str());
}

if (it.abilities->speed) {
ss.str("");
ss << std::showpos << (it.abilities->speed >> 1) << std::noshowpos;
descriptions.emplace_back("Speed", ss.str());
}

if (it.abilities->cleavePercent) {
ss.str("");
ss << std::showpos << (it.abilities->cleavePercent) << std::noshowpos << "%";
Expand Down Expand Up @@ -1728,17 +1719,6 @@ Item::getDescriptions(const ItemType &it, std::shared_ptr<Item> item /*= nullptr
descriptions.emplace_back("Effect", ss.str());
}

for (size_t i = 0; i < COMBAT_COUNT; ++i) {
if (it.abilities->absorbPercent[i] == 0) {
continue;
}

ss.str("");
ss << getCombatName(indexToCombatType(i)) << ' '
<< std::showpos << it.abilities->absorbPercent[i] << std::noshowpos << '%';
descriptions.emplace_back("Protection", ss.str());
}

for (size_t i = 0; i < COMBAT_COUNT; ++i) {
if (it.abilities->fieldAbsorbPercent[i] == 0) {
continue;
Expand Down Expand Up @@ -2587,6 +2567,7 @@ std::string Item::getDescription(const ItemType &it, int32_t lookDistance, std::
if (!begin) {
s << ')';
}
// This block refers to the look of the weapons.
} else if (it.weaponType != WEAPON_AMMO) {
bool begin = true;

Expand All @@ -2601,6 +2582,28 @@ std::string Item::getDescription(const ItemType &it, int32_t lookDistance, std::
extraDefense = it.extraDefense;
}

if (it.isContainer() || (item && item->getContainer())) {
uint32_t volume = 0;

if (!item || !item->hasAttribute(ItemAttribute_t::UNIQUEID)) {
if (it.isContainer()) {
volume = it.maxItems;
} else if (item) {
volume = item->getContainer()->capacity();
}
}

if (volume != 0) {
if (begin) {
begin = false;
s << " (";
} else {
s << ", ";
}

s << "Vol:" << volume;
}
}
if (attack != 0) {
begin = false;
s << " (Atk:" << attack;
Expand Down
Loading