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("
Settimanale (non meno di %d partite) %s | ", WEE_FEW_GAMES, placing_show($user, "wee_hi") );
$ret .= sprintf("Settimanale (meno di %d partite) %s |
Mensile (non meno di %d partite) %s | ", MON_FEW_GAMES, placing_show($user, "mon_hi") );
$ret .= sprintf("Mensile (meno di %d partite) %s |
Trimestrale (non meno di %d partite) %s | ", TRI_FEW_GAMES, placing_show($user, "tri_hi"));
$ret .= sprintf("Trimestrale (meno di %d partite) %s |
Pos. | Utente | Score | (Punti/Partite) | "); 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("
---|---|---|---|
%d | %s%s%s | %s | (%d/%d) |
. . . . . . . . . . | |||
%d | %s%s%s | %s | (%d/%d) |