X-Git-Url: https://git.nubati.net/cgi-bin/gitweb.cgi?p=e-DoKo.git;a=blobdiff_plain;f=include%2Fgame.php;h=b41ca26382b2b45283622106b7b2f6a019cbc6c8;hp=0d4f0a9856606465caabe651390a197e333b170b;hb=f922adf616e3a3effca51f85edfdbc11eef91799;hpb=086ed1db2ec28817b3370481455c84ceaf6448c2
diff --git a/include/game.php b/include/game.php
index 0d4f0a9..b41ca26 100644
--- a/include/game.php
+++ b/include/game.php
@@ -5,6 +5,7 @@
if(!isset($HOST))
exit;
+/* calling game.php only makes sense when we give it a hash for a game */
if(!myisset("me"))
{
echo "Hmm, you really shouldn't mess with the urls.
\n";
@@ -12,10 +13,9 @@ if(!myisset("me"))
DB_close();
exit();
}
-
$me = $_REQUEST["me"];
-/* test for valid ID */
+/* Ok, got a hash, but is it valid? */
$myid = DB_get_userid('hash',$me);
if(!$myid)
{
@@ -30,7 +30,7 @@ if(!$myid)
if(isset($_SESSION["name"]))
output_status($_SESSION["name"]);
-/* the user had done something, update the timestamp */
+/* the user has done something, update the timestamp */
DB_update_user_timestamp($myid);
/* get some information from the DB */
@@ -41,17 +41,11 @@ $mypos = DB_get_pos_by_hash($me);
$myhand = DB_get_handid('hash',$me);
$session = DB_get_session_by_gameid($gameid);
-/* get prefs and save them */
-DB_get_PREF($myid);
+/* get prefs and save them in a variable*/
+$PREF = DB_get_PREF($myid);
/* get rule set for this game */
-$r = DB_query_array("SELECT * FROM Rulesets".
- " LEFT JOIN Game ON Game.ruleset=Rulesets.id ".
- " WHERE Game.id='$gameid'" );
-
-$RULES["dullen"] = $r[2];
-$RULES["schweinchen"] = $r[3];
-$RULES["call"] = $r[4];
+$RULES = DB_get_RULES($gameid);
/* get some infos about the game */
$gametype = DB_get_gametype_by_gameid($gameid);
@@ -63,18 +57,35 @@ if($gametype=="solo")
$GT = $gametype." ".$GT;
}
-/* does anyone have both foxes */
-$GAME["schweinchen"]=0;
-for($i=1;$i<5;$i++)
- {
- $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) )
- {
- $GAME["schweinchen"]=1;
- $GAME["schweinchen-who"]=$hash;
- }
- };
+/* do we need to worry about Schweinchen?
+ * check gametype and rules
+ * if yes, figure out if someone actually has Schweinchen
+ * save information in $GAME
+ */
+$ok=0;
+if( $gametype == 'normal' || $gametype == 'silent' || $gametype=='trump' )
+ if( in_array($RULES['schweinchen'],array('both','second','secondaftercall')) )
+ $ok=1;
+
+if($ok)
+{
+ /* need to check for Schweinchen */
+ for($i=1;$i<5;$i++)
+ {
+ $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) )
+ $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 */
/* put everyting in a form */
echo "