PERL Craps game
-
Well this is my code and i just want to modify it so that i can have buttons doing all the action. All that is coming up now is just text on the screen. How would i make like a button and two dice come up or just two numbers come up randomly telling me if i win or lose and if i do i gain money and if not i lose money. Also have a bank account keeping track of my money and when i hit $5 the game is over and if i hit $1000 dollars the game is over. Can anyone please help me i've asked all over and no ones been able to help me thanks. This is the link: !/usr/bin/perl use CGI ':standard'; use CGI::Carp "fatalsToBrowser"; # How many games would you like to roll? $iterations = 1000; for ($count = $iterations; $count >= 1; $count--) { print "$count \n"; # Bankroll per game. Rules are set up for a $5 bet on a 3x/4x/5x table. $bankroll = 200; $rollcount = 0; $high = 200; $itson = 1; while ($itson == 1) { $die1 = int(rand() * 6) + 1; $die2 = int(rand() * 6) + 1; $roll = $die1 + $die2; $rollcount = $rollcount + 1; if ($roll == 7 || $roll == 11) { $bankroll = $bankroll + 5; # print "W $roll $bankroll $rollcount\n"; if ($bankroll > $high) { $high = $bankroll; } } elsif ($roll == 2 || $roll == 3 || $roll == 12) { $bankroll = $bankroll - 5; # print "L $roll $bankroll $rollcount\n"; } else { $setnum = $roll; $notcrapped = 1; while ($notcrapped == 1) { $die1 = int(rand() * 6) + 1; $die2 = int(rand() * 6) + 1; $roll = $die1 + $die2; $rollcount = $rollcount + 1; if ($roll == $setnum) { $bankroll = $bankroll + 35; # print "W $roll $bankroll $rollcount\n"; if ($bankroll > $high) { $high = $bankroll; } $notcrapped = 0; } if ($roll == 7) { if ($setnum == 4 || $setnum == 10) { $bankroll = $bankroll - 20; } if ($setnum == 5 || $setnum == 9) { $bankroll = $bankroll - 25; } if ($setnum == 6 || $setnum == 8) { $bankroll = $bankroll - 30; } # print "L $roll $bankroll $rollcount\n"; $notcrapped = 0; } } } # Game ends when you have less than $5 if ($bankroll < 5) { $losses = $losses + 1; $itson = 0; } # It also ends if youmake $1000 if ($bankroll >= 1000) { $wins = $wins + 1; $itson = 0; } } if ($high > $biggest) { $biggest = $high; } if ($rollcount > $mostrolls) { $mostrolls
-
Well this is my code and i just want to modify it so that i can have buttons doing all the action. All that is coming up now is just text on the screen. How would i make like a button and two dice come up or just two numbers come up randomly telling me if i win or lose and if i do i gain money and if not i lose money. Also have a bank account keeping track of my money and when i hit $5 the game is over and if i hit $1000 dollars the game is over. Can anyone please help me i've asked all over and no ones been able to help me thanks. This is the link: !/usr/bin/perl use CGI ':standard'; use CGI::Carp "fatalsToBrowser"; # How many games would you like to roll? $iterations = 1000; for ($count = $iterations; $count >= 1; $count--) { print "$count \n"; # Bankroll per game. Rules are set up for a $5 bet on a 3x/4x/5x table. $bankroll = 200; $rollcount = 0; $high = 200; $itson = 1; while ($itson == 1) { $die1 = int(rand() * 6) + 1; $die2 = int(rand() * 6) + 1; $roll = $die1 + $die2; $rollcount = $rollcount + 1; if ($roll == 7 || $roll == 11) { $bankroll = $bankroll + 5; # print "W $roll $bankroll $rollcount\n"; if ($bankroll > $high) { $high = $bankroll; } } elsif ($roll == 2 || $roll == 3 || $roll == 12) { $bankroll = $bankroll - 5; # print "L $roll $bankroll $rollcount\n"; } else { $setnum = $roll; $notcrapped = 1; while ($notcrapped == 1) { $die1 = int(rand() * 6) + 1; $die2 = int(rand() * 6) + 1; $roll = $die1 + $die2; $rollcount = $rollcount + 1; if ($roll == $setnum) { $bankroll = $bankroll + 35; # print "W $roll $bankroll $rollcount\n"; if ($bankroll > $high) { $high = $bankroll; } $notcrapped = 0; } if ($roll == 7) { if ($setnum == 4 || $setnum == 10) { $bankroll = $bankroll - 20; } if ($setnum == 5 || $setnum == 9) { $bankroll = $bankroll - 25; } if ($setnum == 6 || $setnum == 8) { $bankroll = $bankroll - 30; } # print "L $roll $bankroll $rollcount\n"; $notcrapped = 0; } } } # Game ends when you have less than $5 if ($bankroll < 5) { $losses = $losses + 1; $itson = 0; } # It also ends if youmake $1000 if ($bankroll >= 1000) { $wins = $wins + 1; $itson = 0; } } if ($high > $biggest) { $biggest = $high; } if ($rollcount > $mostrolls) { $mostrolls
This must have all the basics of the game completed and functioning. This means that the game must generate the two dice values and display an image for each individual dice. Set the correct conditions for the first throw to determine a win or a loss or the setting of a point. If the point is set the play must continue with consecutive throws until the point is matched or a 7 is thrown and a win or a loss is determined.