NAME
Games::PMM::Monster - represents a Monster in a PMM Game
SYNOPSIS
use Games::PMM::Monster;
use Games::PMM::Arena;
my @commands = ( scan charge attack );
my $monster = Games::PMM::Monster->new( commands => \@commands );
my $arena = Games::PMM::Arena->new();
$arena->add_monster( $monster, x => 0, y => 0 );
DESCRIPTION
Games::PMM::Monster represents a Monster that battles in a PMM game. It contains all of the monster state and behavior.
METHODS
new( [ commands => \@commands ] )
Creates and returns a new Monster object. Any
commands
provided will be passed straight through to a Games::PMM::Monster::Commands object.id
Returns the identifier of this Monster. All Monsters created within a program have a unique identifier.
health
Returns the Monster's current health. Monsters start with three points of health.
damage
Removes a point of health from the Monster and returns the current value.
facing
Returns the direction the Monster is currently facing. This is one of the four cardinal directions.
next_command
Returns the next command the Monster would like to execute. This may return a false value if the Monster is looping around its entire command set. See Games::PMM::Monster::Commands for more information.
turn( $direction )
Turns the Monster in the given
$direction
, eitherleft
orright
.closest
Returns information about the closest other Monster this Monster has seen. Data is returned as a hash reference with keys of
id
,distance
, andx
andy
coordinates. You'll probably only use this if you are extending this class.charge( x => $x, y => $y )
Moves or turns the Monster toward the given coordinates. Monsters prefer to move in the direction they are facing, but they will turn if they can go no further in the current direction.
retreat( x => $x, y => $y )
Moves or turns the Monster away from the given coordinates. Monsters prefer to move along the axis it is facing (tending to back up when retreating), but will turn if it can go no further in the current direction.
AUTHOR
chromatic, chromatic@wgz.org
BUGS
No known bugs.
COPYRIGHT
Copyright (c) 2003, chromatic. All rights reserved. This module is distributed under the same terms as Perl itself, in the hope that it is useful but certainly under no guarantee.