Petals Around the Rose!

By log2
Platform:  PHP
Published  May 14, 2005
Updated  Sep 04, 2008
This is the ever popular Petals Around the Rose game converted to PHP!! it's fairly long, but it only took about 30 minutes to code... I used numbers rather than pictures because I can't post pictures! Petals Around the Rose<br><font size="-2">Re-created by: L0g2 St3w</font><br><br>Click the roll button to get started.<br>
I can't tell you how it works but I can tell you the name of the game, and that it is significant!<br>
And I can also tell you it's always an even number!<br><br><table><tr><td>
<?
if ($roll) {
$gue++;
$acc = 0;
$q = rand(1,6);
$w = rand(1,6);
$e = rand(1,6);
$r = rand(1,6);
$t = rand(1,6);
}
$total = 0;
if ($guess == NULL) {
$guess = 0;
}
if ($q == 5 || $q == 3) {
$s = $q - 1;
$total = $total + $s;
}
if ($w == 5 || $w == 3) {
$s = $w - 1;
$total = $total + $s;
}
if ($e == 5 || $e == 3) {
$s = $e - 1;
$total = $total + $s;
}
if ($r == 5 || $r == 3) {
$s = $r - 1;
$total = $total + $s;
}
if ($t == 5 || $t == 3) {
$s = $t - 1;
$total = $total + $s;

}
if ($sub) {
if ($acc == 1) {
$resp = "You must roll the dice before guessing!";
}
else if ($guess == $total) {
$corr++;
$resp = "Correct! The answer was ".$total;
}
else if ($guess % 2 != 0) {
$resp = "It CAN'T be an odd number!";
}
else {
$resp = "The answer was ".$total.", not ".$guess;
}
$acc = 1;
}
if ($corr == NULL) {
$corr = 0;
}
if ($gue == NULL) {
$gue = 0;
}
echo $q. " " .$w. " " .$e. " " .$r. " " .$t. " <br>";
?>
</td><td rowspan="2"><? echo "Correct: ".$corr."<br>";
echo "Guesses: ".$gue;
?></td></tr><tr><td>
<form action="<? $PHP_SELF ?>">
<input type="text" name="guess"><br>
<input type="text" name="answ" value="<? echo $resp ?>" disabled size="40"><br>
<input type="submit" name="roll" value="Roll!">
<input type="hidden" name="q" value="<? echo $q ?>">
<input type="hidden" name="w" value="<? echo $w ?>">
<input type="hidden" name="e" value="<? echo $e ?>">
<input type="hidden" name="r" value="<? echo $r ?>">
<input type="hidden" name="t" value="<? echo $t ?>">
<input type="hidden" name="acc" value="<? echo $acc ?>">
<input type="hidden" name="gue" value="<? echo $gue ?>">
<input type="hidden" name="corr" value="<? echo $corr ?>">
<input type="submit" name="sub" value="Guess!">
</form>
</td></tr></table>

Comments

Sign in to comment.
Hawkee   -  May 25, 2005
exactly enexif, the script won\'t work when the server has register_globals turned off.
 Respond  
log2   -  May 15, 2005
(sorry accidentally pushed enter) \'t need the $_GET[] statement because the variables are already declared
 Respond  
Hawkee   -  May 15, 2005
You need to collect your _GET vars first. Don\'t assume we have our servers configured to automatically set variables like $roll and $sub. Do this: $roll = $_GET[roll]; $sub = $_GET[sub]; etc.
 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.