 class GameScene extends Scene
   events: ->
     if ENV.mobile
-      events =
-        'touchend .pause': 'pause'
-        'touchend .mark': 'changeAction'
-        'touchend .fill': 'changeAction'
-        'touchstart': 'onActionStart'
-        'touchmove': 'onActionMove'
-        'touchend': 'onActionEnd'
+      'touchend .pause': 'pause'
+      'touchend .mark': 'changeAction'
+      'touchend .fill': 'changeAction'
+      'touchstart': 'onActionStart'
+      'touchmove': 'onActionMove'
+      'touchend': 'onActionEnd'
     else
-      events =
-        'click .pause': 'pause'
-        'click .mark': 'changeAction'
-        'click .fill': 'changeAction'
-        'mousedown': 'onActionStart'
-        'mouseup': 'onActionEnd'
+      'click .pause': 'pause'
+      'click .mark': 'changeAction'
+      'click .fill': 'changeAction'
+      'mousedown': 'onActionStart'
+      'mouseup': 'onActionEnd'
 
   GRID_SIZE_RATIO: 0.75
   GRID_BACKGROUND_SIZE_RATIO: 0.97


  resizeGrid: ->
    smallestDimension = if @orientation is 'landscape' then @height else @width
    # gridBackgroundSize = Math.round(smallestDimension * @GRID_BACKGROUND_SIZE_RATIO / 10) * 10
    gridBackgroundSize = Math.round(smallestDimension * @GRID_BACKGROUND_SIZE_RATIO)
    borderWidth = parseInt(@gridBackground.css('border-width'), 10) * 2

    @gridBackground.width(gridBackgroundSize)
    @gridBackground.height(gridBackgroundSize)

    if @orientation is 'landscape'
      horizontalMargin = (@height - @gridBackground.width() - borderWidth) / 2
      verticalMargin = (gridBackgroundSize - @gridBackground.height()) / 2
    else if @orientation is 'portrait'
      verticalMargin = (@width - @gridBackground.height() - borderWidth) / 2
      horizontalMargin = (gridBackgroundSize - @gridBackground.width()) / 2

    @gridBackground.css
      margin: "#{horizontalMargin}px #{verticalMargin}px"

    gridSize = Math.round(@gridBackground.width() * @GRID_SIZE_RATIO / 10) * 10
    @grid.width(gridSize)
    @grid.height(gridSize)

    @cellSize = gridSize / 10

    @$('.vertical.clue', @gridBackground).css
      width: @cellSize
      height: gridBackgroundSize - gridSize

    @$('.horizontal.clue', @gridBackground).css
      width: gridBackgroundSize - gridSize
      height: @cellSize

    @$('.minimap', @gridBackground).css
      width: gridBackgroundSize - gridSize
      height: gridBackgroundSize - gridSize

    @grid.children('div').css
      width: @cellSize

      @$('.horizontal.clue', @elem).eq(i).html(horizontalClue)
      @$('.vertical.clue', @elem).eq(i).html(verticalClue)

      @resizeGrid()

module.exports = GameScene
