X-Git-Url: https://git.nubati.net/cgi-bin/gitweb.cgi?p=e-DoKo.git;a=blobdiff_plain;f=include%2Fgame.php;h=9028364e93bec14ae740ba02d2e64a4d2045e8c1;hp=8ab6f312d3d1e4bc283c0e0a705493737e6db110;hb=ecabf718a77ca979d16ef9d55f8db962fd3e814b;hpb=3f60adfc28f87886827084ebce58f041c1967722
diff --git a/include/game.php b/include/game.php
index 8ab6f31..9028364 100644
--- a/include/game.php
+++ b/include/game.php
@@ -1,5 +1,5 @@
+/* Copyright 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Arun Persaud
*
* This file is part of e-DoKo.
*
@@ -27,7 +27,7 @@ if(!isset($HOST))
/* 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";
+ echo _("Hmm, you really shouldn't mess with the urls.")."
\n";
return;
}
$me = $_REQUEST['me'];
@@ -36,38 +36,50 @@ $me = $_REQUEST['me'];
$myid = DB_get_userid('hash',$me);
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.";
+ echo _('Cannot find you in the database, please check the url.')."
\n";
+ printf(_('Perhaps the game has been canceled, check by login in here.'),$INDEX);
return;
}
global $GAME,$RULES,$CARDS;
-/* get some information from the DB */
+/**************************************
+ * get some information from the DB
+ **************************************/
+start:
$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);
/* get some infos about the game */
-$gametype = DB_get_gametype_by_gameid($gameid);
-$gamestatus = DB_get_game_status_by_gameid($gameid);
-$GT = $gametype;
-if($gametype=='solo')
- {
- $gametype = DB_get_solo_by_gameid($gameid);
- $GT = $gametype.' '.$GT;
- }
+$gametype_raw = DB_get_gametype_by_gameid($gameid);
+$gametype_solo = DB_get_solo_by_gameid($gameid);
+
+/* replace solo with the type of solo */
+$gametype = $gametype_raw;
+if($gametype_raw=='solo')
+ $gametype = $gametype_solo;
+
+/* gametype for displaying it (hides hidden solo)*/
+$GT = get_display_gametype($gameid);
+
+$gamestatus = DB_get_game_status_by_gameid($gameid);
+
+
/* do we need to worry about Schweinchen?
* check gametype and rules
@@ -117,9 +129,6 @@ 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 */
@@ -1171,13 +1247,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;
}
}
@@ -1189,15 +1265,17 @@ 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);
+ set_language($userid,'uid');
+ $email_message = sprintf(_("It's your turn now in game %s.\n".
+ 'Use this link to play a card: '),DB_format_gameid($gameid)).$HOST.$INDEX."?action=game&me=".$hash."\n\n" ;
+ mymail($userid,$gameid, GAME_READY, $email_message);
+ set_language($myid,'uid');
}
}
}
@@ -1207,19 +1285,6 @@ switch($mystatus)
* accordingly
*/
- $gametype = DB_get_gametype_by_gameid($gameid);
- $GT = $gametype;
- if($gametype=='solo')
- {
- $gametype = DB_get_solo_by_gameid($gameid);
- if($gametype=='silent')
- $GT = 'normal';
- else
- $GT = $gametype.' '.$GT;
- }
- else
- $gametype = 'normal';
-
set_gametype($gametype); /* this sets the $CARDS variable */
/* get some infos about the game, need to reset this, since it might have changed */
@@ -1228,55 +1293,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 ".
- "WHERE Trick.game_id='".$gameid."' ".
- "GROUP BY Trick.id, sequence ".
- "ORDER BY Trick.id, sequence ASC");
+ ' 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=".DB_quote_smart($gameid).
+ ' GROUP BY Trick.id, sequence'.
+ ' ORDER BY Trick.id, sequence ASC');
$trickNR = 0;
$lasttrick = DB_get_max_trickid($gameid);
@@ -1285,22 +1326,39 @@ switch($mystatus)
$pos = DB_get_startplayer_by_gameid($gameid)-1;
$firstcard = ''; /* first card in a trick */
- echo "\n