武将:升阶
This commit is contained in:
@@ -404,7 +404,7 @@ export class HeroHandler {
|
||||
let dicJob = gameData.job.get(hero.job);
|
||||
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);
|
||||
if (hero.job >= getMaxGradeByjobClass(dicJob.job_class))
|
||||
return resResult(STATUS.HERO_JOB_REACH_MAX_STAGE);
|
||||
@@ -434,7 +434,6 @@ export class HeroHandler {
|
||||
|
||||
//进阶
|
||||
async heroJobStageUp(msg: { hid: number }, session: BackendSession) {
|
||||
console.log(JSON.stringify([...gameData.jobClassMaxGrades]))
|
||||
let roleId: string = session.get('roleId');
|
||||
const serverId = session.get('serverId');
|
||||
let sid: string = session.get('sid');
|
||||
@@ -538,10 +537,9 @@ export class HeroHandler {
|
||||
let hero = await HeroModel.findByHidAndRole(hid, roleId);
|
||||
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; // 好感度最大等级
|
||||
console.log(maxLv)
|
||||
let maxLv = lv > gameData.maxFriendShipLv.max? gameData.maxFriendShipLv.max: lv; // 好感度最大等级
|
||||
if (maxLv <= oldLv)
|
||||
return resResult(STATUS.HERO_FAVOUR_LEVEL_REACH_MAXT);
|
||||
|
||||
|
||||
@@ -24,12 +24,14 @@ export interface DicJob {
|
||||
// 升阶消耗
|
||||
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 };
|
||||
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 jobClassMaxGrades = new Map<number, {grade:number, jobid:number}>();
|
||||
@@ -42,8 +44,9 @@ export function loadJob() {
|
||||
arr.forEach(o => {
|
||||
o.seid = parseNumberList(o.seid);
|
||||
o.trainingConsume = parseGoodStr(o.trainingConsume);
|
||||
o.maxStage = o.trainingConsume.length;
|
||||
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)));
|
||||
let jobClass = jobClassMaxGrades.get(o.job_class);
|
||||
if (!jobClass || jobClass.grade < o.grade) {
|
||||
@@ -55,12 +58,12 @@ export function loadJob() {
|
||||
arr = undefined;
|
||||
}
|
||||
|
||||
function parseCeAttr(str: string) {
|
||||
function parseCeAttr(maxStage: number, str: string) {
|
||||
let result = new Map<number, { id: number, attr: number }>();
|
||||
if (!str) return result;
|
||||
let decodeArr = decodeArrayListStr(str);
|
||||
for (let i = 0; i < decodeArr.length; i++) {
|
||||
let [id, attr] = decodeArr[i];
|
||||
for (let i = 1; i <= maxStage; i++) {
|
||||
let [id, attr] = decodeArr[i]||[i.toString(), "0"];
|
||||
if (isNaN(parseInt(id)) || isNaN(parseInt(attr))) {
|
||||
throw new Error('data table format wrong');
|
||||
}
|
||||
|
||||
@@ -444,16 +444,16 @@ export function calHeroTrainIncAttr(originHero: HeroType, update: HeroUpdate) {
|
||||
|
||||
let dicJob = gameData.job.get(job);
|
||||
|
||||
if (dicJob.grade > 1) {
|
||||
if (dicJob.grade >= 1) {
|
||||
let jobGradeAndClass = getJobByGradeAndClass(dicJob.job_class, dicJob.grade - 1);
|
||||
let lastJob = gameData.job.get(jobGradeAndClass.jobid);
|
||||
let targetAttrId = dicJob.ceAttr.get(jobStage).id;
|
||||
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 {
|
||||
let targetAttrId = dicJob.ceAttr.get(jobStage).id;
|
||||
let inc = dicJob.ceAttr.get(jobStage).attr * HERO_CE_RATIO;
|
||||
updateHeroAttr(heroAttrs, targetAttrId, { inc: { fixUp: inc } })
|
||||
updateHeroAttr(heroAttrs, targetAttrId, { inc: { fixUp: inc } });
|
||||
}
|
||||
return heroAttrs;
|
||||
}
|
||||
|
||||
@@ -1838,7 +1838,7 @@
|
||||
{
|
||||
"jobid": 700,
|
||||
"name": "名医0阶",
|
||||
"grade": 1,
|
||||
"grade": 0,
|
||||
"unlockLevel": 1,
|
||||
"job_class": 7,
|
||||
"type": 2,
|
||||
|
||||
Reference in New Issue
Block a user