string Item::getNameAndModifiers(bool getPlural, bool blind) const { if (inspected) { string artStr = artifactName ? " named " + *artifactName : ""; if (getType() == ItemType::WEAPON) return getName(getPlural, blind) + artStr + " (" + withSign(toHit) + " accuracy, " + withSign(damage) + " damage)"; if (getType() == ItemType::RANGED_WEAPON) return getName(getPlural, blind) + artStr + " (" + withSign(rangedWeaponAccuracy) + " accuracy)"; if (getType() == ItemType::ARMOR) return getName(getPlural, blind) + artStr + " (" + withSign(defense) + " defense)"; } return getName(getPlural, blind); }
string Item::getModifiers(bool shorten) const { EnumSet<AttrType> printAttr; if (!shorten) { for (auto attr : ENUM_ALL(AttrType)) if (attributes->modifiers[attr] != 0) printAttr.insert(attr); } else switch (getClass()) { case ItemClass::RANGED_WEAPON: printAttr.insert(getRangedWeapon()->getDamageAttr()); break; case ItemClass::WEAPON: printAttr.insert(getWeaponInfo().meleeAttackAttr); break; case ItemClass::ARMOR: printAttr.insert(AttrType::DEFENSE); break; default: break; } vector<string> attrStrings; for (auto attr : printAttr) attrStrings.push_back(withSign(attributes->modifiers[attr]) + (shorten ? "" : " " + ::getName(attr))); if (attributes->damageReduction > 0) attrStrings.push_back(toString(int(attributes->damageReduction * 100)) + "%"); string attrString = combine(attrStrings, true); if (!attrString.empty()) attrString = "(" + attrString + ")"; if (attributes->uses > -1 && attributes->displayUses) appendWithSpace(attrString, "(" + toString(attributes->uses) + " uses left)"); return attrString; }
string Item::getModifiers(bool shorten) const { string artStr; if (attributes->artifactName) { artStr = *attributes->artifactName; if (!shorten) artStr = " named " + artStr; } EnumSet<ModifierType> printMod; switch (getClass()) { case ItemClass::WEAPON: printMod.insert(ModifierType::ACCURACY); printMod.insert(ModifierType::DAMAGE); break; case ItemClass::ARMOR: printMod.insert(ModifierType::DEFENSE); break; case ItemClass::RANGED_WEAPON: case ItemClass::AMMO: printMod.insert(ModifierType::FIRED_ACCURACY); break; default: break; } if (!shorten) for (auto mod : ENUM_ALL(ModifierType)) if (attributes->modifiers[mod] != 0) printMod.insert(mod); vector<string> attrStrings; for (auto mod : printMod) attrStrings.push_back(withSign(attributes->modifiers[mod]) + (shorten ? "" : " " + Creature::getModifierName(mod))); if (!shorten) for (auto attr : ENUM_ALL(AttrType)) if (attributes->attrs[attr] != 0) attrStrings.push_back(withSign(attributes->attrs[attr]) + " " + Creature::getAttrName(attr)); string attrString = combine(attrStrings, true); if (!attrString.empty()) attrString = " (" + attrString + ")"; if (attributes->uses > -1 && attributes->displayUses) attrString += " (" + toString(attributes->uses) + " uses left)"; return artStr + attrString; }