X-Git-Url: https://git.nubati.net/cgi-bin/gitweb.cgi?p=e-DoKo.git;a=blobdiff_plain;f=include%2Ffunctions.php;h=82b4bb6bbcde05c2fe2b74779d304b22d35062e5;hp=4abaf935ce9fd6bb2efccbce28e422367f503fa1;hb=4f932986e02718cba7aef75d69702e2b7daa88fe;hpb=64f953012ebda0912a4e92ff3301f09957019477;ds=sidebyside
diff --git a/include/functions.php b/include/functions.php
index 4abaf93..82b4bb6 100644
--- a/include/functions.php
+++ b/include/functions.php
@@ -1,5 +1,5 @@
\n".
" \n";
- while($r = mysql_fetch_array($result,MYSQL_NUM))
+ while($r = DB_fetch_array($result))
{
$name = $r[0];
$pos = $r[1];
@@ -700,9 +734,13 @@ 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")
+ if( $RULES["schweinchen"]=="both" && $GAME["schweinchen-who"]==$hash )
+ echo " Schweinchen.
";
+
if($GT=="poverty" && $party=="re")
if($sickness=="poverty")
{
@@ -809,63 +847,110 @@ function display_table ()
function display_user_menu()
{
global $WIKI,$myid,$INDEX;
- echo "
".substr($r[1],0,2)." | \n"; + $re_score = DB_get_score_by_gameid($gameid); + foreach($player as $id=>$points) + { + $party = DB_get_party_by_gameid_and_userid($gameid,$id); + if($party == "re") + if(DB_get_gametype_by_gameid($gameid)=="solo") + $player[$id] += 3*$re_score; + else + $player[$id] += $re_score; + else if ($party == "contra") + $player[$id] -= $re_score; + } + $score[$i]['gameid'] = $gameid ; + $score[$i]['players'] = $player; + $score[$i]['points'] = abs($re_score); + $score[$i]['solo'] = (DB_get_gametype_by_gameid($gameid)=="solo"); + + $i++; } - $output.="P | \n||||||
".$player[$key]['points']." | \n"; + if($party) + $player[$key]['nr']+=1; } - $output.="".abs($re_score);
+ }
+
+ function cmp($a,$b)
+ {
+ if($a['nr']==0 ) return 1;
+ if($b['nr']==0) return 1;
+
+ $a=$a['points']/$a['nr'];
+ $b=$b['points']/$b['nr'];
+
+ if ($a == $b)
+ return 0;
+ return ($a > $b) ? -1 : 1;
+ }
+ usort($player,"cmp");
+
+ foreach($player as $pl)
+ {
+ /* limit to players with at least 10 games */
+ if($pl['nr']>10)
+ $return[] = array( $pl['name'], round($pl['points']/$pl['nr'],3) );
+ }
+
+ return $return;
+}
+
+function format_score_table_ascii($score)
+{
+ $output="";
+ if(sizeof($score)==0)
+ return "";
+
+ // if(sizeof($score)>5) $header.= " ... \n";
+
+ /* output header */
+ foreach($score[0]['players'] as $id=>$points)
+ {
+ $name = DB_get_name('userid',$id); /*TODO*/
+ $output.= " ".substr($name,0,2)." |";
+ }
+ $output.=" P |\n ";
+ $output.= "------+------+------+------+------+\n";
+
+ $max = sizeof($score);
+ $i=0;
+
+ if($i<$max-6) $output.=" ...\n";
+
+ foreach($score as $game)
+ {
+ $i++;
+ if($i-1<$max-6) continue;
+ foreach($game['players'] as $id=>$points)
+ $output.=str_pad($points,6," ",STR_PAD_LEFT)."|";
+ $output.=str_pad($game['points'],4," ",STR_PAD_LEFT);
/* check for solo */
- if(DB_get_gametype_by_gameid($gameid)=="solo")
+ if($game['solo'])
+ $output.= " S|";
+ else
+ $output.= " |";
+
+ $output.="\n";
+ }
+ return $output;
+}
+
+function format_score_table_html($score,$userid)
+{
+ global $INDEX;
+
+ if(sizeof($score)==0)
+ return "";
+
+ $output = " \n \n";
+ $output.="\n
|