NetHack::Item - parse and interact with a NetHack item
use NetHack::Item; my $item = NetHack::Item->new("f - a wand of wishing named SWEET (0:3)" ); $item->slot # f $item->type # wand $item->specific_name # SWEET $item->charges # 3 $item->spend_charge; $item->wield; $item->buc("blessed"); $item->charges # 2 $item->is_wielded # 1 $item->is_blessed # 1 $item->is_cursed # 0
NetHack's items are complex beasts. This library attempts to control that complexity.
These are the attributes common to every NetHack item. Subclasses (e.g. Wand) may have additional attributes.
The raw string passed in to "new", to be parsed. This is the only required attribute.
The identity of the item (a string). For example, "clear potion" will be "potion of water". For artifacts, the base item is used for identity, so for "the Eye of the Aethiopica" you'll have "amulet of ESP".
The appearance of the item (a string). For example, "potion of water" will be "clear potion". For artifacts, the base item is used for appearance, so for "the Eye of the Aethiopica" you'll have "pyramidal amulet" (or any of the random appearances for amulets of ESP).
The name of the artifact, if applicable. The leading "The" is stripped (so you'll have "Eye of the Aethiopica").
The inventory or container slot in which this item resides. Obviously not applicable to items on the ground.
The item stack's quantity. Usually 1.
The amount of zorkmids that a shopkeeper is demanding for this item.
A name for this specific item, as opposed to a name for all items of this class. Artifacts use specific name.
A name for all items of this class, as opposed to a name for a specific item. Identification uses generic name.
- is_wielded, is_quivered, is_greased, is_offhand
Interesting boolean states of an item.
- is_blessed, is_cursed, is_uncursed
Boolean states about the BUC status of an item. If one returns true, the others will return false.
Returns "blessed", "cursed", "uncursed", or
- is_holy, is_unholy
Shawn M Moore,
Copyright 2009-2011 Shawn M Moore.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.