     if player.word?.remain == ''
         player.point += player.word.full.length
         inventory.add(player.word)
-        pool_words.update()
+        pool.update()
         player.word.reset()
         player.word = null
         player.lvl += 1
-        pool_words.autofill()
+        pool.autofill()
     if player.pair?.remain == ''
         player.pair = null

        @game = null
        @longest = []


pool_words = new class
    constructor: ->
        @words = []
        @actions = ['box', 'kick', 'punch', 'strike']

        if @remain == @full
            @repr.html($('<b>').html(@full))
        else
            @repr.html([$('<u>').html(@done()), $('<b>').html(@remain)])

    reset: ->
        @remain = @full
        @update()




animate = new class
    constructor: ->
        @id = null

    start: ->
        @id = setInterval(@loop, 12)
        $('#playground').css('background-color', 'lightblue')

    stop: ->
        clearInterval(@id)
        $('#playground').css('background-color', 'darkred')

    reset: ->
        @id = null
        for reinit_object in [player, inventory, pool]
            reinit_object.constructor()
        pool.autofill()

    loop: =>
        fps.loop()
        pool.loop()
        $('#fps').html(fps.show())
        $('#point').html(player.point)
        $('#keep').html(inventory.show())
        $('#playground').html(word.repr for word in pool.words)
        player.die = true if pool.attack()
        if player.die
            @stop()
            @reset()


$(document).keydown (event) ->
    if event.keyCode == 13 # enter
        if not animate.id?
            animate.start()
            if animate.id == 1
                pool.words = []
                pool.add('kick')
    if event.keyCode in [8, 27, 46] # backspace, escape, delete
        player.reset()


$(document).keypress (event) ->
    c = String.fromCharCode(event.charCode)
    if not player.word?
        player.word = pool.get(c)
    if not player.word?
        player.word = inventory.get_name(c)
    if player.word?
        if player.word.full == player.word.remain
            player.pair = inventory.get(player.word.full)
