 
 
   mouseOverHandler: (evt) =>
-    if game.state isnt game.states.GameOver
+    if not game.state.is StateManager.GameOver
       @tileBackground.attr fill: '#ccc'
 
 
   mouseOutHandler: (evt) =>
-    if game.state isnt game.states.GameOver
+    if not game.state.is StateManager.GameOver
       @tileBackground.attr fill: '#ddd'
 
 
   mouseUpHandler: (evt) =>
-    return if game.state is game.states.GameOver
-    if game.state is game.states.Empty
+    return if game.state.is StateManager.GameOver
+    if game.state.is StateManager.Empty
       game.initGame @x, @y
 
     if evt.button is 2 # Right click
       casePosition = game.positionFromCoord @x, @y
       game.board.cases[casePosition].g.remove()
       if game.board.cases[casePosition].constructor is Flag
-        game.board.flagsLbl.attr text: --game.flags
+        game.board.flagsLbl.attr text: "Flags: #{--game.flags}/#{game.nbMines}"
         game.board.cases[casePosition] = new Tile @ctx, @x, @y
       else
-        game.board.flagsLbl.attr text: ++game.flags
+        game.board.flagsLbl.attr text: "Flags: #{++game.flags}/#{game.nbMines}"
         game.board.cases[casePosition] = new Flag @ctx, @x, @y
     else
       @showTile()

      tmp = new Tile @board, x, y
      @cases[i] = tmp

    @flagsLbl = @board.text 0, 0, 'Flags'
    @flagsLbl.transform 'translate(0, 580)'


class Flag extends Tile



  mouseUpHandler: (evt) =>
    return if game.state.is StateManager.GameOver
    if @countFlags() is @countMines()
      for [x, y] in game.neighborCoord @x, @y
        game.board.cases[game.positionFromCoord(x, y)].showTile()
