std::string Item::getDescription(const ItemType& it, int32_t lookDistance, const Item* item/* = NULL*/,
int32_t subType/* = -1*/, bool addArticle/* = true*/)
{
std::stringstream s;
s << getNameDescription(it, item, subType, addArticle);
if(item)
subType = item->getSubType();
bool dot = true;
if(it.isRune())
{
if(it.runeMagLevel > 0)
s << " for magic level " << it.runeMagLevel;
if(!it.runeSpellName.empty())
s << ". It's an \"" << it.runeSpellName << "\" spell (" << subType << "x)";
}
else if(it.weaponType != WEAPON_NONE)
{
bool begin = true;
if(it.weaponType == WEAPON_DIST && it.ammoType != AMMO_NONE)
{
begin = false;
s << " (Range:" << int32_t(item ? item->getShootRange() : it.shootRange);
if(it.attack || it.extraAttack || (item && (item->getAttack() || item->getExtraAttack())))
{
s << ", Atk " << std::showpos << int32_t(item ? item->getAttack() : it.attack);
if(it.extraAttack || (item && item->getExtraAttack()))
s << " " << std::showpos << int32_t(item ? item->getExtraAttack() : it.extraAttack) << std::noshowpos;
}
if(it.hitChance != -1 || (item && item->getHitChance() != -1))
s << ", Hit% " << std::showpos << (item ? item->getHitChance() : it.hitChance) << std::noshowpos;
if(it.attackSpeed || (item && item->getAttackSpeed()))
s << ", AS: " << (item ? item->getAttackSpeed() : it.attackSpeed);
}
else if(it.weaponType != WEAPON_AMMO && it.weaponType != WEAPON_WAND)
{
if(it.attack || it.extraAttack || (item && (item->getAttack() || item->getExtraAttack())))
{
begin = false;
s << " (Atk:";
if(it.hasAbilities() && it.abilities->elementType != COMBAT_NONE)
{
s << std::max((int32_t)0, int32_t((item ? item->getAttack() : it.attack) - it.abilities->elementDamage));
if(it.extraAttack || (item && item->getExtraAttack()))
s << " " << std::showpos << int32_t(item ? item->getExtraAttack() : it.extraAttack) << std::noshowpos;
s << " physical + " << it.abilities->elementDamage << " " << getCombatName(it.abilities->elementType);
}
else
{
s << int32_t(item ? item->getAttack() : it.attack);
if(it.extraAttack || (item && item->getExtraAttack()))
s << " " << std::showpos << int32_t(item ? item->getExtraAttack() : it.extraAttack) << std::noshowpos;
}
}
if(it.defense || it.extraDefense || (item && (item->getDefense() || item->getExtraDefense())))
{
if(begin)
{
begin = false;
s << " (";
}
else
s << ", ";
s << "Def:" << int32_t(item ? item->getDefense() : it.defense);
if(it.extraDefense || (item && item->getExtraDefense()))
s << " " << std::showpos << int32_t(item ? item->getExtraDefense() : it.extraDefense) << std::noshowpos;
}
}
if(it.attackSpeed || (item && item->getAttackSpeed()))
{
if(begin)
{
begin = false;
s << " (";
}
else
s << ", ";
s << "AS: " << (item ? item->getAttackSpeed() : it.attackSpeed);
}
if(it.hasAbilities())
{
for(uint16_t i = SKILL_FIRST; i <= SKILL_LAST; ++i)
{
if(!it.abilities->skills[i])
continue;
if(begin)
{
begin = false;
s << " (";
}
else
s << ", ";
s << getSkillName(i) << " " << std::showpos << (int32_t)it.abilities->skills[i] << std::noshowpos;
}
if(it.abilities->stats[STAT_MAGICLEVEL])
{
if(begin)
{
begin = false;
s << " (";
}
else
s << ", ";
s << "magic level " << std::showpos << (int32_t)it.abilities->stats[STAT_MAGICLEVEL] << std::noshowpos;
}
int32_t show = it.abilities->absorb[COMBAT_ALL];
if(!show)
{
bool tmp = true;
for(uint32_t i = (COMBAT_FIRST + 1); i <= COMBAT_LAST; i <<= 1)
{
if(!it.abilities->absorb[i])
continue;
if(tmp)
{
tmp = false;
if(begin)
{
begin = false;
s << " (";
}
else
s << ", ";
s << "protection ";
}
else
s << ", ";
s << getCombatName((CombatType_t)i) << " " << std::showpos << it.abilities->absorb[i] << std::noshowpos << "%";
}
}
else
{
if(begin)
{
begin = false;
s << " (";
}
else
s << ", ";
s << "protection all " << std::showpos << show << std::noshowpos << "%";
}
show = it.abilities->fieldAbsorb[COMBAT_ALL];
if(!show)
{
bool tmp = true;
for(uint32_t i = (COMBAT_FIRST + 1); i <= COMBAT_LAST; i <<= 1)
{
if(!it.abilities->fieldAbsorb[i])
continue;
if(tmp)
{
tmp = false;
if(begin)
{
begin = false;
s << " (";
}
else
s << ", ";
s << "protection ";
}
else
s << ", ";
s << getCombatName((CombatType_t)i) << " field " << std::showpos << it.abilities->absorb[i] << std::noshowpos << "%";
}
}
else
{
if(begin)
{
begin = false;
s << " (";
}
else
s << ", ";
s << "protection all fields " << std::showpos << show << std::noshowpos << "%";
}
show = it.abilities->reflect[REFLECT_CHANCE][COMBAT_ALL];
if(!show)
{
bool tmp = true;
for(uint32_t i = (COMBAT_FIRST + 1); i <= COMBAT_LAST; i <<= 1)
{
if(!it.abilities->reflect[REFLECT_CHANCE][i] || !it.abilities->reflect[REFLECT_PERCENT][i])
continue;
if(tmp)
{
tmp = false;
if(begin)
{
begin = false;
s << " (";
}
else
s << ", ";
s << "reflect: ";
}
else
s << ", ";
s << it.abilities->reflect[REFLECT_CHANCE][i] << "% for ";
if(it.abilities->reflect[REFLECT_PERCENT][i] > 99)
s << "whole";
else if(it.abilities->reflect[REFLECT_PERCENT][i] >= 75)
s << "huge";
else if(it.abilities->reflect[REFLECT_PERCENT][i] >= 50)
s << "medium";
else if(it.abilities->reflect[REFLECT_PERCENT][i] >= 25)
s << "small";
else
s << "tiny";
s << getCombatName((CombatType_t)i);
}