40 lines
1.3 KiB
TypeScript
40 lines
1.3 KiB
TypeScript
import { readFileAndParse } from '../util';
|
|
import { GACHA_PLAN_TYPE, FILENAME } from '../../consts';
|
|
|
|
export interface DicGachaPlan {
|
|
// 内容id
|
|
readonly id: number;
|
|
// 指向gacha表的percent
|
|
readonly planId: number;
|
|
// 类型
|
|
readonly type: GACHA_PLAN_TYPE;
|
|
// 内容物具体id 武将id or 道具id
|
|
readonly content: number;
|
|
// 数量
|
|
readonly count: number;
|
|
// 权重
|
|
readonly weight: number;
|
|
// 武将品质,指定武将就当做是橙将。如果有混的,按照武将品质最高的来判断
|
|
readonly heroQuality: number;
|
|
}
|
|
|
|
export const dicGachaPlan = new Map<number, DicGachaPlan[]>(); // planId => plans
|
|
export const dicGachaPlanQuality = new Map<number, number>(); // planId => heroQuality
|
|
export function loadGachaPlan() {
|
|
dicGachaPlan.clear();
|
|
let arr = readFileAndParse(FILENAME.DIC_GACHA_PLAN);
|
|
|
|
arr.forEach(o => {
|
|
if(!dicGachaPlan.has(o.planId)) {
|
|
dicGachaPlan.set(o.planId, [o]);
|
|
dicGachaPlanQuality.set(o.planId, o.heroQuality);
|
|
} else {
|
|
dicGachaPlan.get(o.planId)?.push(o);
|
|
if(dicGachaPlanQuality.get(o.planId)??0 < o.heroQuality) {
|
|
dicGachaPlanQuality.set(o.planId, o.heroQuality);
|
|
}
|
|
}
|
|
});
|
|
|
|
arr = undefined;
|
|
} |