装备:镶嵌天晶石
This commit is contained in:
@@ -26,6 +26,7 @@ import Counter from '../../../db/Counter';
|
||||
import { getExpByLv } from '../../../pubUtils/data';
|
||||
import { reportTAUserSet } from '../../../services/sdkService';
|
||||
import { saveLoginAndOutLog } from '../../../pubUtils/logUtil';
|
||||
import { JewelModel } from '../../../db/Jewel';
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
@@ -79,7 +80,7 @@ export class EntryHandler {
|
||||
addRoleToWorldChannel(role.roleId, self.app.get('serverId'), role.serverId);
|
||||
await self.app.rpc.chat.chatRemote.addWorldChannel.route(session)(role.roleId, serverId, self.app.get('serverId'));
|
||||
let heros = await HeroModel.findByRole(role.roleId, [], HERO_SELECT.ENTRY, true);
|
||||
let equips = await EquipModel.findbyRole(role.roleId);
|
||||
let jewels = await JewelModel.findbyRole(role.roleId);
|
||||
let items = await ItemModel.findbyRole(role.roleId);
|
||||
let skins = await SkinModel.findbyRole(role.roleId);
|
||||
reportOneOnline(role.roleId, user.userCode, self.app.get('serverId'), true, user);
|
||||
@@ -98,7 +99,7 @@ export class EntryHandler {
|
||||
pushData(role.hasInit, role, session);
|
||||
|
||||
role['heros'] = heros;
|
||||
role['equips'] = equips;
|
||||
role['jewels'] = jewels;
|
||||
role['consumeGoods'] = items;
|
||||
role['skins'] = skins;
|
||||
let ip = session.remoteAddress.ip.replace('::ffff:', '');
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -8,6 +8,7 @@ import { dicGoods, DicGoods } from '../pubUtils/dictionary/DicGoods';
|
||||
import { QuenchLogParam } from '../domain/roleField/equip';
|
||||
import { QUENCH } from '../pubUtils/dicParam';
|
||||
import { DicQuenchQuality } from '../pubUtils/dictionary/DicQuenchQuality';
|
||||
import { JewelType } from '../db/Jewel';
|
||||
|
||||
/**
|
||||
* 校验前端传入的消耗数量是否准确,并返回消耗的道具并加上特殊材料needConsumes
|
||||
@@ -225,4 +226,20 @@ export function updateEplaces(eplace: EPlace[], update: Map<number, Partial<EPla
|
||||
}
|
||||
}
|
||||
return {newEplace, updatedEplace};
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查天晶石能否装备上这个装备
|
||||
* @param equip
|
||||
* @param jewel
|
||||
*/
|
||||
export function checkJewelCanPutOnEquip(equip: EPlace, jewel: JewelType) {
|
||||
// 位置是否满足
|
||||
let dicJewel = gameData.jewel.get(jewel.id);
|
||||
console.log('####', dicJewel, dicJewel.eplaceId, equip.id)
|
||||
if(!dicJewel || dicJewel.eplaceId != equip.id) return false;
|
||||
// 品质是否满足
|
||||
let dicEquipQualityExtra = gameData.equipQualityExtra.get(equip.quality);
|
||||
if(!dicEquipQualityExtra || dicEquipQualityExtra.jewelCnt == 0) return false;
|
||||
return true
|
||||
}
|
||||
Reference in New Issue
Block a user