🐞 fix(重生): 修复传承的时候消耗道具没有交换

This commit is contained in:
luying
2023-08-30 15:08:12 +08:00
parent fe1e6ad30f
commit d8514c0717
3 changed files with 34 additions and 3 deletions

View File

@@ -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);
}

View File

@@ -314,4 +314,23 @@ export enum REFINE_TYPE {
ONE_LEVEL = 2, // 精炼一级
}
export const DELICACY_GID = 11011;
export const DELICACY_GID = 11011;
export const REBORN_ITEM = [
// 经验书
11001, 11002, 11003, 11004,
// 训练丹
17002, 17003, 17004, 17005, 17006, 17007, 17008, 17009, 17010, 17011, 17012, 17013, 17014, 17015, 17016, 17017, 17018, 17019, 17020, 17021, 17022, 17023, 17024, 17025, 17026, 17027, 17028, 17029, 17030, 17031, 17032, 17033, 17034, 17035, 17036, 17037, 17038, 17039, 17040, 17041,
// 虎符
17042,
// 通用丹
17059, 17060,
// 镔铁,天外陨金
17054, 17055,
// 图纸
50001, 50002, 50003, 50004, 50005, 50006, 50007,
// 地玉
60001, 60002, 60003, 60004, 60005, 60006, 60007, 60008, 60009, 60011, 60012, 60013, 60014, 60015, 60016, 60017, 60018, 60019, 60021, 60022, 60023, 60024, 60025, 60026, 60027, 60028, 60029, 60031, 60032, 60033, 60034, 60035, 60036, 60037, 60038, 60039,
// 铜币
31001,
]

View File

@@ -1254,6 +1254,7 @@ export enum ITEM_CHANGE_REASON {
ROUGE_FIRST_REWARD = 201, // 肉鸽首通奖励
RECEIVE_COLLECT_REWARD = 202, // 领取图鉴奖励
RECEIVE_ROUGE_SCORE_REWARD = 203, // 领取积分奖励
REBORN_COST = 204, // 重生优化,传承
}
export enum TA_EVENT {