#!/usr/bin/env ruby -Ks # レーサー集計一覧表作成 require 'gvglib.rb' start_day = ARGV[0] # 開始日付 end_day = ARGV[1] # 終了日付 world = ARGV[2] # ワールド名(鯖名) prefix = ARGV[3] # 形式(ropp, time, timetableなど) out_format = ARGV[4] # 出力形式(txt, html) before_date = ARGV[5].to_i # 数字型:何日前か(参照する日付)未入力は0 if ARGV == [] # 引数が何も指定されていない時 print RACER_COMMAND, "#$0 : 開始日付(未入力の時:マイグレがあった日; 2004/05/20) : 終了日付(未入力の時:実行した日) : ワールド名(鯖名) : 形式(ropp, time, timetableなど) : 出力形式(txt, html, htmllink, bbs) \n" exit end world = check_argv_world(world) # ワールド名のチェック check_dir("./" + world) # ワールドディレクトリチェック check_dir("./" + world + "/csv") # 合計ディレクトリチェック check_dir("./" + world + "/total") # 合計ディレクトリチェック # 開始日付が 0 の時は DATE['START']['SET'] に設定 start_day = check_argv_day(start_day, DATE['START']['SET']) # 終了日付が 0 の時は今日の日付に設定 end_day = check_argv_day(end_day, Date.today.ymd) start_date = Date.parse(start_day) end_date = Date.parse(end_day) use_datelist = datelist_make(start_date, end_date) # 日付リスト use_datelist = datelist_delete(use_datelist) # 中止日付リスト limit_week = use_datelist.length # 開始日付、終了日付 slash_start_ymd = Date.parse(use_datelist[0][0]).ymd_slash slash_end_ymd = Date.parse(use_datelist[limit_week-1][0]).ymd_slash # 個別設定 index_path = "./index.html" # インデックスへのリンク(TOPに戻るリンク先) index_up_path = "../index.html" # トップへのリンク(一つ上に戻るリンク先) img_path = "../../img/" # 生成されるHTMLから見たImageディレクトリの場所 css_file = "racer.css" # 使用するCSSファイル css_set = img_path + css_file # HTML内のCSSファイルパス css_up_set = "../img/" + css_file # index.htmlから見たCSSファイルパス css_read = "./img/" + css_file # スクリプトから見たCSSファイルパス map_file = "mapviewer.js" # 使用するJavaScriptファイル map_set = img_path + map_file # HTML内のJavaScriptファイルパス map_read = "./img/" + map_file # スクリプトから見たJavaScriptファイルパス integer = 0 # 整数の時は0, 小数点下の時は桁数を入れる param = 2 # 数字を桁揃えしない、集計あり figure = 2 # 数字の桁数(数字型) # 倍率: V C B L (ROWikiランキング用) rate = [0.5, 1.2, 1.5, 1 ] #rate = [1 , 6.5, 9 , 1 ] # Lydiaの場合 list_path = "./" + world + "/list.html" last_path = "./" + world + "/total/last.txt" table_path = "./" + world + "/index.html" total_dir = "./" + world + "/total/" last_html = total_dir + "last.html" cp_html = total_dir + "cp.html" # それぞれの回数データを格納するハッシュ # 全部、10回、8回、5回、4回 total_times = ['all', 'ten', 'eight', 'five', 'four'] total_timescount = { 'all' => limit_week, 'ten' => 10, 'eight' => 8, 'five' => 5, 'four' => 4, } total = {} total_times.each{ |times| dates = limit_week - total_timescount[times] total[times] = {} total[times]['slash_ymd'] = Date.parse(use_datelist[dates][0]).ymd_slash total[times]['fort'] = fortlist_init('', 0) total[times]['racer'] = {} total[times]['sera'] = {} total[times]['rowiki'] = {} total[times]['average'] = {} total[times]['defense'] = {} total[times]['race_fort'] = {} total[times]['bprate'] = {} total[times]['min_bprate'] = {} total[times]['odds'] = {} total[times]['html_racer'] = total_dir + times + "_racer.html" total[times]['html_sera'] = total_dir + times + "_sera.html" total[times]['html_rowiki'] = total_dir + times + "_rowiki.html" total[times]['html_stat'] = total_dir + times + "_stat.html" total[times]['csv_racer'] = total_dir + times + "_racer.csv" total[times]['csv_sera'] = total_dir + times + "_sera.csv" total[times]['csv_rowiki'] = total_dir + times + "_rowiki.csv" total[times]['bef_week'] = dates total[times]['week'] = 0 } # 表データ(ハッシュ)要素名、表の後には"\"を付ける linklist = { # 表の要素の属性名(ラベル) 'index' => ["日付", "レーサー集計", "SERA集計", "時系列表", "砦別戦績", "ギルド別戦績", "統計"], 'abbr' => ["date", "racer", "sera", "timetable", "fort", "guild", "stat"], # ファイル名の接頭辞 (racer, sera, time, ropp, ...) 最初は日付: "" 'prefix' => ["", "racer_", "sera_", "timetable_", "fort_", "guild_", "stat_"], # ファイル名の接尾辞 (rank, guild, ajito, ...) 最初は日付: "" 'suffix' => ["", "", "", "", "", "", ""], 'link' => "./report/", 'file' => "./" + world + "/report/" } # 閾値まで商業値を増やす week_two = 29 week_four = 50 all = 100 defense_count = fortlist_init('', 0) cp100_two = fortlist_init('', 0) cp100_four = fortlist_init('', 0) cp100_all = fortlist_init('', 0) cp100_datelist = fortlist_init('', 0) cp100_date = use_date = "" cp_two = fortlist_init('', 1) cp_four = fortlist_init('', 1) cp_all = fortlist_init('', 1) deny_count = week = count_week = count_day = 0 bef_fortlist = now_fortlist = fortlist_init('', 0) # 初期化 for count_week in 0 ... limit_week if use_datelist[count_week][1] == 1 deny_count += 1 # 攻城戦中止回数 end log_file = prefix + "_" + use_datelist[count_week][0] + ".txt" log_path = "./" + world + "/log/" + log_file csv_racer_file = "racer_" + use_datelist[count_week][0] + ".csv" csv_racer_path = "./" + world + "/csv/" + csv_racer_file csv_sera_file = "sera_" + use_datelist[count_week][0] + ".csv" csv_sera_path = "./" + world + "/csv/" + csv_sera_file csv_rowiki_file = "rowiki_" + use_datelist[count_week][0] + ".csv" csv_rowiki_path = "./" + world + "/csv/" + csv_rowiki_file csv_breakfort_file = "breakfort_" + use_datelist[count_week][0] + ".csv" csv_breakfort_path = "./" + world + "/csv/" + csv_breakfort_file if FileTest.exist?(log_path) == true week += 1 # 攻城戦データが存在する週数 if use_datelist[count_week][1] == 1 then next end # 攻城戦中止なら飛ばす file_date = Date.parse(use_datelist[count_week][0]) # 日付取得(YMD) now_ymd = file_date.ymd # 日付取得(YYYYMMDD) now_y_m_d = file_date.ymd_under # 日付取得(YYYY_MM_DD) # 何も指定しない時は1週間前の日付を設定する if before_date == 0 then before_date = 7 end bef_ymd = (file_date - before_date).ymd bef_ymd = datelist_before(use_datelist, bef_ymd) # 前回の日付(中止前) # 前回と今回の砦所有リスト設定 bef_fort_path = world + "/log/fortlist_" + bef_ymd + ".txt" # 前回の砦名一覧リストチェック if FileTest.exist?(bef_fort_path) == true # 前回の砦占領リスト bef_fortlist = log_read_fortlist(bef_fort_path) else print bef_fort_path, " は見つかりませんでした。\n" print "前回の結果を初期化して使います。\n" bef_fortlist = fortlist_init('', 0) # 初期化 end # 攻城戦ログから砦別占領回数のリスト作成 fort_breakcount = log_read_csv_fortlist(csv_breakfort_path, "\t") guildlist_racer = log_read_csv_guildlist(csv_racer_path, "\t") guildlist_sera = log_read_csv_guildlist(csv_sera_path, "\t") guildlist_rowiki = log_read_csv_guildlist(csv_rowiki_path, "\t") # 回数集計 total_times.each{ |times| if count_week >= total[times]['bef_week'] total[times]['fort'] = fortlist_add(total[times]['fort'], fort_breakcount) total[times]['racer'] = guildlist_add(total[times]['racer'], guildlist_racer) total[times]['sera'] = guildlist_add(total[times]['sera'], guildlist_sera) total[times]['rowiki'] = guildlist_add(total[times]['rowiki'], guildlist_rowiki) total[times]['week'] += 1 # 実際に実行した回数(週) end } # 商業値計算 for count_day in 0 ... 7 # 1週間分繰り返す cp_two = fortlist_cp_upto(cp_two, week_two) cp_four = fortlist_cp_upto(cp_four, week_four) cp_all = fortlist_cp_upto(cp_all, all) # 商業値100の日付を求める cp100_date = Date.parse(use_datelist[count_week][0]) + count_day use_date = cp100_date.ymd_slash cp100_two = fortlist_cp_check(cp100_two, cp_two, use_date) cp100_four = fortlist_cp_check(cp100_four, cp_four, use_date) cp100_all = fortlist_cp_check(cp100_all, cp_all, use_date) end # 砦別占領回数より砦別商業値を減らす cp_two = fortlist_cp_down(cp_two, fort_breakcount) cp_four = fortlist_cp_down(cp_four, fort_breakcount) cp_all = fortlist_cp_down(cp_all, fort_breakcount) defense_count = fortlist_defadd(fort_breakcount, defense_count) bef_fortlist = fort_breakcount else # ファイルが存在しない時 print "攻城戦ログ ", log_path, " は存在しません。\n" next # 次の攻城戦ログファイルへ end end =begin limit_day = end_date.wday for count_day in 0 ... limit_day # 今日の予想商業値 cp_two = fortlist_cp_upto(cp_two, week_two) cp_four = fortlist_cp_upto(cp_four, week_four) cp_all = fortlist_cp_upto(cp_all, all) # 商業値100の日付を求める cp100_date = Date.parse(use_datelist[count_week][0]) + count_day use_date = cp100_date.ymd_slash cp100_two = fortlist_cp_check(cp100_two, cp_two, use_date) cp100_four = fortlist_cp_check(cp100_four, cp_four, use_date) cp100_all = fortlist_cp_check(cp100_all, cp_all, use_date) end =end # 砦別最終占領時間 now_fort_path = world + "/log/fortlist_" + now_ymd + ".txt" # 最終週砦別リスト fort_deftime = log_read_fortlist(now_fort_path) # 砦別防衛時間 fort_breaktime = fortlist_timediff(fort_deftime, GVG_TIME_END) # 砦別最終占領時間 if out_format =~ /^html/ # HTML形式で出力 link = out_format.gsub('html', '') insert = html_head_insert(link, css_set, css_read, "", "") path_top = index_up_path ##### 回数集計 total_times.each{ |times| # レーサー総集計用 total[times]['all_break'] = 0 total[times]['racer'].each{ |key, value| total[times]['all_break'] += value # 占領総回数 } total[times]['all_guild'] = total[times]['racer'].length # ギルド総数 total[times]['average'] = fortlist_average(total[times]['fort'], total[times]['all_break']) total[times]['defense'] = fortlist_defense(total[times]['fort'], total[times]['average']) total[times]['race_fort'] = fortlist_race(total[times]['defense']) # レース会場リスト total[times]['bprate'] = fortlist_bprate(total[times]['fort'], total[times]['all_break']) total[times]['min_bprate'] = fortlist_min_bprate(total[times]['bprate']) total[times]['odds'] = fortlist_odds(total[times]['bprate'], total[times]['min_bprate']) # 全体集計出力(HTML) racer = File.open(total[times]['html_racer'], "w") # レーサー集計 title = world.capitalize + " レーサー集計" input = File.read('./template/header.rhtml') input += File.read('./template/times_racer.rhtml') input += File.read('./template/footer.rhtml') racer.puts ERB.new(input, nil, 1).result(binding()) racer.close sera = File.open(total[times]['html_sera'], "w") # SERA集計 title = world.capitalize + " SERA集計" input = File.read('./template/header.rhtml') input += File.read('./template/times_sera.rhtml') input += File.read('./template/footer.rhtml') sera.puts ERB.new(input, nil, 1).result(binding()) sera.close rowiki = File.open(total[times]['html_rowiki'], "w") # RoWiki集計 title = world.capitalize + " RoWiki集計" input = File.read('./template/header.rhtml') input += File.read('./template/times_rowiki.rhtml') input += File.read('./template/footer.rhtml') rowiki.puts ERB.new(input, nil, 1).result(binding()) rowiki.close stat = File.open(total[times]['html_stat'], "w") # 統計 title = world.capitalize + " 統計" input = File.read('./template/header.rhtml') input += File.read('./template/times_stat.rhtml') input += File.read('./template/footer.rhtml') stat.puts ERB.new(input, nil, 1).result(binding()) stat.close # 全体集計出力(CSV) log_write_csv_guildlist_ranking(total[times]['csv_racer'], total[times]['racer'], "\t") log_write_csv_guildlist_ranking(total[times]['csv_sera'], total[times]['sera'], "\t") log_write_csv_guildlist_ranking(total[times]['csv_rowiki'], total[times]['rowiki'], "\t") } ##### 回数集計 # 今回の集計用 total_break = 0 for area in 0 ... ROW # 占領総回数(ログの長さ) for number in 0 ... COLUMN total_break += fort_breakcount[area][number][1] end end average = fortlist_average(fort_breakcount, total_break) defense = fortlist_defense(fort_breakcount, average) perfect_defense = fortlist_perfect_defense(fort_breakcount) # 堅守砦文字列 race_fort = fortlist_race(defense) # レース会場文字列 last = File.open(last_html, "w") # 最終結果 title = world.capitalize + " 最終結果" input = File.read('./template/header.rhtml') input += File.read('./template/last.rhtml') input += File.read('./template/footer.rhtml') last.puts ERB.new(input, nil, 1).result(binding()) last.close cp = File.open(cp_html, "w") # 商業値予想 title = world.capitalize + " 商業値予\想" input = File.read('./template/header.rhtml') input += File.read('./template/cp.rhtml') input += File.read('./template/footer.rhtml') cp.puts ERB.new(input, nil, 1).result(binding()) cp.close list = File.open(list_path, "w") insert = html_head_insert(link, css_up_set, css_read, "", "") title = world.capitalize + " 全一覧表" input = File.read('./template/header.rhtml') input += File.read('./template/list.rhtml') input += File.read('./template/footer.rhtml') list.puts ERB.new(input, nil, 1).result(binding()) list.close # 最初の10週だけコピー ten_datelist = [] last_ten = use_datelist.length - 10 for ten_count in 0 ... 10 ten_datelist[ten_count] = use_datelist[last_ten] last_ten += 1 end table = File.open(table_path, "w") title = world.capitalize + " 集計目次" # index.html(=table)用CSS input = File.read('./template/header.rhtml') input += File.read('./template/index.rhtml') input += File.read('./template/footer.rhtml') table.puts ERB.new(input, nil, 1).result(binding()) table.close # 最終結果テキスト版 last = File.open(last_path, "w") input = File.read('./template/last.rtxt') last.puts ERB.new(input, nil, 1).result(binding()) last.close else input = File.read('./template/last.rtxt') puts ERB.new(input, nil, 1).result(binding()) print "\n" input = File.read('./template/cp.rtxt') puts ERB.new(input, nil, 1).result(binding()) exit end exit