I'm using the following function to create part of the environment required for a simple card game:
Code: Select all
function set_Cards () {
// Create the correct set of cards to use for the game
// based on the value of $_SESSION['outcome']
// CREATES THE SESSION ENVIRONMENT FOR THE FLASH...
if ( $_SESSION['outcome'] == 0 ) {
// Aaaaaaaah, they're gonna lose...
$num = rand(1,3); // Generate a number to represent a card
$movie = $num+1; // The outcome will be mismatched cards
switch ( $num ) { // Defines the card that the player will "choose"
case 1 : $_SESSION['card'] = "jack"; break;
case 2 : $_SESSION['card'] = "queen"; break;
case 3 : $_SESSION['card'] = "king"; break;
}
switch ( $movie ) { // Defines the movie that the player will see
case 1 : $_SESSION['swf'] = "queen"; break;
case 2 : $_SESSION['swf'] = "king"; break;
case 3 : $_SESSION['swf'] = "jack"; break;
}
} // end of first "if" statement
if ( $_SESSION['outcome'] == 1 ) {
// Oooooooooh, they're gonna win!!
$num = rand(1,3);
$movie = $num;
switch ( $num ) { // Defines the card that the player will "choose"
case 1 : $_SESSION['card'] = "jack"; break;
case 2 : $_SESSION['card'] = "queen"; break;
case 3 : $_SESSION['card'] = "king"; break;
}
switch ( $movie ) { // Defines the movie that the player will see
case 1 : $_SESSION['swf'] = "jack"; break;
case 2 : $_SESSION['swf'] = "queen"; break;
case 3 : $_SESSION['swf'] = "king"; break;
}
} // end of second "if" statement
}Also, occasionally the $_SESSION['outcome'] var is supposed to produce a "win" outcome, but (particularly with the "king" movie + card match), the outcome is "lose", which makes no sense. Have I fried my noggin' too much to be able to see a simple error in what I thought was logical randomizer code?
Thanks in advance!