From: Arun Persaud
Date: Sun, 14 Mar 2010 21:36:47 +0000 (-0700)
Subject: Merge branch 'master' of /home/arun/nubati.net/git/e-DoKo
X-Git-Url: https://git.nubati.net/cgi-bin/gitweb.cgi?p=e-DoKo.git;a=commitdiff_plain;h=c581cd05476d07f0fd17dab41cbb211a443fd57f;hp=f47ddae6b4d00d950c3a29d6b7536ce1ae9ac813
Merge branch 'master' of /home/arun/nubati.net/git/e-DoKo
---
diff --git a/INSTALL b/INSTALL
index 0fada71..1929213 100644
--- a/INSTALL
+++ b/INSTALL
@@ -3,7 +3,7 @@ Installation
------------
-1) What you need
- all you need is PHP and MYSQL
+ all you need is PHP and MYSQL. PHP has to include gettext support.
0) Get files
diff --git a/TRANSLATION b/TRANSLATION
new file mode 100644
index 0000000..38bbaaa
--- /dev/null
+++ b/TRANSLATION
@@ -0,0 +1,23 @@
+Translation:
+
+to update the pot file run:
+
+xgettext -L PHP -n --package-name=edoko --msgid-bugs-address=arun@nubati.net *php */*php
+mv messages.po po/messages.pot
+
+
+To start a new translation use something like (here shown to create de.po):
+
+cd po
+msginit -i messages.pot -o de.po
+
+To update a po file run:
+
+cd po
+msgmerge de.po messages.pot
+
+Start editing and then after updating a po run:
+
+msgconv -t ISO-8859-1 de.po > de.po.new && mv de.po.new de.po
+msgfmt -cv -o de.mo de.po
+mv de.mo ../locale/de/LC_MESSAGES/edoko.mo
\ No newline at end of file
diff --git a/cards/altenburg/License b/cards/altenburg/License
index 02f0f20..303db83 100644
--- a/cards/altenburg/License
+++ b/cards/altenburg/License
@@ -1,8 +1,12 @@
-Verwendung der ASS Altenburger Spielkartenbilder mit Genehmigung der
+You need to a license from
+
Spielkartenfabrik Altenburg GmbH,
ASS Altenburger
-Leipziger Strasse 7, 04600 Altenburg bis zum 31.12.2009
+Leipziger Strasse 7, 04600 Altenburg
Email: info@spielkarten.com
-internet: www.spielkarten.com
\ No newline at end of file
+internet: www.spielkarten.com
+
+for these images. This involves some paperwork, but was free for non-commercial purposes.
+
diff --git a/create_database.sql b/create_database.sql
index fd7b22a..71a6dfc 100644
--- a/create_database.sql
+++ b/create_database.sql
@@ -48,7 +48,7 @@ CREATE TABLE `Version` (
/*!40000 ALTER TABLE `Card` DISABLE KEYS */;
LOCK TABLES `Version` WRITE;
-INSERT INTO `Version` VALUES (1);
+INSERT INTO `Version` VALUES (2);
UNLOCK TABLES;
/*!40000 ALTER TABLE `Version` ENABLE KEYS */;
@@ -141,7 +141,7 @@ CREATE TABLE `Game` (
`sickness` int(11) default NULL,
`startplayer` tinyint(4) default '1',
`player` int(11) default NULL,
- `status` enum('pre','play','gameover','cancel-timedout','cancel-nines','cancel-trump','cancel-noplay') default NULL,
+ `status` enum('pre','play','gameover','cancel-timedout','cancel-nines','cancel-trump','cancel-noplay','cancel-lowtrump') default NULL,
`ruleset` int(11) default NULL,
`session` int(11) default NULL,
`id` int(11) NOT NULL auto_increment,
@@ -171,6 +171,7 @@ CREATE TABLE `Rulesets` (
`dullen` enum('none','firstwins','secondwins') default 'secondwins',
`schweinchen` enum ('none','both','second','secondaftercall') default 'second',
`call` enum ('1st-own-card','5th-card','9-cards') default '1st-own-card',
+ `lowtrump` enum('poverty','cancel','none') default 'poverty',
`id` int(11) NOT NULL auto_increment,
UNIQUE KEY `id` (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
@@ -200,7 +201,7 @@ CREATE TABLE `Hand` (
`status` enum('start','init','check','poverty','play','gameover') default 'start',
`position` tinyint(4) NOT NULL default '0',
`party` enum('re','contra') default NULL,
- `sickness` enum('wedding','nines','poverty','solo') default NULL,
+ `sickness` enum('wedding','nines','poverty','solo','lowtrump') default NULL,
`solo` enum('trumpless','jack','queen','trump','club','spade','heart','silent') default NULL,
`point_call` enum('120','90','60','30','0') default NULL,
UNIQUE KEY `id` (`id`),
@@ -263,7 +264,7 @@ CREATE TABLE `Card_Exchange` (
/*!40000 ALTER TABLE `Hand_Card` DISABLE KEYS */;
-LOCK TABLES `Hand_Card` WRITE;
+LOCK TABLES `Card_Exchange` WRITE;
UNLOCK TABLES;
/*!40000 ALTER TABLE `Hand_Card` ENABLE KEYS */;
diff --git a/include/db.php b/include/db.php
index b79da87..ad6c6f0 100644
--- a/include/db.php
+++ b/include/db.php
@@ -30,17 +30,24 @@ if(!isset($HOST))
function DB_open()
{
+ $version_needed = 2;
+
global $DB,$DB_user,$DB_host,$DB_database,$DB_password;
$DB = @mysql_connect($DB_host,$DB_user, $DB_password);
if ( $DB )
{
- mysql_select_db($DB_database) or die('Could not select database');
+ mysql_select_db($DB_database) or die('Error: Could not select database');
}
else
{
echo mysql_errno() . ": " . mysql_error(). "\n";
return -1;
- }
+ };
+
+ $version = DB_get_version();
+ if ($version != $version_needed)
+ return -2;
+
return 0;
}
@@ -696,14 +703,15 @@ function DB_get_hashes_by_session($session,$user)
return $r;
}
-function DB_get_ruleset($dullen,$schweinchen,$call)
+function DB_get_ruleset($dullen,$schweinchen,$call,$lowtrump)
{
$r = array();
$result = DB_query("SELECT id FROM Rulesets WHERE".
" dullen=".DB_quote_smart($dullen)." AND ".
" Rulesets.call=".DB_quote_smart($call)." AND ".
- " schweinchen=".DB_quote_smart($schweinchen));
+ " schweinchen=".DB_quote_smart($schweinchen)." AND ".
+ " lowtrump=".DB_quote_smart($lowtrump));
if($result)
$r = DB_fetch_array($result);
@@ -715,6 +723,7 @@ function DB_get_ruleset($dullen,$schweinchen,$call)
$result = DB_query("INSERT INTO Rulesets VALUES (NULL, NULL, ".
DB_quote_smart($dullen).",".
DB_quote_smart($schweinchen).",".
+ DB_quote_smart($lowtrump).",".
DB_quote_smart($call).
", NULL)");
if($result)
@@ -763,6 +772,7 @@ function DB_get_PREF($myid)
$PREF['vacation_start'] = NULL;
$PREF['vacation_stop'] = NULL;
$PREF['vacation_comment'] = '';
+ $PREF['language'] = 'en';
/* get all preferences */
$r = DB_query('SELECT pref_key, value FROM User_Prefs'.
@@ -816,8 +826,14 @@ function DB_get_PREF($myid)
if($pref[1])
$PREF['vacation_comment'] = $pref[1];
break;
+
+ case 'language':
+ if($pref[1])
+ $PREF['language'] = $pref[1];
+ break;
}
}
+ $_SESSION['language'] = $PREF['language'];
return $PREF;
}
@@ -827,9 +843,10 @@ function DB_get_RULES($gameid)
" LEFT JOIN Game ON Game.ruleset=Rulesets.id ".
" WHERE Game.id='$gameid'" );
- $RULES["dullen"] = $r[2];
- $RULES["schweinchen"] = $r[3];
- $RULES["call"] = $r[4];
+ $RULES['dullen'] = $r[2];
+ $RULES['schweinchen'] = $r[3];
+ $RULES['lowtrump'] = $r[4];
+ $RULES['call'] = $r[5];
return $RULES;
}
diff --git a/include/functions.php b/include/functions.php
index 998ca02..a06f3d4 100644
--- a/include/functions.php
+++ b/include/functions.php
@@ -146,8 +146,8 @@ function sendmail($To,$Subject,$message)
* change txt -> html
*/
$message = str_replace("\n","
\n",$message);
- $message = ereg_replace("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]",
- "\\0", $message);
+ $message = preg_replace("#(\w+://[^<>\s]+[\w/]*)#",
+ "$1", $message);
echo "
To: $To
";
if($header != "")
@@ -455,6 +455,39 @@ function count_trump($cards,$status='pregame')
return $trump;
}
+function check_low_trump($cards)
+{
+ global $RULES;
+
+ if($RULES['lowtrump']=='none')
+ return 0;
+
+ /* check if we have low trump */
+
+ $lowtrump=1;
+ foreach($cards as $card)
+ {
+ /* card a trump, but not a diamond? */
+ if( $card<19 )
+ $lowtrump=0;
+ }
+
+ /* handle case where player has schweinchen */
+ if( in_array("19",$cards) && in_array("20",$cards) )
+ switch($RULES["schweinchen"])
+ {
+ case "both":
+ case "second":
+ case "secondaftercall":
+ $lowtrump=0;
+ break;
+ case "none":
+ break;
+ }
+
+ return $lowtrump;
+}
+
function create_array_of_random_numbers($useridA,$useridB,$useridC,$useridD)
{
global $debug;
@@ -467,12 +500,12 @@ function create_array_of_random_numbers($useridA,$useridB,$useridC,$useridD)
$r[ 1]=2; $r[13]=23; $r[25]=14; $r[37]=38;
$r[ 2]=3; $r[14]=27; $r[26]=15; $r[38]=39;
$r[ 3]=4; $r[15]=16; $r[27]=28; $r[39]=40;
- $r[ 4]=5; $r[16]=17; $r[28]=29; $r[40]=41;
+ $r[ 4]=5; $r[16]=17; $r[28]=29; $r[40]=21;
$r[ 5]=18; $r[17]=6; $r[29]=30; $r[41]=42;
- $r[ 6]=21; $r[18]=7; $r[30]=31; $r[42]=43;
- $r[ 7]=22; $r[19]=8; $r[31]=32; $r[43]=44;
- $r[ 8]=45; $r[20]=9; $r[32]=19; $r[44]=33;
- $r[ 9]=46; $r[21]=10; $r[33]=20; $r[45]=24;
+ $r[ 6]=41; $r[18]=7; $r[30]=31; $r[42]=43;
+ $r[ 7]=22; $r[19]=8; $r[31]=32; $r[43]=20;
+ $r[ 8]=45; $r[20]=9; $r[32]=33; $r[44]=19;
+ $r[ 9]=46; $r[21]=10; $r[33]=44; $r[45]=24;
$r[10]=35; $r[22]=11; $r[34]=48; $r[46]=25;
$r[11]=36; $r[23]=12; $r[35]=34; $r[47]=26;
}
@@ -933,7 +966,7 @@ function display_table ()
echo " Schweinchen.
";
if($GT=="poverty" && $party=="re")
- if($sickness=="poverty")
+ if($sickness=="poverty" || ($RULES['lowtrump']=='poverty' && $sickness=='lowtrump'))
{
$userhash = DB_get_hash_from_gameid_and_userid($gameid,$user);
$cards = DB_get_all_hand($userhash);
@@ -948,7 +981,7 @@ function display_table ()
if($GT=="dpoverty")
if($party=="re")
- if($sickness=="poverty")
+ if($sickness=="poverty" || ($RULES['lowtrump']=='poverty' && $sickness=='lowtrump'))
{
$userhash = DB_get_hash_from_gameid_and_userid($gameid,$user);
$cards = DB_get_all_hand($userhash);
@@ -961,7 +994,7 @@ function display_table ()
else
echo " \" title=\"poverty partner\" />";
else
- if($sickness=="poverty")
+ if($sickness=="poverty" || ($RULES['lowtrump']=='poverty' && $sickness=='lowtrump'))
{
$userhash = DB_get_hash_from_gameid_and_userid($gameid,$user);
$cards = DB_get_all_hand($userhash);
@@ -980,21 +1013,21 @@ function display_table ()
else
echo " ";
- if(ereg("solo",$GT) && $party=="re")
+ if( (strpos($GT,"solo")!==false) && $party=="re")
{
- if(ereg("queen",$GT))
+ if(strpos($GT,"queen")!==false)
echo " ";
- else if(ereg("jack",$GT))
+ else if(strpos($GT,"jack")!==false)
echo " ";
- else if(ereg("club",$GT))
+ else if(strpos($GT,"club")!==false)
echo " ";
- else if(ereg("spade",$GT))
+ else if(strpos($GT,"spade")!==false)
echo " ";
- else if(ereg("heart",$GT))
+ else if(strpos($GT,"heart")!==false)
echo " ";
- else if(ereg("trumpless",$GT))
+ else if(strpos($GT,"trumpless")!==false)
echo " ";
- else if(ereg("trump",$GT))
+ else if(strpos($GT,"trump")!==false)
echo " ";
}
@@ -1156,7 +1189,8 @@ function generate_global_score_table()
/* save information in an array */
while( $r = DB_fetch_array($result))
- $player[$r[0]] = array('name'=> $r[1], 'points' => 0 ,'nr' => 0);
+ $player[$r[0]] = array('name'=> $r[1], 'points' => 0 , 'nr' => 0, 'active' => 0,
+ 'response' => 0 , 'solo' => 0, 'soloavg' => 0);
/* get points and generate table */
foreach($gameids as $gameid)
@@ -1182,9 +1216,53 @@ function generate_global_score_table()
}
}
+ /* add number of active games */
+ $result = DB_query_array_all("SELECT user_id, COUNT(*) as c " .
+ " FROM Hand".
+ " LEFT JOIN Game ON Game.id=game_id".
+ " WHERE Game.status IN ('pre','play')".
+ " GROUP BY user_id");
+
+ foreach($result as $res)
+ {
+ $player[$res[0]]['active'] = $res[1];
+ }
+
+ /* response time of users*/
+ $result = DB_query_array_all("SELECT user_id,".
+ "IFNULL(AVG(if(P1.sequence in (2,3,4),".
+ "-timestampdiff(MINUTE,mod_date,(select mod_date from Play P2 where P1.trick_id=P2.trick_id and P2.sequence=P1.sequence-1)),NULL )),1e9) as a ".
+ "FROM Play P1 ".
+ "LEFT JOIN Hand_Card ON P1.hand_card_id=Hand_Card.id ".
+ "LEFT JOIN Hand ON Hand.id=Hand_Card.hand_id ".
+ "GROUP BY user_id ");
+
+ foreach($result as $res)
+ {
+ $player[$res[0]]['response'] = $res[1];
+ }
+
+ /* most solos */
+ $result = DB_query_array_all("SELECT user_id as uid,".
+ " COUNT(*), ".
+ " COUNT(*)/(SELECT COUNT(*) FROM Hand LEFT JOIN User ON User.id=Hand.user_id WHERE User.id=uid) as c ".
+ " FROM Game ".
+ " LEFT JOIN Hand ON Hand.position=startplayer AND Game.id=Hand.game_id ".
+ " WHERE type='solo' AND Game.status='gameover' ".
+ " GROUP BY user_id ");
+
+ foreach($result as $res)
+ {
+ $player[$res[0]]['solo'] = $res[1];
+ $player[$res[0]]['soloavg'] = $res[2];
+ }
+
+
+ /* sort everything nicely */
+
function cmp($a,$b)
{
- if($a['nr']==0 ) return 1;
+ if($a['nr']==0) return 1;
if($b['nr']==0) return 1;
$a=$a['points']/$a['nr'];
@@ -1196,11 +1274,13 @@ function generate_global_score_table()
}
usort($player,'cmp');
+
foreach($player as $pl)
{
/* limit to players with at least 10 games */
if($pl['nr']>10)
- $return[] = array( $pl['name'], round($pl['points']/$pl['nr'],3), $pl['points'],$pl['nr']);
+ $return[] = array( $pl['name'], round($pl['points']/$pl['nr'],3), $pl['points'],$pl['nr'],$pl['active'],
+ $pl['response'],$pl['solo'],$pl['soloavg']);
}
return $return;
@@ -1391,6 +1471,9 @@ function cancel_game($why,$gameid)
case 'noplay':
DB_query("UPDATE Game SET status='cancel-noplay' WHERE id=$gameid");
break;
+ case 'lowtrump':
+ DB_query("UPDATE Game SET status='cancel-lowtrump' WHERE id=$gameid");
+ break;
}
/* set each player to gameover */
$result = DB_query("SELECT id FROM Hand WHERE game_id=".DB_quote_smart($gameid));
diff --git a/include/game.php b/include/game.php
index a1c02a0..db27bde 100644
--- a/include/game.php
+++ b/include/game.php
@@ -47,6 +47,7 @@ global $GAME,$RULES,$CARDS;
$gameid = DB_get_gameid_by_hash($me);
$myname = DB_get_name('hash',$me);
$mystatus = DB_get_status_by_hash($me);
+$origmystatus = DB_get_status_by_hash($me); /* to show "it's your turn" menu when game has just finished */
$mypos = DB_get_pos_by_hash($me);
$myhand = DB_get_handid('hash',$me);
$myparty = DB_get_party_by_hash($me);
@@ -222,6 +223,7 @@ if($session)
echo " 10ofhearts : {$RULES['dullen']}
\n";
echo " schweinchen: {$RULES['schweinchen']}
\n";
echo " call: {$RULES['call']}
\n";
+ echo " lowtrump: {$RULES['lowtrump']}
\n";
echo " \n \n";
/* show score */
@@ -399,7 +401,7 @@ switch($mystatus)
$mycards = DB_get_hand($me);
$mycards = mysort($mycards,$gametype);
- if(!myisset('solo','wedding','poverty','nines') )
+ if(!myisset('solo','wedding','poverty','nines','lowtrump') )
{
/* output sickness of other playes, in case the already selected and are sitting in front of the current player */
echo "\n\n";
@@ -438,9 +440,10 @@ switch($mystatus)
/* check if someone selected more than one sickness */
$Nsickness = 0;
if($_REQUEST['solo']!='No') $Nsickness++;
- if($_REQUEST['wedding'] == 'yes') $Nsickness++;
- if($_REQUEST['poverty'] == 'yes') $Nsickness++;
- if($_REQUEST['nines'] == 'yes') $Nsickness++;
+ if($_REQUEST['wedding'] == 'yes') $Nsickness++;
+ if($_REQUEST['poverty'] == 'yes') $Nsickness++;
+ if($_REQUEST['nines'] == 'yes') $Nsickness++;
+ if($_REQUEST['lowtrump'] == 'yes') $Nsickness++;
if($Nsickness>1)
{
@@ -502,6 +505,16 @@ switch($mystatus)
" 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".
+ " is playing solo, this game will be canceled.
\n";
+ else
+ echo "Don't think you can win with low trumps...? ok, poverty chosen
.
\n";
+
+ DB_set_sickness_by_hash($me,'lowtrump');
+ }
echo "
\n";
@@ -591,7 +604,7 @@ switch($mystatus)
$startplayer = DB_get_startplayer_by_gameid($gameid);
/* check for sickness */
- $nines = 0;
+ $cancel = 0;
$poverty = 0;
$wedding = 0;
$solo = 0;
@@ -599,12 +612,13 @@ switch($mystatus)
{
$name = DB_get_name('userid',$user);
$usersick = DB_get_sickness_by_userid_and_gameid($user,$gameid);
- if($usersick == 'nines')
+ if($usersick == 'nines' || ($RULES['lowtrump']=='cancel' && $usersick=='lowtrump') )
{
- $nines = $user;
+ $cancel = $user;
+ $cancelsick = $usersick;
break; /* no need to check for other poverties, since only solo can win and that is already set */
}
- else if($usersick == 'poverty')
+ else if($usersick == 'poverty' || ($RULES['lowtrump']=='poverty' && $usersick=='lowtrump'))
$poverty++;
else if($usersick == 'wedding')
$wedding=$user;
@@ -617,13 +631,35 @@ switch($mystatus)
{
/* do nothing */
}
- else if($nines)
+ else if($cancel)
{
/* cancel game */
- $message = "The game has been canceled because ".DB_get_name('userid',$nines).
- " has five or more nines and nobody is playing solo.\n\n".
- "To redeal either start a new game or, in case the game was part of a tournament,\n".
- "go to the last game and use the link at the bottom of the page to redeal.\n\n";
+ if($cancelsick == 'nines')
+ {
+ $message = "The game has been canceled because ".DB_get_name('userid',$cancel).
+ " has five or more nines and nobody is playing solo.\n\n".
+ "To redeal either start a new game or, in case the game was part of a tournament,\n".
+ "go to the last game and use the link at the bottom of the page to redeal.\n\n";
+
+ /* 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";
+ }
+ else if ($cancelsick == 'lowtrump')
+ {
+ $message = "The game has been canceled because ".DB_get_name('userid',$cancel).
+ " has low trump and nobody is playing solo.\n\n".
+ "To redeal either start a new game or, in case the game was part of a tournament,\n".
+ "go to the last game and use the link at the bottom of the page to redeal.\n\n";
+
+ /* 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";
+ };
$userids = DB_get_all_userid_by_gameid($gameid);
foreach($userids as $user)
@@ -632,12 +668,7 @@ switch($mystatus)
mymail($user,$subject,$message);
}
- /* update game status */
- cancel_game('nines',$gameid);
-
- echo "The game has been canceled because ".DB_get_name('userid',$nines).
- " has five or more nines and nobody is playing solo.
\n";
- echo "\n";
+ echo "\n"; /* end div message */
break;
}
else if($poverty==1) /* one person has poverty */
@@ -648,7 +679,7 @@ switch($mystatus)
if(!$who)
{
$firstsick = DB_get_sickness_by_pos_and_gameid(1,$gameid);
- if($firstsick == 'poverty')
+ if($firstsick == 'poverty' || ($RULES['lowtrump']=='poverty' && $firstsick=='lowtrump'))
DB_set_sickness_by_gameid($gameid,2); /* who needs to be asked first */
else
DB_set_sickness_by_gameid($gameid,1); /* who needs to be asked first */
@@ -662,10 +693,10 @@ switch($mystatus)
if(!$who)
{
$firstsick = DB_get_sickness_by_pos_and_gameid(1,$gameid);
- if($firstsick == 'poverty')
+ if($firstsick == 'poverty' || ($RULES['lowtrump']=='poverty' && $firstsick=='lowtrump'))
{
- $seconsick = DB_get_sickness_by_pos_and_gameid(1,$gameid);
- if($secondsick == 'poverty')
+ $secondsick = DB_get_sickness_by_pos_and_gameid(1,$gameid);
+ if($secondsick == 'poverty' || ($RULES['lowtrump']=='poverty' && $secondsick=='lowtrump'))
DB_set_sickness_by_gameid($gameid,30); /* who needs to be asked first */
else
DB_set_sickness_by_gameid($gameid,20); /* who needs to be asked first */
@@ -725,7 +756,7 @@ switch($mystatus)
case 'dpoverty':
/* set person with poverty to play status */
$usersick = DB_get_sickness_by_userid_and_gameid($userid,$gameid);
- if($usersick == 'poverty')
+ if($usersick == 'poverty' || ($RULES['lowtrump']=='poverty' && $usersick=='lowtrump'))
DB_set_hand_status_by_hash($userhash,'play');
/* set status of first player to be asked to poverty */
@@ -776,7 +807,7 @@ switch($mystatus)
}
}
else
- echo "\n";
+ echo "Please, start the game.
\n";
}
else
{
@@ -786,7 +817,7 @@ switch($mystatus)
$whoid = DB_get_userid('gameid-position',$gameid,$who);
if($whoid==$myid)
- echo "\n";
+ echo "Please, start the game.
\n";
break;
}
+
case 'poverty':
/* user only gets here in a poverty game, several things have to be handled here:
* A) ask, if user wants to take trump
@@ -862,7 +894,7 @@ switch($mystatus)
/* get information so show the cards that have been handed over in a poverty game */
output_exchanged_cards();
- echo " \n \n"; /* end div trick, end li trick */
+ echo " \n \n\n\n"; /* end div trick, end li trick , end ul tricks */
}
/* end output pre-game trick */
@@ -918,7 +950,7 @@ switch($mystatus)
$userhash = DB_get_hash_from_gameid_and_userid($gameid,$user);
$userparty = DB_get_party_by_hash($userhash);
- if($usersick=='poverty' && !$userparty)
+ if(($usersick=='poverty'|| ($RULES['lowtrump']=='poverty' && $usersick=='lowtrump')) && !$userparty)
{
$hash = DB_get_hash_from_gameid_and_userid($gameid,$user);
$cards = DB_get_hand($hash);
@@ -926,7 +958,10 @@ switch($mystatus)
$nrtrump = 0;
foreach($cards as $card)
if($card<27) $nrtrump++;
- echo "Player $name has $nrtrump trump. Do you want to take them?".
+ $low='';
+ if($usersick=='lowtrump')
+ $low='low';
+ echo "Player $name has $nrtrump $low trump. Do you want to take them?".
"Yes
\n";
}
}
@@ -955,9 +990,9 @@ switch($mystatus)
/* don't ask people who have poverty */
$next=1;
- if($firstsick=='poverty')
+ if($firstsick=='poverty' || ($RULES['lowtrump']=='poverty' && $firstsick=='lowtrump'))
{
- if($secondsick=='poverty')
+ if($secondsick=='poverty'|| ($RULES['lowtrump']=='poverty' && $secondsick=='lowtrump'))
$next=3;
else
$next=2;
@@ -1072,8 +1107,8 @@ switch($mystatus)
$secondsick = (string) DB_get_sickness_by_pos_and_gameid($mypos+2,$gameid);
$next=1;
- if($firstsick=='poverty')
- if($secondsick=='poverty')
+ if($firstsick=='poverty'|| ($RULES['lowtrump']=='poverty' && $firstsick=='lowtrump'))
+ if($secondsick=='poverty'|| ($RULES['lowtrump']=='poverty' && $secondsick=='lowtrump'))
$next=3;
else
$next=2;
@@ -1096,7 +1131,7 @@ switch($mystatus)
echo "\n";
}
}
- echo "";
+ echo "\n";
break;
case 'play':
@@ -1115,9 +1150,11 @@ switch($mystatus)
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.
";
break;
case 'cancel-nines':
- case 'cancel-timedout':
echo "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.
";
+ break;
case 'cancel-trump':
echo "The game has been canceled because nobody wanted to take the trump.
";
break;
@@ -1487,28 +1524,31 @@ switch($mystatus)
/* same as for foxes, karlchen doesn't always make sense
* check what kind of game it is and set karlchen accordingly */
- $ok = 1; /* default: karlchen should be accounted for */
- if($tricknr != 12 )
- $ok = 0; /* Karlchen works only in the last trick */
- if($ok && DB_get_gametype_by_gameid($gameid)=='solo' )
+
+ if($tricknr == 12 ) /* Karlchen works only in the last trick */
{
- $solo = DB_get_solo_by_gameid($gameid);
- if($solo == 'trumpless' || $solo == 'jack' || $solo == 'queen' )
- $ok = 0; /* no Karlchen in these solos */
- }
+ /* check for solo */
+ $solo = 'none';
+ if(DB_get_gametype_by_gameid($gameid)=='solo' )
+ $solo = DB_get_solo_by_gameid($gameid);
- if($ok)
- foreach($play as $played)
- if ( $played['card']==11 || $played['card']==12 )
- if ($played['pos'] == $winner )
- {
- /* possible caught a fox, check party */
- $uid1 = DB_get_userid('gameid-position',$gameid,$winner);
- $party1 = DB_get_party_by_gameid_and_userid($gameid,$uid1);
+ /* no Karlchen in these solos */
+ if($solo != 'trumpless' && $solo != 'jack' && $solo != 'queen' )
+ {
+ foreach($play as $played)
+ if ( $played['card']==11 || $played['card']==12 )
+ if ($played['pos'] == $winner )
+ {
+ /* save Karlchen */
+ $uid1 = DB_get_userid('gameid-position',$gameid,$winner);
+ $party1 = DB_get_party_by_gameid_and_userid($gameid,$uid1);
+
+ DB_query("INSERT INTO Score".
+ " VALUES( NULL,NULL,$gameid,'$party1',$uid1,NULL,'karlchen')");
+ };
+ };
+ }; /* end scoring Karlchen */
- DB_query("INSERT INTO Score".
- " VALUES( NULL,NULL,$gameid,'$party1',$uid1,NULL,'karlchen')");
- }
/*
* check for doppelopf (>40 points)
***********************************/
@@ -2031,11 +2071,20 @@ switch($mystatus)
/* output other games where it is the users turn
* make sure that the people looking at old games don't see the wrong games here
*/
-if( $mystatus != 'gameover' )
- display_user_menu($myid);
+if( $gamestatus != 'gameover' )
+ {
+ /* game isn't over, only valid user can get here, so show menu */
+ display_user_menu($myid);
+ }
+else if( $origmystatus != 'gameover' )
+ {
+ /* user just played the very last card, game is now over, it's still ok to show the menu though */
+ display_user_menu($myid);
+ }
else if( $mystatus == 'gameover' &&
- isset($_SESSION['id']) )
+ isset($_SESSION['id']) )
{
+ /* user is looking at someone else's game, show the menu for the correct user */
display_user_menu($_SESSION['id']);
}
else
diff --git a/include/newgame.php b/include/newgame.php
index d7a2d7f..f06bebe 100644
--- a/include/newgame.php
+++ b/include/newgame.php
@@ -40,7 +40,7 @@ else
DB_update_user_timestamp($myid);
- if( !myisset("PlayerA", "PlayerB","PlayerC","PlayerD","dullen","schweinchen","callrule" ))
+ if( !myisset("PlayerA", "PlayerB","PlayerC","PlayerD","dullen","schweinchen","callrule","lowtrump" ))
{
/* only get players that want to be in new games */
$names = DB_get_all_user_names_open_for_games();
@@ -80,6 +80,7 @@ else
$dullen = $_REQUEST["dullen"];
$schweinchen = $_REQUEST["schweinchen"];
$call = $_REQUEST["callrule"];
+ $lowtrump = $_REQUEST["lowtrump"];
/* get the emails addresses of the players */
$EmailA = DB_get_email('name',$PlayerA);
@@ -142,7 +143,7 @@ else
else /* no follow up, start a new session */
{
/* get ruleset information or create new one */
- $ruleset = DB_get_ruleset($dullen,$schweinchen,$call);
+ $ruleset = DB_get_ruleset($dullen,$schweinchen,$call,$lowtrump);
if($ruleset <0)
{
myerror("Error defining ruleset: $ruleset");
diff --git a/include/output.php b/include/output.php
index 06eb8de..79e42c2 100644
--- a/include/output.php
+++ b/include/output.php
@@ -31,7 +31,7 @@ function output_ask_for_new_game($playerA,$playerB,$playerC,$playerD,$oldgameid)
global $RULES;
echo "