X-Git-Url: https://mop.ddnsfree.com/gitweb/?a=blobdiff_plain;ds=inline;f=web%2Fbriskin5%2FObj%2Fplacing.phh;fp=web%2Fbriskin5%2FObj%2Fplacing.phh;h=69e2758dd6b8af6dbd0ca2ed9011106db603c0f1;hb=7f31c2b3b37621dfce4652b0822a6656b0c8c2c2;hp=0000000000000000000000000000000000000000;hpb=95bdfa257b2bd14ae7572fa26953cf62b9074b88;p=brisk.git diff --git a/web/briskin5/Obj/placing.phh b/web/briskin5/Obj/placing.phh new file mode 100644 index 0000000..69e2758 --- /dev/null +++ b/web/briskin5/Obj/placing.phh @@ -0,0 +1,154 @@ +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) |