Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. Linux, Apache, MySQL, PHP
  4. PERL Craps game

PERL Craps game

Scheduled Pinned Locked Moved Linux, Apache, MySQL, PHP
perlcssgame-devhelpquestion
2 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Rhodge09
    wrote on last edited by
    #1

    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

    R 1 Reply Last reply
    0
    • R Rhodge09

      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

      R Offline
      R Offline
      Rhodge09
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups