import StartScene from './start'
import MapScene from './map'
import BattleScene from './battle'

let currentScene

const draw = ctx => currentScene.draw(ctx)
const update = dt => currentScene.update(dt)

const callback = (event, data) => {
    if (event === 'set-scene') {
        setScene(data)
    }
}

const getSceneByName = name => {
    if (name === 'start') return new StartScene(callback)
    if (name === 'map') return new MapScene(callback)
    if (name === 'battle') return new BattleScene(callback)
}

const setScene = scene => {
    currentScene = getSceneByName(scene)
}

setScene('start')

export default {
    draw,
    update
}
