✨ feat(宝物): 添加宝物系统
This commit is contained in:
73
shared/pubUtils/dictionary/DicArtifact.ts
Normal file
73
shared/pubUtils/dictionary/DicArtifact.ts
Normal file
@@ -0,0 +1,73 @@
|
||||
// 物品表
|
||||
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;
|
||||
}
|
||||
54
shared/pubUtils/dictionary/DicArtifactLvPlan.ts
Normal file
54
shared/pubUtils/dictionary/DicArtifactLvPlan.ts
Normal file
@@ -0,0 +1,54 @@
|
||||
// 物品表
|
||||
import { readFileAndParse, parseGoodStr, decodeArrayListStr, } from '../util'
|
||||
import { FILENAME, } from '../../consts'
|
||||
import { RewardInter } from '../interface';
|
||||
const _ = require('lodash');
|
||||
|
||||
export interface DicArtifactLvPlan {
|
||||
// 方案id
|
||||
planId: number;
|
||||
// 等级
|
||||
lv: number;
|
||||
// 升到这级需要消耗什么,id&count
|
||||
consumes: RewardInter[];
|
||||
// 这级的属性
|
||||
attr: {id: number, attr: number}[];
|
||||
}
|
||||
|
||||
type KeysEnum<T> = { [P in keyof Required<T>]: true };
|
||||
const DicArtifactLvPlanKeys: KeysEnum<DicArtifactLvPlan> = {
|
||||
planId: true,
|
||||
lv: true,
|
||||
consumes: true,
|
||||
attr: true,
|
||||
}
|
||||
export const dicArtifactLvPlan = new Map<number, Map<number, DicArtifactLvPlan>>(); // planId => lv => dic
|
||||
|
||||
export function loadArtifactLvPlan() {
|
||||
dicArtifactLvPlan.clear();
|
||||
|
||||
let arr = readFileAndParse(FILENAME.DIC_ARTIFACT_LV_PLAN);
|
||||
arr.forEach(o => {
|
||||
o.consumes = parseGoodStr(o.consumes);
|
||||
o.attr = parseAttr(o.attr);
|
||||
if(!dicArtifactLvPlan.has(o.planId)) {
|
||||
dicArtifactLvPlan.set(o.planId, new Map());
|
||||
}
|
||||
dicArtifactLvPlan.get(o.planId)?.set(o.lv, _.pick(o, Object.keys(DicArtifactLvPlanKeys)));
|
||||
});
|
||||
|
||||
arr = undefined;
|
||||
}
|
||||
|
||||
function parseAttr(str: string) {
|
||||
let result = new Array<{id: number, attr: number}>();
|
||||
if(!str) return result;
|
||||
let decodeArr = decodeArrayListStr(str);
|
||||
for(let [id, attr] of decodeArr) {
|
||||
if(isNaN(parseInt(id)) || isNaN(parseInt(attr))) {
|
||||
throw new Error('data table format wrong');
|
||||
}
|
||||
result.push({id: parseInt(id), attr: parseInt(attr)});
|
||||
}
|
||||
return result
|
||||
}
|
||||
66
shared/pubUtils/dictionary/DicArtifactQuality.ts
Normal file
66
shared/pubUtils/dictionary/DicArtifactQuality.ts
Normal file
@@ -0,0 +1,66 @@
|
||||
// 物品表
|
||||
import { readFileAndParse, parseGoodStr, } from '../util'
|
||||
import { FILENAME, } from '../../consts'
|
||||
import { RewardInter } from '../interface';
|
||||
const _ = require('lodash');
|
||||
|
||||
export interface DicArtifactQuality {
|
||||
// 唯一id,品质+品阶=唯一
|
||||
uniqId: number;
|
||||
// 品质,key1
|
||||
quality: number;
|
||||
// 品阶,key2
|
||||
qualityStage: number;
|
||||
// 这个品质下最大的等级
|
||||
maxLv: number;
|
||||
// 合成相关
|
||||
// 可以合成到他这个品质的uniqId,即原料的品质+品阶
|
||||
previousId: number;
|
||||
// 下一阶uniqId
|
||||
nextId: number;
|
||||
// 作为狗粮的宝物品质uniqId
|
||||
materialId: number;
|
||||
// 作为狗粮的宝物的数量
|
||||
materialCnt: number;
|
||||
// 作为狗粮的是否需要同名 1-是 0-不是
|
||||
materialGroup: number;
|
||||
// 是否可以分解 1-是 0-不是
|
||||
canDecompose: number;
|
||||
// 是否可以一键合成 1-是 0-不是
|
||||
canComposeAll: number;
|
||||
// 这个品质可以替换的通用道具,id&count。分解同样用这个字段,不可分解填&
|
||||
generalItem: RewardInter[];
|
||||
}
|
||||
|
||||
type KeysEnum<T> = { [P in keyof Required<T>]: true };
|
||||
const DicArtifactQualityKeys: KeysEnum<DicArtifactQuality> = {
|
||||
uniqId: true,
|
||||
quality: true,
|
||||
qualityStage: true,
|
||||
maxLv: true,
|
||||
previousId: true,
|
||||
nextId: true,
|
||||
materialId: true,
|
||||
materialCnt: true,
|
||||
materialGroup: true,
|
||||
canDecompose: true,
|
||||
canComposeAll: true,
|
||||
generalItem: true,
|
||||
}
|
||||
export const dicArtifactQuality = new Map<string, number>(); // quality+qualityStage
|
||||
export const dicArtifactQualityById = new Map<number, DicArtifactQuality>(); // uniqId
|
||||
|
||||
export function loadArtifactQuality() {
|
||||
dicArtifactQuality.clear();
|
||||
dicArtifactQualityById.clear();
|
||||
|
||||
let arr = readFileAndParse(FILENAME.DIC_ARTIFACT_QUALITY);
|
||||
|
||||
arr.forEach(o => {
|
||||
o.generalItem = parseGoodStr(o.generalItem);
|
||||
dicArtifactQualityById.set(o.uniqId, _.pick(o, Object.keys(DicArtifactQualityKeys)));
|
||||
dicArtifactQuality.set(`${o.quality}_${o.qualityStage}`, o.uniqId);
|
||||
});
|
||||
|
||||
arr = undefined;
|
||||
}
|
||||
44
shared/pubUtils/dictionary/DicArtifactQualityPlan.ts
Normal file
44
shared/pubUtils/dictionary/DicArtifactQualityPlan.ts
Normal file
@@ -0,0 +1,44 @@
|
||||
// 物品表
|
||||
import { readFileAndParse, decodeArrayListStr, } from '../util'
|
||||
import { FILENAME, } from '../../consts'
|
||||
const _ = require('lodash');
|
||||
|
||||
export interface DicArtifactQualityPlan {
|
||||
// 方案id
|
||||
planId: number;
|
||||
// 这级的属性
|
||||
attr: {id: number, attr: number}[];
|
||||
}
|
||||
|
||||
type KeysEnum<T> = { [P in keyof Required<T>]: true };
|
||||
const DicArtifactQualityPlanKeys: KeysEnum<DicArtifactQualityPlan> = {
|
||||
planId: true,
|
||||
attr: true,
|
||||
}
|
||||
export const dicArtifactQualityPlan = new Map<number, DicArtifactQualityPlan>();
|
||||
|
||||
export function loadArtifactQualityPlan() {
|
||||
dicArtifactQualityPlan.clear();
|
||||
|
||||
let arr = readFileAndParse(FILENAME.DIC_ARTIFACT_QUALITY_PLAN);
|
||||
|
||||
arr.forEach(o => {
|
||||
o.attr = parseAttr(o.attr);
|
||||
dicArtifactQualityPlan.set(o.planId, _.pick(o, Object.keys(DicArtifactQualityPlanKeys)));
|
||||
});
|
||||
|
||||
arr = undefined;
|
||||
}
|
||||
|
||||
function parseAttr(str: string) {
|
||||
let result = new Array<{id: number, attr: number}>();
|
||||
if(!str) return result;
|
||||
let decodeArr = decodeArrayListStr(str);
|
||||
for(let [id, attr] of decodeArr) {
|
||||
if(isNaN(parseInt(id)) || isNaN(parseInt(attr))) {
|
||||
throw new Error('data table format wrong');
|
||||
}
|
||||
result.push({id: parseInt(id), attr: parseInt(attr)});
|
||||
}
|
||||
return result
|
||||
}
|
||||
36
shared/pubUtils/dictionary/DicArtifactSeid.ts
Normal file
36
shared/pubUtils/dictionary/DicArtifactSeid.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
// 物品表
|
||||
import { readFileAndParse, } from '../util'
|
||||
import { FILENAME, } from '../../consts'
|
||||
const _ = require('lodash');
|
||||
|
||||
export interface DicArtifactQuality {
|
||||
// 对应的se表的id
|
||||
seid: number;
|
||||
// 解锁的品质
|
||||
quality: number;
|
||||
// 生效的职业,0表示全生效
|
||||
jobClass: number;
|
||||
// 生效的武将
|
||||
hid: number;
|
||||
}
|
||||
|
||||
type KeysEnum<T> = { [P in keyof Required<T>]: true };
|
||||
const DicArtifactSeidKeys: KeysEnum<DicArtifactQuality> = {
|
||||
seid: true,
|
||||
quality: true,
|
||||
jobClass: true,
|
||||
hid: true,
|
||||
}
|
||||
export const dicArtifactSeid = new Map<number, DicArtifactQuality>(); // seid => dic
|
||||
|
||||
export function loadArtifactSeid() {
|
||||
dicArtifactSeid.clear();
|
||||
|
||||
let arr = readFileAndParse(FILENAME.DIC_ARTIFACT_SEID);
|
||||
|
||||
arr.forEach(o => {
|
||||
dicArtifactSeid.set(o.seid, _.pick(o, Object.keys(DicArtifactSeidKeys)));
|
||||
});
|
||||
|
||||
arr = undefined;
|
||||
}
|
||||
Reference in New Issue
Block a user