   largeFlag: false
   secretary: -1
   shipId: -1
-## ## ## ## ## ## ## ##
+# Game listener
+### TODO Add event map level ###
 window.addEventListener 'game.response', async (e) ->
   {method, path, body, postBody} = e.detail
-  {_ships, _decks} = window
+  {_ships, _decks, _teitokuLv} = window
   switch path
+    # Create ship report
     when '/kcsapi/api_req_kousyou/createship'
       creating = true
       kdockId = parseInt(postBody.api_kdock_id) - 1

      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
    # when '/kcsapi/api_get_member/questlist'
    #  try
    #    yield request.postAsync "http://#{SERVER_HOSTNAME}/api/report/quest_list",
    #      form:
    #        data: JSON.stringify body.api_list
    #  catch e
    #    console.error e
module.exports =
  name: 'Reporter'
  author: [<a key={0} href="https://github.com/magicae">Magica</a>]
  displayName: <span><FontAwesome key={0} name='pie-chart' /> 数据汇报</span>
  description: '汇报建造数据、海域掉落数据、任务数据'
  show: false
  version: '1.1.0'

Promise = require 'bluebird'
async = Promise.coroutine
request = Promise.promisifyAll require 'request'
# Create ship record
creating = false
kdockId = -1
detail =
