Commits

Lucian Brănescu-Mihăilă committed 46fad78

Fix repeating forfeit alert.

Comments (0)

Files changed (1)

scripts/game.coffee

     @clicks += 1
     @env.anvil.view.innerHTML = @clicks
 
-  cps: ->
-    (@clicks / @duration).toPrecision 3
-
   countdown: =>
     if @forfeiting
       return
     if @timer - @refresh > 0 # floats make code silly
       @timer -= @refresh
 
-      @env.timer.view.innerHTML = @timer.toPrecision 2
+      @env.timer.view.innerHTML = @timer.toFixed 2
       @env.cps.view.innerHTML =
-        (@clicks / (@duration - @timer)).toPrecision 3
+        (@clicks / (@duration - @timer)).toFixed 3
 
       setTimeout @countdown, 1000 * @refresh
 
     else
-      alert "Finished! You had #{@cps()} CPS."
+      alert "Finished! You had #{(@clicks / @duration).toFixed 3} CPS."
       @cleanup()
 
   cleanup: ->
 
   forfeit: ->
     @forfeiting = true
-    alert "You forfeited. Coward!"
+    alert "You forfeited. Coward!" if @running
     @cleanup()
 
 setup = ->
     
     $("##{env.menu.id} > .#{env.menu.forfeitClass}").click (ev) ->
       game.forfeit()
+      $("##{env.menu.id} > .#{env.menu.forfeitClass}").unbind('click')
 
 env =
   anvil: