X-Git-Url: https://git.nubati.net/cgi-bin/gitweb.cgi?p=e-DoKo.git;a=blobdiff_plain;f=functions.php;h=2f2e07d6ee9713893b1dce079101682ed63cd4b1;hp=af0cc8eef61ddd92e314852421e3ec5a186ca4ed;hb=0c5b3eeca3006f61dd326a86e8989c52694d581b;hpb=42aae8a38789ec102478db6dc58795c4b095546e diff --git a/functions.php b/functions.php index af0cc8e..2f2e07d 100644 --- a/functions.php +++ b/functions.php @@ -317,28 +317,38 @@ function count_trump($cards) $trump = 0; - /* count each trump */ + /* count each trump, including the foxes */ foreach($cards as $c) if( (int)($c) <27) $trump++; - switch($RULES["schweinchen"]) - { - case "none": - break; - case "second": - case "secondaftercall": - /* add one, in case the player has both foxes (schweinchen) */ - if( in_array("19",$cards) && in_array("20",$cards) ) + /* normally foxes don't count as trump, so we substract them here + * in case someone has schweinchen, one or two of them should count as trump + * though, so we need to add one trump for those cases */ + + /* subtract foxes */ + if( in_array("19",$cards)) + $trump--; + if( in_array("20",$cards) ) + $trump--; + + /* handle case where player has schweinchen */ + if( in_array("19",$cards) && in_array("20",$cards) ) + switch($RULES["schweinchen"]) + { + case "both": + /* add two, in case the player has both foxes (schweinchen) */ $trump++; - case "both": - /* subtract foxes */ - if( in_array("19",$cards)) - $trump--; - if( in_array("20",$cards) ) - $trump--; - break; - } + $trump++; + break; + case "second": + case "secondaftercall": + /* add one, in case the player has both foxes (schweinchen) */ + $trump++; + break; + case "none": + break; + } return $trump; }