武将:一键训练
This commit is contained in:
@@ -8,7 +8,7 @@ import { CURRENCY_BY_TYPE, CURRENCY_TYPE, CONSUME_TYPE, HERO_GROW_MAX, HERO_SYST
|
|||||||
import { RoleModel } from '../../../db/Role';
|
import { RoleModel } from '../../../db/Role';
|
||||||
import { ItemModel } from '../../../db/Item';
|
import { ItemModel } from '../../../db/Item';
|
||||||
import { gameData, getHeroExpByLv, getHeroStarByQuality, getHeroWakeByQuality, getHeroLvByExp, getMaxGradeByjobClass, getJobByGradeAndClass, getFriendShipById, getFavourLvByExp, reloadDicParam } from '../../../pubUtils/data';
|
import { gameData, getHeroExpByLv, getHeroStarByQuality, getHeroWakeByQuality, getHeroLvByExp, getMaxGradeByjobClass, getJobByGradeAndClass, getFriendShipById, getFavourLvByExp, reloadDicParam } from '../../../pubUtils/data';
|
||||||
import { RewardInter } from '../../../pubUtils/interface';
|
import { ItemInter, RewardInter } from '../../../pubUtils/interface';
|
||||||
import { getDropItems, FIGURE_UNLOCK_CONDITION } from '../../../consts/constModules/itemConst'
|
import { getDropItems, FIGURE_UNLOCK_CONDITION } from '../../../consts/constModules/itemConst'
|
||||||
import { pushComposeOrangeHero, pushHeroQualityUpMsg, pushHeroStarMax, pushHeroWakeUp } from '../../../services/chatService';
|
import { pushComposeOrangeHero, pushHeroQualityUpMsg, pushHeroStarMax, pushHeroWakeUp } from '../../../services/chatService';
|
||||||
import { calculatetopLineup } from '../../../pubUtils/playerCe';
|
import { calculatetopLineup } from '../../../pubUtils/playerCe';
|
||||||
@@ -396,12 +396,12 @@ export class HeroHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//训练
|
//训练
|
||||||
async heroJobTrain(msg: { hid: number }, session: BackendSession) {
|
async heroJobTrain(msg: { hid: number, isOneClick: boolean }, session: BackendSession) {
|
||||||
let roleId: string = session.get('roleId');
|
let roleId: string = session.get('roleId');
|
||||||
let sid: string = session.get('sid');
|
let sid: string = session.get('sid');
|
||||||
let funcs: number[] = session.get('funcs');
|
let funcs: number[] = session.get('funcs');
|
||||||
const serverId = session.get('serverId');
|
const serverId = session.get('serverId');
|
||||||
let { hid } = msg;
|
let { hid, isOneClick } = msg;
|
||||||
let hero = await HeroModel.findByHidAndRole(hid, roleId);
|
let hero = await HeroModel.findByHidAndRole(hid, roleId);
|
||||||
if (!hero) return resResult(STATUS.HERO_NOT_FIND);
|
if (!hero) return resResult(STATUS.HERO_NOT_FIND);
|
||||||
|
|
||||||
@@ -413,18 +413,21 @@ export class HeroHandler {
|
|||||||
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);
|
||||||
|
|
||||||
let consume = new Array<RewardInter>();
|
let newJobStage = 0;
|
||||||
if (dicJob.trainingConsume[hero.jobStage]) {
|
let max = isOneClick ? dicJob.maxStage: hero.jobStage + 1;
|
||||||
consume.push(dicJob.trainingConsume[hero.jobStage]);
|
for(let i = 0; i < max; i++) {
|
||||||
}
|
let singleConsume = dicJob.trainingConsume[hero.jobStage];
|
||||||
let result = await handleCost(roleId, sid, consume);
|
if(!singleConsume) break; // 每天消耗不可训练
|
||||||
if (!result) {
|
|
||||||
return resResult(STATUS.BATTLE_CONSUMES_NOT_ENOUGH);
|
let result = await handleCost(roleId, sid, [singleConsume]);
|
||||||
|
if (!result) break; // 材料不足
|
||||||
|
newJobStage ++;
|
||||||
}
|
}
|
||||||
|
if (newJobStage == 0) return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
|
||||||
|
|
||||||
//重算战力并下发
|
//重算战力并下发
|
||||||
hero = await calPlayerCeAndSave(HERO_SYSTEM_TYPE.TRAIN, sid, roleId, hero, {
|
hero = await calPlayerCeAndSave(HERO_SYSTEM_TYPE.TRAIN, sid, roleId, hero, {
|
||||||
jobStage: hero.jobStage + 1
|
jobStage: newJobStage
|
||||||
});
|
});
|
||||||
// 任务
|
// 任务
|
||||||
await checkTaskWithHero(roleId, sid, funcs, TASK_TYPE.HERO_TRAIN, hero);
|
await checkTaskWithHero(roleId, sid, funcs, TASK_TYPE.HERO_TRAIN, hero);
|
||||||
|
|||||||
+11
-10
@@ -463,17 +463,18 @@ export function calHeroTrainIncAttr(originHero: HeroType, update: HeroUpdate) {
|
|||||||
let { job = oldJob, jobStage = oldJobStage } = update;
|
let { job = oldJob, jobStage = oldJobStage } = update;
|
||||||
|
|
||||||
let dicJob = gameData.job.get(job);
|
let dicJob = gameData.job.get(job);
|
||||||
|
let lastJob = getJobByGradeAndClass(dicJob.job_class, dicJob.grade - 1);
|
||||||
|
let dicLastJob = lastJob? gameData.job.get(lastJob.jobid): null;
|
||||||
|
|
||||||
if (dicJob.grade >= 1) {
|
for(let i = 1; i <= dicJob.maxStage; i++) {
|
||||||
let jobGradeAndClass = getJobByGradeAndClass(dicJob.job_class, dicJob.grade - 1);
|
if(oldJobStage < i && jobStage >= i) {
|
||||||
let lastJob = gameData.job.get(jobGradeAndClass.jobid);
|
let lastAttr = dicLastJob? dicLastJob.ceAttr.get(i).attr: 0;
|
||||||
let targetAttrId = dicJob.ceAttr.get(jobStage).id;
|
let targetAttrId = dicJob.ceAttr.get(i).id;
|
||||||
let inc = (dicJob.ceAttr.get(jobStage).attr - lastJob.ceAttr.get(jobStage).attr) * HERO_CE_RATIO;
|
let targetAttrValue = dicJob.ceAttr.get(i).attr;
|
||||||
updateHeroAttr(heroAttrs, targetAttrId, { inc: { fixUp: inc } });
|
let inc = (targetAttrValue - lastAttr) * HERO_CE_RATIO;
|
||||||
} else {
|
console.log('*******', targetAttrId, targetAttrValue, lastAttr, inc )
|
||||||
let targetAttrId = dicJob.ceAttr.get(jobStage).id;
|
updateHeroAttr(heroAttrs, targetAttrId, { inc: { fixUp: inc } });
|
||||||
let inc = dicJob.ceAttr.get(jobStage).attr * HERO_CE_RATIO;
|
}
|
||||||
updateHeroAttr(heroAttrs, targetAttrId, { inc: { fixUp: inc } });
|
|
||||||
}
|
}
|
||||||
return heroAttrs;
|
return heroAttrs;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user