projects
/
e-DoKo.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
NEW FEATURE: new sorting algorithm
[e-DoKo.git]
/
include
/
functions.php
diff --git
a/include/functions.php
b/include/functions.php
index db7ccadb059a747f422dd7481f74151b341ae41f..466b4ae34f631d7c6a08414ebbbdd079aa0943b9 100644
(file)
--- a/
include/functions.php
+++ b/
include/functions.php
@@
-608,21
+608,39
@@
function set_gametype($gametype)
function mysort($cards,$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;
}
return $cards;
}
-function sort_comp($a,$b)
+function sort_comp
_high_low
($a,$b)
{
global $CARDS;
$ALL = array();
{
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);
}
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;
function can_call($what,$hash)
{
global $RULES;
@@
-1052,22
+1070,22
@@
function format_score_table_html($score,$userid)
if(sizeof($score)==0)
return "";
if(sizeof($score)==0)
return "";
- $output = "<div class=\"scoretable\">\n<table class=\"score\">\n <thead><tr>\n";
+ $output = "<div class=\"scoretable\">\n<table class=\"score\">\n <thead>
\n
<tr>\n";
/* output header */
/* output header */
- $output.= " <th> No </th>";
+ $output.= "
<th> No </th>";
foreach($score[0]['players'] as $id=>$points)
{
$name = DB_get_name('userid',$id); /*TODO*/
$output.= "<th> ".substr($name,0,2)." </th>";
}
foreach($score[0]['players'] as $id=>$points)
{
$name = DB_get_name('userid',$id); /*TODO*/
$output.= "<th> ".substr($name,0,2)." </th>";
}
- $output.="<th>P</th>\n
</tr>\n</thead>\n
<tbody>\n";
+ $output.="<th>P</th>\n
</tr>\n </thead>\n
<tbody>\n";
$i=0;
foreach($score as $game)
{
$i++;
$i=0;
foreach($score as $game)
{
$i++;
- $output.=" <tr>";
+ $output.="
<tr>";
$userhash = DB_get_hash_from_gameid_and_userid($game['gameid'],$userid);
/* create link to old games only if you are logged in and its your game*/
if(isset($_SESSION['id']) && $_SESSION['id']==$userid)
$userhash = DB_get_hash_from_gameid_and_userid($game['gameid'],$userid);
/* create link to old games only if you are logged in and its your game*/
if(isset($_SESSION['id']) && $_SESSION['id']==$userid)
@@
-1085,7
+1103,7
@@
function format_score_table_html($score,$userid)
$output.="</td></tr>\n";
}
$output.="</td></tr>\n";
}
- $output.="
</tbody>\n</table>
</div>\n";
+ $output.="
</tbody>\n</table>\n
</div>\n";
return $output;
}
return $output;
}