-fs = require('fs');
-path = require('path-extra');
+fs = require 'fs'
+glob = require 'glob'
+path = require 'path-extra'
 
 {React, ReactDOM, ReactBootstrap} = window
 ModalArea = require './modal-area'

    battlePacketsNonce: 0
    battleNonce: 0
    battlePacket: null

  handleResponse: (e) ->
    `var path;`   # HACK: Force shadowing an variable `path`;

  packet.poi_comment = comment

savePacket = (packet) ->
  setTimeout ->
    return unless packet? and packet.poi_timestamp?
    filename = packet.poi_timestamp
    file = path.join(APPDATA, "#{filename}.json")
    data = JSON.stringify(packet)
    fs.writeFileSync(file, data, FS_RW_OPTIONS)

# filename = "#{packet.poi_timestamp}.json"
loadPacket = (filename, callback) ->
  setTimeout ->
    return unless filename? and callback?
    file = path.join(APPDATA, filename)
    data = fs.readFileSync(file, FS_RW_OPTIONS)
    packet = JSON.parse(data)
    callback(packet)

loadPacketSync = (path) ->
  try
    return unless path?
    data = fs.readFileSync(path, FS_RW_OPTIONS)
    packet = JSON.parse(data)
  catch error
    console.error error


MainArea = React.createClass
  getInitialState: ->
    # Game states
    isCombined: false
