import Game from '../engine';
import Rooms from './rooms';
import Items from './items';
import MeowCommand from './commands/meow';

if (localStorage.getItem("save")) {
    document.getElementById("save-game-found").hidden = false;
    document.getElementById("before-play").hidden = true;
    document.getElementById("load-save-game").addEventListener("click", () => {
        document.getElementById("save-game-found").hidden = true;
        document.getElementById("play-area").hidden = false;
        startGame(false);
    })
    document.getElementById("start-new-game").addEventListener("click", () => {
        document.getElementById("save-game-found").hidden = true;
        document.getElementById("play-area").hidden = false;
        startGame(true);
    })
}

document.getElementById("begin").addEventListener("click", () => {
    document.getElementById("before-play").hidden = true;
    document.getElementById("play-area").hidden = false;
    startGame(true);
})

function startGame(newGame) {
    const game = new Game(newGame);

    game.init({
        rooms: Rooms,
        commands: [
            [["meow", "mew"], MeowCommand]
        ],
        items: Items
    });
}
