X-Git-Url: https://git.nubati.net/cgi-bin/gitweb.cgi?p=e-DoKo.git;a=blobdiff_plain;f=include%2Fgame.php;h=93144a6e4c9f75e0d8fb87d83f674b7fc98bc2b3;hp=3540be4592c052f77ba5b791482939e4d9d01ce5;hb=de8089a2e706b0d83b8bff90d11559500f1a6711;hpb=95b72fab501b778555252b005ea8618a3305ad4c
diff --git a/include/game.php b/include/game.php
index 3540be4..93144a6 100644
--- a/include/game.php
+++ b/include/game.php
@@ -1,4 +1,23 @@
+ *
+ * This file is part of e-DoKo.
+ *
+ * e-DoKo is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * e-DoKo is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with e-DoKo. If not, see
\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,30 +38,28 @@ 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;
}
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"]);
-
-/* the user has done something, update the timestamp */
-DB_update_user_timestamp($myid);
-
-/* get some information from the DB */
+/**************************************
+ * get some information from the DB
+ **************************************/
$gameid = DB_get_gameid_by_hash($me);
$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);
+$playid = DB_get_current_playid($gameid); /* might be -1 at beginning of the game */
/* get prefs and save them in a variable*/
-$PREF = DB_get_PREF($myid);
+$PREF = DB_get_PREF(isset($_SESSION['id'])?$_SESSION['id']:$myid);
+/* set language chosen in preferences, will become active on the next reload (see index.php)*/
+$_SESSION['language'] = $PREF['language'];
+
/* get rule set for this game */
$RULES = DB_get_RULES($gameid);
@@ -53,10 +68,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?
@@ -69,11 +84,14 @@ if( $gamestatus == 'pre' )
{
/* always need to use Schweinchen to figure out for example who has poverty */
$ok=1;
+ /* unless the gametype is set and we know that we are in poverty were schweinchen is not valid */
+ if( in_array( $gametype,array('poverty','dpoverty') ))
+ $ok=0;
}
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;
}
@@ -90,7 +108,7 @@ 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 */
@@ -104,31 +122,394 @@ if($ok)
*/
set_gametype('normal');
-/* put everyting in a form */
-echo "