import Scene from '../cgt/scene'
import Menu from '../menu'
import App from '../app'

export default class EndScene extends Scene {

    start() {
        this.lastItemSelected = null

        this.lastWorldLoaded = 'new'

        this.world = App.getWorld()
        this.world.angle.setOptions(.1, 0)
        this.world.drawAreasWithResources = false
        this.world.hoveredSector = null
        this.world.selectedSector = null

        const area = this.world.areas.find(area => area.getBuilding() && area.getBuilding().type === 'WIN')
        const menuType = area.buildingOwner === App.Player ? 'win' : 'fail'
        this.menu = Menu.get(menuType)
    }

    update(dt) {
        this.world.angle.inc(10)
        this.world.update(dt)
    }

    draw(ctx) {
        this.world.draw(ctx)
        this.menu.draw(ctx)
    }
}
