UNPKG

gbf-raidfinder-parser

Version:
41 lines 1.63 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); Object.defineProperty(exports, "__esModule", { value: true }); var TextParser_1 = require("./TextParser"); var Boss_1 = require("../Boss"); var BOSS_REGEXP = /^(Lv|Lvl )(\d{1,3})\s+(.+)$/u; function parseBoss(text) { var parser = new BossParser(); return parser.parse(text); } exports.parseBoss = parseBoss; var BossParser = /** @class */ (function (_super) { __extends(BossParser, _super); function BossParser() { return _super !== null && _super.apply(this, arguments) || this; } BossParser.prototype.parse = function (text) { var matches = text.match(BOSS_REGEXP); if (!matches) { throw this.invalidFormatError(text); } var language = matches[1] === 'Lv' ? 'jp' : 'en'; var level = Number(matches[2]); var name = matches[3]; return new Boss_1.default(text, name, language, level); }; BossParser.BOSS_REGEXP = BOSS_REGEXP; BossParser.parse = parseBoss; return BossParser; }(TextParser_1.default)); exports.default = BossParser; //# sourceMappingURL=BossParser.js.map