+ $return[] = array( $pl['name'], round($pl['points']/$pl['nr'],3) );
+ }
+
+ return $return;
+}
+
+function format_score_table_ascii($score)
+{
+ $output="";
+ if(sizeof($score)==0)
+ return "";
+
+ /* truncate table if we have too many games */
+ $max = sizeof($score);
+ if($max>6) $output.=" (table truncated to last 6 games)\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";
+
+ /* output score for each game */
+ $i=0;
+ 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($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 = "<div class=\"scoretable\">\n<table class=\"score\">\n";
+
+ /* output header */
+ $header = "";
+ $header.= " <thead>\n <tr>\n";
+ $header.= " <th> No </th>";
+ foreach($score[0]['players'] as $id=>$points)
+ {
+ $name = DB_get_name('userid',$id); /*TODO*/
+ $header.= "<th> ".substr($name,0,2)." </th>";
+ }
+ $header.="<th>P</th>\n </tr>\n </thead>\n";
+
+ /* use the same as footer */
+ $footer = "";
+ $footer.= " <tfoot>\n <tr>\n";
+ $footer.= " <td> No </td>";
+ foreach($score[0]['players'] as $id=>$points)
+ {
+ $name = DB_get_name('userid',$id); /*TODO*/
+ $footer.= "<td> ".substr($name,0,2)." </td>";