summaryrefslogtreecommitdiffstats
path: root/include/functions.php
diff options
context:
space:
mode:
authorArun Persaud <arun@nubati.net>2008-12-02 23:29:29 -0800
committerArun Persaud <arun@nubati.net>2008-12-02 23:29:29 -0800
commitb568d14fe83e919b41452d8ae5b57a7dedc671cf (patch)
tree100d5d90836776e82dcdd31be91e2c95a48bfd70 /include/functions.php
parent53e8cff40ccebaa711fa8aab6dc9af1eb4e5c3a1 (diff)
downloade-DoKo-b568d14fe83e919b41452d8ae5b57a7dedc671cf.tar.gz
e-DoKo-b568d14fe83e919b41452d8ae5b57a7dedc671cf.tar.bz2
e-DoKo-b568d14fe83e919b41452d8ae5b57a7dedc671cf.zip
NEW FEATURE: new sorting algorithm
you can now sort your hand "low to high" and change your default using the setting dialog
Diffstat (limited to 'include/functions.php')
-rw-r--r--include/functions.php26
1 files changed, 22 insertions, 4 deletions
diff --git a/include/functions.php b/include/functions.php
index 5c23958..466b4ae 100644
--- a/include/functions.php
+++ b/include/functions.php
@@ -608,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;