/*
http://squarefaction.ru/files/game/680/gallery/13b2c9fb8129cf2916bd1145d17e4fff.jpg
*/

import res from '../../cgt/resources'
import Font from '../font'
import config from '../../config'

let font
const init = () => {
    font = Font.get()
}

let texts = []
const setText = _texts => {
    texts = _texts
}

let marker = -1
const setMarker = _marker => {
    marker = _marker
}

const render = ctx => {
    ctx.drawImage( res.get('battle'), 0, 0)

    ctx.fillStyle = '#61b946'
    ctx.fillRect(5, 5, 94, 28)

    ctx.fillStyle = '#376928'
    ctx.fillRect(7, 7, 90, 24)

    font.draw(ctx, 'Некроморф', 10, 0)
    font.draw(ctx, 'Здоровье ' + config.player().battle.health, 10, 10)



    ctx.fillStyle = '#61b946'
    ctx.fillRect(60, 80, 94, 28)

    ctx.fillStyle = '#376928'
    ctx.fillRect(62, 82, 90, 24)

    font.draw(ctx, 'Айзек', 65, 75)
    font.draw(ctx, 'Здоровье ' + config.player().health, 65, 85)



    ctx.fillStyle = '#61b946'
    ctx.fillRect(0, 110, 160, 34)

    ctx.fillStyle = '#376928'
    ctx.fillRect(2, 112, 156, 30)

    texts.forEach((text, i) => {
        font.draw(ctx, text, 15, 105 + i * 9)
    })

    if (texts[marker]) {
        ctx.fillStyle = '#c1e3b6'
        ctx.fillRect(6, 117 + marker * 9, 4, 4)
    }
}

export default {
    render,
    init,
    setText,
    setMarker
}
