X-Git-Url: https://git.nubati.net/cgi-bin/gitweb.cgi?p=e-DoKo.git;a=blobdiff_plain;f=include%2Fgame.php;h=de19cabb8b0c20b7a36bb4b3bedc5abdc9d20d3f;hp=bbaa5b3500a2e945c5d4a2b113806b0cdb4f2d40;hb=e2d7a3291f85403b4faf6f8be7e30caeefb0c1a3;hpb=e525ec3c4a6e6234fd63caad097845cc2935fc1b
diff --git a/include/game.php b/include/game.php
index bbaa5b3..de19cab 100644
--- a/include/game.php
+++ b/include/game.php
@@ -6,14 +6,12 @@ if(!isset($HOST))
exit;
/* calling game.php only makes sense when we give it a hash for a game */
-if(!myisset("me"))
+if(!myisset('me'))
{
echo "Hmm, you really shouldn't mess with the urls.
\n";
- output_footer();
- DB_close();
- exit();
+ return;
}
-$me = $_REQUEST["me"];
+$me = $_REQUEST['me'];
/* Ok, got a hash, but is it valid? */
$myid = DB_get_userid('hash',$me);
@@ -21,17 +19,14 @@ if(!$myid)
{
echo "Can't find you in the database, please check the url.
\n";
echo "perhaps the game has been canceled, check by login in here.";
- output_footer();
- DB_close();
- exit();
+ return;
}
-/* 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"]);
+global $GAME,$RULES,$CARDS;
/* the user has done something, update the timestamp */
-DB_update_user_timestamp($myid);
+if(isset($_SESSION['id']))
+ DB_update_user_timestamp($_SESSION['id']);
/* get some information from the DB */
$gameid = DB_get_gameid_by_hash($me);
@@ -39,10 +34,11 @@ $myname = DB_get_name('hash',$me);
$mystatus = DB_get_status_by_hash($me);
$mypos = DB_get_pos_by_hash($me);
$myhand = DB_get_handid('hash',$me);
+$myparty = DB_get_party_by_hash($me);
$session = DB_get_session_by_gameid($gameid);
/* get prefs and save them in a variable*/
-$PREF = DB_get_PREF($myid);
+$PREF = DB_get_PREF(isset($_SESSION['id'])?$_SESSION['id']:$myid);
/* get rule set for this game */
$RULES = DB_get_RULES($gameid);
@@ -51,10 +47,10 @@ $RULES = DB_get_RULES($gameid);
$gametype = DB_get_gametype_by_gameid($gameid);
$gamestatus = DB_get_game_status_by_gameid($gameid);
$GT = $gametype;
-if($gametype=="solo")
+if($gametype=='solo')
{
$gametype = DB_get_solo_by_gameid($gameid);
- $GT = $gametype." ".$GT;
+ $GT = $gametype.' '.$GT;
}
/* do we need to worry about Schweinchen?
@@ -71,11 +67,16 @@ if( $gamestatus == 'pre' )
else
{
/* in a game Schweinchen is not valid in all types of games */
- if( $gametype == 'normal' || $gametype == 'silent' || $gametype=='trump' )
+ if( in_array($gametype,array('normal','wedding','trump','silent') ))
if( in_array($RULES['schweinchen'],array('both','second','secondaftercall')) )
$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 */
@@ -83,42 +84,196 @@ if($ok)
{
$hash = DB_get_hash_from_game_and_pos($gameid,$i);
$cards = DB_get_all_hand($hash);
- if( in_array("19",$cards) && in_array("20",$cards) )
+ if( in_array('19',$cards) && in_array('20',$cards) )
$GAME['schweinchen-who']=$hash;
};
$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 "