X-Git-Url: https://git.nubati.net/cgi-bin/gitweb.cgi?p=e-DoKo.git;a=blobdiff_plain;f=index.php;h=7addf0ef375a7f371238ffda434f372b3c2fbef9;hp=40fc4122cac2c5565fffafd716e8e4f32d7365df;hb=a0b3efd697ed19fe2bf204868ab5920e4af5d467;hpb=fb8907b3f2daf368222f514d5ff36a059e330a0d
diff --git a/index.php b/index.php
index 40fc412..7addf0e 100644
--- a/index.php
+++ b/index.php
@@ -31,12 +31,15 @@ if(myisset("new"))
output_form_for_new_game($names);
}
/*check if everything is ready to set up a new game */
-else if( myisset("PlayerA", "PlayerB","PlayerC","PlayerD" ))
+ else if( myisset("PlayerA", "PlayerB","PlayerC","PlayerD","dullen","schweinchen" ))
{
$PlayerA = $_REQUEST["PlayerA"];
$PlayerB = $_REQUEST["PlayerB"];
$PlayerC = $_REQUEST["PlayerC"];
$PlayerD = $_REQUEST["PlayerD"];
+
+ $dullen = $_REQUEST["dullen"];
+ $schweinchen = $_REQUEST["schweinchen"];
$EmailA = DB_get_email_by_name($PlayerA);
$EmailB = DB_get_email_by_name($PlayerB);
@@ -46,6 +49,7 @@ else if( myisset("PlayerA", "PlayerB","PlayerC","PlayerD" ))
if($EmailA=="" || $EmailB=="" || $EmailC=="" || $EmailD=="")
{
echo "couldn't find one of the names, please start a new game";
+ output_footer();
exit();
}
@@ -58,25 +62,39 @@ else if( myisset("PlayerA", "PlayerB","PlayerC","PlayerD" ))
$randomNR = create_array_of_random_numbers();
$randomNRstring = join(":",$randomNR);
+ /* get ruleset information or create new one */
+ $ruleset = DB_get_ruleset($dullen,$schweinchen);
+ if($ruleset <0)
+ {
+ echo "Error defining ruleset: $ruleset";
+ output_footer();
+ exit();
+ };
+
/* create game */
$followup = NULL;
if(myisset("followup") )
{
$followup= $_REQUEST["followup"];
$session = DB_get_session_by_gameid($followup);
+ $ruleset = DB_get_ruleset_by_gameid($followup); /* just copy ruleset from old game,
+ this way no manipulation is possible */
if($session)
- mysql_query("INSERT INTO Game VALUES (NULL, NULL, '$randomNRstring', 'normal', NULL,'1','pre','$session' ,NULL)");
+ mysql_query("INSERT INTO Game VALUES (NULL, NULL, '$randomNRstring', 'normal', NULL,'1','pre',".
+ "'$ruleset','$session' ,NULL)");
else
{
/* get max session */
$max = DB_get_max_session();
$max++;
- mysql_query("INSERT INTO Game VALUES (NULL, NULL, '$randomNRstring', 'normal', NULL,'1','pre','$max' ,NULL)");
+ mysql_query("INSERT INTO Game VALUES (NULL, NULL, '$randomNRstring', 'normal', NULL,'1','pre',".
+ "'$ruleset','$max' ,NULL)");
mysql_query("UPDATE Game SET session='".$max."' WHERE id=".DB_quote_smart($followup));
}
}
else
- mysql_query("INSERT INTO Game VALUES (NULL, NULL, '$randomNRstring', 'normal', NULL,'1','pre', NULL ,NULL)");
+ mysql_query("INSERT INTO Game VALUES (NULL, NULL, '$randomNRstring', 'normal', NULL,'1','pre', ".
+ "'$ruleset',NULL ,NULL)");
$game_id = mysql_insert_id();
/* create hash */
@@ -141,6 +159,7 @@ else if(myisset("cancle","me"))
{
echo "Can't find you in the database, please check the url.
\n";
echo "perhaps the game has been cancled, check by login in here.";
+ output_footer();
exit();
}
@@ -187,6 +206,7 @@ else if(myisset("me"))
{
echo "Can't find you in the database, please check the url.
\n";
echo "perhaps the game has been cancled, check by login in here.";
+ output_footer();
exit();
}
@@ -198,8 +218,47 @@ else if(myisset("me"))
$mystatus = DB_get_status_by_hash($me);
$mypos = DB_get_pos_by_hash($me);
- /* display the game number */
- echo "
your cards are:
\n";
+ echo "
your cards are:
\n";
foreach($mycards as $card)
display_card($card);
echo "
$name | ".date("Y-m-d H:i:s")." |