解析修改:heroHandler
This commit is contained in:
@@ -1,19 +1,16 @@
|
||||
import {Application, BackendSession, createTcpMailBox, ChannelService} from 'pinus';
|
||||
import { handleCost } from '../../../services/rewardService';
|
||||
import { calPlayerCeAndSave, getAllAttrStage } from '../../../services/playerCeService';
|
||||
import { resResult, getItems, decodeStr } from '../../../pubUtils/util';
|
||||
import { resResult } from '../../../pubUtils/util';
|
||||
import { STATUS } from '../../../consts/statusCode';
|
||||
import {HeroModel} from '../../../db/Hero';
|
||||
import {CURRENCY_BY_TYPE, CURRENCY_TYPE, CONSUME_TYPE, HERO_GROW_MAX, HERO_SYSTEM_TYPE, ITID} from '../../../consts/consts';
|
||||
import {getJobInfoById, getMaxGradeByjobClass, getHidAndLevelByShipId, getGoodById, getJobByGradeAndClass, getFriendShipById, getFriendShipLevels, getFashionsById} from '../../../pubUtils/gamedata';
|
||||
import { ABI_STAGE } from '../../../consts/abilityConst';
|
||||
import { RoleModel } from '../../../db/Role';
|
||||
import { ItemModel } from '../../../db/Item';
|
||||
import { gameData, getHeroExpByLv, getHeroStarByQuality, getHeroWakeByQuality, getHeroLvByExp } from '../../../pubUtils/data';
|
||||
import { gameData, getHeroExpByLv, getHeroStarByQuality, getHeroWakeByQuality, getHeroLvByExp, getMaxGradeByjobClass, getJobByGradeAndClass, getFriendShipById } from '../../../pubUtils/data';
|
||||
import { RewardInter } from '../../../pubUtils/interface';
|
||||
|
||||
const _ = require('underscore');
|
||||
|
||||
export default function(app: Application) {
|
||||
return new HeroHandler(app);
|
||||
}
|
||||
@@ -276,7 +273,7 @@ export class HeroHandler {
|
||||
let hero = await HeroModel.findByHidAndRole(hid, roleId, false);
|
||||
if (!hero)
|
||||
return resResult(STATUS.HERO_NOT_FIND);
|
||||
let heroJob = getJobInfoById(hero.job);
|
||||
let heroJob = gameData.job.get(hero.job);
|
||||
let nextHeroJob = getJobByGradeAndClass(heroJob.job_class, heroJob.grade + 1);
|
||||
if (nextHeroJob.unlockLevel > hero.lv)
|
||||
return resResult(STATUS.NOT_REACH_UNLOCK_LEVEL);
|
||||
@@ -284,8 +281,7 @@ export class HeroHandler {
|
||||
return resResult(STATUS.HERO_JOB_STAGE_REACH_MAX_STAGE);
|
||||
if (hero.job >= getMaxGradeByjobClass(heroJob.job_class))
|
||||
return resResult(STATUS.HERO_JOB_REACH_MAX_STAGE);
|
||||
let cousumeGoods = getItems(heroJob.trainingConsume);
|
||||
let result = await handleCost(roleId, sid, cousumeGoods);
|
||||
let result = await handleCost(roleId, sid, heroJob.trainingConsume);
|
||||
if(!result) {
|
||||
return resResult(STATUS.BATTLE_CONSUMES_NOT_ENOUGH);
|
||||
}
|
||||
@@ -304,14 +300,13 @@ export class HeroHandler {
|
||||
if (!hero)
|
||||
return resResult(STATUS.HERO_NOT_FIND);
|
||||
let curJob = hero.job;
|
||||
let heroJob = getJobInfoById(curJob);
|
||||
let heroJob = gameData.job.get(curJob);
|
||||
let nextHeroJob = getJobByGradeAndClass(heroJob.job_class, heroJob.grade + 1);
|
||||
if (nextHeroJob.unlockLevel > hero.lv)
|
||||
return resResult(STATUS.NOT_REACH_UNLOCK_LEVEL);
|
||||
if (curJob >= getMaxGradeByjobClass(heroJob.job_class))
|
||||
return resResult(STATUS.HERO_JOB_REACH_MAX_STAGE);
|
||||
let cousumeGoods = getItems(heroJob.upGradeConsume);
|
||||
let result = await handleCost(roleId, sid, cousumeGoods);
|
||||
let result = await handleCost(roleId, sid, heroJob.upGradeConsume);
|
||||
if(!result) {
|
||||
return resResult(STATUS.BATTLE_CONSUMES_NOT_ENOUGH);
|
||||
}
|
||||
@@ -327,7 +322,7 @@ export class HeroHandler {
|
||||
let roleId: string = session.get('roleId');
|
||||
let sid: string = session.get('sid');
|
||||
let { shipId } = msg;
|
||||
let shipHidAndLevel = getHidAndLevelByShipId(shipId);
|
||||
let shipHidAndLevel = gameData.friendShipHidAandIds.get(shipId);
|
||||
if (!shipHidAndLevel)
|
||||
return resResult(STATUS.HERO_CONECTION_IS_NOT_EXIT);
|
||||
let hero = await HeroModel.findByHidAndRole(shipHidAndLevel.actorId, roleId, false);
|
||||
@@ -380,7 +375,7 @@ export class HeroHandler {
|
||||
let lastLv = hero.favourLv;
|
||||
if (!hero)
|
||||
return resResult(STATUS.HERO_NOT_FIND);
|
||||
let friendShipLevels = getFriendShipLevels();
|
||||
let friendShipLevels = gameData.friendShipLevel;
|
||||
if (friendShipLevels[friendShipLevels.length - 1].level <= hero.favourLv)
|
||||
return resResult(STATUS.HERO_FAVOUR_LEVEL_REACH_MAXT);
|
||||
//计算消耗物品转化的经验
|
||||
@@ -421,7 +416,7 @@ export class HeroHandler {
|
||||
let roleId: string = session.get('roleId');
|
||||
let sid: string = session.get('sid');
|
||||
let { id } = msg;
|
||||
let skinInfo = getFashionsById(id);
|
||||
let skinInfo = gameData.fashion.get(id);
|
||||
if (!skinInfo)
|
||||
return resResult(STATUS.HERO_SKIN_NOT_FIND);
|
||||
let hero = await HeroModel.findByHidAndRole(skinInfo.actorId, roleId, false);
|
||||
|
||||
Reference in New Issue
Block a user