🐞 fix(重生): 修复传承的时候消耗道具没有交换
This commit is contained in:
@@ -8,7 +8,7 @@ import { RoleModel } from '../../../db/Role';
|
||||
import { ItemModel } from '../../../db/Item';
|
||||
import { gameData, getHeroExpByLv, getHeroStarByQuality, getHeroWakeByQuality, getHeroLvByExp, getMaxGradeByjobClass, getJobByGradeAndClass, getConnectLvByExp, getEquipByJobClassAndEPlace, getScollByStar, getExpByLv, getConnectMaxLv, getFriendShipByIdAndLv } from '../../../pubUtils/data';
|
||||
import { ItemInter, RewardInter } from '../../../pubUtils/interface';
|
||||
import { getDropItems, FIGURE_UNLOCK_CONDITION, ITID, DELICACY_GID } from '../../../consts/constModules/itemConst'
|
||||
import { getDropItems, FIGURE_UNLOCK_CONDITION, ITID, DELICACY_GID, REBORN_ITEM } from '../../../consts/constModules/itemConst'
|
||||
import { pushHeroStarMax, pushHeroWakeUp } from '../../../services/chatService';
|
||||
import { PvpDefenseModel } from '../../../db/PvpDefense';
|
||||
import { checkTask, checkTaskInHeroGiveFavor, checkTaskInHeroQUalityUp, checkTaskInHeroStarUp, checkTaskInHeroTrain, checkTaskInHeroWakeUp } from '../../../services/task/taskService';
|
||||
@@ -823,6 +823,7 @@ export class HeroHandler {
|
||||
const serverId: number = session.get('serverId');
|
||||
|
||||
const { originHid, targetHid } = msg;
|
||||
|
||||
let dbHeros = await HeroModel.findByHidsAndRole(roleId, [originHid, targetHid]);
|
||||
if (dbHeros.length != 2) return resResult(STATUS.HERO_NOT_FIND);
|
||||
const heroMap = dbHeros.reduce((map, obj) => { map.set(obj.hid, obj); return map; }, new Map<number, HeroType>());
|
||||
@@ -866,9 +867,19 @@ export class HeroHandler {
|
||||
curJewels.push({ seqId:result.seqId, hid:result.hid});
|
||||
}
|
||||
|
||||
// 消耗
|
||||
let originalConsumes = originHero.consumes||[];
|
||||
let targetConsumes = targetHero.consumes||[];
|
||||
originHero.consumes = [...targetConsumes.filter(cur => REBORN_ITEM.includes(cur.id)), ...originalConsumes.filter(cur => !REBORN_ITEM.includes(cur.id))];
|
||||
targetHero.consumes = [...originalConsumes.filter(cur => REBORN_ITEM.includes(cur.id)), ...targetConsumes.filter(cur => !REBORN_ITEM.includes(cur.id))];
|
||||
|
||||
let cost = [getGoldObject(REBORN.EXCHANGE_COST)];
|
||||
let costResult = await handleCost(roleId, sid, cost, ITEM_CHANGE_REASON.REBORN_COST);
|
||||
if(!costResult) return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
|
||||
|
||||
let heroesRet: HeroType[] = [];
|
||||
for (let hero of [originHero, targetHero]) {
|
||||
let result = await HeroModel.updateHeroInfo(roleId, hero.hid, { ...pick(hero, ['lv','exp', 'job', 'jobStage', 'ePlace', 'skins']) });
|
||||
let result = await HeroModel.updateHeroInfo(roleId, hero.hid, { ...pick(hero, ['lv','exp', 'job', 'jobStage', 'ePlace', 'skins', 'consumes']) });
|
||||
if (!result) return resResult(STATUS.HERO_NOT_FIND);
|
||||
heroesRet.push(result);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user