Files
ZYZ/shared/pubUtils/dictionary/DicArtifact.ts
2022-12-08 15:49:51 +08:00

74 lines
2.3 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// 物品表
import { readFileAndParse, parseNumberList, } from '../util'
import { FILENAME, } from '../../consts'
const _ = require('lodash');
export interface DicArtifact {
// 宝物idt其中形态1和goodId必须一致
readonly artifactId: number;
// 宝物名
readonly name: string;
// 物品表id不同品质&品阶的同名宝物的物品id不同
readonly goodId: number;
// 同名宝物比如史记可以直接写shiji不过要当心多音词注意唯一性
readonly group: string;
// 形态
readonly type: number;
// 是否是初始形态,用于服务器获取
readonly isDefaultType: boolean;
// 品质每个宝物id直接对应一种品质
readonly quality: number;
// 品阶每个宝物id直接对应一种品阶
readonly qualityStage: number;
// 专属职业
readonly jobClass: number;
// 专属武将
readonly hid: number;
// 词条seid&seid
readonly seids: number[];
// 等级配置方案
readonly lvAttrPlan: number;
// 升品配置方案
readonly qualityAttrPlan: number;
}
type KeysEnum<T> = { [P in keyof Required<T>]: true };
const DicArtifactKeys: KeysEnum<DicArtifact> = {
artifactId: true,
name: true,
goodId: true,
group: true,
type: true,
isDefaultType: true,
quality: true,
qualityStage: true,
jobClass: true,
hid: true,
seids: true,
lvAttrPlan: true,
qualityAttrPlan: true,
}
export const dicArtifact = new Map<number, DicArtifact>();
export const dicArtifactByGid = new Map<number, number>();
export const dicArtifactByGidAndType = new Map<string, number>();
export const dicArtifactsByGroup = new Map<string, DicArtifact>();
export function loadArtifact() {
dicArtifact.clear();
dicArtifactByGid.clear();
dicArtifactByGidAndType.clear();
dicArtifactsByGroup.clear();
let arr = readFileAndParse(FILENAME.DIC_ARTIFACT);
arr.forEach(o => {
o.seids = parseNumberList(o.seids);
if(o.isDefaultType) dicArtifactByGid.set(o.goodId, o.artifactId);
dicArtifactByGidAndType.set(`${o.goodId}_${o.type}`, o.artifactId);
dicArtifact.set(o.artifactId, _.pick(o, Object.keys(DicArtifactKeys)));
dicArtifactsByGroup.set(`${o.group}_${o.type}_${o.quality}_${o.qualityStage}`, o);
});
arr = undefined;
}