let resources = {
    startImg: 'img/start1.png',
    all: [{
        type: 'image',
        name: 'font',
        path: 'img/fnt.png'
    }, {
        type: 'image',
        name: 'mapitems',
        path: 'img/mapitems.png'
    }, {
        type: 'image',
        name: 'person',
        path: 'img/person.png'
    }, {
        type: 'image',
        name: 'battle',
        path: 'img/battle.png'
    }]
}

let keybindings = {
    keyboard: {
        'LEFT': 'KeyA',
        'DOWN': 'KeyS',
        'RIGHT': 'KeyD',
        'UP': 'KeyW',
        'A': 'Enter',
        'B': 'Backspace',
        'START': 'Space',
        'SELECT': 'Escape',
    }
}

let player = {
    level: 'level1',
    dir: 4,
    lastItem: '',
    position: {
        x: 11,
        y: 21
    },
    health: 100,
    items: []
}

import enemies from './enemies'

import maps from './map'

class Config {
    resources() {
        return resources
    }

    keybindings() {
        return keybindings
    }

    player() {
        return player
    }

    enemies() {
        return enemies
    }

    map(level) {
        return level ? maps[level] : maps[player.level]
    }

    startGame() {
        this.loadLevel('level1')
        player.health = 100
        player.items = []
    }

    loadLevel(level) {
        player.level = level
        const initialPosition = this.map().initialPosition()
        player.position = {
            x: initialPosition.x,
            y: initialPosition.y
        }
    }
}

export default new Config()
