import Game from '../core/game'

export default class Rules {
    constructor () {
        this.score = 0

        this.msg = ''

        Game.on('enemykilled', () => {
            this.score += 5
        })

        Game.on('userwonround', reason => {
            this.score += 10

            this.msg = 'You won'

            Game.stop()
        })

        Game.on('enemyhit', reason => {
            this.score += 1
        })

        Game.on('lose', reason => {
            this.score += 1
            this.msg = 'You lose'

            Game.stop()
        })

        Game.on('draw', () => {
            Game.emit('log', this.msg)
            Game.emit('log', 'Score: ' + this.score)
        })

        // this.mousemsg = ''
        // Game.on('scenepointermove', ev => {
        //     const x = Math.floor(ev.x)
        //     const y = Math.floor(ev.y)
        //     this.mousemsg = `mouse: ${x}, ${y}`
        // })

        // Game.on('draw', () => {
        //     Game.emit('log', this.mousemsg)
        // })
    }
}
