 moment = require 'moment'
 
 respawnTimeouts = {}
-healTimeouts = {}
+healIntervals = {}
 
 # A participant in the hammersportening.
 #

    @storage.nextRespawn = moment().add('ms', @reviveTime()).valueOf()
    respawnTimeouts[@id()] = setTimeout fn, @reviveTime()

  # Public: Begin the healing process.
  #
  healOverTime: ->
    healTimeouts[@id()] = null
    return if @hp() >= @maxHP()
    fn = =>
      @storage.hp = Math.min(@maxHP(), @hp() + @healingRate())
      @healOverTime()
    healTimeouts[@id()] = setTimeout fn, 5000

  # Public: Halt the healing process begun with `healOverTime`. Important so you don't heal during
  # a Match!
  #
  startCombat: ->
    clearTimeout(healTimeouts[@id()]) if healTimeouts[@id()]?
    @storage.inCombat = true

  # Public: The Match has ended. Resume healing or schedule a respawn.
  #
  stopCombat: ->
    @storage.inCombat = false
    if @hp() > 0
      @healOverTime()
    else
      @kill()

  displayName: -> "@#{@user.name}"



  levelUp: (amount) -> @storage.exp += amount

  # Public: Simple predicate to determine if this Challenger is alive.
  #
  isAlive: -> @hp() > 0

  # Public: Predicate to determine if this Challenger is in an active Match or not.
  #
  isInCombat: -> @storage.inCombat

  # Public: Revive this Challenger with full HP.
  #
  respawn: ->
