 inventory = new class Inventory
     constructor: ->
         @words = []
+        @name = null
 
     add: (word) ->
-        if word == shoot_name?.full
+        if word == @name?.full
+            if @words.length >= player.longest.length
+                player.longest = @words
             @words = []
         else if word in @words
             @words.remove(word)
         else
             @words.push(word)
         if not @words.length
-            shoot_name = null
+            @name = null
         else
-            shoot_name = new ShootingWord('@neizod')
+            @name = new ShootingWord('@neizod')
 
     show: ->
-        follow = if shoot_name? then ' ' + shoot_name.show.html() else ''
+        follow = if @name? then ' ' + @name.show.html() else ''
         (word for word in @words).join(' ') + follow
 
 


stage_height = 300
stage_width = 1000

animate_id = null
shoot_name = null


player = new class Player

    player.die = true if pool_words.attack()
    pool_words.draw()
    if player.die
        clearInterval(player.game)
        player.game = null
        $('#playground').css('background-color', 'darkred')


$(document).keydown (event) ->
    if event.keyCode == 13 # enter
        if not player.game?
            player.game = setInterval(draw, 12)
    if event.keyCode in [8, 27, 46] # backspace, escape, delete
        if player.word?
            player.word.reset()
