Some adjustments to item interesting strings
For weapons, negative bonus is now shown as "- 2" instead of as "+ -2". For armour, the bonus is now accounted for and the numbers should match what is actually calculated in damage_pc(). Thanks to @fosnola for noticing the armour discrepancy.
This commit is contained in:
@@ -35,3 +35,8 @@ inline void move_to_zero(T& val){
|
|||||||
if(val > 0)
|
if(val > 0)
|
||||||
val--;
|
val--;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
inline T sgn(T val) {
|
||||||
|
return val == 0 ? 0 : std::copysign(1, val);
|
||||||
|
}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
#include "utility.hpp"
|
#include "utility.hpp"
|
||||||
#include "fileio/fileio.hpp"
|
#include "fileio/fileio.hpp"
|
||||||
#include "fileio/tagfile.hpp"
|
#include "fileio/tagfile.hpp"
|
||||||
|
#include "mathutil.hpp"
|
||||||
|
|
||||||
#include "damage.hpp"
|
#include "damage.hpp"
|
||||||
#include "spell.hpp"
|
#include "spell.hpp"
|
||||||
@@ -90,6 +91,18 @@ short cItem::item_weight() const {
|
|||||||
return w;
|
return w;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static short min_defense_bonus(short bonus) {
|
||||||
|
if(bonus == 0) return 0;
|
||||||
|
if(bonus < 0) return bonus;
|
||||||
|
return 1 + bonus / 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
static short max_defense_bonus(short bonus) {
|
||||||
|
if(bonus == 0) return 0;
|
||||||
|
if(bonus < 0) return bonus;
|
||||||
|
return bonus + bonus / 2;
|
||||||
|
}
|
||||||
|
|
||||||
std::string cItem::interesting_string() const {
|
std::string cItem::interesting_string() const {
|
||||||
if(property) {
|
if(property) {
|
||||||
return "Not yours.";
|
return "Not yours.";
|
||||||
@@ -109,17 +122,22 @@ std::string cItem::interesting_string() const {
|
|||||||
case eItemType::THROWN_MISSILE:
|
case eItemType::THROWN_MISSILE:
|
||||||
case eItemType::BOLTS:
|
case eItemType::BOLTS:
|
||||||
case eItemType::MISSILE_NO_AMMO:
|
case eItemType::MISSILE_NO_AMMO:
|
||||||
if(bonus != 0)
|
sout << "Damage: 1-" << item_level;
|
||||||
sout << "Damage: 1-" << item_level << " + " << bonus;
|
if(bonus > 0) {
|
||||||
else sout << "Damage: 1-" << item_level;
|
sout << " + " << bonus;
|
||||||
|
} else if(bonus < 0) {
|
||||||
|
sout << " - " << -bonus;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case eItemType::SHIELD:
|
case eItemType::SHIELD:
|
||||||
case eItemType::ARMOR:
|
case eItemType::ARMOR:
|
||||||
case eItemType::HELM:
|
case eItemType::HELM:
|
||||||
case eItemType::GLOVES:
|
case eItemType::GLOVES:
|
||||||
case eItemType::SHIELD_2:
|
case eItemType::SHIELD_2:
|
||||||
case eItemType::BOOTS: // TODO: Verify that this is displayed correctly
|
case eItemType::BOOTS:
|
||||||
sout << "Blocks " << item_level + ((protection > 0) ? 1 : 0) << '-' << item_level + protection << " damage";
|
sout << "Blocks " << 1 + min_defense_bonus(bonus) + sgn(protection);
|
||||||
|
sout << '-' << max(1,item_level) + max_defense_bonus(bonus) + protection;
|
||||||
|
sout << " damage";
|
||||||
break;
|
break;
|
||||||
case eItemType::BOW:
|
case eItemType::BOW:
|
||||||
case eItemType::CROSSBOW:
|
case eItemType::CROSSBOW:
|
||||||
|
|||||||
Reference in New Issue
Block a user