-{_} = window
+{_, SERVER_HOSTNAME} = window
 Promise = require 'bluebird'
 async = Promise.coroutine
 request = Promise.promisifyAll require 'request'

      kdockId = parseInt(postBody.api_kdock_id) - 1
      secretaryIdx = _.sortedIndex _ships, {api_id: _decks[0].api_ship[0]}, 'api_id'
      detail =
        item: [parseInt(postBody.api_item1), parseInt(postBody.api_item2), parseInt(postBody.api_item3), parseInt(postBody.api_item4), parseInt(postBody.api_item5)]
        kdockId: kdockId
        largeFlag: (parseInt(postBody.api_large_flag) != 0)
        highspeed: parseInt(postBody.api_highspeed)

    when '/kcsapi/api_get_member/kdock'
      return unless creating
      dock = body[kdockId]
      return if dock.api_item1 != detail.items[0] || dock.api_item2 != detail.items[1] || dock.api_item3 != detail.items[2] || dock.api_item4 != detail.items[3] || dock.api_item5 != detail.items[4]
      detail.shipId = dock.api_created_ship_id
      creating = false
      try
        yield request.postAsync "http://#{SERVER_HOSTNAME}/api/report/create_ship",
          form:
            data: JSON.stringify detail
      catch e
        console.error e
    when '/kcsapi/api_req_sortie/battleresult'
      info =
        shipId: -1
        quest: body.api_quest_name
        enemy: body.api_enemy_info.api_deck_name
        rank: body.api_win_rank
      if body.api_get_ship?
        info.shipId = body.api_get_ship.api_ship_id
      try
        yield request.postAsync "http://#{SERVER_HOSTNAME}/api/report/drop_ship",
          form:
            data: JSON.stringify info
      catch e
        console.error e
module.exports =
