summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArun Persaud <arun@nubati.net>2008-04-14 21:06:04 -0700
committerArun Persaud <arun@nubati.net>2008-04-15 08:50:39 -0700
commita8d4508271abbc3dce5dcc07397baeb72e0e35fb (patch)
tree5ba24bee7cf3b927672e123eeb5cd242428f7c67
parent9f3cec73181b5ac35486fea031828b11468bceb9 (diff)
downloade-DoKo-a8d4508271abbc3dce5dcc07397baeb72e0e35fb.tar.gz
e-DoKo-a8d4508271abbc3dce5dcc07397baeb72e0e35fb.tar.bz2
e-DoKo-a8d4508271abbc3dce5dcc07397baeb72e0e35fb.zip
BUGFIX: counted foxes wrong for poverty
had two cases (no schweinchen and two schweinchen) mixed up. Signed-off-by: Arun Persaud <arun@nubati.net>
-rw-r--r--functions.php44
1 files changed, 27 insertions, 17 deletions
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;
}