养成:修复武将升阶的时候战力反而下降的问题
This commit is contained in:
@@ -159,23 +159,11 @@ export class CalCe {
|
|||||||
|
|
||||||
// 职业基础
|
// 职业基础
|
||||||
public setJob(hid: number, job: number, jobStage: number) {
|
public setJob(hid: number, job: number, jobStage: number) {
|
||||||
this.data.clearHeroAttrByHid(hid, 'job');
|
|
||||||
this.data.clearHeroAttrByHid(hid, 'subBase');
|
|
||||||
const dicJob = gameData.job.get(job);
|
const dicJob = gameData.job.get(job);
|
||||||
let lastJob = getJobByGradeAndClass(dicJob.job_class, dicJob.grade - 1);
|
let ceAttr = dicJob.ceAttr.get(jobStage)||[];
|
||||||
let dicLastJob = lastJob? gameData.job.get(lastJob.jobid): null;
|
for(let { id, attr } of ceAttr) {
|
||||||
for(let i = 1; i <= (dicJob.maxStage||dicLastJob.maxStage); i++) {
|
let heroAttr = this.data.getHeroAttrByHidAndId(hid, id);
|
||||||
if(jobStage >= i) {
|
heroAttr.job = attr;
|
||||||
let { id, attr } = dicJob.ceAttr.get(i);
|
|
||||||
let heroAttr = this.data.getHeroAttrByHidAndId(hid, id);
|
|
||||||
heroAttr.job = attr;
|
|
||||||
} else {
|
|
||||||
if(dicLastJob) {
|
|
||||||
let { id, attr } = dicLastJob.ceAttr.get(i);
|
|
||||||
let heroAttr = this.data.getHeroAttrByHidAndId(hid, id);
|
|
||||||
heroAttr.job = attr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
for(let { id, val } of dicJob.baseSubAttr) {
|
for(let { id, val } of dicJob.baseSubAttr) {
|
||||||
let heroAttr = this.data.getHeroAttrByHidAndId(hid, id);
|
let heroAttr = this.data.getHeroAttrByHidAndId(hid, id);
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ export interface DicJob {
|
|||||||
// 升阶消耗
|
// 升阶消耗
|
||||||
readonly upGradeConsume: Array<RewardInter>;
|
readonly upGradeConsume: Array<RewardInter>;
|
||||||
// 每阶升级属性 stage => {}
|
// 每阶升级属性 stage => {}
|
||||||
readonly ceAttr: Map<number, {id: number, attr: number}>;
|
readonly ceAttr: Map<number, {id: number, attr: number}[]>;
|
||||||
// 次级属性基础 attr => value attr1
|
// 次级属性基础 attr => value attr1
|
||||||
readonly baseSubAttr: {id: number, val: number}[];
|
readonly baseSubAttr: {id: number, val: number}[];
|
||||||
// 一共有多少阶升级
|
// 一共有多少阶升级
|
||||||
@@ -49,6 +49,7 @@ export function loadJob() {
|
|||||||
|
|
||||||
let arr = readFileAndParse(FILENAME.DIC_JOB);
|
let arr = readFileAndParse(FILENAME.DIC_JOB);
|
||||||
// let jobByJobClass = new Map<number, number[]>(); // jobClass => jobid[]
|
// let jobByJobClass = new Map<number, number[]>(); // jobClass => jobid[]
|
||||||
|
let lastJob: DicJob;
|
||||||
|
|
||||||
arr.forEach(o => {
|
arr.forEach(o => {
|
||||||
if(o.isPlayer) {
|
if(o.isPlayer) {
|
||||||
@@ -56,7 +57,7 @@ export function loadJob() {
|
|||||||
o.trainingConsume = parseGoodStr(o.trainingConsume);
|
o.trainingConsume = parseGoodStr(o.trainingConsume);
|
||||||
o.maxStage = o.trainingConsume.length;
|
o.maxStage = o.trainingConsume.length;
|
||||||
o.upGradeConsume = parseGoodStr(o.upGradeConsume);
|
o.upGradeConsume = parseGoodStr(o.upGradeConsume);
|
||||||
o.ceAttr = parseCeAttr(o.maxStage, o.attr);
|
o.ceAttr = parseCeAttr(o.maxStage, o.attr, lastJob, o.job_class);
|
||||||
o.baseSubAttr = parseAttribute(o.baseAttr||'');
|
o.baseSubAttr = parseAttribute(o.baseAttr||'');
|
||||||
dicJob.set(o.jobid, _.pick(o, Object.keys(DicJobKeys)));
|
dicJob.set(o.jobid, _.pick(o, Object.keys(DicJobKeys)));
|
||||||
let jobClass = jobClassMaxGrades.get(o.job_class);
|
let jobClass = jobClassMaxGrades.get(o.job_class);
|
||||||
@@ -69,6 +70,7 @@ export function loadJob() {
|
|||||||
// }
|
// }
|
||||||
// jobByJobClass.get(o.job_class).push(o.jobid);
|
// jobByJobClass.get(o.job_class).push(o.jobid);
|
||||||
talentPointOfJob.set(o.jobid, o.talentPoint);
|
talentPointOfJob.set(o.jobid, o.talentPoint);
|
||||||
|
lastJob = o;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// for(let [_, { job_class, talentPoint }] of dicJob) {
|
// for(let [_, { job_class, talentPoint }] of dicJob) {
|
||||||
@@ -86,16 +88,40 @@ export function loadJob() {
|
|||||||
arr = undefined;
|
arr = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseCeAttr(maxStage: number, str: string) {
|
function parseCeAttr(maxStage: number, str: string, lastJob: DicJob, job_class: number) {
|
||||||
let result = new Map<number, { id: number, attr: number }>();
|
let result = new Map<number, { id: number, attr: number }[]>();
|
||||||
|
for (let i = 1; i <= maxStage; i++) {
|
||||||
|
if(lastJob && lastJob.job_class == job_class && lastJob.ceAttr && lastJob.ceAttr.has(maxStage)) {
|
||||||
|
let attrs: { id: number, attr: number }[] = [];
|
||||||
|
for(let { id, attr} of lastJob.ceAttr.get(maxStage)||[]) {
|
||||||
|
attrs.push({ id, attr });
|
||||||
|
}
|
||||||
|
result.set(i, attrs)
|
||||||
|
} else {
|
||||||
|
result.set(i, []);
|
||||||
|
}
|
||||||
|
}
|
||||||
if (!str) return result;
|
if (!str) return result;
|
||||||
let decodeArr = decodeArrayListStr(str);
|
let decodeArr = decodeArrayListStr(str);
|
||||||
for (let i = 1; i <= maxStage; i++) {
|
for (let i = 1; i <= maxStage; i++) {
|
||||||
let [id, attr] = decodeArr[i - 1]||[i.toString(), "0"];
|
let [id, attr] = decodeArr[i - 1]||[i.toString(), "0"];
|
||||||
|
let _id = parseInt(id);
|
||||||
|
let _attr = parseFloat(attr);
|
||||||
|
|
||||||
if (isNaN(parseInt(id)) || isNaN(parseInt(attr))) {
|
if (isNaN(parseInt(id)) || isNaN(parseInt(attr))) {
|
||||||
throw new Error('data table format wrong');
|
throw new Error('data table format wrong');
|
||||||
}
|
}
|
||||||
result.set(i, { id: parseInt(id), attr: parseFloat(attr) });
|
for(let j = i; j <= maxStage; j++) {
|
||||||
|
let arr = result.get(j)||[];
|
||||||
|
let index = arr.findIndex(cur => cur.id == _id);
|
||||||
|
if(index == -1) {
|
||||||
|
arr.push({ id: _id, attr: _attr });
|
||||||
|
} else {
|
||||||
|
arr[index].attr = _attr;
|
||||||
|
}
|
||||||
|
|
||||||
|
result.set(j, arr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user