NAME
Games::Roguelike::Item - Roguelike item object
SYNOPSIS
package myItem;
use base 'Games::Roguelike::Item';
$i = myItem->new($area, sym=>'!', x=>5,y=>6); # creates an item at location 5, 6
# with symbol '!', inside area $area
DESCRIPTION
Item object used by drawing routines in Roguelke::Area
METHODS
- new($container, %opts)
-
$container is usually an "area" or "mob" or another "item" object.
At a minimum, it must support the additem and delitem methods.
The "new" method automatically calls additem on the container.
Options include:
sym : symbol this item is drawn with color : color this item is drawn with x : map location of item y : map location of item
Other options are saved in the hash as "user defined" options.
- x()
- y()
-
Return the item's x/y members only if the item is in an ::Area object,
Otherwise, return the container's x and y members.
Direct access to the $item->{x}/{y} members is encouraged if you don't care how it's contained.
- setcont(newcont)
-
Sets the container for an item, returns 0 if it's already contained within that continer.
Dies if the container has no {items} list (ie: can't contain things)
** Should only ever be called** - by the container's "additem" method, and - only if the container is derived from ::Area, ::Mob or ::Item.
(This can & will be made generic at some point)
- additem (item)
-
Add item to reside within me. Override this to make backpacks, etc.
Return value 0 = can't add, too full/or not a backpack Return value 1 = add ok Return value -1 = move occured, but not added
Default implementation is to return "0", cannot add.
- delitem (item)
-
Deletes item from within me. Override this to make backpacks, etc.