<commit_before>'use strict';

/**
 * @param {jQuery} $el
 * @param {int}    size
 * @param {Player} player
 *
 * @constructor
 */
function Battlefield($el, size, player) {
    this.$html = $el;
    this.size = size;
    this.player = player;

    this.init();
}

/**
 * @property {jQuery}        $html
 *
 * @property {int}           size
 * @property {Player}        player
 * @property {cellContainer} cellContainer
 */
Battlefield.prototype = {
    /**
     * @returns {Battlefield}
     */
    init: function () {
        this.cellContainer = new CellContainer();

        let cellHTML = Cell.resources.html.layout,
            $cellRow = $(CellContainer.resources.html.layout),
            $top = $cellRow
                .clone()
                .append(cellHTML);

        this.$html.append($top);

        for (let y = 0; y < this.size; y++) {
            let $row = $cellRow.clone();

            this.cellContainer.xAxisNav.push((new Cell(this.prepareCoordinate(0, y), this)).actAsAxisLabel('digit'));
            this.cellContainer.yAxisNav.push((new Cell(this.prepareCoordinate(y, 0), this)).actAsAxisLabel('letter'));

            this.$html.append($row);

            $row.append(this.cellContainer.xAxisNav[y].$html.clone());
            $top.append(this.cellContainer.yAxisNav[y].$html.clone());

            for (let x = 0; x < this.size; x++) {
                let cell = (new Cell(this.prepareCoordinate(x, y), this)).setState(Cell.resources.config.state.sea.live);
                $row.append(cell.$html);
                this.cellContainer.addCell(cell);
            }

            $row.append(this.cellContainer.xAxisNav[y].$html.clone());
        }

        $top.append(cellHTML);
        this.$html.append($top.clone());

        return this;
    },
    /**
     * @param {{id: {int}, coordinate: {string}}} criteria
     *
     * @returns {Cell}
     */
    findCell: function (criteria) {
        return this.cellContainer.findCell(criteria);
    },
    /**
     * @return {{id: {int|string}}
     */
    getJSON: function () {
        return {id: this.id}
    },
    /** *** *** *** *** *** *** *** *** *** *** *** *** *** **/
    mockData: function () {
        let ship = Cell.resources.config.state.ship,
            self = this;

        ["A2", "A3", "C3", "C4", "C5", "C1", "D1", "E1", "F1", "G5", "G6", "F3"].forEach(function (coordinate) {
            self.findCell({coordinate: coordinate}).setState(ship.live);
        });
        ["A1"].forEach(function (coordinate) {
            self.findCell({coordinate: coordinate}).setState(ship.dead);
        })
    },
    /**
     * @param {int} x
     * @param {int} y
     *
     * @returns {string}
     */
    prepareCoordinate: function (x, y) {
        return String.fromCharCode(97 + x).toUpperCase() + (1 + y);
    }
};<commit_msg>ES6/ECMA6 Conversion: Battlefield Model<commit_after>'use strict';

class Battlefield {
    /**
     * @param {jQuery} $el
     * @param {int}    size
     * @param {Player} player
     */
    constructor($el, size, player) {
        this.$html  = $el;
        this.size   = size;
        this.player = player;

        this.init();
    }

    /**
     * @returns {Battlefield}
     */
    init() {
        this.cellContainer = new CellContainer();

        let cellLayout     = Cell.resources.layout,
            cellCoordinate = Cell.resources.coordinate,
            $cellContainer = $(CellContainer.resources.layout),
            $top           = $cellContainer
                .clone()
                .append(cellLayout);

        this.$html.append($top);

        for (let y = 0; y < this.size; y++) {
            let $row = $cellContainer.clone();

            this.cellContainer.xAxisNav.push((new Cell(cellCoordinate.full(0, y), this)).actAsAxisLabel('digit'));
            this.cellContainer.yAxisNav.push((new Cell(cellCoordinate.full(y, 0), this)).actAsAxisLabel('letter'));

            this.$html.append($row);

            $row.append(this.cellContainer.xAxisNav[y].$html.clone());
            $top.append(this.cellContainer.yAxisNav[y].$html.clone());

            for (let x = 0; x < this.size; x++) {
                let cell = (new Cell(cellCoordinate.full(x, y), this)).setState(Cell.resources.config.state.sea.live);
                $row.append(cell.$html);
                this.cellContainer.addCell(cell);
            }

            $row.append(this.cellContainer.xAxisNav[y].$html.clone());
        }

        $top.append(cellLayout);
        this.$html.append($top.clone());

        return this;
    }

    /**
     * @param {{id: {int}, coordinate: {string}}} criteria
     *
     * @returns {Cell}
     */
    findCell(criteria) {
        return this.cellContainer.findCell(criteria);
    }

    /**
     * @return {{id: {int|string}}
     */
    getJSON() {
        return { id: this.id }
    }

    /** *** *** *** *** *** *** *** *** *** *** *** *** *** **/
    mockData() {
        let self  = this,
            state = Cell.resources.config.state;

        ["A1"].forEach(function (coordinate) {
            self.findCell({ coordinate: coordinate }).setState(state.shipDead);
        });
        ["A2", "A3", "C3", "C4", "C5", "C1", "D1", "E1", "F1", "G5", "G6", "F3"].forEach(function (coordinate) {
            self.findCell({ coordinate: coordinate }).setState(state.shipLive);
        });
    }
}
{'fraction_non_alphanumeric': 0.1829222720478326, 'fraction_numerical': 0.0072869955156950675, 'mean_word_length': 2.0328611898016997, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3229376', 'n_tokens_mistral': 1685, 'n_tokens_neox': 1639, 'n_words': 290}