{
/* 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
{
{
/* asks the player, if he wants to join the game */
output_check_want_to_play($me);
+ echo '<div class="mycards"></div>';
break;
}
else
$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,$message);
}
/* update game status */
$message = "It's your turn now in game ".DB_format_gameid($gameid).".\n".
"Use this link to go the game: ".$HOST.$INDEX."?action=game&me=".$hash."\n\n" ;
- mymail($who,"Ready, set, go... (game ".DB_format_gameid($gameid).") ",$message);
+ mymail($who, $gameid, GAME_READY,$message);
*/
}
}
/* move on to the next stage*/
DB_set_hand_status_by_hash($me,'check');
+ $mystatus='check';
};
};
$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, $message);
}
echo "</div>\n"; /* end div message */
/* 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" ;
- $subject = 'Ready, set, go... (game '.DB_format_gameid($gameid).')';
- mymail($who,$subject,$message);
+ mymail($who,$gameid,GAME_READY,$message);
}
}
else
/* email player for poverty */
$message = "Poverty: It's your turn now in game ".DB_format_gameid($gameid).".\n".
"Use this link to play a card: ".$HOST.$INDEX."?action=game&me=".$whohash."\n\n" ;
- $subject = 'Poverty (game '.DB_format_gameid($gameid).') ';
- mymail($whoid,$subject,$message);
+ mymail($whoid,$gameid,GAME_POVERTY,$message);
}
}
}
echo "</div>\n";
+ /* show cards */
+ echo '<div class="mycards">'._('Your cards are').": <br />\n";
+ foreach($mycards as $card)
+ display_card($card,$PREF['cardset']);
+ echo "</div>\n";
+
break;
}
/* 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" ;
- $subject = 'Ready, set, go... (game '.DB_format_gameid($gameid).') ';
- mymail($who,$subject,$message);
+ mymail($who,$gameid,GAME_READY,$message);
}
}
else
echo "<div class=\"message\">Please, <a href=\"$INDEX?action=game&me=$me\">start</a> the game.</div>\n";
+ echo '<div class="mycards"></div>'."\n"; /* needed to make sure the message area is in the right position */
}
/* the following is part A) of what needs to be done */
$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, $message);
}
/* update game status */
$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, $message);
}
}
else
$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, $message);
}
}
echo "<div class=\"message\">Please, <a href=\"$INDEX?action=game&me=$me\">continue</a> here.</div>\n";
/* 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" ;
- $subject = 'Ready, set, go... (game '.DB_format_gameid($gameid).')';
- mymail($who,$subject,$message);
+ mymail($who,$gameid, GAME_READY, $message);
}
}
}
"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, $message);
}
}
else /* send out final email */
*/
/* 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);
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;
/* 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)
* 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)
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)
if($contra > 120+$offset)
$winning_party='contra';
- else if ($call_re == NULL )
+ else if ($call_re == -1 )
$winning_party='re';
}
}
/* 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 )
{
" 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 )
{
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)
/* 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')");
}
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)
/* 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')");
}
$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);
+ mymail($userids,$gameid, GAME_OVER, $message);
}
}
else
$howmanycards = 0;
foreach($mycards as $card)
{
- if($howmanycard>1)
+ if($howmanycards>1)
break;
/* display only cards that the player is allowed to play as links, the rest just display normal
in_array($gametype,array('normal','wedding','trump','silent'))
)
)
- continue ;
+ continue;
else
$howmanycards++;
}
+
if($howmanycards==1)
$howmanycards=1;
else
)
display_card($card,$PREF['cardset']);
else
- display_link_card($card,$PREF['cardset'],$selected=$howmanycards);
+ display_link_card($card,$PREF['cardset'],$type='card',$selected=$howmanycards);
}
}
else if($mystatus=='play' )