Games::PMM::Monster - represents a Monster in a PMM Game
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 );
Games::PMM::Monster represents a Monster that battles in a PMM game. It contains all of the monster state and behavior.
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.
commands
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, either left or right.
$direction
left
right
closest
Returns information about the closest other Monster this Monster has seen. Data is returned as a hash reference with keys of id, distance, and x and y coordinates. You'll probably only use this if you are extending this class.
distance
x
y
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.
chromatic, chromatic@wgz.org
chromatic@wgz.org
No known bugs.
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.
To install Games::PMM, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Games::PMM
CPAN shell
perl -MCPAN -e shell install Games::PMM
For more information on module installation, please visit the detailed CPAN module installation guide.