#!/usr/bin/env ruby
require File.expand_path('../../../config/environment', __FILE__)

ENV["RUN_REMOTE"] = "true"

tp Swars::User

tp Swars::Agent.new.record_get(key: "MinoriChihara-YamadaTaro-20190111_084942")

Swars::Battle.destroy_all
Swars::Importer::BattleImporter.new(key: "MinoriChihara-YamadaTaro-20190111_084942").call
record = Swars::Battle.first
tp record
puts record.kifu_body
# >> |----+---------------+----------+-------------------+-------------------+---------------------------+---------------------------|
# >> | id | user_key      | grade_id | last_reception_at | search_logs_count | created_at                | updated_at                |
# >> |----+---------------+----------+-------------------+-------------------+---------------------------+---------------------------|
# >> |  1 | MinoriChihara |       12 |                   |                 0 | 2019-01-12 15:54:24 +0900 | 2019-01-12 17:04:24 +0900 |
# >> |  2 | YamadaTaro     |        1 |                   |                 0 | 2019-01-12 15:54:24 +0900 | 2019-01-12 17:04:24 +0900 |
# >> |----+---------------+----------+-------------------+-------------------+---------------------------+---------------------------|
# >> |-------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
# >> |               key | MinoriChihara-YamadaTaro-20190111_084942                                                                                                                                                                                                                             |
# >> |               url | https://shogiwars.heroz.jp/games/MinoriChihara-YamadaTaro-20190111_084942?locale=ja                                                                                                                                                                                    |
# >> |        battled_at | 20190111_084942                                                                                                                                                                                                                                                     |
# >> | preset_magic_number | 5                                                                                                                                                                                                                                                                   |
# >> |          gamedata | {:name=>"MinoriChihara-YamadaTaro-20190111_084942", :avatar0=>"_e1812s10c", :avatar1=>"coach04", :dan0=>"2級", :dan1=>"十段", :gtype=>""}                                                                                                                            |
# >> |        user_stats | [{:user_key=>"MinoriChihara", :grade_key=>"2級"}, {:user_key=>"YamadaTaro", :grade_key=>"十段"}]                                                                                                                                                                     |
# >> |       __final_key | GOTE_WIN_TORYO                                                                                                                                                                                                                                                      |
# >> |           csa_seq | [["-7162GI", 599], ["+2726FU", 597], ["-4132KI", 598], ["+6978KI", 590], ["-5354FU", 596], ["+3948GI", 588], ["-6253GI", 595], ["+9796FU", 582], ["-9394FU", 594], ["+7776FU", 568], ["-4344FU", 592], ["+7968GI", 563], ["-5162OU", 589], ["+6877GI", 552], ["-... |
# >> |           st_done | true                                                                                                                                                                                                                                                                |
# >> |-------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
# >> |-------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
# >> |                id | 5                                                                                                                                                                                                                                                                                                          |
# >> |               key | MinoriChihara-YamadaTaro-20190111_084942                                                                                                                                                                                                                                                                    |
# >> |        battled_at | 2019-01-11 08:49:42 +0900                                                                                                                                                                                                                                                                                  |
# >> |          rule_key | ten_min                                                                                                                                                                                                                                                                                                    |
# >> |           csa_seq | [["-7162GI", 599], ["+2726FU", 597], ["-4132KI", 598], ["+6978KI", 590], ["-5354FU", 596], ["+3948GI", 588], ["-6253GI", 595], ["+9796FU", 582], ["-9394FU", 594], ["+7776FU", 568], ["-4344FU", 592], ["+7968GI", 563], ["-5162OU", 589], ["+6877GI", 552], ["-...                                        |
# >> |         final_key | TORYO                                                                                                                                                                                                                                                                                                      |
# >> |       win_user_id | 2                                                                                                                                                                                                                                                                                                          |
# >> |          turn_max | 67                                                                                                                                                                                                                                                                                                         |
# >> |         meta_info | {:header=>{"先手"=>"MinoriChihara 2級", "後手"=>"YamadaTaro 十段", "開始日時"=>"2019/01/11 08:49:42", "棋戦"=>"将棋ウォーズ(10分切れ負け 指導対局 二枚落ち)", "持ち時間"=>"00:10+00"}, :detail_names=>[[], []], :simple_names=>[[["MinoriChihara", "2級"]], [["YamadaTaro", "十段"]]], :skill_set_hash=>{... |
# >> |   last_accessd_at | 2019-01-12 17:04:34 +0900                                                                                                                                                                                                                                                                                  |
# >> | access_logs_count | 0                                                                                                                                                                                                                                                                                                          |
# >> |        created_at | 2019-01-12 17:04:35 +0900                                                                                                                                                                                                                                                                                  |
# >> |        updated_at | 2019-01-12 17:04:35 +0900                                                                                                                                                                                                                                                                                  |
# >> |        preset_key | 二枚落ち                                                                                                                                                                                                                                                                                                   |
# >> |  defense_tag_list |                                                                                                                                                                                                                                                                                                            |
# >> |   attack_tag_list |                                                                                                                                                                                                                                                                                                            |
# >> |    other_tag_list |                                                                                                                                                                                                                                                                                                            |
# >> |   secret_tag_list |                                                                                                                                                                                                                                                                                                            |
# >> |-------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
# >> N+MinoriChihara 2級
# >> N-YamadaTaro 十段
# >> $START_TIME:2019/01/11 08:49:42
# >> $EVENT:将棋ウォーズ(10分切れ負け 指導対局 二枚落ち)
# >> $TIME_LIMIT:00:10+00
# >> P1-KY-KE-GI-KI-OU-KI-GI-KE-KY
# >> P2 *  *  *  *  *  *  *  *  *
# >> P3-FU-FU-FU-FU-FU-FU-FU-FU-FU
# >> P4 *  *  *  *  *  *  *  *  *
# >> P5 *  *  *  *  *  *  *  *  *
# >> P6 *  *  *  *  *  *  *  *  *
# >> P7+FU+FU+FU+FU+FU+FU+FU+FU+FU
# >> P8 * +KA *  *  *  *  * +HI *
# >> P9+KY+KE+GI+KI+OU+KI+GI+KE+KY
# >> -
# >> -7162GI
# >> T1
# >> +2726FU
# >> T3
# >> -4132KI
# >> T1
# >> +6978KI
# >> T7
# >> -5354FU
# >> T2
# >> +3948GI
# >> T2
# >> -6253GI
# >> T1
# >> +9796FU
# >> T6
# >> -9394FU
# >> T1
# >> +7776FU
# >> T14
# >> -4344FU
# >> T2
# >> +7968GI
# >> T5
# >> -5162OU
# >> T3
# >> +6877GI
# >> T11
# >> -6172KI
# >> T2
# >> +6766FU
# >> T2
# >> -7374FU
# >> T5
# >> +4958KI
# >> T2
# >> -3142GI
# >> T9
# >> +5867KI
# >> T7
# >> -5455FU
# >> T1
# >> +4746FU
# >> T3
# >> -4243GI
# >> T6
# >> +4847GI
# >> T2
# >> -4354GI
# >> T14
# >> +3736FU
# >> T19
# >> -3334FU
# >> T8
# >> +2625FU
# >> T13
# >> -3233KI
# >> T1
# >> +2937KE
# >> T15
# >> -1314FU
# >> T7
# >> +1716FU
# >> T10
# >> -7273KI
# >> T11
# >> +4645FU
# >> T17
# >> -3435FU
# >> T21
# >> +5756FU
# >> T32
# >> -5556FU
# >> T14
# >> +6756KI
# >> T4
# >> -3536FU
# >> T15
# >> +4736GI
# >> T5
# >> -0035FU
# >> T2
# >> +3647GI
# >> T8
# >> -0055FU
# >> T6
# >> +5646KI
# >> T13
# >> -3334KI
# >> T2
# >> +2524FU
# >> T15
# >> -4445FU
# >> T20
# >> +3745KE
# >> T6
# >> -5445GI
# >> T3
# >> +2423TO
# >> T10
# >> -4546GI
# >> T23
# >> +4746GI
# >> T4
# >> -0025FU
# >> T9
# >> +0044FU
# >> T42
# >> -0047KI
# >> T42
# >> +4443TO
# >> T25
# >> -5364GI
# >> T18
# >> +8879KA
# >> T31
# >> -0036KE
# >> T4
# >> +2818HI
# >> T36
# >> -5556FU
# >> T1
# >> +4635GI
# >> T40
# >> -5657TO
# >> T4
# >> +0049FU
# >> T48
# >> -3435KI
# >> T4
# >> +6665FU
# >> T25
# >> -0058GI
# >> T3
# >> %TORYO
