X-Git-Url: https://git.nubati.net/cgi-bin/gitweb.cgi?p=e-DoKo.git;a=blobdiff_plain;f=include%2Fgame.php;h=4dbf68f0a6e291dd194c485d8844a4c8aa49bc2b;hp=0ec52e2da554c5a13f387dc557b2d7380647243d;hb=c956a58882bbfef255af6817d8f21432968ac785;hpb=a4149c6703653b2d0d5f3da4277d7fe065048edd diff --git a/include/game.php b/include/game.php index 0ec52e2..4dbf68f 100644 --- a/include/game.php +++ b/include/game.php @@ -26,6 +26,8 @@ if(!$myid) exit(); } +global $GAME,$RULES,$CARDS; + /* user might get here by clicking on the link in an email, so session might not be set */ if(isset($_SESSION["name"])) output_status($_SESSION["name"]); @@ -76,6 +78,11 @@ else $ok=1; } +/* these are the defaults */ +$GAME['schweinchen-who'] = NULL; +$GAME['schweinchen-first'] = NULL; +$GAME['schweinchen-second'] = NULL; + if($ok) { /* need to check for Schweinchen */ @@ -89,14 +96,13 @@ if($ok) $GAME['schweinchen-first'] = 0; /* to keep track if they have been played already */ $GAME['schweinchen-second'] = 0; } -else -{ - /* no need to check for Schweinchen */ - $GAME['schweinchen-who']=NULL; -} /* end check for Schweinchen */ -set_gametype($gametype); /* this sets the $CARDS variable */ +/* set the $CARDS variable, needed for sorting the cards + * we set it to normal so that the pre-game phase is handled ok + * and later set it to the correct game type that is played + */ +set_gametype('normal'); /* put everyting in a form */ echo "
\n"; @@ -183,6 +189,7 @@ switch($mystatus) /* whos turn is it? */ DB_set_player_by_gameid($gameid,$user); $ok = 0; + break; } }; if($ok) @@ -303,7 +310,7 @@ switch($mystatus) } else if($_REQUEST["wedding"] == "yes") { - /* TODO: add silent solo somewhere*/ + /* silent solo is set further down */ echo "Ok, you don't want to play a silent solo...wedding was chosen.
\n"; DB_set_sickness_by_hash($me,"wedding"); } @@ -374,6 +381,7 @@ switch($mystatus) { $ok = 0; DB_set_player_by_gameid($gameid,$user); + break; } }; @@ -634,6 +642,7 @@ switch($mystatus) * poverty: set re/contra * dpoverty: first time: set re, send email to second player * second time: set contra + * poverty: set status of other players to 'play' * set status to play in case 0 trump * no -> set status to play, * ask next player or cancle the game if no more players @@ -665,6 +674,7 @@ switch($mystatus) " WHERE hand_id='$myhand' AND card_id=".DB_quote_smart($exchange)); }; } + /* update hand */ $mycards = DB_get_hand($me); $mycards = mysort($mycards,$gametype); @@ -685,7 +695,26 @@ switch($mystatus) { /* user is done, ready to play */ DB_set_hand_status_by_hash($me,'play'); - /* TODO if resolved; email start player, set startplayer */ + + /* email start player */ + $startplayer = DB_get_startplayer_by_gameid($gameid); + $email = DB_get_email('position-gameid',$startplayer,$gameid); + $hash = DB_get_hash_from_game_and_pos($gameid,$startplayer); + $who = DB_get_userid('email',$email); + DB_set_player_by_gameid($gameid,$who); + + if($hash!=$me) + { + if(DB_get_email_pref_by_hash($hash)!="emailaddict") + { + /* email startplayer */ + $message = "It's your turn now in game ".DB_format_gameid($gameid).".\n". + "Use this link to play a card: ".$HOST.$INDEX."?action=game&me=".$hash."\n\n" ; + mymail($email,$EmailName."ready, set, go... (game ".DB_format_gameid($gameid).") ",$message); + } + } + else + echo " Please, start the game.
\n"; } /* the following is part A) of what needs to be done */ @@ -799,6 +828,7 @@ switch($mystatus) /* copy trump from player A to B */ $result = DB_query("UPDATE Hand_Card SET hand_id='$myhand' WHERE hand_id='$userhand' AND card_id<'27'" ); + /* reload cards */ $mycards = DB_get_hand($me); /* set re/contra */ @@ -809,18 +839,19 @@ switch($mystatus) { $hash = DB_get_hash_from_gameid_and_userid($gameid,$user); if($hash==$userhash||$hash==$me) - DB_set_party_by_hash($hash,"re"); + { + DB_set_party_by_hash($hash,"re"); + } else - DB_set_party_by_hash($hash,"contra"); + { + DB_set_party_by_hash($hash,"contra"); + DB_set_hand_status_by_hash($hash,'play'); /* the contra party is ready to play */ + } } - /* check if we are done, if so, send everyone into the 'play' phase */ + /* check if we are done (in case of no trump handed over), if so, go to 'play' phase right away*/ if(count($mycards)==12) { - foreach($userids as $user) - { - $hash = DB_get_hash_from_gameid_and_userid($gameid,$user); - DB_set_hand_status_by_hash($hash,'play'); - } + DB_set_hand_status_by_hash($me,'play'); } } else /*dpoverty*/ @@ -901,6 +932,7 @@ switch($mystatus) { $ok = 0; DB_set_player_by_gameid($gameid,$user); + break; } } if($ok) @@ -1129,6 +1161,7 @@ switch($mystatus) { $card = $_REQUEST["card"]; $handid = DB_get_handid('hash',$me); + $commentSchweinchen =""; /* used to add a comment when Schweinchen is being played */ /* check if we have card and that we haven't played it yet*/ /* set played in hand_card to true where hand_id and card_id*/