Processing what you selected in the last step...";
+ $messages[] = "Processing what you selected in the last step...";
/* check if this sickness needs to be handled first */
$gametype = DB_get_gametype_by_gameid($gameid);
@@ -474,7 +471,7 @@ switch($mystatus)
DB_set_solo_by_hash($me,$_REQUEST['solo']);
DB_set_sickness_by_hash($me,'solo');
- echo " Seems like you want to play a {$_REQUEST['solo']} solo. Got it. \n";
+ $messages[] = " Seems like you want to play a {$_REQUEST['solo']} solo. Got it. \n";
if($gametype == 'solo' && $startplayer<$mypos)
{}/* do nothing, since someone else already is playing solo */
@@ -491,35 +488,34 @@ switch($mystatus)
else if($_REQUEST['wedding'] == 'yes')
{
/* silent solo is set further down */
- echo _("Ok, you don't want to play a silent solo...wedding was chosen.")." \n";
+ $messages[] = _("Ok, you don't want to play a silent solo...wedding was chosen.")." \n";
DB_set_sickness_by_hash($me,'wedding');
}
else if($_REQUEST['poverty'] == 'yes')
{
- echo _("Don't think you can win with just a few trump...? Ok, poverty chosen.")." \n";
+ $messages[] = _("Don't think you can win with just a few trump...? Ok, poverty chosen.")." \n";
DB_set_sickness_by_hash($me,'poverty');
}
else if($_REQUEST['nines'] == 'yes')
{
- echo _("What? You just don't want to play a game because you have a few nines? Well, if no one".
+ $messages[] = _("What? You just don't want to play a game because you have a few nines? Well, if no one".
" is playing solo, this game will be canceled.")." \n";
DB_set_sickness_by_hash($me,'nines');
}
else if($_REQUEST['lowtrump'] == 'yes')
{
if($RULES['lowtrump']=='cancel')
- echo _("What? You just don't want to play a game because you have low trump? Well, if no one".
+ $messages[] = _("What? You just don't want to play a game because you have low trump? Well, if no one".
" is playing solo, this game will be canceled.")." \n";
else
- echo _("Don't think you can win with low trumps...? Ok, poverty chosen.")." . \n";
+ $messages[] = _("Don't think you can win with low trumps...? Ok, poverty chosen.")." . \n";
DB_set_sickness_by_hash($me,'lowtrump');
}
- echo "
\n";
-
/* move on to the next stage*/
DB_set_hand_status_by_hash($me,'check');
+ $mystatus='check';
};
};
@@ -528,12 +524,8 @@ switch($mystatus)
* this can therefore only be handled once all players finished the last stage
*/
- $mycards = DB_get_hand($me);
- $mycards = mysort($mycards,$gametype);
-
- /* output sickness of other playes, in case the already selected and are sitting in front of the current player */
+ /* output sickness of other playes, in case they already selected and are sitting in front of the current player */
echo "\n\n";
- echo '
'._('Checking if someone else selected solo, nines, wedding or poverty.').'
';
+ $messages[] = _('Checking if someone else selected solo, nines, wedding or poverty.');
/* check if everyone has reached this stage */
$userids = DB_get_all_userid_by_gameid($gameid);
@@ -573,10 +564,10 @@ switch($mystatus)
if(!$ok)
{
- echo '
'._('This step can only be handled after everyone finished the last step. '.
+ $messages[] = _('This step can only be handled after everyone finished the last step. '.
'Seems like this is not the case, so you need to wait a bit... '.
'you will get an email once that is the case, please use the link in '.
- 'that email to continue the game.').'
';
+ 'that email to continue the game.');
/* display cards, if player was just at the init-phase he will still see the cards from there
* we can put this one here, since the last player to finish the init state won't get here and
@@ -584,13 +575,8 @@ switch($mystatus)
*/
if($mystatus=='check')
{
- /* show cards */
- echo ''._('Ok, everyone is done... figuring out what kind of game we are playing.').'
';
+ $messages[] = _('Ok, everyone is done... figuring out what kind of game we are playing.');
$gametype = DB_get_gametype_by_gameid($gameid);
$startplayer = DB_get_startplayer_by_gameid($gameid);
@@ -636,7 +622,7 @@ switch($mystatus)
/* cancel game */
if($cancelsick == 'nines')
{
- $message = "The game has been canceled because ".DB_get_name('userid',$cancel).
+ $email_message = "The game has been canceled because ".DB_get_name('userid',$cancel).
" has five or more nines and nobody is playing solo.\n\n".
"To redeal either start a new game or, in case the game was part of a tournament,\n".
"go to the last game and use the link at the bottom of the page to redeal.\n\n";
@@ -644,12 +630,12 @@ switch($mystatus)
/* update game status */
cancel_game('nines',$gameid);
- echo "The game has been canceled because ".DB_get_name('userid',$cancel).
- " has five or more nines and nobody is playing solo.
\n";
+ $messages[] = "The game has been canceled because ".DB_get_name('userid',$cancel).
+ " has five or more nines and nobody is playing solo.";
}
else if ($cancelsick == 'lowtrump')
{
- $message = "The game has been canceled because ".DB_get_name('userid',$cancel).
+ $email_message = "The game has been canceled because ".DB_get_name('userid',$cancel).
" has low trump and nobody is playing solo.\n\n".
"To redeal either start a new game or, in case the game was part of a tournament,\n".
"go to the last game and use the link at the bottom of the page to redeal.\n\n";
@@ -657,18 +643,16 @@ switch($mystatus)
/* update game status */
cancel_game('lowtrump',$gameid);
- echo "The game has been canceled because ".DB_get_name('userid',$cancel).
- " has low trump and nobody is playing solo.
\n";
+ $messages[] = "The game has been canceled because ".DB_get_name('userid',$cancel).
+ " has low trump and nobody is playing solo.";
};
$userids = DB_get_all_userid_by_gameid($gameid);
foreach($userids as $user)
{
- $subject = 'Game '.DB_format_gameid($gameid).' canceled';
- mymail($user,$subject,$message);
+ mymail($user,$gameid, GAME_CANCELED, $email_message);
}
- echo "\n"; /* end div message */
break;
}
else if($poverty==1) /* one person has poverty */
@@ -712,7 +696,7 @@ switch($mystatus)
$gametype = 'wedding';
};
/* now the gametype is set correctly in the database */
- echo '\n";
- echo " Game ".DB_format_gameid($gameid).": \n";
$mygametype = DB_get_gametype_by_gameid($gameid);
@@ -898,17 +875,16 @@ switch($mystatus)
}
/* end output pre-game trick */
+ /* get hand */
+ $mycards = DB_get_hand($me);
+
+ /* default: show cards, will be overwritten, if we need to give back cards */
+ $card_status = CARDS_SHOW;
+
/* check if user need to give more cards back */
if( ($myparty=='re' || $myparty=='contra') && count($mycards)>12)
{
- echo ' '._('You need to get rid of a few cards')."
\n";
-
- $type='exchange';
- echo ''._('Your cards are').": \n";
- foreach($mycards as $card)
- display_link_card($card,$PREF['cardset'],$type);
- echo " \n";
- echo "
\n";
+ $card_status = CARDS_EXCHANGE;
}
else if( ($myparty=='re' || $myparty=='contra') && count($mycards)==12)
{
@@ -926,14 +902,13 @@ switch($mystatus)
if(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);
}
}
else
- echo "\n";
+ $messages[]= "Please, start the game.";
}
/* the following is part A) of what needs to be done */
@@ -966,12 +941,7 @@ switch($mystatus)
}
}
echo "No way \n";
- echo "\n";
-
- echo '
'._('Your cards are').": \n";
- foreach($mycards as $card)
- display_card($card,$PREF['cardset']);
- echo "
\n";
+ echo "\n";
}
break;
}
@@ -1005,20 +975,19 @@ switch($mystatus)
/* no more people to ask, need to cancel the game */
if($mypos+$next>4)
{
- $message = "Hello, \n\n".
+ $email_message = "Hello, \n\n".
"Game ".DB_format_gameid($gameid)." has been canceled since nobody wanted to take the trump.\n\n";
$userids = DB_get_all_userid_by_gameid($gameid);
foreach($userids as $user)
{
- $subject = 'Game '.DB_format_gameid($gameid).' canceled (poverty not resolved)';
- mymail($user,$subject,$message);
+ mymail($user, $gameid, GAME_CANCELED_POVERTY, $email_message);
}
/* update game status */
cancel_game('trump',$gameid);
- echo "Game ".DB_format_gameid($gameid)." has been canceled.
";
+ $messages[] = "Game ".DB_format_gameid($gameid)." has been canceled.";
break;
}
else
@@ -1030,11 +999,12 @@ switch($mystatus)
DB_set_player_by_gameid($gameid,$userid);
DB_set_hand_status_by_hash($userhash,'poverty');
- $message = "Someone has poverty, it's your turn to decide, if you want to take the trump. Please visit:".
+ $email_message = "Someone has poverty, it's your turn to decide, if you want to take the trump. Please visit:".
" ".$HOST.$INDEX."?action=game&me=".$userhash."\n\n" ;
- $subject = 'Poverty (game '.DB_format_gameid($gameid).')';
- mymail($userid,$subject,$message);
+ mymail($userid,$gameid, GAME_POVERTY, $email_message);
}
+
+ $cards_status = CARDS_SHOW;
}
else
{
@@ -1114,7 +1084,7 @@ switch($mystatus)
$next=2;
if($mypos+$next>4)
- echo "Error in poverty, please contact the Admin
\n";
+ $messages[] = "Error in poverty, please contact the Admin";
$userhash = DB_get_hash_from_game_and_pos($gameid,$mypos+$next);
$userid = DB_get_userid('hash',$userhash);
@@ -1122,16 +1092,14 @@ switch($mystatus)
DB_set_player_by_gameid($gameid,$userid);
DB_set_hand_status_by_hash($userhash,'poverty');
- $message = "Two people have poverty, it's your turn to decide, if you want to take the trump. Please visit:".
+ $email_message = "Two people have poverty, it's your turn to decide, if you want to take the trump. Please visit:".
" ".$HOST.$INDEX."?action=game&me=".$userhash."\n\n" ;
- $subject = 'Double poverty (game '.DB_format_gameid($gameid).')';
- mymail($userid,$subject,$message);
+ mymail($userid,$gameid, GAME_DPOVERTY, $email_message);
}
}
- echo "\n";
+ $messages[] = "Please, continue here";
}
}
- echo "\n";
break;
case 'play':
@@ -1144,19 +1112,19 @@ switch($mystatus)
switch($gamestatus)
{
case 'cancel-noplay':
- echo "The game has been canceled due to the request of one player.
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 due to the request of one player.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 +1164,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,16 +1197,10 @@ 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);
+ $messages[] = _('You finished the setup, but not everyone else finished it... '.
+ 'You need to wait for the others. Just wait for an email.');
- echo ''._('Your cards are').": \n";
- foreach($mycards as $card)
- display_card($card,$PREF['cardset']);
- echo "
\n";
+ $card_status = CARDS_SHOW;
break; /* not sure this works... the idea is that you can
* only play a card after everyone is ready to play */
@@ -1288,20 +1249,21 @@ switch($mystatus)
$firstcard = ''; /* first card in a trick */
echo "\n\n";
- echo ' '._('Game').' '.DB_format_gameid($gameid).": \n";
/* output vorbehalte */
- $mygametype = DB_get_gametype_by_gameid($gameid);
- if($mygametype != 'normal' && $mygametype != 'silent') /* only show when needed */
- {
- echo " Pre \n".
- " \n";
+ $mygametype = DB_get_gametype_by_gameid($gameid);
+ $mygamesolo = DB_get_solo_by_gameid($gameid);
+ if($mygametype != 'normal') /* only show when needed */
+ if(!( $mygametype == 'solo' && $mygamesolo == 'silent') )
+ {
+ echo "
Pre \n".
+ " \n";
- /* get information so show the cards that have been handed over in a poverty game */
- output_exchanged_cards();
+ /* get information so show the cards that have been handed over in a poverty game */
+ output_exchanged_cards();
- echo "
\n \n"; /* end div trick, end li trick */
- }
+ echo "
\n \n"; /* end div trick, end li trick */
+ }
/* output tricks */
while($r = DB_fetch_array($result))
@@ -1574,7 +1536,7 @@ switch($mystatus)
if($winner>0)
DB_query("UPDATE Trick SET winner='$winner' WHERE id='$trickid'");
else
- echo "ERROR during scoring";
+ $messages[] = "ERROR during scoring";
if($debug)
echo "DEBUG: position $winner won the trick ";
@@ -1645,13 +1607,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 +1626,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 +1639,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 +1657,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 +1671,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 +1689,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 +1703,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 +1711,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 +1723,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 +1731,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 +1746,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 +1775,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 +1785,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 +1795,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 +1805,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 +1813,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,21 +1851,20 @@ 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) )
@@ -1974,84 +1934,21 @@ switch($mystatus)
echo " "._('next')." \n";
echo " \n"; /* end ul tricks*/
- $mycards = DB_get_hand($me);
- $mycards = mysort($mycards,$gametype);
- echo "\n";
-
if($myturn && !myisset('card') && $mystatus=='play' )
{
- 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')
@@ -2066,8 +1963,154 @@ switch($mystatus)
break;
default:
myerror("error in testing the status");
+ } /*end of output: tricks, table, messages, card */
+
+/**************
+ * 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";
+
+/*****************
+ * show messages *
+ *****************/
+
+if( sizeof($messages) )
+ {
+ echo "\n\n";
+ foreach($messages as $message)
+ {
+ echo "
\n";
+ }
+ echo "
\n\n";
}
+/***********************************************
+ * Comments, re/contra calls, user menu
+ ***********************************************/
+
/* 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
*/
@@ -2076,13 +2119,13 @@ if( $gamestatus != 'gameover' )
/* game isn't over, only valid user can get here, so show menu */
display_user_menu($myid);
}
-else if( $origmystatus != 'gameover' )
+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']) )
+else if( $mystatus == 'gameover'
+ && isset($_SESSION['id']) )
{
/* user is looking at someone else's game, show the menu for the correct user */
display_user_menu($_SESSION['id']);
@@ -2092,7 +2135,7 @@ else
echo "\n";
+ echo "\n\n";
}
/*
@@ -2139,10 +2182,23 @@ if(sizeof($other_game_ids)>0 && $mystatus=='gameover')
echo " \n";
}
-echo "\n"; /* end gameinfo */
+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 "