async parseMap(event) {
        // Load the file
        let text = await this.loadMap(event);
        /* Data format as presented in v1.4 of Azgaar's Fantasy Map Generator
    const data = [params, settings, coords, biomes, notesData, svg_xml,
      gridGeneral, grid.cells.h, grid.cells.prec, grid.cells.f, grid.cells.t, grid.cells.temp,
      features, cultures, states, burgs,
      pack.cells.biome, pack.cells.burg, pack.cells.conf, pack.cells.culture, pack.cells.fl,
      pop, pack.cells.r, pack.cells.road, pack.cells.s, pack.cells.state,
      pack.cells.religion, pack.cells.province, pack.cells.crossroad, religions, provinces,
      namesData, rivers].join("\r\n");
    */

        /* We are interested in the following fields, so extract them smartly (since order may change)
    Biomes: Biomes of the world (?)
    Cultures: Cultures
    States: Countries
    Burgs: Cities
    Religions: Relgions of the world
    Provinces: Group of Burgs in States
    namesData: Real world basis (culture) for countries/cultures.
    Rivers: Rivers
    */
        // Turn file into array of lines
        const lines = text.split(/[\r\n]+/g);

        // FMG Settings
        let firstLine = lines[0].split("|");
        // Extract FMG seed
        this.seed = firstLine[3];
        // Extract image size
        this.mapWidth = firstLine[4];
        this.mapHeight = firstLine[5];

        lines.forEach((line) => {
            try {
                // Only interested in JSON objects
                const obj = JSON.parse(line);

                /**
                 * Each JSON object is one of the following categories
                 * so here we determine which one it is, then assign
                 * the proper variables to it.
                 */

                // Provinces
                if ("state" in obj[1] && !("cell" in obj[1])) {
                    console.log("Provinces:", obj);
                    this.provinces = obj;
                } // Burgs
                else if ("population" in obj[1] && "citadel" in obj[1]) {
                    console.log("Burgs:", obj);
                    this.burgs = obj;
                }
                // These are our countries
                else if ("diplomacy" in obj[0]) {
                    console.log("Countries:", obj);
                    this.countries = obj;
                    // Religions
                } else if (obj[0].name === "No religion") {
                    console.log("Religions:", obj);
                    this.religions = obj;
                    // Cultures
                } else if (obj[0].name === "Wildlands") {
                    console.log("Cultures:", obj);
                    this.cultures = obj;
                    // Rivers
                } else if ("mouth" in obj[0]) {
                    console.log("Rivers:", obj);
                    this.rivers = obj;
                }
                // Many things in the file are not JSON, we don't care about them.
            } catch (error) {}
        });
    }
/**
     * Adhering to the data format of FMG, extract all valuable information
     * and save it to Memory.
     *
     * @param  {event} event    triggered by change of the "map" input
     * @return {Promise}        resolve() once all parsing is done
     */
Adhering to the data format of FMG, extract all valuable information
and save it to Memory.

@param  {event} event    triggered by change of the "map" input
@return {Promise}        resolve() once all parsing is done
Adhering to the data format of FMG extract all valuable information and save it to Memory . @param { event } event triggered by change of the " map " input @return { Promise } resolve () once all parsing is done
async parseMap(event) {
        let text = await this.loadMap(event);
        const lines = text.split(/[\r\n]+/g);
        let firstLine = lines[0].split("|");
        this.seed = firstLine[3];
        this.mapWidth = firstLine[4];
        this.mapHeight = firstLine[5];
        lines.forEach((line) => {
            try {
                const obj = JSON.parse(line);
                if ("state" in obj[1] && !("cell" in obj[1])) {
                    console.log("Provinces:", obj);
                    this.provinces = obj;
                } 
                else if ("population" in obj[1] && "citadel" in obj[1]) {
                    console.log("Burgs:", obj);
                    this.burgs = obj;
                }
                else if ("diplomacy" in obj[0]) {
                    console.log("Countries:", obj);
                    this.countries = obj;
                } else if (obj[0].name === "No religion") {
                    console.log("Religions:", obj);
                    this.religions = obj;
                } else if (obj[0].name === "Wildlands") {
                    console.log("Cultures:", obj);
                    this.cultures = obj;
                } else if ("mouth" in obj[0]) {
                    console.log("Rivers:", obj);
                    this.rivers = obj;
                }
            } catch (error) {}
        });
    }
async parseMap ( event ) { let text = await this . loadMap ( event ) ; const lines = text . split ( / [\r\n]+ / g ) ; let firstLine = lines [ 0 ] . split ( "|" ) ; this . seed = firstLine [ 3 ] ; this . mapWidth = firstLine [ 4 ] ; this . mapHeight = firstLine [ 5 ] ; lines . forEach ( ( line ) => { try { const obj = JSON . parse ( line ) ; if ( "state" in obj [ 1 ] && ! ( "cell" in obj [ 1 ] ) ) { console . log ( "Provinces:" , obj ) ; this . provinces = obj ; } else if ( "population" in obj [ 1 ] && "citadel" in obj [ 1 ] ) { console . log ( "Burgs:" , obj ) ; this . burgs = obj ; } else if ( "diplomacy" in obj [ 0 ] ) { console . log ( "Countries:" , obj ) ; this . countries = obj ; } else if ( obj [ 0 ] . name === "No religion" ) { console . log ( "Religions:" , obj ) ; this . religions = obj ; } else if ( obj [ 0 ] . name === "Wildlands" ) { console . log ( "Cultures:" , obj ) ; this . cultures = obj ; } else if ( "mouth" in obj [ 0 ] ) { console . log ( "Rivers:" , obj ) ; this . rivers = obj ; } } catch ( error ) { } } ) ; }
Adhering to the data format of FMG, extract all valuable information
 and save it to Memory.
Adhering to the data format of FMG extract all valuable information and save it to Memory .
// Load the file /* Data format as presented in v1.4 of Azgaar's Fantasy Map Generator
    const data = [params, settings, coords, biomes, notesData, svg_xml,
      gridGeneral, grid.cells.h, grid.cells.prec, grid.cells.f, grid.cells.t, grid.cells.temp,
      features, cultures, states, burgs,
      pack.cells.biome, pack.cells.burg, pack.cells.conf, pack.cells.culture, pack.cells.fl,
      pop, pack.cells.r, pack.cells.road, pack.cells.s, pack.cells.state,
      pack.cells.religion, pack.cells.province, pack.cells.crossroad, religions, provinces,
      namesData, rivers].join("\r\n");
    */ /* We are interested in the following fields, so extract them smartly (since order may change)
    Biomes: Biomes of the world (?)
    Cultures: Cultures
    States: Countries
    Burgs: Cities
    Religions: Relgions of the world
    Provinces: Group of Burgs in States
    namesData: Real world basis (culture) for countries/cultures.
    Rivers: Rivers
    */ // Turn file into array of lines // FMG Settings // Extract FMG seed // Extract image size // Only interested in JSON objects /**
                 * Each JSON object is one of the following categories
                 * so here we determine which one it is, then assign
                 * the proper variables to it.
                 */ // Provinces // Burgs // These are our countries // Religions // Cultures // Rivers // Many things in the file are not JSON, we don't care about them.