X-Git-Url: https://git.nubati.net/cgi-bin/gitweb.cgi?p=e-DoKo.git;a=blobdiff_plain;f=include%2Ffunctions.php;h=a338f388df0bb2822a654f3a13afb27e01d39a3a;hp=28e5937c5a1259f5c9841fcf16f8aa1ef2967789;hb=932a309e7db3043fd22bd497a1f50b0ba09d112f;hpb=924f395a39eeccbcd54d540613e440cbedd6ba3d
diff --git a/include/functions.php b/include/functions.php
index 28e5937..a338f38 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];
@@ -703,6 +737,10 @@ function display_table ()
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")
{
@@ -808,37 +846,39 @@ function display_table ()
function display_user_menu()
{
- global $WIKI,$myid,$INDEX,$STATS;
- echo "
\n";
return;
}
function generate_score_table($session)
{
-
/* get all ids */
$gameids = DB_get_gameids_of_finished_games_by_session($session);
@@ -850,10 +890,10 @@ function generate_score_table($session)
/* get player id, names... from the first game */
$player = array();
- $result = mysql_query("SELECT User.id, User.fullname from Hand".
- " LEFT JOIN User On Hand.user_id=User.id".
- " WHERE Hand.game_id=".$gameids[0]);
- while( $r = mysql_fetch_array($result,MYSQL_NUM))
+ $result = DB_query("SELECT User.id, User.fullname from Hand".
+ " LEFT JOIN User On Hand.user_id=User.id".
+ " WHERE Hand.game_id=".$gameids[0]);
+ while( $r = DB_fetch_array($result))
{
$player[] = array( 'id' => $r[0], 'points' => 0 );
$output.= " ".substr($r[1],0,2)." | \n";
@@ -892,4 +932,67 @@ function generate_score_table($session)
return $output;
}
+function generate_global_score_table()
+{
+ $return = array();
+
+ /* get all ids */
+ $gameids = DB_get_gameids_of_finished_games_by_session(0);
+
+ if($gameids == NULL)
+ return "";
+
+ /* get player id, names... from the User table */
+ $player = array();
+ $result = DB_query("SELECT User.id, User.fullname FROM User");
+
+ while( $r = DB_fetch_array($result))
+ $player[] = array( 'id' => $r[0], 'name'=> $r[1], 'points' => 0 ,'nr' => 0);
+
+ /* get points and generate table */
+ foreach($gameids as $gameid)
+ {
+ $re_score = DB_get_score_by_gameid($gameid);
+ /* TODO: this shouldn't loop over all players, just the 4 players that are in the game */
+ foreach($player as $key=>$pl)
+ {
+ $party = DB_get_party_by_gameid_and_userid($gameid,$pl['id']);
+ if($party == "re")
+ if(DB_get_gametype_by_gameid($gameid)=="solo")
+ $player[$key]['points'] += 3*$re_score;
+ else
+ $player[$key]['points'] += $re_score;
+ else if ($party == "contra")
+ $player[$key]['points'] -= $re_score;
+ if($party)
+ $player[$key]['nr']+=1;
+ }
+ }
+
+ 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;
+}
+
+
+
?>