# レーサー集計HTML/CSS template # header, footer, link, ankerlink # フォーマット:XHTML1.1 / CSS2.0 形式 # 文字列のエスケープ # 特殊文字(&\"<>)、空白スペースをHTML用にエスケープする。 module HTMLUtils ESC = { '&' => '&', '"' => '"', '<' => '<', '>' => '>', ' ' => ' ' } def escape(str) table = ESC # optimize str.gsub(/[&"<>]/n) {|s| table[s] } return str end def urlencode(str) str.gsub(/[^\w\.\-]/n) {|ch| sprintf('%%%02X', ch[0]) } return str end end include HTMLUtils # 文字列のエスケープ - cgi.rb CGI::escapeHTML(string) より # ギルド名に含まれる特殊文字(&\"<>)をHTML用にエスケープする。 #def escape(string) # string = string.gsub(/&/n, '&').gsub(/\"/n, '"').gsub(/>/n, '>').g#sub(/[#{getfortarea(area, 2).to_s}] 〜#{getfortarea(area, 4).to_s}〜(#{getfortarea(area, 7).to_s})
EOF for number in 0 ... COLUMN strings += " \n" fortname = (number+1).to_s strings += " \n" strings += " \n" count_week = limit_week - 1 while count_week > (limit_week-4) if use_datelist[count_week][1] == 1 # 攻城戦中止 strings += " \n" else if history[count_week] == nil strings += " \n" else if history[count_week][area][number][1] != 0 strings += " \n" end end count_week -= 1 end strings += " \n" end strings += "
No. 砦名 所有ギルド 前回の砦所有ギルド 前々回の砦所有ギルド
" + (number+1).to_s + "" + FORT_NAME[LANG][area][number] + "攻城戦中止" + history[count_week][area][number][0] strings += "(" + history[count_week][area][number][1].to_s + ")" else strings += " " + history[count_week][area][number][0] end strings += "
\n" strings += "

\n" return strings end # 砦地域・番号別取得回数 def html_history_fort(history, use_datelist, area, summary) limit_week = use_datelist.length count_week = number = count = count_bin = 0 strings =<#{getfortarea(area, 2).to_s} EOF for number in 0 ... COLUMN fortname = getfortarea(area, 2).to_s + " " + (number+1).to_s strings += "\n" end strings += " \n" count_week = limit_week - 1 while count_week >= 0 use_date = Date.parse(use_datelist[count_week][0]) # 日付オブジェクト slash_ymd = use_date.ymd_slash strings += " \n" strings += " \n" if use_datelist[count_week][1] == 1 # 攻城戦中止 strings += " \n" else for number in 0 ... COLUMN if history[count_week] == nil strings += " \n" else if history[count_week][area][number][1] != 0 strings += " \n" end end end strings += " \n" count_week -= 1 end strings += "
Date/No." + fortname + "
" + FORT_NAME[LANG][area][number] + "
" + slash_ymd + "攻城戦中止" + history[count_week][area][number][0] strings += "(" + history[count_week][area][number][1].to_s + ")" else strings += " " + history[count_week][area][number][0] end strings += "
\n" strings += "

