From 4064c0f157255114c6f262f4709fea2b92460be9 Mon Sep 17 00:00:00 2001
From: Arun Persaud
Date: Sun, 13 Nov 2011 21:17:12 -0800
Subject: LAYOUT: moved output of all game message after the tricks and table
this should make the html layout more consistent and easier to manage for different screen sizes, e.g. for mobile phones
---
include/game.php | 98 ++++++++++++++++++++++++++++++++------------------------
1 file changed, 56 insertions(+), 42 deletions(-)
(limited to 'include/game.php')
diff --git a/include/game.php b/include/game.php
index 3564d9c..11cb66f 100644
--- a/include/game.php
+++ b/include/game.php
@@ -333,6 +333,12 @@ display_table();
*/
$cards_status = CARDS_EMPTY;
+/* Also collect message that should be displayed to the user, so that we can show
+ * them after showing the table. This makes the html flow more consistent and easier
+ * tournament change layouts, especially for smaller displays, e.g. mobile phones
+ */
+$messages = array();
+
switch($mystatus)
{
case 'start':
@@ -441,8 +447,8 @@ switch($mystatus)
if($Nsickness>1)
{
- echo " You selected more than one sickness, please go back ".
- "and answer the question again.
";
+ $messages[] = "You selected more than one sickness, please go back ".
+ "and answer the question again.";
$card_status = CARDS_SHOW;
@@ -451,7 +457,7 @@ switch($mystatus)
else
{
/* everything is ok, save what user said and proceed */
- echo "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);
@@ -465,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 */
@@ -482,33 +488,31 @@ 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';
@@ -542,8 +546,7 @@ switch($mystatus)
echo " \n \n\n"; /* end div trick, end li trick , end tricks*/
/* end displaying sickness */
- echo "\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);
@@ -561,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
@@ -581,7 +584,7 @@ switch($mystatus)
* are playing, in case there are any solos this already
* will have the correct information in it */
- 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);
@@ -627,8 +630,8 @@ 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')
{
@@ -640,8 +643,8 @@ 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);
@@ -650,7 +653,6 @@ switch($mystatus)
mymail($user,$gameid, GAME_CANCELED, $email_message);
}
- echo "\n"; /* end div message */
break;
}
else if($poverty==1) /* one person has poverty */
@@ -694,7 +696,7 @@ switch($mystatus)
$gametype = 'wedding';
};
/* now the gametype is set correctly in the database */
- echo ''._('Got it').' :)
';
+ $messages[] = _('Got it').' :)';
/* loop over all players, set re/contra if possible and start the game if possible */
$userids = DB_get_all_userid_by_gameid($gameid);
@@ -788,7 +790,7 @@ switch($mystatus)
}
}
else
- echo "Please, start the game.
\n";
+ $messages[] = "Please, start the game.
\n";
}
else
{
@@ -798,7 +800,7 @@ switch($mystatus)
$whoid = DB_get_userid('gameid-position',$gameid,$who);
if($whoid==$myid)
- echo "Please, start the game.
start the game.
\n";
$card_status = CARDS_SHOW;
}
break;
@@ -907,7 +908,7 @@ switch($mystatus)
}
}
else
- echo "\n";
+ $messages[]= "Please, start the game.";
}
/* the following is part A) of what needs to be done */
@@ -940,7 +941,7 @@ switch($mystatus)
}
}
echo "No way
\n";
- echo "\n";
+ echo "
\n";
}
break;
}
@@ -986,7 +987,7 @@ switch($mystatus)
/* 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
@@ -1083,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);
@@ -1096,10 +1097,9 @@ switch($mystatus)
mymail($userid,$gameid, GAME_DPOVERTY, $email_message);
}
}
- echo "\n";
+ $messages[] = "Please, continue here";
}
}
- echo "\n";
break;
case 'play':
@@ -1112,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 */
@@ -1197,8 +1197,8 @@ 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.').'
';
+ $messages[] = _('You finished the setup, but not everyone else finished it... '.
+ 'You need to wait for the others. Just wait for an email.');
$card_status = CARDS_SHOW;
@@ -1536,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
";
@@ -1859,12 +1859,12 @@ switch($mystatus)
}
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) )
@@ -1972,6 +1972,7 @@ switch($mystatus)
$mycards = DB_get_hand($me);
$mycards = mysort($mycards,$gametype);
+echo "\n";
echo '';
switch ($card_status) {
case CARDS_SHOW:
@@ -2090,8 +2091,21 @@ switch ($card_status) {
default:
break;
}
-echo '
';
+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
--
cgit v1.2.3-18-g5258