diff options
author | Arun Persaud <arun@nubati.net> | 2008-01-05 22:43:53 +0100 |
---|---|---|
committer | Arun Persaud <arun@nubati.net> | 2008-01-05 23:21:35 +0100 |
commit | 9122cf59b57c7405a14b5a61238667b98dd58150 (patch) | |
tree | bc7d82130f69c54be1c17a459df453a0dc033a43 | |
parent | 2264646817a59a6e3aefa835c492938dde4f25ee (diff) | |
download | e-DoKo-9122cf59b57c7405a14b5a61238667b98dd58150.tar.gz e-DoKo-9122cf59b57c7405a14b5a61238667b98dd58150.tar.bz2 e-DoKo-9122cf59b57c7405a14b5a61238667b98dd58150.zip |
CLEANUP: started rewrite of pre-game phase, fixed 'start' section
the whole process is not very easy to read... you could get from start to init, but then
the error check for the start phase was done during the init phase and if something went
wrong init sent you back to the start-phase... now all error-checking for the start-phase
is done during the start phase. should be a bit easier to read ;)
Still need to fix the other sections
Signed-off-by: Arun Persaud <arun@nubati.net>
-rw-r--r-- | index.php | 79 |
1 files changed, 56 insertions, 23 deletions
@@ -410,20 +410,6 @@ else if(myisset("me")) } else { - /* move on to the next stage*/ - DB_set_hand_status_by_hash($me,'init'); - } - case 'init': - /* first check if everything went ok in the last step - * if not, send user back, if yes, check what he did - */ - if( !myisset("in") ) - { - echo "<p class=\"message\"> You need to answer the <a href=\"$INDEX?me=$me\">question</a>.</p>"; - DB_set_hand_status_by_hash($me,'start'); - } - else - { if($_REQUEST["in"] == "no") { /* cancel the game */ @@ -439,23 +425,70 @@ else if(myisset("me")) /* delete everything from the dB */ DB_cancel_game($me); + break; } else { - $mycards = DB_get_hand($me); - sort($mycards); + /* user wants to join the game */ - output_check_for_sickness($me,$mycards); + /* move on to the next stage, + * no break statement to immediately go to the next stage + */ - echo "<p class=\"mycards\">Your cards are: <br />\n"; - foreach($mycards as $card) - display_card($card,$PREF["cardset"]); - echo "</p>\n"; + DB_set_hand_status_by_hash($me,'init'); - /* move on to the next stage*/ - DB_set_hand_status_by_hash($me,'check'); + /* check if everyone has reached this stage, send out email */ + $userids = DB_get_all_userid_by_gameid($gameid); + $ok = 1; + foreach($userids as $user) + { + $userstat = DB_get_hand_status_by_userid_and_gameid($user,$gameid); + if($userstat!='init') + { + /* whos turn is it? */ + DB_set_player_by_gameid($gameid,$user); + $ok = 0; + } + }; + if($ok) + { + /* all done, send out email unless this player is the startplayer */ + $startplayer = DB_get_startplayer_by_gameid($gameid); + if($mypos == $startplayer) + { + /* do nothing, go to next stage */ + } + else + { + /* email startplayer */ + /* + $email = DB_get_email_by_pos_and_gameid($startplayer,$gameid); + $hash = DB_get_hash_from_game_and_pos($gameid,$startplayer); + $who = DB_get_userid_by_email($email); + DB_set_player_by_gameid($gameid,$who); + + $message = "It's your turn now in game ".DB_format_gameid($gameid).".\n". + "Use this link to play a card: ".$HOST.$INDEX."?me=".$hash."\n\n" ; + mymail($email,$EmailName."ready, set, go... (game ".DB_format_gameid($gameid).") ",$message); + */ + } + } } } + case 'init': + + $mycards = DB_get_hand($me); + sort($mycards); + + output_check_for_sickness($me,$mycards); + + echo "<p class=\"mycards\">Your cards are: <br />\n"; + foreach($mycards as $card) + display_card($card,$PREF["cardset"]); + echo "</p>\n"; + + /* move on to the next stage*/ + DB_set_hand_status_by_hash($me,'check'); break; case 'check': |