形象:修改好感度解锁逻辑

This commit is contained in:
luying
2021-03-12 16:20:58 +08:00
parent df5d6ba92e
commit 6a7a3eadca
8 changed files with 67 additions and 43 deletions

View File

@@ -59,7 +59,7 @@ export interface DicGoods {
// 对应的装备id
readonly equipId?: number;
// 解锁条件
readonly condition: {type: number, param: number}[];
readonly condition: {id: number, type: number, params: number[]}[];
// 时间限制
readonly timeLimit: number;
}
@@ -99,7 +99,7 @@ const DicGoodsKeys: KeysEnum<DicGoods> = {
export const dicJewel = new Map<number, DicGoods>();
export const dicGoods = new Map<number, DicGoods>();
export const blueprt = new Map<number, Array<number>>();
export const figureCondition = new Map<number, { param: number, id: number }[]>(); // type => {param, id}
export const figureCondition = new Map<number, {params: number[], id: number, gid: number}[]>(); // type => {params, id, gid}
arr.forEach(o => {
o.goodsAbility = parseAbility(o);
@@ -116,9 +116,9 @@ arr.forEach(o => {
o.equipId = good.good_id;
}
let condition = parseConditionStr(o.condition);
for(let {type, param} of condition) {
let mapArr = figureCondition.get(type)||new Array<{param: number, id: number}>();
mapArr.push({ param, id: o.good_id});
for(let {id, type, params} of condition) {
let mapArr = figureCondition.get(type)||new Array<{params: number[], id: number, gid: number}>();
mapArr.push({ params, id: id, gid: o.good_id});
figureCondition.set(type, mapArr);
}
o.condition = condition;
@@ -203,14 +203,23 @@ function parseSpecialMaterial(str: string) {
// 解析物品 {"type": number, "param": number} 格式
export function parseConditionStr(str: string) {
let result = new Array<{ type: number, param: number }>();
let result = new Array<{ id: number, type: number, params: number[] }>();
if (!str) return result;
let decodeArr = decodeArrayListStr(str);
for (let [type, param] of decodeArr) {
if (isNaN(parseInt(type)) || isNaN(parseInt(param))) {
for (let i = 0; i < decodeArr.length; i++) {
let [type, ...params] = decodeArr[i];
if (isNaN(parseInt(type))) {
throw new Error('data table format wrong');
}
result.push({ type: parseInt(type), param: parseInt(param) });
let parsedParam = new Array<number>();
for(let param of params) {
if (isNaN(parseInt(param))) {
throw new Error('data table format wrong');
}
parsedParam.push(parseInt(param))
}
result.push({ id: i + 1, type: parseInt(type), params: parsedParam });
}
return result
}