\n".
- "
\n";
+ echo '
\n".
+ '
\n";
}
- echo "
\n ";
+ echo '
\n ";
/* display comments */
display_card($card,$PREF['cardset']);
@@ -1569,7 +1636,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)
@@ -1596,46 +1663,47 @@ switch($mystatus)
if(DB_get_game_status_by_gameid($gameid)=='play')
{
$next_hash = DB_get_hash_from_game_and_pos($gameid,$next);
- $email = DB_get_email('hash',$next_hash);
- $who = DB_get_userid('email',$email);
- 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".
+ $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' )
- mymail($email,$EmailName."a card has been played in game ".DB_format_gameid($gameid),$message);
+ 'Use this link to play a card: '.$HOST.$INDEX.'?action=game&me='.$next_hash."\n\n" ;
+ if( DB_get_email_pref_by_uid($userid)!='emailaddict' )
+ {
+ mymail($userid,$gameid, GAME_YOUR_TURN, $email_message);
+ }
}
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".
+ $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";
+ ' GROUP BY User.fullname' );
+ $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";
-
- $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".
+ $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'.
+ ' 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";
+ ' GROUP BY Hand.party' );
+ $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')
@@ -1648,8 +1716,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);
@@ -1662,14 +1730,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;
@@ -1680,7 +1748,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)
@@ -1694,7 +1762,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)
@@ -1702,11 +1770,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)
@@ -1714,7 +1782,7 @@ switch($mystatus)
if($contra > 120+$offset)
$winning_party='contra';
- else if ($call_re == NULL )
+ else if ($call_re == -1 )
$winning_party='re';
}
}
@@ -1722,33 +1790,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')");
}
}
@@ -1756,7 +1824,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')");
}
@@ -1766,18 +1834,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')");
}
}
@@ -1786,215 +1854,154 @@ 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";
+ $email_message .= "\n";
$Tpoint = 0;
- $message .= " Points Re: \n";
- $queryresult = DB_query("SELECT score FROM Score ".
- " WHERE game_id=$gameid AND party='re'".
- " ");
+ $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";
- $queryresult = DB_query("SELECT score FROM Score ".
- " WHERE game_id=$gameid AND party='contra'".
- " ");
+ $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 */
- $all = array();
-
foreach($userids as $user)
{
- $all[] = DB_get_email('userid',$user);
-
/* add links for all players */
$hash = DB_get_hash_from_gameid_and_userid($gameid,$user);
$name = DB_get_name('userid',$user);
$link = "$name: ".$HOST.$INDEX."?action=game&me=".$hash."\n" ;
- $message .= $link;
+ $email_message .= $link;
}
- $To = implode(",",$all);
-
- $message .= "\n\n (you can use reply all on this email to reach all the players.)\n";
- mymail($To,$EmailName."Game over (game ".DB_format_gameid($gameid).") ",$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