武将:升阶

This commit is contained in:
luying
2021-07-07 16:45:52 +08:00
parent ed534aa715
commit 70cb181222
4 changed files with 16 additions and 15 deletions
@@ -404,7 +404,7 @@ export class HeroHandler {
let dicJob = gameData.job.get(hero.job); let dicJob = gameData.job.get(hero.job);
if (!dicJob) return resResult(STATUS.DIC_DATA_NOT_FOUND); if (!dicJob) return resResult(STATUS.DIC_DATA_NOT_FOUND);
if (hero.jobStage >= ABI_STAGE.END) if (hero.jobStage >= dicJob.maxStage)
return resResult(STATUS.HERO_JOB_STAGE_REACH_MAX_STAGE); return resResult(STATUS.HERO_JOB_STAGE_REACH_MAX_STAGE);
if (hero.job >= getMaxGradeByjobClass(dicJob.job_class)) if (hero.job >= getMaxGradeByjobClass(dicJob.job_class))
return resResult(STATUS.HERO_JOB_REACH_MAX_STAGE); return resResult(STATUS.HERO_JOB_REACH_MAX_STAGE);
@@ -434,7 +434,6 @@ export class HeroHandler {
//进阶 //进阶
async heroJobStageUp(msg: { hid: number }, session: BackendSession) { async heroJobStageUp(msg: { hid: number }, session: BackendSession) {
console.log(JSON.stringify([...gameData.jobClassMaxGrades]))
let roleId: string = session.get('roleId'); let roleId: string = session.get('roleId');
const serverId = session.get('serverId'); const serverId = session.get('serverId');
let sid: string = session.get('sid'); let sid: string = session.get('sid');
@@ -538,10 +537,9 @@ export class HeroHandler {
let hero = await HeroModel.findByHidAndRole(hid, roleId); let hero = await HeroModel.findByHidAndRole(hid, roleId);
if (!hero) return resResult(STATUS.ROLE_HERO_NOT_EXISTS); if (!hero) return resResult(STATUS.ROLE_HERO_NOT_EXISTS);
let { favourLv: oldLv, favour: oldExp } = hero; let { favourLv: oldLv, favour: oldExp, lv } = hero;
let maxLv = gameData.maxFriendShipLv.max; // 好感度最大等级 let maxLv = lv > gameData.maxFriendShipLv.max? gameData.maxFriendShipLv.max: lv; // 好感度最大等级
console.log(maxLv)
if (maxLv <= oldLv) if (maxLv <= oldLv)
return resResult(STATUS.HERO_FAVOUR_LEVEL_REACH_MAXT); return resResult(STATUS.HERO_FAVOUR_LEVEL_REACH_MAXT);
+9 -6
View File
@@ -24,12 +24,14 @@ export interface DicJob {
// 升阶消耗 // 升阶消耗
readonly upGradeConsume: Array<RewardInter>; readonly upGradeConsume: Array<RewardInter>;
// 每阶升级属性 // 每阶升级属性
readonly ceAttr: Map<number, {id: number, attr: number}> readonly ceAttr: Map<number, {id: number, attr: number}>;
// 一共有多少阶升级
readonly maxStage: number;
} }
type KeysEnum<T> = { [P in keyof Required<T>]: true }; type KeysEnum<T> = { [P in keyof Required<T>]: true };
const DicJobKeys: KeysEnum<DicJob> = {jobid: true, name: true, grade: true, unlockLevel: true, job_class: true, type: true, seid: true,trainingConsume: true, upGradeConsume: true, ceAttr: true}; const DicJobKeys: KeysEnum<DicJob> = {jobid: true, name: true, grade: true, unlockLevel: true, job_class: true, type: true, seid: true,trainingConsume: true, upGradeConsume: true, ceAttr: true, maxStage: true};
export const dicJob = new Map<number, DicJob>(); export const dicJob = new Map<number, DicJob>();
export const jobClassMaxGrades = new Map<number, {grade:number, jobid:number}>(); export const jobClassMaxGrades = new Map<number, {grade:number, jobid:number}>();
@@ -42,8 +44,9 @@ export function loadJob() {
arr.forEach(o => { arr.forEach(o => {
o.seid = parseNumberList(o.seid); o.seid = parseNumberList(o.seid);
o.trainingConsume = parseGoodStr(o.trainingConsume); o.trainingConsume = parseGoodStr(o.trainingConsume);
o.maxStage = o.trainingConsume.length;
o.upGradeConsume = parseGoodStr(o.upGradeConsume); o.upGradeConsume = parseGoodStr(o.upGradeConsume);
o.ceAttr = parseCeAttr(o.attr); o.ceAttr = parseCeAttr(o.maxStage, o.attr);
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);
if (!jobClass || jobClass.grade < o.grade) { if (!jobClass || jobClass.grade < o.grade) {
@@ -55,12 +58,12 @@ export function loadJob() {
arr = undefined; arr = undefined;
} }
function parseCeAttr(str: string) { function parseCeAttr(maxStage: number, str: string) {
let result = new Map<number, { id: number, attr: number }>(); let result = new Map<number, { id: number, attr: number }>();
if (!str) return result; if (!str) return result;
let decodeArr = decodeArrayListStr(str); let decodeArr = decodeArrayListStr(str);
for (let i = 0; i < decodeArr.length; i++) { for (let i = 1; i <= maxStage; i++) {
let [id, attr] = decodeArr[i]; let [id, attr] = decodeArr[i]||[i.toString(), "0"];
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');
} }
+3 -3
View File
@@ -444,16 +444,16 @@ export function calHeroTrainIncAttr(originHero: HeroType, update: HeroUpdate) {
let dicJob = gameData.job.get(job); let dicJob = gameData.job.get(job);
if (dicJob.grade > 1) { if (dicJob.grade >= 1) {
let jobGradeAndClass = getJobByGradeAndClass(dicJob.job_class, dicJob.grade - 1); let jobGradeAndClass = getJobByGradeAndClass(dicJob.job_class, dicJob.grade - 1);
let lastJob = gameData.job.get(jobGradeAndClass.jobid); let lastJob = gameData.job.get(jobGradeAndClass.jobid);
let targetAttrId = dicJob.ceAttr.get(jobStage).id; let targetAttrId = dicJob.ceAttr.get(jobStage).id;
let inc = (dicJob.ceAttr.get(jobStage).attr - lastJob.ceAttr.get(jobStage).attr) * HERO_CE_RATIO; let inc = (dicJob.ceAttr.get(jobStage).attr - lastJob.ceAttr.get(jobStage).attr) * HERO_CE_RATIO;
updateHeroAttr(heroAttrs, targetAttrId, { inc: { fixUp: inc } }) updateHeroAttr(heroAttrs, targetAttrId, { inc: { fixUp: inc } });
} else { } else {
let targetAttrId = dicJob.ceAttr.get(jobStage).id; let targetAttrId = dicJob.ceAttr.get(jobStage).id;
let inc = dicJob.ceAttr.get(jobStage).attr * HERO_CE_RATIO; let inc = dicJob.ceAttr.get(jobStage).attr * HERO_CE_RATIO;
updateHeroAttr(heroAttrs, targetAttrId, { inc: { fixUp: inc } }) updateHeroAttr(heroAttrs, targetAttrId, { inc: { fixUp: inc } });
} }
return heroAttrs; return heroAttrs;
} }
+1 -1
View File
@@ -1838,7 +1838,7 @@
{ {
"jobid": 700, "jobid": 700,
"name": "名医0阶", "name": "名医0阶",
"grade": 1, "grade": 0,
"unlockLevel": 1, "unlockLevel": 1,
"job_class": 7, "job_class": 7,
"type": 2, "type": 2,