Example #1
0
//inv_name: Return the name of something as it would appear in an inventory.
std::string Item::inventory_name(const Hero& hero, bool lowercase) const
{
    std::string name = InventoryName();

    if (this == hero.get_current_armor())
        name += " (being worn)";
    if (this == hero.get_current_weapon())
        name += " (weapon in hand)";
    if (this == hero.get_ring(LEFT))
        name += " (on left hand)";
    else if (this == hero.get_ring(RIGHT))
        name += " (on right hand)";

    if (lowercase && isupper(name[0]))
        name[0] = tolower(name[0]);
    else if (!lowercase && islower(name[0]))
        name[0] = toupper(name[0]);

    return name;
}