Files
ZYZ/shared/pubUtils/dictionary/DicGiftPackagePlan.ts
2023-02-18 19:38:28 +08:00

47 lines
1.3 KiB
TypeScript

// 礼包奖励表
import { readFileAndParse } from '../util';
import { FILENAME } from '../../consts';
const _ = require('lodash');
export interface DicGiftPackagePlan {
// 唯一id
readonly id: number;
// 礼包类型 dic_zyz_giftPackage的id
readonly giftPackageId: number;
// addReward中的type
readonly contentType: number;
// 物品id或武将id
readonly content: number;
// 数量
readonly count: number;
// 权重
readonly weight: number;
// 保底表id
readonly floorId: number;
}
type KeysEnum<T> = { [P in keyof Required<T>]: true };
const DicGiftPackagePlanKeys: KeysEnum<DicGiftPackagePlan> = {
id: true,
giftPackageId: true,
contentType: true,
content: true,
count: true,
weight: true,
floorId: true,
}
export const dicGiftPackagePlan = new Map<number, DicGiftPackagePlan[]>(); // packageId => [plan]
export function loadGiftPackagePlan() {
dicGiftPackagePlan.clear();
let arr = readFileAndParse(FILENAME.DIC_GIFT_PACKAGE_PLAN);
arr.forEach(o => {
o.floorId = o.floor;
if(!dicGiftPackagePlan.has(o.giftPackageId)) {
dicGiftPackagePlan.set(o.giftPackageId, []);
}
dicGiftPackagePlan.get(o.giftPackageId)?.push(_.pick(o, Object.keys(DicGiftPackagePlanKeys)));
});
arr = undefined;
}