import { Container, RenderLayer } from "pixi.js";

export class Game {
    constructor() {
        this._difficulty = 1;
        this.won = false;
        this.gameContainer = new Container(); // main container, to add the game to a node, add this container as a child
        this.gameContainer.layout = true;
        /*
        this._uiLayer = new Container();
        this._gameObjectsLayer = new Container();*/
        this._uiLayer = new RenderLayer();
        this._gameObjectsLayer = new RenderLayer();
        this._gameObjectsLayer.sortableChildren = true;
        this.gameContainer.addChild(this._gameObjectsLayer);
        this.gameContainer.addChild(this._uiLayer);
    }

    /* should reset the game to its initial position*/
    reset() {
        this.won = false;
    }

    /* start the game */
    start() {
        this.reset();
    }

    /* status indicates if its a win or a loss */
    end(status) {
        this.win = status;
        console.log(status ? "game won" : "game lost");
        // we probably want to call a callback here
    }

    _addGameObjectChild(node) {
        this.gameContainer.addChild(node);
        this._gameObjectsLayer.attach(node);
    }

    _addUiChild(node) {
        this.gameContainer.addChild(node);
        this._uiLayer.attach(node);
    }
}
