@colour93/koishi-plugin-apex-helper
Version:
Koishi 插件: Apex Legends 信息助手
106 lines (105 loc) • 3.66 kB
JavaScript
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.CraftingData = exports.MapData = void 0;
const localeData = __importStar(require("./locale.json"));
const locale = localeData;
class MapData {
constructor(data) {
this.battle_royale = new MapItem(data.battle_royale);
this.ranked = new MapItem(data.ranked);
this.ltm = new MapItem(data.ltm);
}
}
exports.MapData = MapData;
class MapItem {
constructor(data) {
this.current = new MapInfo(data.current);
this.next = new MapInfo(data.next);
}
}
class MapInfo {
constructor(data) {
Object.assign(this, data);
this.map_zh = locale.map[this.code];
if (this.eventName)
this.eventName_zh = locale.event[this.eventName];
}
}
class Rotation {
constructor(ts) {
this.time = new Date(ts);
this.timestamp = ts;
this.timestr = this.time.toLocaleTimeString();
}
}
class CraftingData {
constructor(data) {
let weaponOrigin;
data.forEach(item => {
switch (item.bundleType) {
case 'daily':
this.daily = new BundleItem(item);
break;
case 'weekly':
this.weekly = new BundleItem(item);
break;
case 'permanent':
if (item.bundle == 'weapon_one')
weaponOrigin = item;
if (item.bundle == 'weapon_two')
weaponOrigin.bundleContent.push(...item.bundleContent);
break;
default:
break;
}
});
weaponOrigin.bundle = 'weapon';
this.weapon = new BundleItem(weaponOrigin);
}
}
exports.CraftingData = CraftingData;
class BundleItem {
constructor(data) {
if (data.bundle == 'weapon')
data.bundleContent = data.bundleContent.map((e) => new BundleWeaponContent(e));
else
data.bundleContent = data.bundleContent.map((e) => new BundleCommonContent(e));
this.duration = data.end * 1000 - (new Date()).getTime();
Object.assign(this, data);
}
}
class BundleCommonContent {
constructor(data) {
Object.assign(this, data);
this.item_zh = `${locale.crafting.rarity[this.itemType.rarity] + locale.crafting.item[this.itemType.name]}/${this.cost}`;
}
}
class BundleWeaponContent {
constructor(data) {
Object.assign(this, data);
this.item_zh = `${locale.crafting.weapon[this.itemType.name]}/${this.cost}`;
}
}