username = $username; $this->pts = $pts; $this->gam = $gam; } function &myclone() { $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() * 100.0); 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) { $mtime = placing_time(); $tm = placing_date($mtime); $ret = sprintf("
Settimanale dal %s al %s (non meno di %d partite) %s | ", $tmwee[1], $tm[1], WEE_MAX_GAMES, placing_show($user, "wee_hi") );
$ret .= sprintf("Settimanale dal %s al %s (meno di %d partite, più di %d) %s |
Mensile dal %s al %s (non meno di %d partite) %s | ", $tmmon[1], $tm[1], MON_MAX_GAMES, placing_show($user, "mon_hi") );
$ret .= sprintf("Mensile dal %s al %s (meno di %d partite, più di %d) %s |
Trimestrale dal %s al %s (non meno di %d partite) %s | ", $tmtri[1], $tm[1], TRI_MAX_GAMES, placing_show($user, "tri_hi"));
$ret .= sprintf("Trimestrale dal %s al %s (meno di %d partite, più di %d) %s |
Pos. | Utente | Score | (Punti/Partite) | "); $old_normpts = 1000000000; $old_gam = -1; 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 ($pg->normpts() == $old_normpts && $pg->gam == $old_gam) $i--; if ($i < TOP_NUM) { $ret .= sprintf("
---|---|---|---|
%d | %s%s%s | %s | (%d/%d) |
. . . . . . . . . . | |||
%d | %s%s%s | %s | (%d/%d) |