import State from '../state'
import config from '../../config'
import keys from '../../cgt/inputs/keyboard'
import font from '../font'

import screen from './screen'

class PickupState extends State {
    init() {
        this.font = font.get()
    }

    draw(ctx) {
        screen.render(ctx)

        ctx.fillStyle = '#61b946'
        ctx.fillRect(10, 60, 140, 44)

        ctx.fillStyle = '#376928'
        ctx.fillRect(12, 62, 136, 40)

        this.font.draw(ctx, 'Вы подобрали', 15, 55)
        this.font.draw(ctx, config.player().lastItem, 15, 65)
        this.font.draw(ctx, 'A: закрыть', 70, 80)
    }

    update() {
        if (keys.get('A')) {
            this.emit('done')
        }
    }
}

export default PickupState
