UNPKG

@ginstone/nga-api

Version:

31 lines (30 loc) 976 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.CommonUiData = void 0; const AvatarBuff_1 = require("../enums/AvatarBuff"); const AVATAR_BUFF_PATTERN = /v0==(\d+) \? '(.+?)'/g; /** * 由 js_commonui.js 解析得到的数据 */ class CommonUiData { constructor(data) { this.avatarBuffs = new Array; // 头像buff的id和对应地址 let matcher; while (matcher = AVATAR_BUFF_PATTERN.exec(data)) { const id = Number(matcher[1]); const value = matcher[2]; if (value.endsWith(".png")) { // 添加buff this.avatarBuffs.push(new AvatarBuff_1.AvatarBuff(id, value)); } else { const buff = this.avatarBuffs.filter(i => i.id === id)[0]; if (buff) { buff.suffix = `...${value}~`; } } } } } exports.CommonUiData = CommonUiData;