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=db27bde601dd75d743c62d99c0674f4ea07df303;hb=4281c9e477f9aafff66f8b9dd6912a2495b0e853;hpb=c581cd05476d07f0fd17dab41cbb211a443fd57f
diff --git a/include/game.php b/include/game.php
index db27bde..93144a6 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, 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);
@@ -79,6 +84,9 @@ 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
{
@@ -114,11 +122,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 */
@@ -1196,10 +1285,9 @@ switch($mystatus)
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".
+ $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" ;
- $subject = 'Ready, set, go... (game '.DB_format_gameid($gameid).')';
- mymail($who,$subject,$message);
+ mymail($who,$gameid, GAME_READY, $email_message);
}
}
}
@@ -1230,37 +1318,13 @@ 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.
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,".
@@ -1287,20 +1351,40 @@ switch($mystatus)
$pos = DB_get_startplayer_by_gameid($gameid)-1;
$firstcard = ''; /* first card in a trick */
- echo "\n
\n";
- echo "
Game ".DB_format_gameid($gameid).":
\n";
+ echo "\n
\n";
/* output vorbehalte */
- $mygametype = DB_get_gametype_by_gameid($gameid);
- if($mygametype != 'normal' && $mygametype != 'silent') /* only show when needed */
+ $mygametype = DB_get_gametype_by_gameid($gameid);
+ $mygamesolo = DB_get_solo_by_gameid($gameid);
+ $show_pre_game_comments=1;
+ if($mygametype != 'normal') /* only show when needed */
+ if(!( $mygametype == 'solo' && $mygamesolo == 'silent') )
+ {
+ echo "
\n";
+
+ /* get information so show the cards that have been handed over in a poverty game */
+ output_exchanged_cards();
+ $show_pre_game_comments=0;
+
+ echo "
\n"; /* end div trick, end li trick */
+ }
+ if($show_pre_game_comments==1)
{
- echo "
\n";
+ /* display all comments on the top right (card1)*/
+ $comments = DB_get_pre_comment($gameid);
- /* get information so show the cards that have been handed over in a poverty game */
- output_exchanged_cards();
+ if(sizeof($comments))
+ {
+ echo "
\n \n"; /* end div trick, end li trick */
+ echo "
\n"; /* end div trick, end li trick */
+ }
}
/* output tricks */
@@ -1332,15 +1416,13 @@ switch($mystatus)
if($trick!=$lasttrick)
{
/* start of an old trick? */
- echo "
\n"; /* end div trick, end li trick */
/*check if we still have cards left, else set status to gameover */
if(sizeof(DB_get_hand($me))==0)
@@ -1645,13 +1737,12 @@ switch($mystatus)
$who = DB_get_userid('hash',$next_hash);
DB_set_player_by_gameid($gameid,$who);
- $message = "A card has been played in game ".DB_format_gameid($gameid).".\n\n".
+ $email_message = "A card has been played in game ".DB_format_gameid($gameid).".\n\n".
"It's your turn now.\n".
"Use this link to play a card: ".$HOST.$INDEX."?action=game&me=".$next_hash."\n\n" ;
if( DB_get_email_pref_by_uid($who)!='emailaddict' )
{
- $subject = 'A card has been played in game '.DB_format_gameid($gameid);
- mymail($who,$subject,$message);
+ mymail($who,$gameid, GAME_YOUR_TURN, $email_message);
}
}
else /* send out final email */
@@ -1665,10 +1756,10 @@ switch($mystatus)
" LEFT JOIN Card ON Card.id=Hand_Card.card_id".
" WHERE Hand.game_id='$gameid'".
" GROUP BY User.fullname" );
- $message = "The game is over. Thanks for playing :)\n";
- $message .= "Final score:\n";
+ $email_message = "The game is over. Thanks for playing :)\n";
+ $email_message .= "Final score:\n";
while( $r = DB_fetch_array($result) )
- $message .= " ".$r[0]."(".$r[2].") ".$r[1]."\n";
+ $email_message .= " ".$r[0]."(".$r[2].") ".$r[1]."\n";
$result = DB_query("SELECT Hand.party, IFNULL(SUM(Card.points),0) FROM Hand".
" LEFT JOIN Trick ON Trick.winner=Hand.position AND Trick.game_id=Hand.game_id".
@@ -1678,12 +1769,12 @@ switch($mystatus)
" LEFT JOIN Card ON Card.id=Hand_Card.card_id".
" WHERE Hand.game_id='$gameid'".
" GROUP BY Hand.party" );
- $message .= "\nTotals:\n";
+ $email_message .= "\nTotals:\n";
$re = 0;
$contra = 0;
while( $r = DB_fetch_array($result) )
{
- $message .= " ".$r[0]." ".$r[1]."\n";
+ $email_message .= " ".$r[0]." ".$r[1]."\n";
if($r[0] == 're')
$re = $r[1];
else if($r[0] == 'contra')
@@ -1696,8 +1787,8 @@ switch($mystatus)
*/
/* get calls from re/contra */
- $call_re = NULL;
- $call_contra = NULL;
+ $call_re = -1;
+ $call_contra = -1;
foreach($userids as $user)
{
$hash = DB_get_hash_from_gameid_and_userid($gameid,$user);
@@ -1710,14 +1801,14 @@ switch($mystatus)
if($party=='re')
{
- if($call_re==NULL)
+ if($call_re== -1)
$call_re = $call;
else if( $call < $call_re)
$call_re = $call;
}
else if($party=='contra')
{
- if($call_contra==NULL)
+ if($call_contra== -1)
$call_contra = $call;
else if( $call < $call_contra)
$call_contra = $call;
@@ -1728,7 +1819,7 @@ switch($mystatus)
/* figure out who one */
$winning_party = NULL;
- if($call_re == NULL && $call_contra==NULL)
+ if($call_re == -1 && $call_contra == -1)
{
/* nobody made a call, so it's easy to figure out who won */
if($re>120)
@@ -1742,7 +1833,7 @@ switch($mystatus)
* if only one party made a call, the other one wins,
* if the first one didn't make it
*/
- if($call_re)
+ if($call_re != -1)
{
$offset = 120 - $call_re;
if($call_re == 0)
@@ -1750,11 +1841,11 @@ switch($mystatus)
if($re > 120+$offset)
$winning_party='re';
- else if ($call_contra == NULL )
+ else if ($call_contra == -1 )
$winning_party='contra';
}
- if($call_contra)
+ if($call_contra != -1)
{
$offset = 120 - $call_contra;
if($call_contra == 0)
@@ -1762,7 +1853,7 @@ switch($mystatus)
if($contra > 120+$offset)
$winning_party='contra';
- else if ($call_re == NULL )
+ else if ($call_re == -1 )
$winning_party='re';
}
}
@@ -1770,7 +1861,7 @@ switch($mystatus)
/* one point for each call of the other party in case the other party didn't win
* and one point each in case the party made more than points than one of the calls
*/
- if($winning_party!='contra' && $call_contra!=NULL)
+ if($winning_party!='contra' && $call_contra!= -1)
{
for( $p=$call_contra;$p<=120; $p+=30 )
{
@@ -1785,7 +1876,7 @@ switch($mystatus)
" VALUES( NULL,NULL,$gameid,'re',NULL,NULL,'made$p')");
}
}
- if($winning_party!='re' and $call_re!=NULL)
+ if($winning_party!='re' and $call_re!= -1)
{
for( $p=$call_re;$p<=120; $p+=30 )
{
@@ -1814,7 +1905,7 @@ switch($mystatus)
foreach(array(120,150,180,210,240) as $p)
{
$offset = 0;
- if($p==240 || $call_contra!=NULL)
+ if($p==240 || $call_contra != -1)
$offset = 1;
if($re>$p-$offset)
@@ -1824,7 +1915,7 @@ switch($mystatus)
/* re called something and won */
foreach(array(0,30,60,90,120) as $p)
{
- if($call_re!=NULL && $call_re<$p+1)
+ if($call_re!= -1 && $call_re<$p+1)
DB_query("INSERT INTO Score".
" VALUES( NULL,NULL,$gameid,'re',NULL,NULL,'call$p')");
}
@@ -1834,7 +1925,7 @@ switch($mystatus)
foreach(array(120,150,180,210,240) as $p)
{
$offset = 0;
- if($p==240 || $call_re!=NULL)
+ if($p==240 || $call_re != -1)
$offset = 1;
if($contra>$p-$offset)
@@ -1844,7 +1935,7 @@ switch($mystatus)
/* re called something and won */
foreach(array(0,30,60,90,120) as $p)
{
- if($call_contra!=NULL && $call_contra<$p+1)
+ if($call_contra != -1 && $call_contra<$p+1)
DB_query("INSERT INTO Score".
" VALUES( NULL,NULL,$gameid,'contra',NULL,NULL,'call$p')");
}
@@ -1852,35 +1943,35 @@ switch($mystatus)
/* add score points to email */
- $message .= "\n";
+ $email_message .= "\n";
$Tpoint = 0;
- $message .= " Points Re: \n";
+ $email_message .= " Points Re: \n";
$queryresult = DB_query("SELECT score FROM Score ".
" WHERE game_id=$gameid AND party='re'".
" ");
while($r = DB_fetch_array($queryresult) )
{
- $message .= " ".$r[0]."\n";
+ $email_message .= " ".$r[0]."\n";
$Tpoint ++;
}
- $message .= " Points Contra: \n";
+ $email_message .= " Points Contra: \n";
$queryresult = DB_query("SELECT score FROM Score ".
" WHERE game_id=$gameid AND party='contra'".
" ");
while($r = DB_fetch_array($queryresult) )
{
- $message .= " ".$r[0]."\n";
+ $email_message .= " ".$r[0]."\n";
$Tpoint --;
}
- $message .= " Total Points (from the Re point of view): $Tpoint\n";
- $message .= "\n";
+ $email_message .= " Total Points (from the Re point of view): $Tpoint\n";
+ $email_message .= "\n";
$session = DB_get_session_by_gameid($gameid);
$score = generate_score_table($session);
- $message .= "Score Table:\n";
- $message .= format_score_table_ascii($score);
- $message .= "\nUse these links to have a look at game ".DB_format_gameid($gameid).": \n";
+ $email_message .= "Score Table:\n";
+ $email_message .= format_score_table_ascii($score);
+ $email_message .= "\nUse these links to have a look at game ".DB_format_gameid($gameid).": \n";
/* send out final email */
foreach($userids as $user)
@@ -1890,31 +1981,29 @@ switch($mystatus)
$name = DB_get_name('userid',$user);
$link = "$name: ".$HOST.$INDEX."?action=game&me=".$hash."\n" ;
- $message .= $link;
+ $email_message .= $link;
}
- $message .= "\n\n (you can use reply all on this email to reach all the players.)\n\n";
- $subject = ' Game over (game '.DB_format_gameid($gameid).') ';
- mymail($userids,$subject,$message);
+ $email_message .= "\n\n (you can use reply all on this email to reach all the players.)\n\n";
+ mymail($userids,$gameid, GAME_OVER, $email_message);
}
}
else
{
- echo "can't find that card?! \n";
+ $messages[] = "can't find that card?!";
}
}
else if(myisset('card') && !$myturn )
{
- echo "please wait until it's your turn! \n";
+ $messages[] = _("please wait until it's your turn!");
}
if($seq!=4 && $trickNR>=1 && !(myisset('card') && $myturn) )
- echo "
\n \n"; /* end div trick, end li trick */
+ echo "
\n"; /* end div trick, end li trick */
/* display points in case game is over */
if($mystatus=='gameover' && DB_get_game_status_by_gameid($gameid)=='gameover' )
{
- echo "
\n";
/* add pic for re/contra
" \n";*/
@@ -1940,118 +2029,54 @@ switch($mystatus)
" LEFT JOIN Card ON Card.id=Hand_Card.card_id".
" WHERE Hand.game_id='$gameid'".
" GROUP BY Hand.party" );
- echo "
\n"; /* end ul tricks*/
- $mycards = DB_get_hand($me);
- $mycards = mysort($mycards,$gametype);
- echo "
\n";
-
- if($myturn && !myisset('card') && $mystatus=='play' )
+ if( ($myturn && !myisset('card') && $mystatus=='play') /* it's my turn*/
+ || ($myturn && myisset('card') && $next==$mypos && $mystatus=='play') /* a card has been played and player won the trick*/)
{
- echo "Hello ".$myname.", it's your turn! \n";
- echo "Your cards are: \n";
-
- /* do we have to follow suite? */
- $followsuit = 0;
- if(have_suit($mycards,$firstcard))
- $followsuit = 1;
-
- foreach($mycards as $card)
- {
- /* display only cards that the player is allowed to play as links, the rest just display normal
- * also check if we have both schweinchen, in that case only display on of them as playable
- */
- if( ($followsuit && !same_type($card,$firstcard)) ||
- ( (int)($card)==19 &&
- !$GAME['schweinchen-first'] &&
- ( $RULES['schweinchen']=='second' ||
- ( $RULES['schweinchen']=='secondaftercall' &&
- (DB_get_call_by_hash($GAME['schweinchen-who']) ||
- DB_get_partner_call_by_hash($GAME['schweinchen-who']) )
- )
- ) &&
- $GAME['schweinchen-who']==$me &&
- in_array($gametype,array('normal','wedding','trump','silent'))
- )
- )
- display_card($card,$PREF['cardset']);
- else
- display_link_card($card,$PREF['cardset']);
- }
+ $card_status = CARDS_MYTURN;
}
else if($mystatus=='play' )
{
- echo "Your cards are: \n";
- foreach($mycards as $card)
- display_card($card,$PREF['cardset']);
+ $card_status = CARDS_SHOW;
}
else if($mystatus=='gameover')
{
- $oldcards = DB_get_all_hand($me);
- $oldcards = mysort($oldcards,$gametype);
-
if(isset($_SESSION['id']) && $myid==$_SESSION['id'])
- echo "Your cards were: \n";
+ $card_status = CARDS_GAMEOVER_ME;
else
- {
- $name = DB_get_name('userid',$myid);
- echo "$name's were: \n";
- }
-
- foreach($oldcards as $card)
- display_card($card,$PREF['cardset']);
-
- $userids = DB_get_all_userid_by_gameid($gameid);
- foreach($userids as $user)
- {
- $userhash = DB_get_hash_from_gameid_and_userid($gameid,$user);
-
- if($userhash!=$me)
- {
- echo " ";
-
- $name = DB_get_name('userid',$user);
- $oldcards = DB_get_all_hand($userhash);
- $oldcards = mysort($oldcards,$gametype);
- echo "$name's cards were: \n";
- foreach($oldcards as $card)
- display_card($card,$PREF['cardset']);
- }
- };
+ $card_status = CARDS_GAMEOVER;
}
- echo "
\n";
/* if the game is over do some extra stuff, therefore exit the swtich statement if we are still playing*/
if($mystatus=='play')
@@ -2061,78 +2086,235 @@ switch($mystatus)
/* check if game is over, display results */
if(DB_get_game_status_by_gameid($gameid)=='play')
{
- echo "The game is over for you.. other people still need to play though";
+ $messages[] = _('The game is over for you... other people still need to play though');
}
break;
default:
myerror("error in testing the status");
- }
+ } /*end of output: tricks, table, messages, card */
+
+/* display the 2nd half of table and the names */
+display_table_end();
+
+/**************
+ * show cards *
+ **************/
+
+$mycards = DB_get_hand($me);
+$mycards = mysort($mycards,$gametype);
+
+echo "\n";
+echo '
';
+switch ($card_status) {
+ case CARDS_SHOW:
+ echo _('Your cards are').": \n";
+ foreach($mycards as $card)
+ display_card($card,$PREF['cardset']);
+ break;
+ case CARDS_EXCHANGE:
+ echo '
'._('You need to get rid of a few cards')."
\n";
+
+ echo _('Your cards are').": \n";
+ $type='exchange';
+ foreach($mycards as $card)
+ display_link_card($card,$PREF['cardset'],$type);
+ echo ' '."\n";
+ break;
+ case CARDS_MYTURN:
+ echo 'Hello '.$myname.", it's your turn! \n";
+ echo _('Your cards are').": \n";
+
+ /* do we have to follow suite? */
+ $followsuit = 0;
+ if(have_suit($mycards,$firstcard))
+ $followsuit = 1;
+
+ /* count how many cards we can play, so that we can pre-select it if there is only one */
+ $howmanycards = 0;
+ foreach($mycards as $card)
+ {
+ if($howmanycards>1)
+ break;
+
+ /* display only cards that the player is allowed to play as links, the rest just display normal
+ * also check if we have both schweinchen, in that case only display on of them as playable
+ */
+ if( ($followsuit && !same_type($card,$firstcard)) ||
+ ( (int)($card)==19 &&
+ !$GAME['schweinchen-first'] &&
+ ( $RULES['schweinchen']=='second' ||
+ ( $RULES['schweinchen']=='secondaftercall' &&
+ (DB_get_call_by_hash($GAME['schweinchen-who']) ||
+ DB_get_partner_call_by_hash($GAME['schweinchen-who']) )
+ )
+ ) &&
+ $GAME['schweinchen-who']==$me &&
+ in_array($gametype,array('normal','wedding','trump','silent'))
+ )
+ )
+ continue;
+ else
+ $howmanycards++;
+ }
+
+ /* make it boolean, so that we can pass it later to display_link_card */
+ if($howmanycards!=1)
+ $howmanycards=0;
+
+ foreach($mycards as $card)
+ {
+ /* display only cards that the player is allowed to play as links, the rest just display normal
+ * also check if we have both schweinchen, in that case only display on of them as playable
+ */
+ if( ($followsuit && !same_type($card,$firstcard)) ||
+ ( (int)($card)==19 &&
+ !$GAME['schweinchen-first'] &&
+ ( $RULES['schweinchen']=='second' ||
+ ( $RULES['schweinchen']=='secondaftercall' &&
+ (DB_get_call_by_hash($GAME['schweinchen-who']) ||
+ DB_get_partner_call_by_hash($GAME['schweinchen-who']) )
+ )
+ ) &&
+ $GAME['schweinchen-who']==$me &&
+ in_array($gametype,array('normal','wedding','trump','silent'))
+ )
+ )
+ display_card($card,$PREF['cardset']);
+ else
+ display_link_card($card,$PREF['cardset'],$type='card',$selected=$howmanycards);
+ }
+ break;
+ case CARDS_GAMEOVER_ME:
+ case CARDS_GAMEOVER:
+ if($card_status == CARDS_GAMEOVER_ME)
+ echo _('Your cards were').": \n";
+ else
+ {
+ $name = DB_get_name('userid',$myid);
+ echo "$name's were: \n";
+ }
+ $oldcards = DB_get_all_hand($me);
+ $oldcards = mysort($oldcards,$gametype);
+
+ foreach($oldcards as $card)
+ display_card($card,$PREF['cardset']);
+
+ /* display hands of everyone else */
+ $userids = DB_get_all_userid_by_gameid($gameid);
+ foreach($userids as $user)
+ {
+ $userhash = DB_get_hash_from_gameid_and_userid($gameid,$user);
+
+ if($userhash!=$me)
+ {
+ echo " ";
+
+ $name = DB_get_name('userid',$user);
+ $oldcards = DB_get_all_hand($userhash);
+ $oldcards = mysort($oldcards,$gametype);
+ echo "$name's cards were: \n";
+ foreach($oldcards as $card)
+ display_card($card,$PREF['cardset']);
+ }
+ };
+ break;
+ case CARDS_EMPTY:
+ default:
+ break;
+ }
+echo "
\n";
-/* output other games where it is the users turn
- * make sure that the people looking at old games don't see the wrong games here
- */
-if( $gamestatus != 'gameover' )
- {
- /* game isn't over, only valid user can get here, so show menu */
- display_user_menu($myid);
- }
-else if( $origmystatus != 'gameover' )
- {
- /* user just played the very last card, game is now over, it's still ok to show the menu though */
- display_user_menu($myid);
- }
-else if( $mystatus == 'gameover' &&
- isset($_SESSION['id']) )
+/*****************
+ * show messages *
+ *****************/
+
+if( sizeof($messages) )
{
- /* user is looking at someone else's game, show the menu for the correct user */
- display_user_menu($_SESSION['id']);
+ echo "\n
\n";
+ foreach($messages as $message)
+ {
+ echo "
\n";
- echo "It's your turn in these games: \n";
- echo "Please log in to see this information.\n";
- echo "
\n";
+ /* treat before game calls special, so that we can show them on the first trick and not the pre-phase */
+ if($playid == -1)
+ $playid = -2;
+
+ DB_insert_comment($commentCall,$playid,$gameid,$myid);
}
+/***********************************************
+ * Comments, re/contra calls, user menu
+ ***********************************************/
+
+/*
+ * display gameinfo: re/contra, comment-box, play-card button, games played by others
+ */
-/* display rule set for this game */
echo "
\n";
+/* 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]);
+
+/* comment box */
+if($gamestatus == 'play' || $gamestatus == 'pre' || $gameend < 60*60*24*7)
+ {
+ echo ' '._('A short comment').":\n";
+ }
+
+/* re-contra */
if($gamestatus == 'play' )
{
$myparty = DB_get_party_by_hash($me);
output_form_calls($me,$myparty);
}
-/* 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]);
-if($gamestatus == 'play' || $gameend < 60*60*24*7)
+/* play-card button */
+if($gamestatus == 'play' || $gamestatus == 'pre' || $gameend < 60*60*24*7)
{
- echo " \nA short comment:\n";
+ echo " \n";
}
-echo "\n";
-
/* has this hand been played by others? */
$other_game_ids = DB_played_by_others($gameid);
if(sizeof($other_game_ids)>0 && $mystatus=='gameover')
{
$mypos = DB_get_pos_by_hash($me);
- echo "
See how other played the same hand: \n";
+ echo "
See how other played the same hand: \n";
foreach($other_game_ids as $id)
{
$otherhash = DB_get_hash_from_game_and_pos($id,$mypos);
$othername = DB_get_name('hash',$otherhash);
- echo "$othername ";
+ echo " $othername ";
}
- echo "
\n";
+ echo " \n";
}
-echo "
\n";
+echo "\n\n"; /* end gameinfo */
+
+/* make sure that we don't show the notes to the wrong person
+ * (e.g. other people looking at an old game)
+ */
+if( $mystatus != 'gameover' ||
+ ( $mystatus == 'gameover' &&
+ isset($_SESSION['id']) &&
+ $myid == $_SESSION['id']))
+ output_user_notes($myid,$gameid,$mystatus);
echo "\n";
+/*********************************
+ * suggest next game
+ *********************************/
+
$gamestatus = DB_get_game_status_by_gameid($gameid);
if($mystatus=='gameover' &&
($gamestatus =='gameover' || $gamestatus =='cancel-nines' || $gamestatus =='cancel-trump') &&