summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArun Persaud <arun@nubati.net>2007-06-28 22:36:51 +0200
committerArun Persaud <arun@nubati.net>2007-06-28 22:36:51 +0200
commit906d4b7166440641b753148f9b9f158b2e1f2c0f (patch)
treec3cabb046940e94376e7f211b5ed6cfc6344e9f9
parent300806c8ee000d70fcedf21abd643d6be1c33f55 (diff)
downloade-DoKo-906d4b7166440641b753148f9b9f158b2e1f2c0f.tar.gz
e-DoKo-906d4b7166440641b753148f9b9f158b2e1f2c0f.tar.bz2
e-DoKo-906d4b7166440641b753148f9b9f158b2e1f2c0f.zip
BUGFIX: reload during the setup could mess up the state machine
if a user hits reload during the questions for the vorbehalt, the server printed an error message and the game could not continue. Now this is detected and the user is send back to the right page during the setup and can continue normally.
-rw-r--r--index.php35
-rw-r--r--output.php6
2 files changed, 22 insertions, 19 deletions
diff --git a/index.php b/index.php
index 2c0045d..f5060a0 100644
--- a/index.php
+++ b/index.php
@@ -339,24 +339,30 @@ else if(myisset("me"))
switch($mystatus)
{
case 'start':
- check_want_to_play($me);
- /* move on to the next stage*/
- DB_set_hand_status_by_hash($me,'init');
- break;
+ if( !myisset("in") )
+ {
+ check_want_to_play($me);
+ break;
+ }
+ else
+ {
+ /* move on to the next stage*/
+ DB_set_hand_status_by_hash($me,'init');
+ }
case 'init':
/* first check if everything went ok in the last step
* if not, send user back, if yes, check what he did
*/
if( !myisset("in") )
{
- echo "<p> you need to answer the <a href=\"$host?me=$me\">question</a>.</p>";
+ echo "<p> You need to answer the <a href=\"$host?me=$me\">question</a>.</p>";
DB_set_hand_status_by_hash($me,'start');
}
else
{
if($_REQUEST["in"] == "no")
{
- /* cancle the game */
+ /* cancel the game */
$message = "Hello, \n\n".
"the game has been canceled due to the request of one of the players.\n";
@@ -372,7 +378,7 @@ else if(myisset("me"))
}
else
{
- echo "thanks for joining the game...";
+ echo "Thanks for joining the game...";
$mycards = DB_get_hand($me);
sort($mycards);
@@ -393,17 +399,20 @@ else if(myisset("me"))
/* ok, user is in the game, saw his cards and selected his vorbehalt
* so first we check what he selected
*/
- echo "Processing what you selected in the last step...<br />";
-
if(!myisset("solo","wedding","poverty","nines") )
{
/* all these variables have a pre-selected default,
* so we should never get here,
- * unless a user tries to cheat ;) */
- echo "something went wrong during the setup...please contact the $ADMIN_NAME at $ADMIN_EMAIL.";
+ * unless a user tries to cheat ;)
+ * can also happen if user reloads the page!
+ */
+ echo "<p> You need to answer the <a href=\"$host?me=$me&in=yes\">questions</a>.</p>";
+ DB_set_hand_status_by_hash($me,'init');
}
else
{
+ echo "Processing what you selected in the last step...<br />";
+
/* check if this sickness needs to be handled first */
$gametype = DB_get_gametype_by_gameid($gameid);
$startplayer = DB_get_startplayer_by_gameid($gameid);
@@ -493,7 +502,7 @@ else if(myisset("me"))
* set that one in the Game table
* tell people about it.
*/
- echo "<br /> Checking if someone else selected solo, nines or wedding or poverty.<br />";
+ echo "<br /> Checking if someone else selected solo, nines, wedding or poverty.<br />";
/* check if everyone has reached this stage */
$userids = DB_get_all_userid_by_gameid($gameid);
@@ -635,7 +644,7 @@ else if(myisset("me"))
foreach($userids as $user)
{
/* userids are sorted by position...
- * so output whatever the firstone has, then whatever the next one has
+ * so output whatever the first one has, then whatever the next one has
* stop when the sickness is the same as the gametype
*/
diff --git a/output.php b/output.php
index f22c6df..59cfeea 100644
--- a/output.php
+++ b/output.php
@@ -263,13 +263,7 @@ function check_want_to_play($me)
Do you want to play a game of DoKo?
yes<input type="radio" name="in" value="yes" />
no<input type="radio" name="in" value="no" /> <br />
-
<?php
-/*
- Do you want to get an email for every card played or only if it your move?
- every card<input type="radio" name="update" value="card" />
- only on my turn<input type="radio" name="update" value="turn" /> <br />
-*/
echo "<input type=\"hidden\" name=\"me\" value=\"$me\" />\n";
echo "\n";
echo "<input type=\"submit\" value=\"count me in\" />\n";