<commit_before>"use strict";
require('mapeditor.modal', 'player', 'building');
var MapEditorBrush;

MapEditorBrush = function (mapEditor, mouse, canvas) {
    var map, brush, mouseDown, displayBuildingForm;
    map = mapEditor.getMap();
    mouseDown = false;
    
    this.setBrush = function (newBrush) {
        brush = newBrush;
    };
    
    this.setMap = function (newMap) {
        map = newMap;
    };
    
    this.getBrush = function () {
        return brush;
    };
    
    displayBuildingForm = function (x, y, type) {
        var modal, form, select, button, option, i, player;
        modal = new Modal('Add building', true);
        form = document.createElement('form');
        select = document.createElement('select');
        for (i = 0; player = Player.getPlayer(i); i++) {
            option = document.createElement('option');
            option.style.color = player.color;
            option.value = i;
            option.appendChild(document.createTextNode(player.name));
            select.appendChild(option);
        }
        form.appendChild(select);
        button = document.createElement('input');
        button.type = 'submit';
        button.value = 'OK';
        form.appendChild(button);
        modal.appendChild(form);
        form.addEventListener('submit', function (e) {
            var building;
            e.preventDefault();
            modal.close();
            building = new Building(x, y, type, select.value);
            mapEditor.updateBuilding(building);
        }, false);
        modal.center();
    };
    
    canvas.addEventListener('click', function () {
        var x, y, mapData;
        mapData = map.getMap();
        x = mouse.getX();
        y = mouse.getY();
        switch (brush.layer) {
            case 'terrain':
                if (mapData[y] && mapData[y][x]) {
                    mapData[y][x] = new Tile(brush.type);
                    mapEditor.updateTerrain(x, y);
                }
                break;
            case 'buildings':
                if (mapData[y] && mapData[y][x]) {
                    displayBuildingForm(x, y, brush.type);
                }
                break;
        }
    }, false);
    <commit_msg>MapEditorBrush parses the player id as an integer for the Building class constructor<commit_after>"use strict";
require('mapeditor.modal', 'player', 'building');
var MapEditorBrush;

MapEditorBrush = function (mapEditor, mouse, canvas) {
    var map, brush, mouseDown, displayBuildingForm;
    map = mapEditor.getMap();
    mouseDown = false;
    
    this.setBrush = function (newBrush) {
        brush = newBrush;
    };
    
    this.setMap = function (newMap) {
        map = newMap;
    };
    
    this.getBrush = function () {
        return brush;
    };
    
    displayBuildingForm = function (x, y, type) {
        var modal, form, select, button, option, i, player;
        modal = new Modal('Add building', true);
        form = document.createElement('form');
        select = document.createElement('select');
        for (i = 0; player = Player.getPlayer(i); i++) {
            option = document.createElement('option');
            option.style.color = player.color;
            option.value = i;
            option.appendChild(document.createTextNode(player.name));
            select.appendChild(option);
        }
        form.appendChild(select);
        button = document.createElement('input');
        button.type = 'submit';
        button.value = 'OK';
        form.appendChild(button);
        modal.appendChild(form);
        form.addEventListener('submit', function (e) {
            var building;
            e.preventDefault();
            modal.close();
            building = new Building(x, y, type, parseInt(select.value));
            mapEditor.updateBuilding(building);
        }, false);
        modal.center();
    };
    
    canvas.addEventListener('click', function () {
        var x, y, mapData;
        mapData = map.getMap();
        x = mouse.getX();
        y = mouse.getY();
        switch (brush.layer) {
            case 'terrain':
                if (mapData[y] && mapData[y][x]) {
                    mapData[y][x] = new Tile(brush.type);
                    mapEditor.updateTerrain(x, y);
                }
                break;
            case 'buildings':
                if (mapData[y] && mapData[y][x]) {
                    displayBuildingForm(x, y, brush.type);
                }
                break;
        }
    }, false);
    
{'fraction_non_alphanumeric': 0.12957621477701353, 'fraction_numerical': 0.00044375416019525185, 'mean_word_length': 1.822792736380714, 'pattern_counts': {'":': 0, '<': 3, '<?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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2732170', 'n_tokens_mistral': 1255, 'n_tokens_neox': 1208, 'n_words': 274}