X-Git-Url: https://git.nubati.net/cgi-bin/gitweb.cgi?p=e-DoKo.git;a=blobdiff_plain;f=include%2Fgame.php;h=177b7f33b9c1c4ff04d5e34e3fe9fc6dfa71a8fe;hp=0ef5a3ef85a24cc1c955f818625831c863ccc97c;hb=a38183cf36a31f4372a5e37d09c6312a9fa267f7;hpb=08583506b9bdb4ef2d30bad9752c960f20fe54b6;ds=sidebyside
diff --git a/include/game.php b/include/game.php
index 0ef5a3e..177b7f3 100644
--- a/include/game.php
+++ b/include/game.php
@@ -1,5 +1,5 @@
+/* Copyright 2006, 2007, 2008, 2009, 2010, 2011, 2012 Arun Persaud
*
* This file is part of e-DoKo.
*
@@ -43,18 +43,23 @@ if(!$myid)
global $GAME,$RULES,$CARDS;
-/* 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);
+$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(isset($_SESSION['id'])?$_SESSION['id']:$myid);
+/* set language chosen in preferences */
+$_SESSION['language'] = $PREF['language'];
+set_language($PREF['language']);
/* get rule set for this game */
$RULES = DB_get_RULES($gameid);
@@ -66,7 +71,10 @@ $GT = $gametype;
if($gametype=='solo')
{
$gametype = DB_get_solo_by_gameid($gameid);
- $GT = $gametype.' '.$GT;
+ if($gametype=='silent')
+ $GT = 'normal';
+ else
+ $GT = $gametype.' '.$GT;
}
/* do we need to worry about Schweinchen?
@@ -117,11 +125,8 @@ if($ok)
*/
set_gametype('normal');
-/* put everyting in a form */
-echo "
If this was a mistake all 4 players need to send an Email to $ADMIN_NAME at $ADMIN_EMAIL requesting that the game should be restarted.";
break;
case 'cancel-timedout':
- echo "
The game has been canceled because one player wasn't responding.
If this was a mistake all 4 players need to send an Email to $ADMIN_NAME at $ADMIN_EMAIL requesting that the game should be restarted.
";
+ $messages[] = "The game has been canceled because one player wasn't responding.
If this was a mistake all 4 players need to send an Email to $ADMIN_NAME at $ADMIN_EMAIL requesting that the game should be restarted.";
break;
case 'cancel-nines':
- echo "The game has been canceled because one player had too many nines.
";
+ $messages[] = 'The game has been canceled because one player had too many nines.';
break;
case 'cancel-lowtrump':
- echo "The game has been canceled because one player had low trump.
";
+ $messages[] = 'The game has been canceled because one player had low trump.';
break;
case 'cancel-trump':
- echo "The game has been canceled because nobody wanted to take the trump.
";
+ $messages[] = 'The game has been canceled because nobody wanted to take the trump.';
break;
}
/* for these two types, we shouldn't show the cards, since we might want to restart the game */
@@ -1176,13 +1190,13 @@ switch($mystatus)
{
$ok = 1;
$userids = DB_get_all_userid_by_gameid($gameid);
- foreach($userids as $user)
+ foreach($userids as $userid)
{
- $userstatus = DB_get_hand_status_by_userid_and_gameid($user,$gameid);
+ $userstatus = DB_get_hand_status_by_userid_and_gameid($userid,$gameid);
if($userstatus !='play' && $userstatus!='gameover')
{
$ok = 0;
- DB_set_player_by_gameid($gameid,$user);
+ DB_set_player_by_gameid($gameid,$userid);
break;
}
}
@@ -1194,15 +1208,15 @@ switch($mystatus)
/* email startplayer */
$startplayer = DB_get_startplayer_by_gameid($gameid);
$hash = DB_get_hash_from_game_and_pos($gameid,$startplayer);
- $who = DB_get_userid('hash',$hash);
- DB_set_player_by_gameid($gameid,$who);
+ $userid = DB_get_userid('hash',$hash);
+ DB_set_player_by_gameid($gameid,$userid);
if($hash!=$me && 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($who,$gameid, GAME_READY, $message);
+ $email_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($userid,$gameid, GAME_READY, $email_message);
}
}
}
@@ -1233,55 +1247,31 @@ switch($mystatus)
/* has the game started? No, then just wait here...*/
if($gamestatus == 'pre')
{
- echo ' '._('You finished the setup, but not everyone else finished it... '.
- 'You need to wait for the others. Just wait for an email.').'
';
-
- $mycards = DB_get_hand($me);
- $mycards = mysort($mycards,$gametype);
-
- echo ''._('Your cards are').":
\n";
- foreach($mycards as $card)
- display_card($card,$PREF['cardset']);
- echo "
\n";
+ $messages[] = _('You finished the setup, but not everyone else finished it... '.
+ 'You need to wait for the others. Just wait for an email.');
break; /* not sure this works... the idea is that you can
* only play a card after everyone is ready to play */
}
-
- /* get time from the last action of the game */
- $r = DB_query_array("SELECT mod_date from Game WHERE id='$gameid' " );
- $gameend = time() - strtotime($r[0]);
-
- /* handle comments in case player didn't play a card, allow comments a week after the end of the game */
- if( (!myisset('card') && $mystatus=='play') || ($mystatus=='gameover' && ($gameend < 60*60*24*7)) )
- if(myisset('comment'))
- {
- $comment = $_REQUEST['comment'];
- $playid = DB_get_current_playid($gameid);
-
- if($comment != '')
- DB_insert_comment($comment,$playid,$myid);
- };
-
/* get everything relevant to display the tricks */
- $result = DB_query("SELECT Hand_Card.card_id as card,".
- " Hand.position as position,".
- " Play.sequence as sequence, ".
- " Trick.id, ".
+ $result = DB_query('SELECT Hand_Card.card_id as card,'.
+ ' Hand.position as position,'.
+ ' Play.sequence as sequence, '.
+ ' Trick.id, '.
" GROUP_CONCAT(CONCAT('',User.fullname,': ',Comment.comment,'')".
" SEPARATOR '\n' ), ".
- " Play.create_date, ".
- " Hand.user_id ".
- "FROM Trick ".
- "LEFT JOIN Play ON Trick.id=Play.trick_id ".
- "LEFT JOIN Hand_Card ON Play.hand_card_id=Hand_Card.id ".
- "LEFT JOIN Hand ON Hand_Card.hand_id=Hand.id ".
- "LEFT JOIN Comment ON Play.id=Comment.play_id ".
- "LEFT JOIN User On User.id=Comment.user_id ".
+ ' Play.create_date, '.
+ ' Hand.user_id '.
+ 'FROM Trick '.
+ 'LEFT JOIN Play ON Trick.id=Play.trick_id '.
+ 'LEFT JOIN Hand_Card ON Play.hand_card_id=Hand_Card.id '.
+ 'LEFT JOIN Hand ON Hand_Card.hand_id=Hand.id '.
+ 'LEFT JOIN Comment ON Play.id=Comment.play_id '.
+ 'LEFT JOIN User On User.id=Comment.user_id '.
"WHERE Trick.game_id='".$gameid."' ".
- "GROUP BY Trick.id, sequence ".
- "ORDER BY Trick.id, sequence ASC");
+ 'GROUP BY Trick.id, sequence '.
+ 'ORDER BY Trick.id, sequence ASC');
$trickNR = 0;
$lasttrick = DB_get_max_trickid($gameid);
@@ -1290,23 +1280,41 @@ switch($mystatus)
$pos = DB_get_startplayer_by_gameid($gameid)-1;
$firstcard = ''; /* first card in a trick */
- echo "\n