I need help with this game I am trying to make. It’s super simple but I can’t get the $money variable to change when the user rolls a 7 or doesn’t roll a 7. Please help, it’s getting quite frustrating. Here’s the code:
[php]
Craps Game
<?php $rollNum++; $firstDie = rand(1,6); $secondDie = rand(1,6);print " ";
print “
”;
print “The object of the game is to double your money.
If you roll a 7 or 11 you gain 2 dollars, if not you lose a buck.
GOOD LUCK
”;
print <<<HERE
HERE;
if ($rollNum == 1){
print “
First Roll
”;
}
if ($rollNum != 1){
print “
Not First Roll
”;
}
$yourRoll = $firstDie + $secondDie;
if(!$money){
$money = 10;
}
$payoff = 0;
print “You rolled a $yourRoll
”;
if($yourRoll == 7){
$payoff =2;
$money += $payroll;
}
if ($yourRoll != 7){
$payoff = 1;
$money += $payroll;
}
if($money == 3){
print “Only 3 BUCKS! You better start getting lucky or you’ll lose soon”;
}
if ($money == 0){
print “Sorry you LOSE”;
$money = 10;
}
if ($money == 20){
print “You’ve WON! Great Job”;
$money = 10;
}$money += payoff;
print “Payoff is $payoff
\n”;
print “You have $money Dollars”;
print <<<HERE
HERE;
?>