Games::PMM::Actions - actions for Games::PMM
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 );
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.
All methods that correspond to actions are prefixed with the phrase action_. This may change in a future version.
Creates and returns a new Actions object.
action_forward( $arena, $monster )
Moves the given $monster forward in the $arena, respecting the current facing of the $monster.
action_reverse( $arena, $monster )
Moves the given $monster backwards in the $arena, respecting the $monster's current facing.
action_charge( $arena, $monster )
Moves the $monster toward 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 $monster away 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 $monster in the $arena in a specified direction, either right or left.
action_scan( $arena, $monster )
Makes the $monster look for other monsters in the $arena. Their visibility depends on the $monster's current position and facing.
action_attack( $arena, $monster )
Causes the given $monster to attack the first thing it finds within range within the $arena.
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.
perl -MCPAN -e shell
For more information on module installation, please visit the detailed CPAN module installation guide.