\n" return strings end # 商業値予想まとめ # 29, 59, 100の時 def html_cp_list(cp_week_two, cp_week_four, cp_all, summary) line = [] count = count_bin = 0 line[count+=1] =< 商業投資切替値 29 50 100 EOF for area in 0 ... ROW for number in 0 ... COLUMN fortname = getfortarea(area, 2) + " " + (number+1).to_s if cp_all[area][number][1] > CP_LIMIT # 全力投資にリミットかける line[count+=1] =< #{fortname} #{cp_week_two[area][number][1].to_s} #{cp_week_four[area][number][1].to_s} #{cp_all[area][number][1].to_s} EOF_CP end end end line[count+=1] = "\n" return line end # 商業値100になったと予想される日付 def html_fortlist_cp100_datelist(fortlist, summary) line = [] count = count_bin = 0 line[count+=1] =< 砦名 日 EOF for area in 0 ... ROW for number in 0 ... COLUMN fortname = getfortarea(area, 2) + " " + (number+1).to_s if fortlist[area][number][1] != 0 # 日付が入っていれば line[count+=1] = " \n" line[count+=1] = " " line[count] += fortname + "\n" line[count+=1] = " " + fortlist[area][number][1] + "\n" line[count+=1] = " \n" end end end line[count+=1] = "\n" return line end =begin == 最終結果 各砦の最終確保ギルド名、堅守、落城回数、占領時間を各地域ごとに出力します。 攻城戦時間が終わる20分以上前に占領してそのまま防衛した場合 落城回数の後に占領時間を付けます。 出力形式はLydia板攻城戦スレ形式です。 === 入力 堅守回数 占領回数 防衛時間 === 空白 fortlist[砦地域][砦番号] = nil の場合 fortlist[砦地域][砦番号][1] = 0 の場合 =end def html_fortlist_guildinfo(defense, breakcount, breaktime, limittime) line = [] count = 0 limitsec = str2sec(limittime) for area in 0 ... ROW line[count] = "

▼ " + getfortarea(area, 6) # 街名 line[count] += " ["+ getfortarea(area, 2) + "]

\n" line[count+=1] = "
    \n" for number in 0 ... COLUMN line[count+=1] = "
  1. " if defense[area][number] == nil # 空白の時 line[count] += "\n" elsif defense[area][number][1] != 0 # 堅守している時 line[count] += "" + defense[area][number][0] + " (☆" line[count] += defense[area][number][1].to_s + ")" # (回数/占領時間〜) limittime 以前に占領してたとき elsif str2sec(breaktime[area][number][1]) <= limitsec line[count] += defense[area][number][0] + " (" line[count] += breakcount[area][number][1].to_s + "/" line[count] += breaktime[area][number][1] + "〜)" else line[count] += defense[area][number][0] + " (" line[count] += breakcount[area][number][1].to_s + ")" end line[count+=1] = "
  2. \n" end line[count+=1] = "
