全局:属性修改
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
// 物品表
|
||||
import { decodeArrayListStr, readJsonFile, parseGoodStr } from '../util'
|
||||
import { FILENAME} from '../../consts'
|
||||
import { FILENAME, ABI_STAGE, ABI_TYPE_TO_STAGE, ABI_TYPE} from '../../consts'
|
||||
const _ = require('lodash');
|
||||
|
||||
export interface SpecialMaterial {
|
||||
@@ -9,15 +9,10 @@ export interface SpecialMaterial {
|
||||
}
|
||||
|
||||
export interface DicTitle {
|
||||
// 等级
|
||||
readonly id: number;
|
||||
readonly hp: number;
|
||||
readonly atk: number;
|
||||
readonly def: number;
|
||||
readonly mdef: number;
|
||||
readonly agi: number;
|
||||
readonly luk: number;
|
||||
readonly assiAttrValue: Array<{id: number, number: number}>;
|
||||
// 等级
|
||||
readonly mainAttrValue: Map<number, number>; // id => value 这里的值是上一级的基础上增加的值
|
||||
readonly assiAttrValue: Map<number, number>; // id => value
|
||||
// 等级现在
|
||||
readonly lvLimited: number;
|
||||
// 升级消耗
|
||||
@@ -30,18 +25,14 @@ let arr = JSON.parse(str);
|
||||
type KeysEnum<T> = { [P in keyof Required<T>]: true };
|
||||
const DicTitleKeys: KeysEnum<DicTitle> = {
|
||||
id: true,
|
||||
hp: true,
|
||||
atk: true,
|
||||
def: true,
|
||||
mdef: true,
|
||||
agi: true,
|
||||
luk: true,
|
||||
mainAttrValue: true,
|
||||
assiAttrValue: true,
|
||||
lvLimited: true,
|
||||
material: true
|
||||
}
|
||||
export const dicTitle = new Map<number, DicTitle>();
|
||||
arr.forEach(o => {
|
||||
o.mainAttrValue = parseMainAttr(o);
|
||||
o.assiAttrValue = parseAttr(o.assiAttrValue);
|
||||
o.material = parseGoodStr(o.material);
|
||||
dicTitle.set(o.id, _.pick(o, Object.keys(DicTitleKeys)));
|
||||
@@ -50,14 +41,23 @@ arr.forEach(o => {
|
||||
arr = undefined;
|
||||
|
||||
function parseAttr(str: string) {
|
||||
let result = new Array<{id: number, number: number}>();
|
||||
let result = new Map<number, number>();
|
||||
if(!str) return result;
|
||||
let decodeArr = decodeArrayListStr(str);
|
||||
for(let [id, number] of decodeArr) {
|
||||
if(isNaN(parseInt(id)) || isNaN(parseInt(number))) {
|
||||
for(let [id, value] of decodeArr) {
|
||||
if(isNaN(parseInt(id)) || isNaN(parseInt(value))) {
|
||||
throw new Error('data table format wrong');
|
||||
}
|
||||
result.push({id: parseInt(id), number: parseInt(number)});
|
||||
result.set(parseInt(id), parseInt(value));
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
function parseMainAttr(elem) {
|
||||
let result = new Map<number, number>();
|
||||
result.set(ABI_TYPE.ABI_HP, elem.hp);
|
||||
result.set(ABI_TYPE.ABI_ATK, elem.atk);
|
||||
result.set(ABI_TYPE.ABI_DEF, elem.def);
|
||||
result.set(ABI_TYPE.ABI_MDEF, elem.mdef);
|
||||
return result;
|
||||
}
|
||||
Reference in New Issue
Block a user