 
   around: (idx, x, y) ->
     neighbors = @neighborCoord x, y
-    neighborsIdx = [@positionFromCoord(item[0], item[1]) for item in neighbors][0]
-
-    return idx in neighborsIdx or
+    neighborsIdx = [@positionFromCoord(item[0], item[1]) for item in neighbors]
+
+    return idx in neighborsIdx[0] or
            idx is @positionFromCoord(x, y) or
            @data[idx] is @entities.Mine
 

  countMines: () ->
    nbMines = 0
    for [x, y] in game.neighborCoord @x, @y
      nbMines++ if game.data[game.positionFromCoord(x, y)] is game.entities.Mine
    return nbMines

  countFlags: () ->
    nbFlags = 0
    for [x, y] in game.neighborCoord @x, @y
      nbFlags++ if game.board.cases[game.positionFromCoord(x, y)].constructor is Flag
    return nbFlags


class TextCase extends Case
  constructor: (@ctx, @x, @y, @number) ->
    @colors = ['blue', 'green', 'red', 'navy', 'maroon', 'aqua', 'purple', 'black']

    super
    @g.unmouseover()

    game.board.cases[casePosition].g.remove()
    game.board.cases[casePosition] = new TextCase(@ctx, @x, @y, nbMinesAround)

    if ++game.safe is game.board.cases.length - game.nbMines
      console.log "WIN"
      return