\n" line[count+=1] = "\n" count += 1 end return line end =begin == 最終結果 各砦の最終確保ギルド名、堅守、落城回数、占領時間を各地域ごとに出力します。 時系列表専用です。 === 入力 堅守回数 占領回数 防衛時間 === 出力 最終確保ギルド名 堅守/落城回数/占領時間 === 空白 fortlist[砦地域][砦番号] = nil の場合 fortlist[砦地域][砦番号][1] = 0 の場合 =end def html_fortlist_lastinfo(path, breakcount, breaktime, summary) line = [] count = 0 line[count] =< 地域 EOF for number in 1 .. COLUMN line[count+=1] = " " + number.to_s + "\n" end line[count+=1] = " \n" for area in 0 ... ROW line[count+=1] = " \n" line[count+=1] = " \n" else line[count] += " class=\"note_green\">\n" end line[count] += "\n" # 砦地域 for number in 0 ... COLUMN if breakcount[area][number] == nil # 空白の時 line[count+=1] = " " else # (回数/占領時間〜) line[count+=1] = " " else line[count] += " class=\"note_green\">" end line[count] += "
" + breaktime[area][number][1] + "〜(" line[count] += breakcount[area][number][1].to_s + "回)
" line[count] += "
" + breakcount[area][number][0] + "
" end line[count] += "\n" end line[count+=1] = " \n" end line[count+=1] = "\n" return line end =begin == 砦別集計を行列形式で出力 === 対応点 小数点 行列と全体の合計平均計算 桁数調整 === figure_decimal 小数点下の表示させる桁数 0の時は、整数だけを表示する。 === param 1. 平均、合計を出力するかどうか (ON:2,3 /OFF: 0,1) 2以上/1以下 2. 空白を0で埋めるかどうか (ON:1,3 /OFF: 0,2) 奇数/偶数 例: %010.4 全部で10桁で表現(整数、小数点、'.'(1桁)の桁数の合計) 小数点下は4桁、空白は0で埋める =end def html_fortlist_matrix(fortlist, figure_decimal, param, summary) line = [] count = count_bin = total = average = 0 (total_row, total_column, total) = matrix_total(fortlist, ROW, COLUMN) (average_row, average_column, average) = matrix_average(total_row, total_column, total) # 合計の数の桁数を全体の表示桁数にする(表示を最大の桁数に合わせる) if figure_decimal == 0 # 整数なら小数点の点の桁を削除する figure = total.prec_i.to_s.length else figure = total.prec_i.to_s.length + figure_decimal + 1 end fig_put = "%" # 行列の出力フォーマット設定、空白を0で埋めるかどうか if (param == 1) || (param == 3) then fig_put += "0" end fig_put += figure.to_s + "." + figure_decimal.to_s + "f" line[count] =< 地域\番号 EOF for number in 1 .. COLUMN # 一番上の砦番号 line[count+=1] = " " + number.to_s + "\n" end if (param == 2) || (param == 3) # 一番上の平均、合計の列 line[count+=1] = " 合計\n" line[count+=1] = " 平均\n" end line[count+=1] = " \n" for area in 0 ... ROW line[count+=1] = " \n" line[count+=1] = " " line[count] += getfortarea(area, 4) + "\n" for number in 0 ... COLUMN line[count+=1] = " " # '0'のとき太字、深緑色に変更(例:無占領なら堅守表示) if fortlist[area][number][1] == 0 line[count] += "" line[count] += sprintf("#{fig_put}", fortlist[area][number][1].to_s) line[count] += "" else line[count] += sprintf("#{fig_put}", fortlist[area][number][1].to_s) end line[count] += "\n" end if (param == 2) || (param == 3) # 平均、合計の列 line[count+=1] = " " # 各列の一行の合計 line[count] += sprintf("#{fig_put}", total_row[area]) line[count] += "\n" line[count+=1] = " " # 各列の一行の平均 line[count] += sprintf("#{fig_put}", average_row[area]) line[count] += "\n" end line[count+=1] = " \n" end if (param == 2) || (param == 3) # 平均、合計の行 # 各行の一列の合計 line[count+=1] = " \n" line[count+=1] = " 合計\n" for number in 0 ... COLUMN line[count+=1] = " " line[count] += sprintf("#{fig_put}", total_column[number]) line[count] += "\n" end line[count+=1] = " " + sprintf("#{fig_put}", total) + "\n" line[count+=1] = " \n" line[count+=1] = " \n" # 各行の一列の平均 line[count+=1] = " \n" line[count+=1] = " 平均\n" for number in 0 ... COLUMN line[count+=1] = " " line[count] += sprintf("#{fig_put}", average_column[number]) line[count] += "\n" end line[count+=1] = " \n" line[count+=1] = " " + sprintf("#{fig_put}", average) + "\n" line[count+=1] = " \n" end line[count+=1] = "\n" line[count+=1] = "\n" return line end # 時系列表 def html_timetable(path, img_path, breaklist, start_time, past_time, summary) line = [] count = count_bin = 0 line[count] = "" rate = 6.0 # 行の時間比率(小数点以下も計算する) for area in 0 ... ROW id = "index_" + getfortarea(area, 1) idname = getfortarea(area, 1) # Valkyrie fortarea = getfortarea(area, 1) name = html_image(img_path + fortarea + ".gif", "80", "15", fortarea) line[count+=1] =< #{html_link_hrefid(path, id, idname, name)}

