装备:镶嵌天晶石
This commit is contained in:
@@ -11,13 +11,14 @@ import { calPlayerCeAndSave } from "../../../services/playerCeService";
|
||||
import { getGoodById, gameData, getEquipByJobClassAndEPlace, getNextEquipQuality, getEquipQualityIdByEquipIdAndPoint, getEquipStarIdByEquipId, getNextEquipStar } from "../../../pubUtils/data";
|
||||
import { BAG, EQUIP } from "../../../pubUtils/dicParam";
|
||||
import { ITID, QUALITY_TYPE, equipTypeToSortAttr, IT_TYPE, QUENCH_TYPE, REFINE_TYPE } from "../../../consts";
|
||||
import { checkMaterialEnough, checkEquipCanPut, quenchOnce, checkQuenchMaxByQualityAndGrade, getRandSeResult, refineOnce, checkRefineReachNextLv, calEquipCe, updateEplace, updateEplaces } from "../../../services/equipService";
|
||||
import { checkMaterialEnough, checkEquipCanPut, quenchOnce, checkQuenchMaxByQualityAndGrade, getRandSeResult, refineOnce, checkRefineReachNextLv, calEquipCe, updateEplace, updateEplaces, checkJewelCanPutOnEquip } from "../../../services/equipService";
|
||||
|
||||
import { findIndex, isNumber, pick } from 'underscore';
|
||||
import { pushEquipRefineSucMsg, pushNormalEquipMsg, pushNormalItemMsg } from "../../../services/chatService";
|
||||
import { checkTaskWithHero, checkTaskWithEquip, checkTask, checkTaskWithArgs, checkActivityTask } from "../../../services/taskService";
|
||||
import { QuenchLogParam } from "../../../domain/roleField/equip";
|
||||
import { calEquipSeids } from "../../../pubUtils/playerCe";
|
||||
import { JewelModel, JewelType } from "../../../db/Jewel";
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
@@ -279,66 +280,53 @@ export class EquipHandler {
|
||||
|
||||
}
|
||||
|
||||
// // 装备栏精炼
|
||||
// public async refine(msg: { hid: number, ePlaceId: number, type: REFINE_TYPE }, session: BackendSession) {
|
||||
// let roleId: string = session.get('roleId');
|
||||
// let roleName: string = session.get('roleName');
|
||||
// let serverId = session.get('serverId');
|
||||
// let sid: string = session.get('sid');
|
||||
//镶嵌天晶石
|
||||
public async putOnJewel(msg: { hid: number, eplaceId: number, jewel: number }, session: BackendSession) {
|
||||
let { hid, eplaceId, jewel: seqId } = msg;
|
||||
let roleId: string = session.get('roleId');
|
||||
let sid: string = session.get('sid');
|
||||
|
||||
let hero = await HeroModel.findByHidAndRole(hid, roleId);
|
||||
if (!hero) return resResult(STATUS.HERO_NOT_FIND);
|
||||
|
||||
// let { hid, ePlaceId, type } = msg;
|
||||
let curEquip = hero.ePlace?.find(cur => cur.id == eplaceId);
|
||||
if(!curEquip) return resResult(STATUS.EQUIP_NOT_FIND);
|
||||
let jewel = await JewelModel.findbySeqId(seqId);
|
||||
if(!jewel) return resResult(STATUS.JEWEL_IS_NOT_FIND);
|
||||
if(curEquip.jewel == seqId) return resResult(STATUS.JEWEL_HAS_SUIT);
|
||||
if(!checkJewelCanPutOnEquip(curEquip, jewel)) {
|
||||
return resResult(STATUS.EQUIP_NOT_MATCH_JEWEL)
|
||||
}
|
||||
|
||||
// let hero = await HeroModel.findByHidAndRoleWithEquip(hid, roleId);
|
||||
// if (!hero) return resResult(STATUS.HERO_NOT_FIND);
|
||||
// let { ePlace } = hero; // 装备栏
|
||||
let originHeroResult: { hid: number, ePlace: Partial<EPlace>[] };
|
||||
let originJewel = curEquip.jewel? await JewelModel.findbySeqId(curEquip.jewel): null; // 原本自己的天晶石
|
||||
let canSentMineToOrigin = false; // 自己的能不能塞到对方身上
|
||||
if(jewel.hid != 0) { // 如果天晶石原本镶嵌在其他武将身上,把自己的给他
|
||||
let originHero = await HeroModel.findByHidAndRole(jewel.hid, roleId);
|
||||
let originEquip = originHero?.ePlace?.find(cur => cur.jewel == seqId);
|
||||
if(originEquip) {
|
||||
let canChange = originJewel && checkJewelCanPutOnEquip(originEquip, originJewel);
|
||||
if(canChange) canSentMineToOrigin = true;
|
||||
let { newEplace, updatedEplace } = updateEplace(originHero.ePlace, eplaceId, { jewel: canChange? originJewel.seqId: 0 });
|
||||
await calPlayerCeAndSave(HERO_SYSTEM_TYPE.EQUIP_JEWEL, sid, roleId, originHero, { ePlace: newEplace }, [eplaceId]);
|
||||
originHeroResult = { hid: originHero.hid, ePlace: updatedEplace };
|
||||
}
|
||||
}
|
||||
if(originJewel) { // 更新自己的天晶石
|
||||
await JewelModel.putOnOrOff(originJewel.seqId, canSentMineToOrigin? jewel.hid: 0, canSentMineToOrigin? eplaceId: 0);
|
||||
}
|
||||
|
||||
// let curEplace = ePlace.find(cur => cur.id == ePlaceId);
|
||||
// if (!curEplace) {
|
||||
// return resResult(STATUS.ROLE_EQUIP_PLACE_NOT_ENOUGH);
|
||||
// }
|
||||
// let { lv, refineLv: oldRefineLv, equip } = curEplace; // 强化等级,精炼等级,精炼次数
|
||||
// 目标镶嵌上
|
||||
let curJewel = await JewelModel.putOnOrOff(seqId, hid, eplaceId);
|
||||
let { newEplace, updatedEplace } = updateEplace(hero.ePlace, eplaceId, { jewel: seqId });
|
||||
await calPlayerCeAndSave(HERO_SYSTEM_TYPE.EQUIP_JEWEL, sid, roleId, hero, { ePlace: newEplace }, [eplaceId]);
|
||||
let curHero = {
|
||||
hid,
|
||||
eplace: updatedEplace
|
||||
}
|
||||
|
||||
// let check = new CheckMeterial(roleId);
|
||||
// let refineLv = oldRefineLv, times = 0;
|
||||
// while(
|
||||
// (type == REFINE_TYPE.ONCE && times == 0) ||
|
||||
// (type == REFINE_TYPE.ONE_LEVEL && !checkRefineReachNextLv(oldRefineLv, refineLv) )
|
||||
// ) {
|
||||
// let result = await refineOnce(lv, refineLv);
|
||||
// if(!result) break;
|
||||
|
||||
// let isEnough = await check.decrease(result.consumes);
|
||||
// if(!isEnough) break; // 消耗不足
|
||||
// refineLv = result.refineLv;
|
||||
// times ++;
|
||||
// }
|
||||
// if(times == 0) {
|
||||
// return resResult(STATUS.EQUIP_REFINE_ERR);
|
||||
// }
|
||||
// let consumes = check.getConsume();
|
||||
// let result = await handleCost(roleId, sid, consumes, ITEM_CHANGE_REASON.EQUIP_REFINE);
|
||||
// if (!result)
|
||||
// return resResult(STATUS.BATTLE_CONSUMES_NOT_ENOUGH);
|
||||
|
||||
// curEplace.refineLv = refineLv;
|
||||
|
||||
|
||||
|
||||
// await calPlayerCeAndSave(HERO_SYSTEM_TYPE.EQUIP_BASE, sid, roleId, hero, { ePlace });
|
||||
|
||||
// const curHero = {
|
||||
// hid,
|
||||
// ePlace: [curEplace]
|
||||
// }
|
||||
|
||||
// let curEquip = <EquipType>equip;
|
||||
// pushEquipRefineSucMsg(roleId, roleName, serverId, curEplace, curEquip ? curEquip.quality : 0);
|
||||
// await checkTask(roleId, sid, TASK_TYPE.EQUIP_REFINE, times, true, {});
|
||||
// await checkActivityTask(serverId, sid, roleId, TASK_TYPE.EQUIP_REFINE, times);
|
||||
// await checkActivityTask(serverId, sid, roleId, TASK_TYPE.EQUIP_REFINE_LV, times, { lv: curEplace.refineLv });
|
||||
// return resResult(STATUS.SUCCESS, { curHero });
|
||||
// }
|
||||
return resResult(STATUS.SUCCESS, { curHero, originHero: originHeroResult, curJewel });
|
||||
}
|
||||
|
||||
// // 装备洗炼锁定
|
||||
// public async lockRandSe(msg: { eid: number, id: number, lock: boolean }, session: BackendSession) {
|
||||
|
||||
Reference in New Issue
Block a user