NAME
Games::PMM::Actions - actions for Games::PMM
SYNOPSIS
use Games::PMM::Actions;
my $actions = Games::PMM::Actions->new();
# create $arena
# create and command @monsters
for my $monster (@monsters)
{
while (my ($command, @args) = $monster->next_command())
{
next unless $actions->can( $command );
$actions->$command( $arena, $monster, @args );
}
}
DESCRIPTION
Games::PMM::Action contains all of the glue code to dispatch commands to the appropriate actor in Games::PMM. Since some actions affect only Monsters and others affect the Arena, this class divides the responsibilities between them.
METHODS
All methods that correspond to actions are prefixed with the phrase action_. This may change in a future version.
new
Creates and returns a new Actions object.
action_forward( $arena, $monster )
Moves the given
$monsterforward in the$arena, respecting the current facing of the$monster.action_reverse( $arena, $monster )
Moves the given
$monsterbackwards in the$arena, respecting the$monster's current facing.action_charge( $arena, $monster )
Moves the
$monstertoward the closest other monster it has seen in the$arena. This may cause the monster to turn instead of moving, if necessary.action_retreat( $arena, $monster )
Moves the
$monsteraway from the closest other monster it has seen in the$arena. This may cause the monster to turn instead of moving, if necessary.action_turn( $arena, $monster, $direction )
Turns the $
monsterin the$arenain a specified direction, eitherrightorleft.action_scan( $arena, $monster )
Makes the
$monsterlook for other monsters in the$arena. Their visibility depends on the$monster's current position and facing.action_attack( $arena, $monster )
Causes the given
$monsterto attack the first thing it finds within range within the$arena.
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.