#!/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] # 出力形式(html, txt) if ARGV == [] # 引数が何も指定されていない時 print RACER_COMMAND, "#$0 : 開始日付(未入力の時:マイグレ直後; 2004/05/23) : 終了日付(未入力の時:実行した日) : ワールド名(鯖名) : 形式(ropp, time, timetableなど) : 出力形式出力形式(txt, html, htmllink)\n" exit end world = check_argv_world(world) # ワールド名のチェック check_dir("./" + world) # ワールドディレクトリチェック check_dir("./" + world + "/history") # 履歴ディレクトリチェック # 開始日付が 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 # 個別設定 before_date = 0 history = [] guildlist_breakcount = {} # ギルド別破壊数 guildlist_breakarea = {} # ギルド砦地域別破壊数 guildlist_breaknumber = {} # ギルド砦番号別破壊数 area = number = 0 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_read = "./img/" + css_file # スクリプトから見たCSSファイルパス summary = "Totalize File Table" last3_summary = "Fort Last 3 Week" rank_summary = "Fort Get Ranking" last3_path = "./" + world + "/history/last_3week.html" rank_path = "./" + world + "/history/ranking.html" for count in 0 ... limit_week # time ではなく fortlist の有無で決める prefix = "fortlist" # 日付個別設定 log_path = "./" + world + "/log/" + prefix + "_" + use_datelist[count][0] + ".txt" if FileTest.exist?(log_path) == false # print "攻城戦ログ ", log_path, " は存在しません。\n" # ファイルが存在しないため、日付別砦取得リストに空要素をセット history[count] = fortlist_init('', 0) next # 次の攻城戦ログファイルへ end file_date = Date.parse(use_datelist[count][0]) # 日付取得 now_ymd = file_date.ymd # YYYYMMDD slash_ymd = file_date.ymd_slash # YYYY/MM/DD slash_last3_ymd = (file_date - 14).strftime('%Y/%m/%d') # 3回前(2週間前) # 何も指定しない時は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) # 前回の日付(中止前) other_file = "./" + world + "/log/others_" + now_ymd + ".txt" # その他ファイル bef_fort_path = "./" + world + "/log/fortlist_" + bef_ymd + ".txt" # 前回の砦所有リスト now_fort_path = "./" + world + "/log/fortlist_" + now_ymd + ".txt" # 前回の砦 # 砦別リストファイルの読み込み (fortlist) # bef_fortlist = log_read_fortlist(bef_fort_path) fortlist = log_read_fortlist(now_fort_path) # fortlist: 防衛時間 # 日付別砦取得リストの要素のみを初期化 history[count] = fortlist_setdata(fortlist, 0) # エンペブレイク総回数 guildlist_breakcount = guildlist_fortlist_breakcount(guildlist_breakcount, fortlist) guildlist_breakarea = guildlist_fortlist_breakarea(guildlist_breakarea, fortlist) guildlist_breaknumber = guildlist_fortlist_breaknumber(guildlist_breaknumber, fortlist) end for area in 0 ... ROW history = history_count(history, use_datelist, area) 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 for area in 0 ... ROW fort_summary = getfortarea(area, 2) fort_path = "./" + world + "/history/" + getfortarea(area, 1) + ".html" history_fort = File.open(fort_path, "w") title = world.capitalize + " 砦取得履歴 " + getfortarea(area, 4) input = File.read('./template/header.rhtml') input += File.read('./template/history_fort.rhtml') input += html_history_fort(history, use_datelist, area, fort_summary) input += File.read('./template/footer.rhtml') history_fort.puts ERB.new(input, nil, 1).result(binding()) history_fort.close end history_last3 = File.open(last3_path, "w") title = world.capitalize + " 過去三週履歴" input = File.read('./template/header.rhtml') input += File.read('./template/history_last3.rhtml') for area in 0 ... ROW input += html_history_last3(img_path, history, use_datelist, area, last3_summary) end input += File.read('./template/footer.rhtml') history_last3.puts ERB.new(input, nil, 1).result(binding()) history_last3.close history_rank = File.open(rank_path, "w") title = world.capitalize + " 砦地域別取得回数" input = File.read('./template/header.rhtml') input += File.read('./template/history_rank.rhtml') input += File.read('./template/footer.rhtml') history_rank.puts ERB.new(input, nil, 1).result(binding()) history_rank.close else print "◎砦別取得履歴\n" for area in 0 ... ROW # 砦別取得履歴の出力 print log_history_fort(history, use_datelist, area) end end exit