Herkum,

Thanks for simplifying my code. While I didn't do exactly what you did above, I did use the hash.

For Alignment.pm...

my %alignment = ( parts => [qw(lawful chaotic good evil neutral)], good_vs_evil => [qw(good neutral evil)], lawful_vs_chaotic => [qw(lawful neutral chaotic)], ); $alignment{'evil'} = [map($_." evil",@{$alignment{'lawful_vs_chaotic'} +})]; $alignment{'good'} = [map($_." good",@{$alignment{'lawful_vs_chaotic'} +})]; $alignment{'chaotic'} = [map("chaotic ".$_,@{$alignment{'good_vs_evil' +}})]; $alignment{'lawful'} = [map("lawful ".$_,@{$alignment{'good_vs_evil'}} +)]; $alignment{'neutral_lc'} = [map($_." neutral",grep {$_ ne "neutral"} @ +{$alignment{'lawful_vs_chaotic'}}), "true neutral"]; $alignment{'neutral_ge'} = [map("neutral ".$_,grep {$_ ne "neutral"} @ +{$alignment{'good_vs_evil'}}), "true neutral"]; sub full { my $prefix = $alignment{'lawful_vs_chaotic'}[rand @{$alignment{'lawf +ul_vs_chaotic'}}]; my $suffix = $alignment{'good_vs_evil'}[rand @{$alignment{'good_vs_e +vil'}}]; if ($prefix eq $suffix) { return "true neutral"; } else { return $prefix." ".$suffix; } } sub random_alignment { my $type = shift; my $result; if (exists $alignment{$type}) { $result = $alignment{$type}[rand @{$alignment{$type}}]; } else { $result = &full; } return $result; }

For Effect.pm...

my %effects = ( part => [qw(acid cold electricity fire)], gaze => [qw(paralysis stone stun death)], range_part => [qw(gas sonic)], touch_part => [qw(poison energy_drain)], touch_special => [qw(befouls purifies nullifies_holy_water nullifies +_unholy_water)], vocal => [qw(deafen fear terror flight)], ); $effects{'range'} = [@{$effects{'part'}}, @{$effects{'range_part'}}]; $effects{'touch'} = [@{$effects{'part'}}, @{$effects{'touch_part'}}]; $effects{'general'} = [@{$effects{'part'}}, @{$effects{'gaze'}}, @{$ef +fects{'range_part'}}, @{$effects{'touch_part'}}, @{$effects{'vocal'}} +]; sub random_effect { my $type = shift; my $result; if (exists $effects{$type}) { $result = $effects{$type}[rand @{$effects{$type}}]; } else { $result = $effects{'general'}[rand @{$effects{'general'}}]; } $result =~ tr/_/ /; return $result; }

If there are any further improvements you can think of, please let me know. Thanks again!

Have a nice day!
Lady Aleena

In reply to Re^2: Lady Aleena's first working module by Lady_Aleena
in thread Lady Aleena's first working module by Lady_Aleena

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.