   
 setupUnits = ->
   $("#board").addClass("battle-start")
-  $(".tile").html("").removeClass("path current enemy")
+  $(".tile").html("").removeClass("path current enemy").removeData("unitId")
   clearUnitInfoBoxes()
   for id, unit of window.BattleLog.participants
     unit.currentHP = unit.hp
     tile = getTile(unit.spawn_point)
     tile.html("<span class='unit-icon team-#{unit.team}-unit'></span>")
+    tile.data("unitId", id)
+    unit.id = id
     unit.location = unit.spawn_point
 
 pauseReplay = ->

moveUnit = (source, dest, unit) ->
  tile = getTile(dest)
  tile.html("<span class='unit-icon team-#{unit.team}-unit'></span>")
  getTile(source).html("")
  currentUnit().location = dest

$("#play").click ->

    window.iid = window.setInterval(nextTick, window.replaySpeed)
  false

$(".tile").click( ->
  id = $(this).data("unitId")
  showDetails(id) if id?
)

showDetails = (id) ->
  $(".current").removeClass("current")
  $(".target").removeClass("target")
  $(".path").removeClass("path")
  $(".enemy").removeClass("enemy")
  $(".hit").removeClass("hit")
  unit = getUnit(id)
  qr = unit.location
  $("#tile-#{qr[0]}-#{qr[1]}").addClass("current")

  clearUnitInfoBoxes()
  updateUnitInfoBox(unit, true)
  if unit.target?
    target = getUnit(unit.target)
    qr = target.location
    $("#tile-#{qr[0]}-#{qr[1]}").addClass("enemy")
    updateUnitInfoBox(target, false)
  
