"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Cell = void 0;
const Tile_1 = require("./Tile");
class Cell {
    constructor({ isEmpty = true, tile = Tile_1.Tile.Null, x, y }) {
        this.isEmpty = isEmpty;
        this.tile = tile;
        this.x = x;
        this.y = y;
    }
    clone() {
        return new Cell({
            isEmpty: this.isEmpty,
            tile: this.tile.clone(),
            x: this.x,
            y: this.y,
        });
    }
    equals(other) {
        return this.x === other.x && this.y === other.y && this.isEmpty === other.isEmpty && this.tile.equals(other.tile);
    }
    hasTile() {
        return this.tile !== Tile_1.Tile.Null;
    }
    isCandidate() {
        return this.isEmpty && this.hasTile();
    }
    toJson() {
        return {
            isEmpty: this.isEmpty,
            tile: this.tile.toJson(),
            x: this.x,
            y: this.y,
        };
    }
    toString() {
        return this.tile.toString();
    }
}
exports.Cell = Cell;
Cell.fromJson = (json) => {
    return new Cell({
        isEmpty: json.isEmpty,
        tile: Tile_1.Tile.fromJson(json.tile),
        x: json.x,
        y: json.y,
    });
};
