username = $username; $this->pts = $pts; $this->gam = $gam; } function &clone() { $ret = new Ptsgam($this->username, $this->pts, $this->gam); return ($ret); } function add($pts) { $this->pts += $pts; $this->gam++; } function snormpts() { $ret = sprintf ("%.3f", $this->normpts()); if (strchr($ret, ".")) { $ret = rtrim(rtrim($ret, "0"), "."); } return ($ret); } function normpts() { if ($this->gam == 0) return (0); else return ($this->pts / $this->gam); } } function ptsgam_cmp($a, $b) { $norma = $a->normpts(); $normb = $b->normpts(); if ($norma == $normb) { if ($a->gam == $b->gam) return (0); else return ($a->gam < $b->gam ? 1 : -1); } else return (($norma < $normb) ? 1 : -1); } function placings_show(&$user) { $ret = sprintf("
"); $ret .= sprintf("", WEE_FEW_GAMES, placing_show($user, "wee_hi") ); $ret .= sprintf("\n", WEE_FEW_GAMES, placing_show($user, "wee_lo") ); $ret .= sprintf("", MON_FEW_GAMES, placing_show($user, "mon_hi") ); $ret .= sprintf("\n", MON_FEW_GAMES, placing_show($user, "mon_lo") ); $ret .= sprintf("", TRI_FEW_GAMES, placing_show($user, "tri_hi")); $ret .= sprintf("", TRI_FEW_GAMES, placing_show($user, "tri_lo")); $ret .= sprintf("

Settimanale
(non meno di %d partite)

%s

Settimanale
(meno di %d partite)

%s

Mensile
(non meno di %d partite)

%s

Mensile
(meno di %d partite)

%s

Trimestrale
(non meno di %d partite)

%s

Trimestrale
(meno di %d partite)

%s
"); return ($ret); } function placing_show(&$user, $suff) { $tail = FALSE; if (($fp = @fopen(LEGAL_PATH."/class_".$suff.".log", 'r')) == FALSE) { return (FALSE); } // MLANG $ret = sprintf(""); for ($i = 0 ; !feof($fp) ; $i++) { $bf = fgets($fp, 4096); $ar = csplitter($bf, '|'); $pg = new Ptsgam($ar[0], $ar[1], $ar[2]); if ($pg->username == "") continue; if ($i < 5) { $ret .= sprintf("", $i+1, ($pg->username == $user->name ? "" : ""), $pg->username, ($pg->username == $user->name ? "" : ""), $pg->snormpts(), $pg->pts, $pg->gam); } if ($user != FALSE) { if ($pg->username == $user->name && $i >= 5) { $tail = sprintf(""); $tail .= sprintf("", $i+1, ($pg->username == $user->name ? "" : ""), $pg->username, ($pg->username == $user->name ? "" : ""), $pg->snormpts(), $pg->pts, $pg->gam); } } } if ($tail != FALSE) { $ret .= $tail; } $ret .= "
Pos.UtenteScore(Punti/Partite)
%d%s%s%s%s(%d/%d)
. . . . . . . . . .
%d%s%s%s%s(%d/%d)
"; fclose($fp); return ($ret); }