<?php
-/* Copyright 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Arun Persaud <arun@nubati.net>
+/* Copyright 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Arun Persaud <arun@nubati.net>
*
* This file is part of e-DoKo.
*
/**************************************
* get some information from the DB
**************************************/
+start:
$gameid = DB_get_gameid_by_hash($me);
$myname = DB_get_name('hash',$me);
$mystatus = DB_get_status_by_hash($me);
echo ' '._('Game')." $session.$j";
if($gamestatus != 'pre')
if($gametype_raw != 'normal') /* only show when needed */
- if(!($gametype_raw == 'solo' && $gametyep_solo == 'silent') )
+ if(!($gametype_raw == 'solo' && $gametype_solo == 'silent') )
echo " ($GT)";
if(isset($_SESSION['id']) && $_SESSION['id']==$myid)
/* output vorbehalte */
if($gametype_raw != 'normal') /* only show when needed */
- if(!($gametype_raw == 'solo' && $gametyep_solo == 'silent') )
+ if(!($gametype_raw == 'solo' && $gametype_solo == 'silent') )
echo " <li onclick=\"hl(0);\" class=\"old\"><a href=\"#\">Pre</a></li>\n";
$result = DB_query('SELECT Trick.id'.
*/
DB_set_hand_status_by_hash($me,'init');
+ $mystatus='init';
/* check if everyone has reached this stage, set player in game-table to the next player */
$userids = DB_get_all_userid_by_gameid($gameid);
break;
}
else
- {
- /* everything is ok, save what user said and proceed */
- $messages[] = _('Processing what you selected in the last step...');
+ { /* everything is ok, save what user said and proceed */
/* check if this sickness needs to be handled first */
$startplayer = DB_get_startplayer_by_gameid($gameid); /* need this to check which solo goes first */
{
/* user wants to play a solo */
+ /* double check input value */
+ $s = $_REQUEST['solo'];
+ $solos = array('trumpless','jack','queen','trump','club','spade','heart');
+ if (!in_array($s, $solos))
+ {
+ $messages[] = sprintf(_('There is a problem with the type of solo you selected (%s does not exist), please go back '.
+ 'and answer the <a href="%s">question</a> again.'),
+ $s,$INDEX.'?action=game&me=$me&in=yes');
+ break;
+ }
+
/* store the info in the user's hand info */
DB_set_solo_by_hash($me,$_REQUEST['solo']);
DB_set_sickness_by_hash($me,'solo');
* this can therefore only be handled once all players finished the last stage
*/
- $messages[] = _('Checking if someone else selected solo, nines, wedding or poverty.');
-
- /* in case the user can go do the next stage, we want to skip the break statement at the
- * end. We keep track of these cases using this variable
- */
- $nobreak=0;
-
/* check if everyone has reached this stage */
$userids = DB_get_all_userid_by_gameid($gameid);
$ok = 1;
* are playing, in case there are any solos this already
* will have the correct information in it */
- $messages[] = _('Ok, everyone is done... figuring out what kind of game we are playing.');
-
/* gametype for displaying it (hides hidden solo)*/
$GT = get_display_gametype($gameid);
$gametype = 'wedding';
};
/* now the gametype is set correctly in the database */
- $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);
}
else
{
- $messages[] = sprintf(_('Please, <a href="%s">start</a> the game.'),$INDEX."?action=game&me=$me").
- "<br />\n";
- $nobreak=1;
+ $mystatus = 'play';
+ goto play;
}
}
else
$whoid = DB_get_userid('gameid-position',$gameid,$who);
if($whoid==$myid)
{
- $messages[] = sprintf(_('Please, <a href="%s">start</a> the game.'),$INDEX."?action=game&me=$me").
- "<br /\n";
- $nobreak=1;
+ $mystatus = 'poverty';
+ goto poverty;
}
else
{
}
}
}
- if(!$nobreak)
- break;
+ break;
case 'poverty':
+ poverty:
/* user only gets here in a poverty game, several things have to be handled here:
* A) ask, if user wants to take trump
* yes-> take trump,
* it is easier to check B) first
*/
- /* in case the user can go do the next stage, we want to skip the break statement at the
- * end. We keep track of these cases using this variable
- */
- $nobreak=0;
-
set_gametype($gametype); /* this sets the $CARDS variable */
$myparty = DB_get_party_by_hash($me);
}
}
else
- $messages[]= sprintf(_('Please, <a href="%s">start</a> the game.'),$INDEX."?action=game&me=$me");
+ {
+ $mystatus = 'play';
+ goto play;
+ }
}
/* the following is part A) of what needs to be done */
}
}
$messages[] = sprintf(_('Please, <a href="%s">continue</a> here'),$INDEX."?action=game&me=$me");
- $nobreak = 1;
}
}
- if(!$nobreak)
- break;
+ break;
case 'play':
case 'gameover':
+ play:
/* both entries here, so that the tricks are visible for both.
* in case of 'play' there is a break later that skips the last part
*/
if($party1 != $party2)
DB_query("INSERT INTO Score".
- " VALUES( NULL,NULL,$gameid,'$party1',$uid1,$uid2,'fox')");
+ " VALUES(NULL,CURRENT_TIMESTAMP,$gameid,'$party1',$uid1,$uid2,'fox')");
}
}
$party1 = DB_get_party_by_gameid_and_userid($gameid,$uid1);
DB_query("INSERT INTO Score".
- " VALUES( NULL,NULL,$gameid,'$party1',$uid1,NULL,'karlchen')");
+ " VALUES( NULL,CURRENT_TIMESTAMP,$gameid,'$party1',$uid1,NULL,'karlchen')");
};
};
}; /* end scoring Karlchen */
$party1 = DB_get_party_by_gameid_and_userid($gameid,$uid1);
DB_query("INSERT INTO Score".
- " VALUES( NULL,NULL,$gameid,'$party1',$uid1,NULL,'doko')");
+ " VALUES( NULL,CURRENT_TIMESTAMP,$gameid,'$party1',$uid1,NULL,'doko')");
}
/*
for( $p=$call_contra;$p<=120; $p+=30 )
{
DB_query('INSERT INTO Score'.
- " VALUES( NULL,NULL,$gameid,'re',NULL,NULL,'against$p')");
+ " VALUES( NULL,CURRENT_TIMESTAMP,$gameid,'re',NULL,NULL,'against$p')");
}
for( $p=$call_contra; $p<120; $p+=30)
{
if( $re >= $p )
DB_query('INSERT INTO Score'.
- " VALUES( NULL,NULL,$gameid,'re',NULL,NULL,'made$p')");
+ " VALUES( NULL,CURRENT_TIMESTAMP,$gameid,'re',NULL,NULL,'made$p')");
}
}
if($winning_party!='re' and $call_re!= -1)
for( $p=$call_re;$p<=120; $p+=30 )
{
DB_query('INSERT INTO Score'.
- " VALUES( NULL,NULL,$gameid,'contra',NULL,NULL,'against$p')");
+ " VALUES( NULL,CURRENT_TIMESTAMP,$gameid,'contra',NULL,NULL,'against$p')");
}
for( $p=$call_re; $p<120; $p+=30)
{
if( $contra>=$p )
DB_query('INSERT INTO Score'.
- " VALUES( NULL,NULL,$gameid,'contra',NULL,NULL,'made$p')");
+ " VALUES( NULL,CURRENT_TIMESTAMP,$gameid,'contra',NULL,NULL,'made$p')");
}
}
if($winning_party=='contra')
{
DB_query('INSERT INTO Score'.
- " VALUES( NULL,NULL,$gameid,'contra',NULL,NULL,'againstqueens')");
+ " VALUES( NULL,CURRENT_TIMESTAMP,$gameid,'contra',NULL,NULL,'againstqueens')");
}
/* one point each for winning and each 30 points + calls */
if($re>$p-$offset)
DB_query('INSERT INTO Score'.
- " VALUES( NULL,NULL,$gameid,'re',NULL,NULL,'".(240-$p)."')");
+ " VALUES( NULL,CURRENT_TIMESTAMP,$gameid,'re',NULL,NULL,'".(240-$p)."')");
}
/* re called something and won */
foreach(array(0,30,60,90,120) as $p)
{
if($call_re!= -1 && $call_re<$p+1)
DB_query('INSERT INTO Score'.
- " VALUES( NULL,NULL,$gameid,'re',NULL,NULL,'call$p')");
+ " VALUES( NULL,CURRENT_TIMESTAMP,$gameid,'re',NULL,NULL,'call$p')");
}
}
else if( $winning_party=='contra')
if($contra>$p-$offset)
DB_query('INSERT INTO Score'.
- " VALUES( NULL,NULL,$gameid,'contra',NULL,NULL,'".(240-$p)."')");
+ " VALUES( NULL,CURRENT_TIMESTAMP,$gameid,'contra',NULL,NULL,'".(240-$p)."')");
}
/* re called something and won */
foreach(array(0,30,60,90,120) as $p)
{
if($call_contra != -1 && $call_contra<$p+1)
DB_query('INSERT INTO Score'.
- " VALUES( NULL,NULL,$gameid,'contra',NULL,NULL,'call$p')");
+ " VALUES( NULL,CURRENT_TIMESTAMP,$gameid,'contra',NULL,NULL,'call$p')");
}
};
* this outputs status of healthy, *
* sick, etc during pre-game phase *
**********************************/
+
+$posmax=5; // if user is still in init, we only show vorbehalte from players before him, otherwise all of them
+
switch($mystatus)
{
case 'start':
break;
case 'init':
+ $posmax=$mypos;
case 'check':
/* output sickness of other playes, in case they already selected and are sitting in front of the current player */
echo "\n".'<div class="tricks">'."\n";
echo ' <div class="trick" id="trick0">'."\n";
- for($pos=1;$pos<5;$pos++)
+ for($pos=1;$pos<$posmax;$pos++)
{
$usersick = DB_get_sickness_by_pos_and_gameid($pos,$gameid);
$userid = DB_get_userid('gameid-position',$gameid,$pos);