$wizard=50; $wizardl=1; $gold=10; $damage=3; $firedmg = $wizardl*2; $diflvl=$wizardl-2; print"Welcome to Wizard! Type your wizard's name..."; $name=<STDIN>; chomp ($name); print "Welcome $name, to Wizard. You are now in the Merlins castle. +You are surrounded by other mages and disscussion flows back and for +th.\n"; print "and forth in the room. Suddenly Merlin stands up in front of +all and says, I need a powerful man to go out and slay all the monste +rs that have been plauging my land.\n"; print "Which one of you can raise to the challenge. Slowly all those +in the room rise, including yourself.\n\n"; print "Good, good merlin utters. Then be off.\n\n\n"; sub die{ if($wizard<=0){ print "Thanks for playing"; die; } sub fireball { if($room==1){ $monster = "bats"; $newgold = 3; }elsif($room==2){ $monster = "orcs"; $newgold = 4; }elsif($room==3){ $monster = "trolls"; $newgold = 5; }elsif($room==6){ $monster = "demons"; $newgold = 6; } $fireball = int (rand 2)+1; if($fireball==1){ $goblin-=$firedmg; if($goblin<=0){ print "The $monster have been torched to death!\n"; $gold+=$newgold; print "You got $newgold gold!\n"; &freedale; }elsif($goblin>0){ print "The $monster took $firedmg damage!\n"; print "$monster health: $goblin\t"; print "$name's health: $wizard\t"; &battle; } }elsif($fireball==2){ print "Your spell failed!\n"; print "Minus two health!\n"; $wizard-=2; print "$name's health: $wizard\t"; &battle; } } sub battle { my $monster=""; print "What do you want to do...press 1 to use fireball, 2 for co +mbat, or r to run.\n"; $choice=<STDIN>; if($choice==1){ &fireball; }elsif($choice=="r"){ &run; }elsif($choice=="q"){ &die; }elsif($choice==2){ if($room==6){ $monster = "demon"; $newgold = 6; }elsif($room==3){ $monster = "troll"; $newgold = 5; }elsif($room==2){ $monster = "orc"; $newgold = 4; }elsif($room==1){ $monster = "bat"; $newgold = 3; } do{ $goblin=$goblin-$damage; if($goblin<0){ $goblin=0; }if($wizard<0){ $wizard=0; } $dmg = int (rand $room +2); $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; } } sub forest { $goblin = 10; print "The forest is dark and smells of old mold and rotton fish. + + The foul waters have turned this once peaceful place in to a\n"; + + print "dark evil place.\n"; my $gobbo=int (rand 6)+1; if ($gobbo>=5){ print "bats attack!\n"; &battle; }elsif($gobbo!=5 || $gobbo!=6){ print "There are no monsters here now.\n"; &freedale } } sub mountain { $goblin = 14; print "Its pretty cold up here, but from this altitude you can se +e + the whole town below you.\n"; print "Although it is clear that you are not the first one here!\ +n +"; my $gobbo=int (rand 6)+1; if ($gobbo>=4){ print "orcs attack\n"; &battle; }elsif($gobbo!=4 || $gobbo!=5 || $gobbo!=6){ print "There are no monsters here now.\n"; &freedale } } sub dungeon { $goblin = 17; print "There is a heavy feeling in the air, it's very dark and mu +s +ty down here.\n"; print "You can see clear signs that goblins have been here, and m +a +ybe worse things!\n"; my $gobbo=int (rand 6)+1; if ($gobbo>=3){ print "trolls attack\n"; &battle; }elsif($gobbo!=3 || $gobbo!=4 || $gobbo!=5 || $gobbo!=6){ print "There are no monsters here now.\n"; &freedale } } sub splane { $goblin = 20; print "This is a mysterious place full of horribly powerful monst +ers. +..\n"; print "You see tracks unlike any other you have encountered befor +e.\n +"; my $gobbo=int (rand 8)+1; if ($gobbo>=2){ print "Demons attack!\n"; &battle }elsif($gobbo!=2 || $gobbo!=3 || $gobbo!=4 || $gobbo!=5 || + $go +bbo!=6 || $gobbo!=7 || $gobbo!=8){ print "There are no demons here now.\n"; &freedale } } sub shop { print "Hello welcome to freedale market may I help you?\n"; print "type 1 for 20 more health.............................. +...........10 gold\n"; print "type 2 for daggers (increases damage per round by one). +............................................15 gold\n"; print "type 3 for magic wands(increases magic level by one)... +..................................30 gold\n"; print "type 4 to leave the shop\n"; print "You have $gold gold\n"; $shop=<STDIN>; chomp($shop); if($shop==1){ if($gold>=10){ $gold-=10; $wizard+=20; print "$name's health: $wizard\n"; print "Gold: $gold\n"; &freedale; }elsif($gold<$gold){ print "You don't have enough gold!\n"; $shop; } }elsif($shop==2){ if($gold<15){ print "you don't have enough gold\n"; &freedale; }else{ print "thank you\n"; $gold=$gold-15; $damage=$damage + 1; &freedale; } }elsif($shop==3){ if($gold<30){ print "you don't have enough gold\n"; &shop; }else{ print "thank you\n"; $gold=$gold-30; $wizardl=$wizardl+1; &freedale; } }elsif($shop==4){ print "Thank you for coming!\n"; &freedale; }else{ print "Please enter a number between 1 and 4!\n"; &freedale } } sub run{ $chance = int (rand 2); if($chance==0){ print "You failed to get away!\n"; print "Minus two health!\n"; $wizard-=2; print "$name's health: $wizard\t"; print "$monster' health: $goblin\t"; &battle; }elsif($chance==1){ print "You managed to escape!\n"; &freedale; } } sub cheat{ $wizardl += 2; $wizard += 100; $gold += 60; &freedale } sub stat{ print "health:\t$wizard\n"; print "magic level:\t$wizardl\n"; print "gold:\t$gold\n"; print "damage:\t$damage\n"; &freedale } sub freedale{ if($gold < 0){ $gold = 0; &freedale; } print "you are in freedale\n"; print "where do you want to go\n"; print "type 1 for the forest, 2 for the mountain, 3 for the dun +geon, 4 for the shop, 5 to view stats, 6 for the Shadow Plan +e, or q to quit.\n "; print "press q at anytime to quit.\n"; $room=<STDIN>; if($room==1){ &forest; }elsif($room==2){ &mountain; }elsif($room==3){ &dungeon; }elsif($room==4){ &shop }elsif($room==5){ &stat }elsif($room==6){ if($wizardl < 3){ print "You're level isn't high enough! You must have a + magic lvl o +f 3 to come here.\n"; &freedale }elsif($wizardl => 3){ &splane } }elsif($room==7){ &cheat }elsif($room=="q"){ &die }else{ print "Please enter a number between 1 and 6 or q to quit!\n +"; &freedale; } } } &freedale

In reply to Wizard v1.2 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.