UNPKG

novaparse

Version:
42 lines 1.95 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); const BaseParse_1 = require("./BaseParse"); // TODO: Refactor redundant code function SystemParse(syst, notFoundFunction) { return __awaiter(this, void 0, void 0, function* () { var base = yield BaseParse_1.BaseParse(syst, notFoundFunction); var links = []; for (let i in [...syst.links]) { let linkLocal = [...syst.links][i]; let systLinkedTo = syst.idSpace.sÿst[linkLocal]; if (systLinkedTo) { links.push(systLinkedTo.globalID); } else { notFoundFunction("No corresponding system " + linkLocal + " for link from " + base.id); } } var planets = []; for (let i in syst.spobs) { let planetLocal = syst.spobs[i]; let planetGlobal = syst.idSpace.spöb[planetLocal]; if (planetGlobal) { planets.push(planetGlobal.globalID); } else { notFoundFunction("Missing spöb id " + planetLocal + " for sÿst " + base.id); } } return Object.assign({}, base, { links, position: [syst.position[0], syst.position[1]], planets }); }); } exports.SystemParse = SystemParse; //# sourceMappingURL=SystemParse.js.map