EOF for number in 0 ... COLUMN # 砦地域の後に砦番号を付ける fortname = getfortarea(area, 2) + " " + (number+1).to_s line[count+=1] = " \n" end line[count+=1] = " \n" line[count+=1] = " \n" for number in 0 ... COLUMN # 砦地域の後に砦番号を付ける fortname = getfortarea(area, 2) + " " + (number+1).to_s line[count+=1] =<
" line[count] += fortname + "
" + FORT_NAME[LANG][area][number] + "
EOF_TAB limit = breaklist[fortname].length if limit < 2 print "Limit Error: ", limit, "\n" exit # エラー出力して終了 elsif limit == 2 diff = time_diff(past_time, start_time) # 攻城戦開始からの経過時間 # 防衛時間(秒)から縦の長さを設定 # line[count+=1] =< EOF_HEIGHT1 else count_bin = 0 for row in 0 ... limit-1 # 表の中に表を作る diff = time_diff(breaklist[fortname][row+1][0], breaklist[fortname][row][0]) nowtime = breaklist[fortname][row][0] # 防衛時間(秒)から縦の長さを設定 # line[count+=1] =< EOF_HEIGHT2 end end line[count+=1] = "
#{start_time} #{breaklist[fortname][0][1]}
#{nowtime} #{breaklist[fortname][row][1]}
\n" line[count+=1] = " \n" end line[count+=1] = " \n" line[count+=1] = "\n" end return line end =begin == 砦別リスト ハッシュ、配列両方対応 === 出力 平均防衛時間 陥落回数 商業値下降 最終的な砦主 完全防衛/落城後奪還/なし =end def html_fort(path, breaklist, summary) line = [] count = count_bin = limit = 0 line[count] = "" breaklist.each { |key, value| count_bin = 0 # 最初の行背景色は灰色 limit_break = limit = value.length area = getfortcode(key) # 砦地域番号取得 if /(\d)$/ =~ key number = $1.to_i - 1 # 砦番号取得 end if value == nil then next end # 配列がない場合は飛ばす for row in 0 ... limit # 最初の砦所持はブレイク数から除外 if value[row][0] == GVG_TIME['START'][0] limit_break -= 1 end end if (limit-2) == 0 # fortの場合は開始と終了以外の合計が陥落回数 totaltime = "2:00:00" else totaltime = sec2str(7200 / (limit-2)) end line[count+=1] =<#{html_link_id(key)} - #{FORT_NAME[LANG][area][number]} EOF for row in 0 ... (limit-1) line[count+=1] =< EOF_LIST if value[row][1] != value[row+1][1] guild = value[row][1] guild_link = html_link_href(path, guild) line[count+=1] = " \n" else line[count+=1] = " \n" end guild = value[row+1][1] guild_link = html_link_href(path, guild) line[count+=1] = " \n" line[count+=1] = " \n" end line[count+=1] =<

