X-Git-Url: http://git.sourceforge.jp/view?a=blobdiff_plain;f=mk_html;h=8833d2554ad3671f4f2c608fa693109d56d80100;hb=bf16dc8b2c45fbaa11b5b6761c3984c19b862b44;hp=9203613d6774c3c22ae57f46167642d8718e2c57;hpb=75141999cd62f72ae254d4f9109069d3b8dc1657;p=shogi-server%2Fshogi-server.git diff --git a/mk_html b/mk_html index 9203613..8833d25 100755 --- a/mk_html +++ b/mk_html @@ -40,35 +40,97 @@ USAGE: #{$0} exit 1 end +def remove_long_to_see_players(file) + return unless file["players"][999] # only for Not-Yet-Rated players + + file["players"][999].delete_if do |key, value| + value['last_modified'] < Time.now - 24*3600*30 # 30 days + end +end + def main lines = "" while l = gets do lines << l end file = YAML::load(lines) - erb = ERB.new( DATA.read, nil, "%<>" ) + erb = ERB.new( DATA.read, nil, "%>" ) tables = [] + group_names = [] + file["players"].keys.sort.each do |index| + if index < 999 + group_names << "#{index}" + else + group_names << "Not-Yet-Rated Players" + end + end + remove_long_to_see_players(file) - file["players"].each do |key, yaml| - sorted_keys = yaml.keys.sort {|a,b| yaml[b]['rate'] <=> yaml[a]['rate']} - - table = ERB.new(<") -<% sorted_keys.each do |key| %> + popup_id = 0 + + file["players"].sort.each do |key, yaml| # sort groups in the order written in players.yaml + sorted_keys = yaml.keys.sort do |a,b| + # sort players in a group by one's rate + if yaml[b]['rate'] == 0 && yaml[a]['rate'] == 0 + # mainly for not-rated-yet players + yaml[b]['last_modified'] <=> yaml[a]['last_modified'] + else + yaml[b]['rate'] <=> yaml[a]['rate'] + end + end + top_rate = nil + table = ERB.new(<") +% sorted_keys.each do |key| <% win = yaml[key]['win'] loss = yaml[key]['loss'] win_rate = win.to_f / (win + loss) last_modified = yaml[key]['last_modified'] + + player_decoration = "default" + + case (Time.now - last_modified)/(60*60*24) + when (0..1) then player_decoration = "today" + when (0..7) then player_decoration = "this_week" + end + + case key + when "yowai_gps+95908f6c18338f5340371f71523fc5e3" then player_decoration = "yowai_gps" + when "gps+11648e4e66e7ed6a86cb7f1d0cf604fe" then player_decoration = "gps" + end + + rate = yaml[key]['rate'] + top_rate ||= rate + diff_rate = rate - top_rate + diff_possibility = 1.0/(1.0 + 10**(-diff_rate/400.0)) %> - - <%=h yaml[key]['name']%> - <%="%5d" % [ yaml[key]['rate'] ]%> - <%="%5d" % [ win ]%> - <%="%5d" % [ loss ]%> - <%="%.3f" % [win_rate]%> - <%=show_date(last_modified)%> + + + <%= h yaml[key]['name'] %> + + + + <%= rate != 0 ? "%5d" % [ rate ] : "N/A" %> + + + + <%= "%5d" % [ win ] %> + + <%= "%5d" % [ loss ] %> + + <%= "%.3f" % [win_rate] %> + + <%= show_date(last_modified) %> -<% end %> +% end ENDTABLE tables << table.result(binding) @@ -89,32 +151,43 @@ __END__ Shogi Server Rating + + + + + + + + + + + - +
+ +
+

Shogi Server Rating

-<% tables.each do |t| %> +% tables.each_with_index do |t, index| +@@ -125,20 +198,36 @@ __END__ - + + + + + + -<%= t %> + <%= t %>
Group: <%=group_names[index]%>
name rate win loss win_rate last_modifiednameratewinloss%last_modified
-<% end %> -

The average of the rates is always 1000. +


+ +% end + +

Groups are independently rated. You can not compare rates across them. +

The average of the rates in a group is always 1000. +

BACK


-
+ + +
+

Last modified at <%=Time.now%> +

$Revision$ +

- +