I have a problem. I'm trying to make the damage a monster inflicts on you random within a certain range (bigger range for more powerful monsters.) But, the values are never random; they are always zero. Here's what a portion of the code looks like:
do{ $goblin=$goblin-$damage; if($goblin<0){ $goblin=0; }if($wizard<0){ $wizard=0; } if($room==6){ my $dmg=int (rand 5)+1; }elsif($room==3){ my $dmg=int (rand 4)+1; }elsif($room==2){ my $dmg=int (rand 3)+1; }elsif($room==1){ my $dmg=int (rand 2)+1; } $wizard-=$dmg; print "wizard health: $wizard\t"; print "$monster health: $goblin\n"; }until($goblin<=0 || $wizard<=0); if($wizard>0){ print "good job you got $newgold gold!\n"; $gold+=$newgold; &freedale; }elsif($wizard<=0){ &die; } }else{ print "Please enter 1, 2, or q...\n"; &battle; } }
If anyone could give me some advice as to why this isn't working, I would be very grateful.

In reply to Re: Wizardv1.1 by void_Anthony()
in thread Wizardv1.1 by void_Anthony()

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.