平均防衛時間:#{totaltime}
陥落回数:#{(limit-2).to_s} 商業値下降:#{(-(limit-2)*5).to_s}
最終的な砦主は[#{html_link_href(path, value[row+1][1])}]

EOF_LAST if limit == 2 # 完全防衛したかどうか line[count+=1] = "

完全防衛

\n" else # 落城後奪還 (time, guild) = value.last if value[0][1] == guild line[count+=1] = "

落城後奪還

" end end } line[count+=1] = "\n" return line end =begin == ギルド別リスト ハッシュ、配列両方対応 === 出力 総防衛時間 平均防衛時間 占領回数 =end def html_guild(path_fort, path_guild, breaklist, summary) line = [] count = count_bin = limit = limit_break = 0 key = value = befguild = nextguild = "" breaklist.each { |key, value| count_bin = 0 # 最初の行背景色は灰色 limit_break = limit = value.length if value == nil then next end # 配列がない場合は飛ばす for row in 0 ... limit # 最初の砦所持はブレイク数から除外 if value[row][0] == GVG_TIME['START'][0] limit_break -= 1 end end line[count+=1] =<#{html_link_id(key)}
占領時間 落城時間 防衛時間 占領されたギルド 占領したギルド
#{value[row][0]} #{value[row+1][0]} #{time_diff(value[row+1][0], value[row][0])}" + guild_link + "-" + guild_link + "
EOF total = 0 # 総防衛時間(秒) for row in 0 ... limit line[count+=1] =< EOF_LIST total += (str2sec(value[row][1]) - str2sec(value[row][0])) # 総防衛時間 end average = total / limit # 平均防衛時間(秒) line[count+=1] =<

総防衛時間:#{sec2str(total)}
平均防衛時間:#{sec2str(average)}
占領回数:#{(limit_break).to_s}

EOF_LAST } return line end =begin == レーサー集計表作成(全体用) === fort area 砦地域 (V, C, B, L) number 砦番号 (1-5) etc 無し =end def html_guildlist_breakrank(guildlist, fort, summary) line = [] count = count_bin = limit = total = col = 0 rank = now_rank = before_rank = now_point = before_point = 0 color = guild = "" line[count] =<
EOF # 砦地域の数または砦番号の数を求める guildlist.each_value{ |value| limit = value.length; break; } if fort == "area" # 砦地域 Total, B, C, L, V # 砦地域別取得回数のソート, 重み順番:合計 > B > C > L > V #guild_rank = guildlist.sort{|x, y| [y[1][2], y[1][1], y[1][3], y[1][0]] <=> [x[1][2], x[1][1], x[1][3], x[1][0]]} guild_rank = guildlist.sort{ |x, y| total_y = total_x = 0 for col in 0 ... ROW total_y += y[1][col] total_x += x[1][col] end [total_y, y[1][2], y[1][1], y[1][3], y[1][0]] <=> [total_x, x[1][2], x[1][1], x[1][3], x[1][0]] } line[count+=1] =<VR EOF_AREA elsif fort == "number" # 砦番号 Total, 1-5 guild_rank = guildlist.sort{ |x, y| total_y = total_x = 0 for col in 0 ... COLUMN total_y += y[1][col] total_x += x[1][col] end [total_y, y[1][0], y[1][1], y[1][2], y[1][3], y[1][4]] <=> [total_x, x[1][0], x[1][1], x[1][2], x[1][3], x[1][4]] } for col in 0 ... COLUMN line[count+=1] = " \n" end else end guild_rank.each { |guild| rank += 1 now_point = guild[1] total = 0 for col in 0 ... limit total += guild[1][col] end line[count+=1] = " \n" unless before_point == now_point now_rank = rank end if rank <= 10 # Top 10 に入っている場合緑色にする color = " class=\"darkgreen\"" else color = "" end if before_rank != now_rank # 今と直前が同じでないとき line[count+=1] = " " + now_rank.to_s + "位\n" else line[count+=1] = " \n" # 今と直前が同じなら順位表示しない end line[count+=1] =<#{sprintf("%d回", total)} EOF_LAST for col in 0 ... limit if guild[1][col] == 0 line[count+=1] = " " + "-" else line[count+=1] = " " + sprintf("%d", guild[1][col]) end end line[count+=1] = " \n" count += 1 before_rank = now_rank # 今の順位を記憶 before_point = now_point # 今の点数を記憶 } line[count] = "
占領時間 落城時間 防衛時間 占領した砦 占領されたギルド 占領したギルド
#{value[row][0]} #{value[row][1]} #{time_diff(value[row][1], value[row][0])} #{html_link_href(path_fort, value[row][2])} #{html_link_href(path_guild, value[row][3])} #{html_link_href(path_guild, value[row][4])}
順位 回数 ギルド名CG BG LG" + (col+1).to_s + "
#{guild[0]}
\n" return line end # ギルドランキング # 砦を獲得してる場合はその砦名も出力 def html_guildlist_timelist(guildlist, guildlist_getfort, summary) guild_array = guildlist.sort{ |x, y| y[1] <=> x[1]} line = [] count = count_bin = rank = 0 # 直前の順位 guild = time = before_time = "" color = left = strong_lt = strong_gt = "" line[count] =< 順位 ギルド名 時間 獲得砦 EOF guild_array.each { |guild, time| rank += 1 getfort = guildlist_getfort[guild] if rank <= 10 # Top 10 に入っている場合緑色にする color = " class=\"darkgreen\"" else color = "" end if getfort != nil # 獲得砦がある場合 left = " align=\"left\"" strong_lt = "" strong_gt = "" else getfort = "" # nil を空白に変える(文字列連結用) left = strong_lt = strong_gt = "" end line[count+=1] = " \n" if before_time == time # 今の順位の時間が直前と同じなら順位を省略 line[count+=1] = " \n" else line[count+=1] = " " line[count] += strong_lt + rank.to_s + strong_gt + "位\n" end line[count+=1] =<#{strong_lt}#{escape(guild)}#{strong_gt} #{strong_lt}#{time}#{strong_gt} #{strong_lt}#{getfort}#{strong_gt} EOF_LAST before_time = time # 今の順位の時間を記憶 } line[count+=1] = "\n" return line end # ギルドランキングリスト作成 # breakfort: [0:OFF, 1:ON] def html_guildlist_ranklist(guildlist, breakfort, summary) # caption = "EB Ranking" # #{caption} line = [] count = count_bin = before_rank = 0 # 直前の順位 # イテレータ変数の事前宣言(高速化用) guild = announce = rank = getfort = breaklist = "" color = left = strong_lt = strong_gt = "" line[count] =< 順位 回数 ギルド名 獲得砦 EOF if breakfort == 1 line[count] += " 占領砦\n" end line[count+=1] = " \n" guildlist.each { |guild, announce, rank, getfort, breaklist| line[count+=1] = " \n" if guild == "" then next end # ギルド名が空白の時は省略 if rank <= 10 # Top 10 に入っている場合緑色にする color = " class=\"darkgreen\"" else color = "" end if getfort != "" # 獲得砦がある場合 left = " align=\"left\"" strong_lt = "" strong_gt = "" else left = strong_lt = strong_gt = "" end if before_rank != rank # 今の順位が直前と同じ順位なら順位を表示させない line[count+=1] = " " line[count] += strong_lt + rank.to_s + strong_gt + "位\n" else line[count+=1] = " \n" end line[count+=1] =<#{strong_lt}#{announce.to_s}#{strong_gt}回 #{strong_lt}#{escape(guild)}#{strong_gt} #{strong_lt}#{getfort}#{strong_gt} EOF_LAST if breakfort == 1 line[count+=1] = " " line[count] += strong_lt + breaklist + strong_gt + "\n" end line[count+=1] = " \n" count += 1 before_rank = rank # 今の順位を記憶 } line[count] = "\n" return line end # レーサー集計表作成(全体用) def html_guildlist_ranking(guildlist, table, summary) # caption = "EB Ranking" # #{caption} line = [] count = count_bin = 0 rank = now_rank = before_rank = now_point = before_point = 0 # イテレータ変数の事前宣言(高速化用) color = guild = "" rank_name = table['rank'] point_name = table['point'] figure = table['figure'] line[count] =< 順位 #{rank_name} ギルド名 EOF guild_rank = guildlist.sort{|x, y| y[1] <=> x[1]} guild_rank.each { |guild| rank += 1 if figure > 0 # 小数点下表示桁数 now_point = sprintf("%.#{figure}f", guild[1]).to_f else now_point = guild[1] end line[count+=1] = " \n" unless before_point == now_point now_rank = rank end if rank <= 10 # Top 10 に入っている場合緑色にする color = " class=\"darkgreen\"" else color = "" end if before_rank != now_rank # 今と直前が同じでないとき line[count+=1] = " " + now_rank.to_s + "位\n" else line[count+=1] = " \n" # 今と直前が同じなら順位表示しない end # line[count+=1] = " " + sprintf("%d", guild[1]) + point_name line[count+=1] = " " if figure > 0 # 小数点下表示桁数 line[count] += sprintf("%6.#{figure}f", guild[1]) + point_name else line[count] += guild[1].to_s + point_name end line[count] += "\n" line[count+=1] = " " line[count] += guild[0] + "\n" line[count+=1] = " \n" count += 1 before_rank = now_rank # 今の順位を記憶 before_point = now_point # 今の点数を記憶 } line[count] = "\n" return line end # レーサー集計表作成(全体用) def html_guildlist_racer(guildlist, summary) # caption = "EB Ranking" # #{caption} line = [] count = count_bin = 0 rank = now_rank = before_rank = now_point = before_point = 0 # イテレータ変数の事前宣言(高速化用) color = guild = "" line[count] =< 順位 回数 ギルド名 EOF guild_rank = guildlist.sort{|x, y| y[1] <=> x[1]} guild_rank.each { |guild| rank += 1 now_point = guild[1] line[count+=1] = " \n" unless before_point == now_point now_rank = rank end if rank <= 10 # Top 10 に入っている場合緑色にする color = " class=\"darkgreen\"" else color = "" end if before_rank != now_rank # 今と直前が同じでないとき line[count+=1] = " " + now_rank.to_s + "位\n" else line[count+=1] = " \n" # 今と直前が同じなら順位表示しない end line[count+=1] = " " + sprintf("%d回", guild[1]) line[count] += "\n" line[count+=1] = " " line[count] += guild[0] + "\n" line[count+=1] = " \n" count += 1 before_rank = now_rank # 今の順位を記憶 before_point = now_point # 今の点数を記憶 } line[count] = "\n" return line end # SERA集計表作成 def html_guildlist_sera(guildlist, summary) # caption = "EB Ranking" # #{caption} line = [] count = count_bin = 0 rank = now_rank = before_rank = now_point = before_point = 0 # イテレータ変数の事前宣言(高速化用) color = guild = "" line[count] =< 順位 破壊点 ギルド名 EOF guild_rank = guildlist.sort{|x, y| y[1] <=> x[1]} guild_rank.each { |guild| rank += 1 now_point = sprintf("%.1f", guild[1]).to_f line[count+=1] = " \n" unless before_point == now_point now_rank = rank end if rank <= 10 # Top 10 に入っている場合緑色にする color = " class=\"darkgreen\"" else color = "" end if before_rank != now_rank # 今と直前が同じでないとき line[count+=1] = " " + now_rank.to_s + "位\n" else line[count+=1] = " \n" # 今と直前が同じなら順位表示しない end line[count+=1] =<#{sprintf("%6.1f点", guild[1])} #{guild[0]} EOF_LAST count += 1 before_rank = now_rank # 今の順位を記憶 before_point = now_point # 今の点数を記憶 } line[count] = "\n" return line end # RoWiki集計表作成(全体用) def html_guildlist_rowiki(guildlist, summary) # caption = "EB Ranking" # #{caption} line = [] count = count_bin = 0 rank = now_rank = before_rank = now_point = before_point = 0 # イテレータ変数の事前宣言(高速化用) color = guild = "" line[count] =< 順位 点数 ギルド名 EOF guild_rank = guildlist.sort{|x, y| y[1] <=> x[1]} guild_rank.each { |guild| rank += 1 now_point = guild[1] line[count+=1] = " \n" unless before_point == now_point now_rank = rank end if rank <= 10 # Top 10 に入っている場合緑色にする color = " class=\"darkgreen\"" else color = "" end if before_rank != now_rank # 今と直前が同じでないとき line[count+=1] = " " + now_rank.to_s + "位\n" else line[count+=1] = " \n" # 今と直前が同じなら順位表示しない end line[count+=1] =<#{sprintf("%d点", guild[1])} #{guild[0]} EOF_LAST count += 1 before_rank = now_rank # 今の順位を記憶 before_point = now_point # 今の点数を記憶 } line[count] = "\n" return line end =begin == 画像の貼り付け =end def html_image(path, width, height, alt) string = "\""" return string end =begin == html_link =end =begin == 各種ログのリンク表作成 === linklistの要素名 index 表の要素名 abbr 表の要素の属性名 prefix ファイル名の接頭辞 suffix ファイル名の接尾辞 =end def html_link_table(world, use_datelist, linklist, summary) # 日付の範囲のHTMLを生成する limit_week = use_datelist.length limit_index = linklist["index"].length use_date = "" line = [] count = count_bin = count_week = 0 line[count] = "\n" line[count+=1] = " \n" for count_th in 0 ... limit_index # 一覧表の項目名 line[count+=1] = " \n" end line[count+=1] = " \n" count_week = limit_week - 1 while count_week >= 0 # 一覧表の項目(■)作成 use_date = Date.parse(use_datelist[count_week][0]) # 日付オブジェクト slash_ymd = use_date.ymd_slash line[count+=1] = " \n" line[count+=1] = " \n" if use_datelist[count_week][1] == 1 # 攻城戦中止 line[count+=1] = " \n" else for count_ext in 1 ... limit_index # 0: 日付のため省略 filename = linklist["prefix"][count_ext] + use_datelist[count_week][0] filename += linklist["suffix"][count_ext] + ".html" path_link = linklist["link"] + filename path_file = linklist["file"] + filename line[count+=1] = " \n" end end line[count+=1] = " \n" count_week -= 1 end line[count+=1] = "
" line[count] += linklist["index"][count_th] + "
" + slash_ymd + "攻城戦中止" line[count] += html_link_file(path_file, path_link) + "
\n" return line end =begin == ID付きリンクを張る === 入力 path リンクパス (herf="path") id 選択するID名 (herf="#ID") idname ID名 (id="idname") name リンク名 (
タグで囲まれる) === 出力 path, id, idname全部が空白の時はnameだけを返す path, id, idnameのどれかの入力があった場合はnameのID付きリンクを返す。 =end def html_link_hrefid(path, id, idname, name) if (path == "") && (id == "") && (idname == "") return name # path, id, idname全部が空白の時 else # path, id, idname のどれか1つにデータがあるとき string = "" # リンク名 return string end =begin == IDリンクを作る(エスケープあり) =end def html_link_id(string) return "#{escape(string)}" end =begin == ID付きリンクを張る(エスケープあり) =end def html_link_href(path, string) return "#{escape(string)}" end # ファイルのリンクを張る # ファイルがあるとき:■にリンクを張る # ファイルがないとき:□(リンクなし) def html_link_file(path, path_link) if FileTest.exist?(path) == true return "" + "■" else # ファイルが存在しない時 return "□" end end # HTML内のCSSファイル指定 # CSSファイルの場所をタグで記述する。(XHTML1.1の推奨形式) def html_link_css(path) return " \n" end # 地図表示 # 地図を表示させるJavaScriptファイルの場所をタグで記述する。 def html_link_script(path) return " \n" end # HTML内にCSS/JavaScriptを埋め込む # HTMLとCSS/JavaScriptをまとめて1ファイルにしたい時に使う。 def html_read_tag(path, tag, element) if FileTest.exist?(path) == false print "ファイル ", path, " は見つかりませんでした。\n" exit end line = [] count = 0 file = File.open(path) line[count] = " <" + tag + " " + element + ">\n" line[count+=1] = " \n" line[count+=1] = " \n" return line end # 宣言(XML, XHTML) def html_first string = < EOF return string end # タグに記述するCSS, JavaScript def html_head_insert(link, css_set, css_read, map_set, map_read) if link == "link" string = html_link_css(css_set) if (map_set != "") && (map_read != "") string += html_link_script(map_set) end else string = html_read_tag(css_read, "style", "type=\"text/css\"") if (map_set != "") && (map_read != "") string += html_read_tag(map_read, "script", "type=\"text/javascript\"") end end return string end # ヘッダ(HTMLの最初) def html_head(title, insert) string = < #{title} #{insert} EOF return string end # フッタ(HTMLの最後) # link の中身が"link"の場合はファイルにリンクする def html_footer(path, link) strings = "" if link == "link" strings = < インデックスページに戻ります。

EOF_INDEX end string += < EOF return strings end # 表組の色を決める(時間線の表示用) # 水:奇数のとき # 灰:偶数のとき def color_bin_timeline(count) if (count % 2) == 1 # 奇数行は灰色、偶数行は水色 return "time_blue" else return "time_gray" end end # 表組の色を決める # 白:奇数のとき # 灰:偶数のとき def color_bin(count) if (count % 2) == 1 # 奇数行は灰色、偶数行は白色 return "bg_silver" else return "bg_white" end end # 更新間隔(秒) def html_head_refresh(path, refresh) string = < EOF return string end # 文字コードセット def html_charset_ShiftJIS return "Content-type: text/html; charset=Shift_JIS\n\n" end