import CGT from '../cgt'
import scenes from '../scenes'
import Resources from '../cgt/resources'
import Config from '../config'
import World from '../world'
import Helpers from './helpers'
import Area from './area'
import Market from './market'
import { Player, Bot } from './player'

const start = () => {
    Player.init()
    Bot.init()

    CGT.start(scenes(), {
        keepaspectratio: true,
        init: ctx => {
            ctx.imageSmoothingEnabled = true
            ctx.imageSmoothingQuality = 'high'
        }
    })
}

const makeArea = type => new Area(Config.areas[type])

const getBuildingInfo = type => Config.buildings[type]

let world = null
const getWorld = (createNew) => {
    if (!world || createNew) {
        world = new World
    }
    return world
}

export default {
    CGT,
    Resources,
    Config,
    Helpers,
    Market,

    Player,
    Bot,

    start,
    makeArea,

    getBuildingInfo,
    getWorld
}
