\n".
- "
\n";
+ echo '
\n".
+ '
\n";
}
- echo "
\n ";
+ echo '
\n ";
/* display comments */
display_card($card,$PREF['cardset']);
@@ -1536,7 +1679,7 @@ switch($mystatus)
echo "\n \n";
echo "
\n";
- echo "
\n \n"; /* end div trick, end li 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)
@@ -1563,48 +1706,48 @@ switch($mystatus)
if(DB_get_game_status_by_gameid($gameid)=='play')
{
$next_hash = DB_get_hash_from_game_and_pos($gameid,$next);
- $who = DB_get_userid('hash',$next_hash);
- DB_set_player_by_gameid($gameid,$who);
+ $userid = DB_get_userid('hash',$next_hash);
+ DB_set_player_by_gameid($gameid,$userid);
- $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' )
+ if( DB_get_email_pref_by_uid($userid)!='emailaddict' )
{
- $subject = 'A card has been played in game '.DB_format_gameid($gameid);
- mymail($who,$subject,$message);
+ set_language($userid,'uid');
+ $email_message = sprintf(_("A card has been played in game %s.\n\n".
+ "It's your turn now.\n".
+ 'Use this link to play a card: '),DB_format_gameid($gameid)).$HOST.$INDEX.'?action=game&me='.$next_hash."\n\n" ;
+ mymail($userid,$gameid, GAME_YOUR_TURN, $email_message);
+ set_language($myid,'uid');
}
}
else /* send out final email */
{
/* individual score */
- $result = DB_query("SELECT User.fullname, IFNULL(SUM(Card.points),0), Hand.party FROM Hand".
- " LEFT JOIN Trick ON Trick.winner=Hand.position AND Trick.game_id=Hand.game_id".
- " LEFT JOIN User ON User.id=Hand.user_id".
- " LEFT JOIN Play ON Trick.id=Play.trick_id".
- " LEFT JOIN Hand_Card ON Hand_Card.id=Play.hand_card_id".
- " 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";
+ $result = DB_query('SELECT User.fullname, IFNULL(SUM(Card.points),0), Hand.party FROM Hand'.
+ ' LEFT JOIN Trick ON Trick.winner=Hand.position AND Trick.game_id=Hand.game_id'.
+ ' LEFT JOIN User ON User.id=Hand.user_id'.
+ ' LEFT JOIN Play ON Trick.id=Play.trick_id'.
+ ' LEFT JOIN Hand_Card ON Hand_Card.id=Play.hand_card_id'.
+ ' LEFT JOIN Card ON Card.id=Hand_Card.card_id'.
+ " WHERE Hand.game_id=".DB_quote_smart($gameid).
+ ' GROUP BY User.fullname' );
+ $email_final_score="";
while( $r = DB_fetch_array($result) )
- $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".
- " LEFT JOIN User ON User.id=Hand.user_id".
- " LEFT JOIN Play ON Trick.id=Play.trick_id".
- " LEFT JOIN Hand_Card ON Hand_Card.id=Play.hand_card_id".
- " LEFT JOIN Card ON Card.id=Hand_Card.card_id".
- " WHERE Hand.game_id='$gameid'".
- " GROUP BY Hand.party" );
- $message .= "\nTotals:\n";
+ $email_final_score .= ' '.$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'.
+ ' LEFT JOIN User ON User.id=Hand.user_id'.
+ ' LEFT JOIN Play ON Trick.id=Play.trick_id'.
+ ' LEFT JOIN Hand_Card ON Hand_Card.id=Play.hand_card_id'.
+ ' LEFT JOIN Card ON Card.id=Hand_Card.card_id'.
+ " WHERE Hand.game_id=".DB_quote_smart($gameid).
+ ' GROUP BY Hand.party' );
+ $email_totals="";
$re = 0;
$contra = 0;
while( $r = DB_fetch_array($result) )
{
- $message .= " ".$r[0]." ".$r[1]."\n";
+ $email_totals .= ' '.$r[0].' '.$r[1]."\n";
if($r[0] == 're')
$re = $r[1];
else if($r[0] == 'contra')
@@ -1617,8 +1760,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);
@@ -1631,14 +1774,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;
@@ -1649,7 +1792,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)
@@ -1663,7 +1806,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)
@@ -1671,11 +1814,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)
@@ -1683,7 +1826,7 @@ switch($mystatus)
if($contra > 120+$offset)
$winning_party='contra';
- else if ($call_re == NULL )
+ else if ($call_re == -1 )
$winning_party='re';
}
}
@@ -1691,33 +1834,33 @@ 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 )
{
- DB_query("INSERT INTO Score".
+ DB_query('INSERT INTO Score'.
" VALUES( NULL,NULL,$gameid,'re',NULL,NULL,'against$p')");
}
for( $p=$call_contra; $p<120; $p+=30)
{
if( $re >= $p )
- DB_query("INSERT INTO Score".
+ DB_query('INSERT INTO Score'.
" 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 )
{
- DB_query("INSERT INTO Score".
+ DB_query('INSERT INTO Score'.
" VALUES( NULL,NULL,$gameid,'contra',NULL,NULL,'against$p')");
}
for( $p=$call_re; $p<120; $p+=30)
{
if( $contra>=$p )
- DB_query("INSERT INTO Score".
+ DB_query('INSERT INTO Score'.
" VALUES( NULL,NULL,$gameid,'contra',NULL,NULL,'made$p')");
}
}
@@ -1725,7 +1868,7 @@ switch($mystatus)
/* point in case contra won */
if($winning_party=='contra')
{
- DB_query("INSERT INTO Score".
+ DB_query('INSERT INTO Score'.
" VALUES( NULL,NULL,$gameid,'contra',NULL,NULL,'againstqueens')");
}
@@ -1735,18 +1878,18 @@ 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)
- DB_query("INSERT INTO Score".
+ DB_query('INSERT INTO Score'.
" VALUES( NULL,NULL,$gameid,'re',NULL,NULL,'".(240-$p)."')");
}
/* re called something and won */
foreach(array(0,30,60,90,120) as $p)
{
- if($call_re!=NULL && $call_re<$p+1)
- DB_query("INSERT INTO Score".
+ if($call_re!= -1 && $call_re<$p+1)
+ DB_query('INSERT INTO Score'.
" VALUES( NULL,NULL,$gameid,'re',NULL,NULL,'call$p')");
}
}
@@ -1755,55 +1898,50 @@ 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)
- DB_query("INSERT INTO Score".
+ DB_query('INSERT INTO Score'.
" VALUES( NULL,NULL,$gameid,'contra',NULL,NULL,'".(240-$p)."')");
}
/* re called something and won */
foreach(array(0,30,60,90,120) as $p)
{
- if($call_contra!=NULL && $call_contra<$p+1)
- DB_query("INSERT INTO Score".
+ if($call_contra != -1 && $call_contra<$p+1)
+ DB_query('INSERT INTO Score'.
" VALUES( NULL,NULL,$gameid,'contra',NULL,NULL,'call$p')");
}
- }
-
+ };
/* add score points to email */
- $message .= "\n";
$Tpoint = 0;
- $message .= " Points Re: \n";
- $queryresult = DB_query("SELECT score FROM Score ".
- " WHERE game_id=$gameid AND party='re'".
- " ");
+
+ $email_points_re="";
+ $queryresult = DB_query('SELECT score FROM Score '.
+ " WHERE game_id=".DB_quote_smart($gameid)." AND party='re'");
while($r = DB_fetch_array($queryresult) )
{
- $message .= " ".$r[0]."\n";
+ $email_points_re .= ' '.$r[0]."\n";
$Tpoint ++;
}
- $message .= " Points Contra: \n";
- $queryresult = DB_query("SELECT score FROM Score ".
- " WHERE game_id=$gameid AND party='contra'".
- " ");
+
+ $email_points_contra="";
+ $queryresult = DB_query('SELECT score FROM Score '.
+ " WHERE game_id=".DB_quote_smart($gameid)." AND party='contra'");
while($r = DB_fetch_array($queryresult) )
{
- $message .= " ".$r[0]."\n";
+ $email_points_contra .= ' '.$r[0]."\n";
$Tpoint --;
}
- $message .= " Total Points (from the Re point of view): $Tpoint\n";
- $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_score_table = format_score_table_ascii($score);
- /* send out final email */
+ /* add user links */
+ $email_user_links="";
foreach($userids as $user)
{
/* add links for all players */
@@ -1811,160 +1949,128 @@ switch($mystatus)
$name = DB_get_name('userid',$user);
$link = "$name: ".$HOST.$INDEX."?action=game&me=".$hash."\n" ;
- $message .= $link;
+ $email_user_links .= $link;
+ }
+
+ foreach($userids as $user)
+ {
+ /* set correct language for this user */
+ set_language($user,'uid');
+
+ /* generate message */
+ $email_message = _("The game is over. Thanks for playing :)")."\n";
+ $email_message .= _("Final score:")."\n";
+ $email_message .= $email_final_score;
+ $email_message .= "\n"._("Totals:")."\n";
+ $email_message .= $email_totals;
+ $email_message .= "\n "._("Points Re:")." \n";
+ $email_message .= $email_points_re;
+ $email_message .= " "._("Points Contra:")." \n";
+ $email_message .= $email_points_contra;
+ $email_message .= " "._("Total Points (from the Re point of view):")." $Tpoint\n\n";
+ $email_message .= _("Score Table:")."\n";
+ $email_message .= $email_score_table;
+ $email_message .= "\n"._("Use these links to have a look at game")." ".DB_format_gameid($gameid).": \n";
+ $email_message .= $email_user_links;
+ $email_message .= "\n\n "._("(use in-game comments to reach all players)")."\n\n";
+
+ /* send email */
+ mymail($user,$gameid, GAME_OVER, $email_message);
}
- $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);
+ /* reset language */
+ set_language($myid,'uid');
}
}
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