X-Git-Url: https://git.nubati.net/cgi-bin/gitweb.cgi?p=e-DoKo.git;a=blobdiff_plain;f=include%2Fgame.php;h=b8963d2fc5134aac1a1d782a4d4371a82b1b5e3b;hp=2ab444b1aa0d418007efe0407f9479e7071c22cb;hb=21973b9985f6325315721cba1c4e046fbbe3a1f0;hpb=12a7da9216b33c12ecc7939be1f6e8a48a273b00
diff --git a/include/game.php b/include/game.php
index 2ab444b..b8963d2 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 .
+ *
+ */
+
/* make sure that we are not called from outside the scripts,
* use a variable defined in config.php to check this
*/
@@ -24,19 +43,20 @@ if(!$myid)
global $GAME,$RULES,$CARDS;
-/* 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);
+$origmystatus = DB_get_status_by_hash($me); /* to show "it's your turn" menu when game has just finished */
$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);
@@ -61,11 +81,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;
}
@@ -96,11 +119,8 @@ if($ok)
*/
set_gametype('normal');
-/* put everyting in a form */
-echo "
\n";
+echo "\n";
- if($mystatus=='gameover' && DB_get_game_status_by_gameid($gameid)=='gameover' )
- {
+/*********************************
+ * suggest next game
+ *********************************/
- $session = DB_get_session_by_gameid($gameid);
- $result = DB_query("SELECT id,create_date FROM Game".
- " WHERE session=$session".
- " ORDER BY create_date DESC".
- " LIMIT 1");
- $r = -1;
- if($result)
- $r = DB_fetch_array($result);
+$gamestatus = DB_get_game_status_by_gameid($gameid);
+if($mystatus=='gameover' &&
+ ($gamestatus =='gameover' || $gamestatus =='cancel-nines' || $gamestatus =='cancel-trump') &&
+ isset($_SESSION['id']) && $_SESSION['id']==$myid)
+ {
+ $session = DB_get_session_by_gameid($gameid);
+ $result = DB_query("SELECT id,create_date FROM Game".
+ " WHERE session=$session".
+ " ORDER BY create_date DESC".
+ " LIMIT 1");
+ $r = -1;
+ if($result)
+ $r = DB_fetch_array($result);
+
+ if(!$session || $gameid==$r[0])
+ {
+ /* suggest a new game with the same people in it, just rotated once (unless last game was solo) */
+ $names = DB_get_all_names_by_gameid($gameid);
+ $type = DB_get_gametype_by_gameid($gameid);
- if(!$session || $gameid==$r[0])
+ if($type=='solo')
{
- /* suggest a new game with the same people in it, just rotated once (unless last game was solo) */
- $names = DB_get_all_names_by_gameid($gameid);
- $type = DB_get_gametype_by_gameid($gameid);
-
- if($type=='solo')
- {
- $solo = DB_get_solo_by_gameid($gameid);
+ $solo = DB_get_solo_by_gameid($gameid);
- if($solo!='silent') /* repeat game with same first player */
- output_ask_for_new_game($names[0],$names[1],$names[2],$names[3],$gameid);
- else /* rotate normally */
- output_ask_for_new_game($names[1],$names[2],$names[3],$names[0],$gameid);
- }
+ if($solo!='silent') /* repeat game with same first player */
+ output_ask_for_new_game($names[0],$names[1],$names[2],$names[3],$gameid);
else /* rotate normally */
output_ask_for_new_game($names[1],$names[2],$names[3],$names[0],$gameid);
}
+ else if($gamestatus == 'cancel-nines' || $gamestatus == 'cancel-trump')
+ output_ask_for_new_game($names[0],$names[1],$names[2],$names[3],$gameid);
+ else /* rotate normally */
+ output_ask_for_new_game($names[1],$names[2],$names[3],$names[0],$gameid);
}
+ }
?>
\ No newline at end of file