From dceed6f464ca2a65ba25e454aeaea2e1434cd5f3 Mon Sep 17 00:00:00 2001 From: arun Date: Fri, 8 Dec 2006 10:00:16 +0000 Subject: playing games should work now... new games can be started automatically at the end of an old one. --- index.php | 141 +++++++++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 103 insertions(+), 38 deletions(-) (limited to 'index.php') diff --git a/index.php b/index.php index 58dd183..f0bfad5 100644 --- a/index.php +++ b/index.php @@ -37,6 +37,7 @@ \n"; + + /*check if we still have cards left, else set status to gameover */ if(sizeof(DB_get_hand($me))==0) - DB_set_hand_status_by_hash($me,'gameover'); + { + DB_set_hand_status_by_hash($me,'gameover'); + $mystatus='gameover'; + } + + /* if all players are done, set game status also to game over */ + $userids = DB_get_all_userid_by_gameid($gameid); + $done=1; + foreach($userids as $user) + if(DB_get_hand_status_by_userid($user)!='gameover') + $done=0; + + if($done) + DB_set_game_status_by_gameid($gameid,"gameover"); - echo "TODO: email next player
"; + /* email next player */ + if(DB_get_game_status_by_gameid($gameid)=='play') + { + if($sequence==4) + { + $play = DB_get_cards_by_trick($trickid); + $winner = get_winner($play); /* returns the position */ + $next = $winner; + } + else + { + $next = DB_get_pos_by_hash($me)+1; + } + if($next==5) $next=1; + + echo "TODO: email next player at pos $next
"; + if($debug) + echo "DEBUG: next player
\n"; + + } } else { @@ -430,7 +474,7 @@ else if(isset($_REQUEST["me"])) if($myturn && !isset($_REQUEST["card"])) { - echo "Hello ".DB_get_name_by_hash($me).", it's your turn!
\n"; + echo "Hello ".$myname.", it's your turn!
\n"; echo "Your cards are:
\n"; echo "
\n"; foreach($mycards as $card) @@ -442,19 +486,40 @@ else if(isset($_REQUEST["me"]))
\n"; foreach($mycards as $card) display_card($card); } echo "\n"; - /*check if we still have cards left, else set status to gameover */ - - break; - case 'gameover': - echo "the game is over... guess the final score should be displayed here...
\n"; - echo "TODO: suggest a new game with the next person as dealer
\n"; + + /* check if we need to set status to 'gameover' is done during playing of the card */ + if($mystatus=='play') + break; + /* the following happens only when the gamestatus is 'gameover' */ + /* check if game is over, display results */ + if(DB_get_game_status_by_gameid($gameid)=='play') + { + echo "the game is over for you.. other people still need to play though"; + } + else + { + echo "the game is over now... guess the final score should be displayed here...
\n"; + + /* suggest a new game with the same people in it, just rotated once */ + $names = DB_get_all_names_by_gameid($gameid); + + echo "Do you want to continue playing?(This will start a new game, with the next person as dealer.)\n"; + echo "
\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
\n"; + } break; default: echo "error in testing the status"; -- cgit v1.2.3-18-g5258