import AbstractView from "./abstracts/AbstractView.js";
import { lang } from "../index.js";
import { TicTacToe } from "../api/game/tictactoe/TicTacToeGame.js"

export class TicTacToeOnlineView extends AbstractView
{
    constructor(params, titleKey)
    {
        super(params, lang.get('ticTacToeTitle'));
        this.params = params;
        this.titleKey = titleKey;
		this.game_id = params.id;
        this.height = 660;
        this.width = 660;
    }

    async postInit()
    {
        this.Morpion = new TicTacToe(this.height, this.width, 60, 60, document.getElementById("Morpion"), this.game_id);
        this.Morpion.DrawSuperMorpion();
		await this.Morpion.init();
		this.Morpion.setOutline();
    }

    async leavePage()
    {
		this.Morpion.uninit();
    }

    setTitle()
    {
        document.title = lang.get(this.titleKey, this.titleKey);
    }

    async getHtml() {
        return `
        <link rel="stylesheet" href="/static/css/tictactoe.css">
        <div id="canva">
			<canvas id="Morpion" width="${this.width}" height="${this.height}"></canvas>
		</div>
        <h1>Work in progress bozo</h1>
        <img src="https://i.imgur.com/hh4yjO9.jpeg&">
        <img src="https://i.imgur.com/TpOtHY6.png&">
        <img src="https://i.imgur.com/O8F314O.jpeg&">`;
    }
}