package Games::Random::Effect; use warnings; use strict; use diagnostics; use base 'Exporter'; our @EXPORT_OK = qw(random_effect); =head1 Effect This module generates random effects for AD&D 2nd Edition. =head2 Author Lady Aleena =head2 Use To use this module, please enter the following. use Games::Random::Effect qw(random_effect); When you want to generate a random effect with this module, you can choose from the following. random_effect("general") will generate any of the effects listed below. random_effect("gaze") will generate paralysis, stone, stun, or death. random_effect("range") will generate acid, cold, electricity, fire, gas, or sonic. random_effect("touch") will generate acid, cold, electricity, fire, poison, or energy drain. random_effect("vocal") will generate deafen, fear, terror, or flight. =cut my @part = qw(acid cold electricity fire); my @gaze = qw(paralysis stone stun death); my @range_part = qw(gas sonic); my @range = (@part, @range_part); my @touch_part = qw(poison energy_drain); my @touch = (@part, @touch_part); my @touch_special = qw(befouls purifies nullifies_holy_water nullifies_unholy_water); my @vocal = qw(deafen fear terror flight); my @general = (@part, @gaze, @range_part, @touch_part, @vocal); my $result; sub random_effect { my $type = shift; if ($type eq 'general') { $result = $general[rand @general]; } elsif ($type eq 'gaze') { $result = $gaze[rand @gaze]; } elsif ($type eq 'range') { $result = $range[rand @range]; } elsif ($type eq 'touch') { $result = $touch[rand @touch]; } elsif ($type eq 'vocal') { $result = $vocal[rand @vocal]; } else { $result = $general[rand @general]; } $result =~ tr/_/ /; return $result; } 1;