X-Git-Url: https://git.nubati.net/cgi-bin/gitweb.cgi?p=e-DoKo.git;a=blobdiff_plain;f=include%2Ffunctions.php;h=466b4ae34f631d7c6a08414ebbbdd079aa0943b9;hp=a338f388df0bb2822a654f3a13afb27e01d39a3a;hb=b4b135a91ee29a31fde39fd6792fe680bf0324d8;hpb=af2ee6fe421192cd2b42fcb4bbd09179bbce3943
diff --git a/include/functions.php b/include/functions.php
index a338f38..466b4ae 100644
--- a/include/functions.php
+++ b/include/functions.php
@@ -177,14 +177,27 @@ function compare_cards($a,$b,$game)
return 1;
if($b == 19 || $b == 20 )
return 0;
- };
- if($RULES['schweinchen']=='second' && $GAME['schweinchen-second'])
+ }
+ else if($RULES['schweinchen']=='second' && $GAME['schweinchen-second'])
{
if($a == 19 || $a == 20 )
return 1;
if($b == 19 || $b == 20 )
return 0;
- };
+ }
+ else if($RULES['schweinchen']=='secondaftercall' && $GAME['schweinchen-who'] && $GAME['schweinchen-second'] )
+ {
+ /* check if a call was made either by the player or his partner. If so activate Schweinchen rule. */
+ if(DB_get_call_by_hash($GAME['schweinchen-who']) || DB_get_partner_call_by_hash($GAME['schweinchen-who']) )
+ {
+ if($a == 19 || $a == 20 )
+ return 1;
+ if($b == 19 || $b == 20 )
+ return 0;
+ }
+ /* if not, do nothing and the foxes are just handeled as normal trump */
+ }
+ ;
case "heart":
case "spade":
case "club":
@@ -595,21 +608,39 @@ function set_gametype($gametype)
function mysort($cards,$gametype)
{
- usort ( $cards, "sort_comp" );
+ global $PREF;
+ if(isset($PREF['sorting']))
+ if($PREF['sorting']=='high-low')
+ usort ( $cards, 'sort_comp_high_low' );
+ else
+ usort ( $cards, 'sort_comp_low_high' );
+ else
+ usort ( $cards, 'sort_comp_high_low' );
return $cards;
}
-function sort_comp($a,$b)
+function sort_comp_high_low($a,$b)
{
global $CARDS;
$ALL = array();
- $ALL = array_merge($CARDS["trump"],$CARDS["diamonds"],$CARDS["clubs"],
- $CARDS["hearts"],$CARDS["spades"]);
+ $ALL = array_merge($CARDS['trump'],$CARDS['diamonds'],$CARDS['clubs'],
+ $CARDS['hearts'],$CARDS['spades']);
return pos_array($a,$ALL)-pos_array($b,$ALL);
}
+function sort_comp_low_high($a,$b)
+{
+ global $CARDS;
+
+ $ALL = array();
+ $ALL = array_merge($CARDS['trump'],$CARDS['diamonds'],$CARDS['clubs'],
+ $CARDS['hearts'],$CARDS['spades']);
+
+ return -pos_array($a,$ALL)+pos_array($b,$ALL);
+}
+
function can_call($what,$hash)
{
global $RULES;
@@ -734,7 +765,7 @@ function display_table ()
if(!$debug)
echo " $name \n";
else
- echo " $name\n";
+ echo " $name\n";
/* add hints for poverty, wedding, solo, etc */
if( $gametype != "solo")
@@ -844,27 +875,29 @@ function display_table ()
}
-function display_user_menu()
+function display_user_menu($id)
{
- global $WIKI,$myid,$INDEX;
+ global $WIKI,$INDEX;
$result = DB_query("SELECT Hand.hash,Hand.game_id,Game.player from Hand".
" LEFT JOIN Game On Hand.game_id=Game.id".
- " WHERE Hand.user_id='$myid'".
- " AND Game.player='$myid'".
+ " WHERE Hand.user_id='$id'".
+ " AND ( Game.player='$id' OR ISNULL(Game.player) )".
" AND Game.status<>'gameover'".
" ORDER BY Game.session" );
- if(DB_num_rows($result))
- echo "It's your turn in these games:
\n";
$i=0;
while( $r = DB_fetch_array($result))
{
if($i==0)
- echo "