装备:合成地玉石
This commit is contained in:
@@ -11,7 +11,7 @@ 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, checkJewelCanPutOnEquip, updateStone, checkStoneCanPutOnEquip } from "../../../services/equipService";
|
||||
import { checkEquipCanPut, quenchOnce, checkQuenchMaxByQualityAndGrade, getRandSeResult, refineOnce, checkRefineReachNextLv, calEquipCe, updateEplace, updateEplaces, checkJewelCanPutOnEquip, updateStone, checkStoneCanPutOnEquip } from "../../../services/equipService";
|
||||
|
||||
import { findIndex, isNumber, pick } from 'underscore';
|
||||
import { pushEquipRefineSucMsg, pushNormalEquipMsg, pushNormalItemMsg } from "../../../services/chatService";
|
||||
@@ -199,6 +199,10 @@ export class EquipHandler {
|
||||
if(update.quality == curEquip.quality && update.qualityStage == curEquip.qualityStage) {
|
||||
return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
|
||||
}
|
||||
let consumes = check.getConsume();
|
||||
let result = await handleCost(roleId, sid, consumes, ITEM_CHANGE_REASON.EQUIP_QUALITYUP);
|
||||
if (!result) return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
|
||||
|
||||
let isUpQuality = update.quality != curEquip.quality;
|
||||
|
||||
let { newEplace, updatedEplace } = updateEplace(hero.ePlace, ePlaceId, update);
|
||||
@@ -266,6 +270,9 @@ export class EquipHandler {
|
||||
if(update.star == curEquip.star && update.starStage == curEquip.starStage) {
|
||||
return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
|
||||
}
|
||||
let consumes = check.getConsume();
|
||||
let result = await handleCost(roleId, sid, consumes, ITEM_CHANGE_REASON.EQUIP_STARUP);
|
||||
if (!result) return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
|
||||
|
||||
let { newEplace, updatedEplace } = updateEplace(hero.ePlace, ePlaceId, update);
|
||||
hero = await calPlayerCeAndSave(HERO_SYSTEM_TYPE.EQUIP_STAR, sid, roleId, hero, { ePlace: newEplace }, [ePlaceId]);
|
||||
@@ -608,7 +615,7 @@ export class EquipHandler {
|
||||
for (let { id, count } of origin) {
|
||||
let dicGoods = getGoodById(id);
|
||||
if (!dicGoods) return resResult(STATUS.DIC_DATA_NOT_FOUND);
|
||||
if (!dicGoods.decomposeItem) return resResult(STATUS.CONSUME_TYPE_ERR);
|
||||
if (!dicGoods.decomposeItem || dicGoods.decomposeItem.length <= 0) return resResult(STATUS.CONSUME_TYPE_ERR);
|
||||
|
||||
for(let result of dicGoods.decomposeItem) {
|
||||
goods.push({ id: result.id, count: result.count * count });
|
||||
@@ -652,521 +659,23 @@ export class EquipHandler {
|
||||
return resResult(STATUS.SUCCESS, { goods: combineItems(result) });
|
||||
}
|
||||
|
||||
|
||||
|
||||
// //穿戴或卸载装备 1-穿上装备(包括替换) 2-脱下装备
|
||||
// public async putOnOrOff(msg: { eid: number, hid: number, type: number }, session: BackendSession) {
|
||||
// let { eid, hid, type } = msg;
|
||||
// let roleId: string = session.get('roleId');
|
||||
// let serverId: number = session.get('serverId');
|
||||
// let sid: string = session.get('sid');
|
||||
//宝石合成
|
||||
public async composeStone(msg: { id: number, count: number }, session: BackendSession) {
|
||||
let { id, count } = msg;
|
||||
let roleId: string = session.get('roleId');
|
||||
let roleName: string = session.get('roleName');
|
||||
let sid: string = session.get('sid');
|
||||
|
||||
let check = new CheckMeterial(roleId);
|
||||
let isEnough = await check.composeStone(id, count);
|
||||
if(!isEnough) return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
|
||||
|
||||
// // 原武将:heroA,原武将穿戴着的装备a,将要穿戴的装备b,装备b被装备着的武将B
|
||||
// let heroA = await HeroModel.findByHidAndRoleWithEquip(hid, roleId);
|
||||
// if (!heroA) return resResult(STATUS.HERO_NOT_FIND);
|
||||
// let oldCountA = heroA.ePlace.filter(cur => cur.equip).length;
|
||||
// let oldCountB = 0;
|
||||
|
||||
// let equip = await EquipModel.getEquip(eid); // 装备:1-equipB 2-equipA
|
||||
// if(!equip) return resResult(STATUS.EQUIP_NOT_FIND);
|
||||
|
||||
// let argsA = calEquipSeids(heroA);
|
||||
// let heroB: HeroType, equipA: EquipType, equipB: EquipType, argsB: number[] = [];
|
||||
// let heroAPutNum = 0, heroBPutTNum = 0; // 1:多一件 0:没变化 -1:少一件
|
||||
|
||||
// let goodInfo = getGoodById(equip.id);
|
||||
// let obj = ITID.get(goodInfo.itid);
|
||||
// let eplaceId = obj.type; // 位置
|
||||
|
||||
// if (type == 1) {
|
||||
// equipB = equip; // 要穿上的装备
|
||||
// if (equipB.hid == hid) return resResult(STATUS.WRONG_PARMS);
|
||||
// if(!checkEquipCanPut(heroA, equipB.id)) return resResult(STATUS.EQUIP_NOT_EQUIPED_HERO);
|
||||
|
||||
// let index = heroA.ePlace.findIndex(cur => cur.id == eplaceId);
|
||||
// if (index == -1) return resResult(STATUS.WRONG_PARMS);
|
||||
// equipA = <EquipType>heroA.ePlace[index].equip; // 要脱下的装备
|
||||
|
||||
// if(equipB.hid > 0) {
|
||||
// heroB = await HeroModel.findByHidAndRoleWithEquip(equipB.hid, roleId);
|
||||
// argsB = calEquipSeids(heroB);
|
||||
// oldCountB = heroB.ePlace.filter(cur => cur.equip).length;
|
||||
// }
|
||||
|
||||
// if(equipA) {
|
||||
// if(equipB.hid > 0) {
|
||||
// if(checkEquipCanPut(heroB, equipA.id)) { // A=>b & B=>a
|
||||
// equipA = await EquipModel.putOnOrOff(equipA._id, equipB.hid);
|
||||
// heroB = await HeroModel.addEquip(roleId, heroB.hid, eplaceId, equipA._id);
|
||||
// } else { // A=>b & B=>0 & 0=>a
|
||||
// equipA = await EquipModel.putOnOrOff(equipA._id, 0);
|
||||
// heroB = await HeroModel.removeEquip(roleId, equipB.hid, eplaceId);
|
||||
// heroBPutTNum = -1;
|
||||
// }
|
||||
// } else { // A=>b & 0=>a
|
||||
// equipA = await EquipModel.putOnOrOff(equipA._id, 0);
|
||||
// }
|
||||
// } else {
|
||||
// if(equipB.hid > 0) { // A=>b & B=>0
|
||||
// heroB = await HeroModel.removeEquip(roleId, equipB.hid, eplaceId);
|
||||
// heroBPutTNum = -1;
|
||||
// }
|
||||
// // A=>b
|
||||
// heroAPutNum = 1;
|
||||
// }
|
||||
|
||||
// heroA = await HeroModel.addEquip(roleId, heroA.hid, eplaceId, equipB._id);
|
||||
// equipB = await EquipModel.putOnOrOff(equipB._id, heroA.hid);
|
||||
|
||||
// } else if (type == 2) { // A=>0 & 0=>a
|
||||
// if (!equip.hid) return resResult(STATUS.EQUIP_NOT_EQUIPED);
|
||||
// equipA = await EquipModel.putOnOrOff(equip._id, 0);
|
||||
// heroA = await HeroModel.removeEquip(roleId, heroA.hid, eplaceId);
|
||||
// heroAPutNum = -1;
|
||||
// }
|
||||
|
||||
// if(heroA) {
|
||||
// await calPlayerCeAndSave(HERO_SYSTEM_TYPE.EQUIP, sid, roleId, heroA, {}, argsA);
|
||||
// if(heroAPutNum != 0) {
|
||||
// await checkTaskWithHero(roleId, sid, TASK_TYPE.EQUIP_BY_HERO, heroA, [heroAPutNum, oldCountA]);
|
||||
// }
|
||||
// }
|
||||
// if(heroB) {
|
||||
// await calPlayerCeAndSave(HERO_SYSTEM_TYPE.EQUIP, sid, roleId, heroB, {}, argsB);
|
||||
// if(heroBPutTNum != 0) await checkTaskWithHero(roleId, sid, TASK_TYPE.EQUIP_BY_HERO, heroA, [heroBPutTNum, oldCountB]);
|
||||
// }
|
||||
// if(heroAPutNum + heroBPutTNum != 0) {
|
||||
// await checkTask(roleId, sid, TASK_TYPE.EQUIP_SUM, heroAPutNum + heroBPutTNum, true, {});
|
||||
// await checkActivityTask(serverId, sid, roleId, TASK_TYPE.EQUIP_SUM, heroAPutNum + heroBPutTNum)
|
||||
// }
|
||||
|
||||
// let curEquips: Array<{ seqId: number, hid: number }> = [];
|
||||
// if(equipA) {
|
||||
// curEquips.push(pick(equipA, ['seqId', 'hid']));
|
||||
// if(equipA.hid == 0) {
|
||||
// await checkTaskWithEquip(roleId, sid, TASK_TYPE.EQUIP_QUALITY, equipA, [-1]); // equipA必然是脱,如果hid不为0说明从一个人穿到另一个人,不算任务
|
||||
// await checkActivityTask(serverId, sid, roleId, TASK_TYPE.EQUIP_QUALITY, 1, { quality: equipA.quality });
|
||||
// }
|
||||
// }
|
||||
// if(equipB) {
|
||||
// curEquips.push(pick(equipB, ['seqId', 'hid']));
|
||||
// if(equipB.hid != 0) {
|
||||
// await checkTaskWithEquip(roleId, sid, TASK_TYPE.EQUIP_QUALITY, equipB, [1]); // equipB必然是穿,如果hid为0说明没有变化,不算任务
|
||||
// await checkActivityTask(serverId, sid, roleId, TASK_TYPE.EQUIP_QUALITY, 1, { quality: equipB.quality });
|
||||
// }
|
||||
// }
|
||||
|
||||
// if(type == 1) {
|
||||
// let { isTask, jewelLevel } = await checkTaskConditionEquipSuitJewelStage(heroA)//英雄满装备且都镶嵌相同阶数的宝石
|
||||
// if (isTask) {
|
||||
// await checkActivityTask(serverId, sid, roleId, TASK_TYPE.EQUIP_SUIT_JEWEL_STAGE, 1, { stage: jewelLevel })
|
||||
// }
|
||||
// }
|
||||
|
||||
// return resResult(STATUS.SUCCESS, { curEquips: curEquips });
|
||||
// }
|
||||
|
||||
// // 一次性装备上
|
||||
// public async putOnOnce(msg: { hid: number }, session: BackendSession) {
|
||||
// let { hid } = msg;
|
||||
// let roleId: string = session.get('roleId');
|
||||
// const serverId = session.get('serverId');
|
||||
// let sid: string = session.get('sid');
|
||||
let consumes = check.getConsume();
|
||||
let costResult = await handleCost(roleId, sid, consumes, ITEM_CHANGE_REASON.COMPOSE_STONE);
|
||||
if (!costResult) return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
|
||||
|
||||
// let hero = await HeroModel.findByHidAndRoleWithEquip(hid, roleId);
|
||||
// if (!hero) return resResult(STATUS.HERO_NOT_FIND);
|
||||
// let args = calEquipSeids(hero);
|
||||
let goods = await addItems(roleId, roleName, sid, [{ id, count }], ITEM_CHANGE_REASON.COMPOSE_STONE);
|
||||
return resResult(STATUS.SUCCESS, goods);
|
||||
}
|
||||
|
||||
// let dicHero = gameData.hero.get(hid);
|
||||
// if (!dicHero) return resResult(STATUS.DIC_DATA_NOT_FOUND);
|
||||
// let dicJob = gameData.job.get(dicHero.jobid);
|
||||
|
||||
|
||||
// let allEquips = await EquipModel.findNotWearEquips(roleId);
|
||||
// let sortEquips = allEquips.map(equip => {
|
||||
// let { id, quality, ePlaceId, randMain } = equip;
|
||||
// let { goodsAbility, lvLimited } = gameData.goods.get(id);
|
||||
// let ce = calEquipCe(goodsAbility, randMain);
|
||||
// return { id, quality, ce, equip, goodsAbility, lvLimited, ePlaceId }
|
||||
// });
|
||||
// let { ePlace, lv } = hero;
|
||||
// let oldCount = ePlace.filter(cur => cur.equip).length;
|
||||
|
||||
// let curEquips: Array<{ seqId: number, hid: number }> = [];
|
||||
// let equips: EquipType[] = [];
|
||||
// for (let curEPlace of ePlace) {
|
||||
// if (!curEPlace.equip) { // 未装备
|
||||
// let sortAttrId = equipTypeToSortAttr.get(curEPlace.id);
|
||||
// let sortedAndSuitEquips = sortEquips.filter(equipInfos => { // 筛选可穿的
|
||||
// let { id, lvLimited, ePlaceId } = equipInfos;
|
||||
// return lv >= lvLimited && checkEquipCanPut(hero, id) && curEPlace.id == ePlaceId;
|
||||
// });
|
||||
// // console.log('sortedAndSuitEquips', JSON.stringify(sortedAndSuitEquips, null, 4))
|
||||
// sortedAndSuitEquips = sortedAndSuitEquips.sort((a, b) => { // 排序按:战力 => 根据位置看个别属性 => 品质
|
||||
// if (b.ce - a.ce != 0) return b.ce - a.ce;
|
||||
// let abilityA = a.goodsAbility.get(sortAttrId) || 0;
|
||||
// let abilityB = b.goodsAbility.get(sortAttrId) || 0;
|
||||
// if (abilityA - abilityB != 0) return abilityB - abilityA;
|
||||
// return b.quality - a.quality;
|
||||
// });
|
||||
|
||||
// if (sortedAndSuitEquips.length > 0) {
|
||||
// let { equip } = sortedAndSuitEquips.shift();
|
||||
// hero = await HeroModel.addEquip(roleId, hero.hid, equip.ePlaceId, equip._id);
|
||||
// equip = await EquipModel.putOnOrOff(equip._id, hero.hid);
|
||||
// if (!!equip) {
|
||||
// curEquips.push(pick(equip, ['seqId', 'hid']));
|
||||
// equips.push(equip);
|
||||
// }
|
||||
// }
|
||||
|
||||
// }
|
||||
// }
|
||||
// if (curEquips.length > 0) {
|
||||
// //任务
|
||||
// await checkTaskWithHero(roleId, sid, TASK_TYPE.EQUIP_BY_HERO, hero, [1, oldCount]);
|
||||
// await checkTask(roleId, sid, TASK_TYPE.EQUIP_SUM, curEquips.length, true, {});
|
||||
// await checkActivityTask(serverId, sid, roleId, TASK_TYPE.EQUIP_SUM, curEquips.length);
|
||||
// for(let equip of equips) {
|
||||
// await checkTaskWithEquip(roleId, sid, TASK_TYPE.EQUIP_QUALITY, equip, [1]); // equipA必然是脱,如果hid不为0说明从一个人穿到另一个人,不算任务
|
||||
// await checkActivityTask(serverId, sid, roleId, TASK_TYPE.EQUIP_QUALITY, 1, { quality: equip.quality });
|
||||
// }
|
||||
// //英雄满装备且都镶嵌相同阶数的宝石
|
||||
// let { isTask, jewelLevel } = await checkTaskConditionEquipSuitJewelStage(hero)
|
||||
// if (isTask) {
|
||||
// await checkActivityTask(serverId, sid, roleId, TASK_TYPE.EQUIP_SUIT_JEWEL_STAGE, 1, { stage: jewelLevel })
|
||||
// }
|
||||
|
||||
// await calPlayerCeAndSave(HERO_SYSTEM_TYPE.EQUIP, sid, roleId, hero, {}, args);
|
||||
// }
|
||||
|
||||
// return resResult(STATUS.SUCCESS, { curEquips });
|
||||
// }
|
||||
|
||||
// //装备打孔
|
||||
// public async digHole(msg: { eid: number, id: number }, session: BackendSession) {
|
||||
// let { eid, id } = msg;
|
||||
// let roleId: string = session.get('roleId');
|
||||
// let sid: string = session.get('sid');
|
||||
// let equip = await EquipModel.getEquip(eid);
|
||||
// let index = findIndex(equip.holes, { id });
|
||||
// if (index < 0)
|
||||
// return resResult(STATUS.EQUIP_HOLE_NOT_FIND);
|
||||
// if (equip.holes[index].isOpen)
|
||||
// return resResult(STATUS.EQUIP_HOLE_IS_DUG);
|
||||
// let consumes: Array<{ id: number, count: number }> = [];
|
||||
// if (id == 1) {
|
||||
// consumes = parseGoodStr(EQUIP.EQUIP_ONE_HOLE);
|
||||
// } else if (id == 2) {
|
||||
// consumes = parseGoodStr(EQUIP.EQUIP_TWO_HOLE);
|
||||
// } else if (id == 3) {
|
||||
// consumes = parseGoodStr(EQUIP.EQUIP_THREE_HOLE);
|
||||
// }
|
||||
// let result = await handleCost(roleId, sid, consumes, ITEM_CHANGE_REASON.EQUIP_DIG_HOLE);
|
||||
// if (!result)
|
||||
// return resResult(STATUS.BATTLE_CONSUMES_NOT_ENOUGH);
|
||||
// equip.holes[index].isOpen = true;
|
||||
// await EquipModel.updateEquipInfo(eid, { holes: equip.holes });
|
||||
// return resResult(STATUS.SUCCESS, { curEquip: { seqId: eid, holes: equip.holes } });
|
||||
// }
|
||||
|
||||
// //宝石镶嵌
|
||||
// public async fillHole(msg: { eid: number, id: number, jewel: number }, session: BackendSession) {
|
||||
// let { eid, id, jewel } = msg;
|
||||
// let roleId: string = session.get('roleId');
|
||||
// const serverId = session.get('serverId');
|
||||
// let sid: string = session.get('sid');
|
||||
|
||||
// let consumes: Array<{ id: number, count: number }> = [];
|
||||
// let goods: Array<{ id: number, count: number }> = [];
|
||||
// let equip = await EquipModel.getEquip(eid);
|
||||
// let oldJewelCount = equip.holes.filter(cur => cur.jewel > 0).length;
|
||||
|
||||
// let { itid } = getGoodById(equip.id);
|
||||
// let { equipJewel } = ITID.get(itid);
|
||||
// let jewelInfo = getGoodById(jewel);
|
||||
// if (jewelInfo.itid != equipJewel)
|
||||
// return resResult(STATUS.EQUIP_NOT_MATCH_JEWEL);
|
||||
// let index = findIndex(equip.holes, { id });
|
||||
// if (index < 0)
|
||||
// return resResult(STATUS.EQUIP_HOLE_NOT_FIND);
|
||||
// if (!equip.holes[index].isOpen)
|
||||
// return resResult(STATUS.EQUIP_HOLE_IS_NOT_DUG);
|
||||
// let oldJewel = equip.holes[index].jewel;
|
||||
// if (!!oldJewel)
|
||||
// goods.push({ id: oldJewel, count: 1 });
|
||||
// consumes.push({ id: jewel, count: 1 });
|
||||
// let result = await handleCost(roleId, sid, consumes, ITEM_CHANGE_REASON.EQUIP_FILL_HOLE);
|
||||
// if (!result)
|
||||
// return resResult(STATUS.BATTLE_CONSUMES_NOT_ENOUGH);
|
||||
// equip.holes[index].jewel = jewel;
|
||||
// await EquipModel.updateEquipInfo(eid, { holes: equip.holes });
|
||||
// let roleName: string = session.get('roleName');
|
||||
// if (goods.length)
|
||||
// await addItems(roleId, roleName, sid, goods, ITEM_CHANGE_REASON.TAKE_OUT_JEWEL);
|
||||
// if (!!equip.hid) {
|
||||
// let hero = await HeroModel.findByHidAndRoleWithEquip(equip.hid, roleId);
|
||||
// await calPlayerCeAndSave(HERO_SYSTEM_TYPE.JEWEL_ON, sid, roleId, hero, {}, [jewel, oldJewel]);
|
||||
// //任务
|
||||
// //英雄满装备且都镶嵌相同阶数的宝石
|
||||
// let { isTask, jewelLevel } = await checkTaskConditionEquipSuitJewelStage(hero)
|
||||
// if (isTask) {
|
||||
// await checkActivityTask(serverId, sid, roleId, TASK_TYPE.EQUIP_SUIT_JEWEL_STAGE, 1, { stage: jewelLevel })
|
||||
// }
|
||||
// }
|
||||
|
||||
// // 任务
|
||||
// await checkTaskWithEquip(roleId, sid, TASK_TYPE.EQUIP_JEWEL, equip, [oldJewelCount]);
|
||||
// await checkTaskWithArgs(roleId, sid, TASK_TYPE.EQUIP_JEWEL_STAGE, [jewel, oldJewel]);
|
||||
// await checkTaskWithEquip(roleId, sid, TASK_TYPE.EQUIP_JEWEL_SUM, equip, [oldJewelCount]);
|
||||
// //成长任务
|
||||
// await checkActivityTask(serverId, sid, roleId, TASK_TYPE.EQUIP_JEWEL_SUM, 1)
|
||||
// await checkActivityTask(serverId, sid, roleId, TASK_TYPE.EQUIP_JEWEL_STAGE, 1, { stage: jewelInfo.lvLimited })
|
||||
|
||||
// return resResult(STATUS.SUCCESS, { curEquip: { seqId: eid, holes: equip.holes } });
|
||||
// }
|
||||
|
||||
// //宝石合成(一键放入type:1, 合成type:2)
|
||||
// public async composeJewel(msg: { jewel: number, count: number, consumes: Array<{ id: number, count: number }>, type: number }, session: BackendSession) {
|
||||
// let { count, consumes, jewel, type } = msg;
|
||||
// let roleId: string = session.get('roleId');
|
||||
// let roleName: string = session.get('roleName');
|
||||
// let serverId: number = session.get('serverId');
|
||||
// let sid: string = session.get('sid');
|
||||
// let goodInfo = getGoodById(jewel);
|
||||
// let good = ITID.get(goodInfo.itid);
|
||||
// if (good.type != CONSUME_TYPE.JEWEL)
|
||||
// return resResult(STATUS.WRONG_PARMS);
|
||||
// let needConsumes = checkMaterialEnough(consumes, jewel, count);//检查是否可以合成,并返回最终需要消耗的材料
|
||||
// if (!needConsumes)
|
||||
// return resResult(STATUS.WRONG_PARMS);
|
||||
// let res = await handleCost(roleId, sid, needConsumes, ITEM_CHANGE_REASON.JEWEL_COMPOSE);
|
||||
// if (!res)
|
||||
// return resResult(STATUS.BATTLE_CONSUMES_NOT_ENOUGH);
|
||||
// let result = await addItems(roleId, roleName, sid, [{ id: jewel, count: count }], ITEM_CHANGE_REASON.JEWEL_COMPOSE);
|
||||
|
||||
// if (goodInfo.lvLimited >= JEWEL_PUSH_LV) {
|
||||
// pushNormalItemMsg(roleId, roleName, serverId, MSG_SOURCE.JEWEL_COMPOSE, jewel, goodInfo.name);
|
||||
// }
|
||||
// if (type == 1)
|
||||
// return resResult(STATUS.SUCCESS, { goods: result });
|
||||
|
||||
// return resResult(STATUS.SUCCESS);
|
||||
// }
|
||||
|
||||
// //宝石卸下
|
||||
// public async putOffHole(msg: { eid: number, id: number }, session: BackendSession) {
|
||||
// let { eid, id } = msg;
|
||||
// let roleId: string = session.get('roleId');
|
||||
// let roleName: string = session.get('roleName');
|
||||
|
||||
// let sid: string = session.get('sid');
|
||||
// let goods: Array<{ id: number, count: number }> = [];
|
||||
// let equip = await EquipModel.getEquip(eid);
|
||||
// let oldJewelCount = equip.holes.filter(cur => cur.jewel > 0).length;
|
||||
// let index = findIndex(equip.holes, { id });
|
||||
// if (index < 0)
|
||||
// return resResult(STATUS.EQUIP_HOLE_NOT_FIND);
|
||||
// let jewel = equip.holes[index].jewel;
|
||||
// if (!jewel)
|
||||
// return resResult(STATUS.EQUIP_NOT_FILL_HOLE);
|
||||
// goods.push({ id: jewel, count: 1 });
|
||||
// equip.holes[index].jewel = 0;
|
||||
// await EquipModel.updateEquipInfo(eid, { holes: equip.holes });
|
||||
// await addItems(roleId, roleName, sid, goods, ITEM_CHANGE_REASON.TAKE_OUT_JEWEL);
|
||||
// if (!!equip.hid) {
|
||||
// let hero = await HeroModel.findByHidAndRole(equip.hid, roleId);
|
||||
// await calPlayerCeAndSave(HERO_SYSTEM_TYPE.JEWEL_OFF, sid, roleId, hero, {}, [jewel]);
|
||||
// }
|
||||
|
||||
// // 任务
|
||||
// await checkTaskWithEquip(roleId, sid, TASK_TYPE.EQUIP_JEWEL, equip, [oldJewelCount]);
|
||||
// await checkTaskWithArgs(roleId, sid, TASK_TYPE.EQUIP_JEWEL_STAGE, [0, jewel]);
|
||||
// await checkTaskWithEquip(roleId, sid, TASK_TYPE.EQUIP_JEWEL_SUM, equip, [oldJewelCount]);
|
||||
// return resResult(STATUS.SUCCESS, { curEquip: { seqId: eid, holes: equip.holes } });
|
||||
// }
|
||||
|
||||
// //宝石购买并合成
|
||||
// public async composeAndPurchaseJewel(msg: { jewel: number, count: number, consumes: Array<{ id: number, count: number }>, purchaseGoods: Array<{ id: number, count: number }> }, session: BackendSession) {
|
||||
// let { count, consumes, jewel, purchaseGoods } = msg;
|
||||
// let roleId: string = session.get('roleId');
|
||||
// let roleName: string = session.get('roleName');
|
||||
// let sid: string = session.get('sid');
|
||||
// const serverId = session.get('serverId');
|
||||
// let goodInfo = getGoodById(jewel);
|
||||
// let good = ITID.get(goodInfo.itid);
|
||||
// if (good.type != CONSUME_TYPE.JEWEL)
|
||||
// return resResult(STATUS.WRONG_PARMS);
|
||||
// if (!purchaseGoods) //需要购买才可进行合成的物品
|
||||
// purchaseGoods = [];
|
||||
// if (!consumes)
|
||||
// consumes = [];
|
||||
// let needConsumes = checkMaterialEnough(consumes.concat(purchaseGoods), jewel, count);//检查是否可以合成,并返回最终需要消耗的材料
|
||||
// if (!needConsumes)
|
||||
// return resResult(STATUS.WRONG_PARMS);
|
||||
// let items: ItemInter[] = [];
|
||||
// for (let item of purchaseGoods) {
|
||||
// items.push({ id: item.id, count: item.count })//加上购买的数量
|
||||
// }
|
||||
// items = items.concat(needConsumes);
|
||||
// let costResult = await handleCost(roleId, sid, items, ITEM_CHANGE_REASON.JEWEL_COMPOSE);//合并消耗是否足够
|
||||
// if (!costResult)
|
||||
// return resResult(STATUS.BATTLE_CONSUMES_NOT_ENOUGH);
|
||||
// await addItems(roleId, roleName, sid, [{ id: jewel, count: count }], ITEM_CHANGE_REASON.JEWEL_COMPOSE);
|
||||
// if (goodInfo.lvLimited >= JEWEL_PUSH_LV) {
|
||||
// pushNormalItemMsg(roleId, roleName, serverId, MSG_SOURCE.JEWEL_COMPOSE, jewel, goodInfo.name);
|
||||
// }
|
||||
// return resResult(STATUS.SUCCESS);
|
||||
// }
|
||||
// /**
|
||||
// * 临时使用的购买物品,后应该在商店中购买
|
||||
// * @param msg
|
||||
// * @param session
|
||||
// */
|
||||
// public async purchaseGoods(msg: { purchaseGoods: Array<{ id: number, count: number }> }, session: BackendSession) {
|
||||
// let { purchaseGoods } = msg;
|
||||
// let roleId: string = session.get('roleId');
|
||||
// let roleName: string = session.get('roleName');
|
||||
// let sid: string = session.get('sid');
|
||||
// let result = await addItems(roleId, roleName, sid, purchaseGoods, ITEM_CHANGE_REASON.DEBUG);
|
||||
// if (!result) {
|
||||
// return resResult(STATUS.BATTLE_CONSUMES_NOT_ENOUGH);
|
||||
// }
|
||||
// return resResult(STATUS.SUCCESS);
|
||||
// }
|
||||
// /**
|
||||
// * 合成下一级宝石并穿戴(装备镶嵌界面)
|
||||
// * @param msg
|
||||
// * @param session
|
||||
// */
|
||||
// public async composeNextLevelJewel(msg: { jewel: number, count: number, eid: number, id: number }, session: BackendSession) {
|
||||
// let { count, jewel, eid, id } = msg;
|
||||
// let roleId: string = session.get('roleId');
|
||||
// let roleName: string = session.get('roleName');
|
||||
// let sid: string = session.get('sid');
|
||||
// let serverId = session.get('serverId');
|
||||
|
||||
// let goodInfo = getGoodById(jewel);
|
||||
// let good = ITID.get(goodInfo.itid);
|
||||
// let needUpdate = false;
|
||||
// let oldJewel: number;
|
||||
// let consumes: Array<{ id: number, count: number }> = [];
|
||||
// if (good.type != CONSUME_TYPE.JEWEL || !eid || eid < 0)
|
||||
// return resResult(STATUS.WRONG_PARMS);
|
||||
// let equip = await EquipModel.getEquip(eid);
|
||||
// if (!equip) return resResult(STATUS.EQUIP_NOT_FIND);
|
||||
|
||||
// let oldJewelCount = equip.holes.filter(cur => cur.jewel > 0).length;
|
||||
|
||||
// let index = findIndex(equip.holes, { id });
|
||||
// //装备上该位置有穿戴该宝石,且在合成的材料中
|
||||
// if (!!equip.holes[index] && equip.holes[index].jewel == goodInfo.composeMaterial[0].id) {
|
||||
// oldJewel = equip.holes[index].jewel;
|
||||
// equip.holes[index].jewel = jewel;//合成后的新宝石穿戴到装备上
|
||||
// needUpdate = true;
|
||||
// consumes.push({ id: goodInfo.composeMaterial[0].id, count: 1 });//ratio:1表示可以释放掉一颗宝石
|
||||
// }
|
||||
|
||||
// consumes = consumes.concat(goodInfo.composeMaterial);
|
||||
// if (goodInfo.specialMaterial.count) {
|
||||
// consumes.push({ id: goodInfo.specialMaterial.ids[0], count: goodInfo.specialMaterial.count })
|
||||
// }
|
||||
// let costResult = await handleCost(roleId, sid, consumes, ITEM_CHANGE_REASON.JEWEL_COMPOSE);//检查是消耗是否足够
|
||||
// if (!costResult)
|
||||
// return resResult(STATUS.BATTLE_CONSUMES_NOT_ENOUGH);
|
||||
|
||||
// if (goodInfo.lvLimited >= JEWEL_PUSH_LV) {
|
||||
// pushNormalItemMsg(roleId, roleName, serverId, MSG_SOURCE.JEWEL_COMPOSE, jewel, goodInfo.name);
|
||||
// }
|
||||
|
||||
// let result = {};
|
||||
// if (needUpdate) {
|
||||
// //穿戴宝石
|
||||
// equip = await EquipModel.updateEquipInfo(eid, { holes: equip.holes });
|
||||
// if (!!equip.hid) {
|
||||
// let hero = await HeroModel.findByHidAndRoleWithEquip(equip.hid, roleId);
|
||||
// await calPlayerCeAndSave(HERO_SYSTEM_TYPE.JEWEL_ON, sid, roleId, hero, {}, [jewel, oldJewel]);
|
||||
|
||||
// //任务
|
||||
// //英雄满装备且都镶嵌相同阶数的宝石
|
||||
// let { isTask, jewelLevel } = await checkTaskConditionEquipSuitJewelStage(hero)
|
||||
// if (isTask) {
|
||||
// await checkActivityTask(serverId, sid, roleId, TASK_TYPE.EQUIP_SUIT_JEWEL_STAGE, 1, { stage: jewelLevel })
|
||||
// }
|
||||
// }
|
||||
|
||||
// // 任务
|
||||
// await checkTaskWithEquip(roleId, sid, TASK_TYPE.EQUIP_JEWEL, equip, [oldJewelCount]);
|
||||
// await checkTaskWithArgs(roleId, sid, TASK_TYPE.EQUIP_JEWEL_STAGE, [jewel, oldJewel]);
|
||||
// await checkTaskWithEquip(roleId, sid, TASK_TYPE.EQUIP_JEWEL_SUM, equip, [oldJewelCount]);
|
||||
// //成长任务
|
||||
// await checkActivityTask(serverId, sid, roleId, TASK_TYPE.EQUIP_JEWEL_SUM, count)
|
||||
|
||||
// return resResult(STATUS.SUCCESS, { curEquip: { seqId: eid, holes: equip.holes } });
|
||||
// } else {
|
||||
// result = await addItems(roleId, roleName, sid, [{ id: jewel, count: count }], ITEM_CHANGE_REASON.JEWEL_COMPOSE);
|
||||
// return resResult(STATUS.SUCCESS, { goods: [{ id: jewel, count }] });
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
// /**
|
||||
// * @description 藏宝图合成
|
||||
// * @param {{target: number, original: Array<{id: number, count: number}>}} msg
|
||||
// * @param {BackendSession} session
|
||||
// * @returns
|
||||
// * @memberof ComBattleHandler
|
||||
// */
|
||||
// async composeBlueprt(msg: { target: number, original: Array<{ id: number, count: number }> }, session: BackendSession) {
|
||||
// const roleId = session.get('roleId');
|
||||
// const roleName = session.get('roleName');
|
||||
// const sid = session.get('sid');
|
||||
// const serverId = session.get('serverId');
|
||||
|
||||
|
||||
// const { target, original } = msg;
|
||||
|
||||
// // 原材料检查
|
||||
// let originalQuality: number, originalSum: number = 0;
|
||||
// for (let { id, count } of original) {
|
||||
// const goodInfo = gameData.goods.get(id);
|
||||
// if (!originalQuality) originalQuality = goodInfo.quality;
|
||||
// if (originalQuality != goodInfo.quality) {
|
||||
// return resResult(STATUS.COM_BLUEPRT_QUALITY_ERROR);
|
||||
// }
|
||||
|
||||
// if (goodInfo.itid == IT_TYPE.BLUEPRT) {
|
||||
// originalSum += count;
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
// const dicCompose = gameData.blurprtCompose.get(originalQuality);
|
||||
// if (!dicCompose) {
|
||||
// return resResult(STATUS.COM_BLUEPRT_QUALITY_CANNOT_COMPOSE);
|
||||
// }
|
||||
// if (originalSum != dicCompose.blueprtNum) {
|
||||
// return resResult(STATUS.COM_BLUEPRT_COUNT_ERROR);
|
||||
// }
|
||||
|
||||
// let dicTargetInfo = gameData.goods.get(target);
|
||||
// if (!dicTargetInfo) return resResult(STATUS.WRONG_PARMS);
|
||||
// if (dicTargetInfo.quality != dicCompose.targetQuality) return resResult(STATUS.COM_BLUEPRT_QUALITY_ERROR);
|
||||
|
||||
// // 消耗藏宝图和寻宝币
|
||||
|
||||
// let costResult = await handleCost(roleId, sid, [...original, ...dicCompose.coinNum], ITEM_CHANGE_REASON.BLUEPRT_COMPOSE);
|
||||
// if (!costResult) return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
|
||||
|
||||
// const reward = [{ id: target, count: 1 }];
|
||||
// const goods = await addItems(roleId, roleName, sid, reward, ITEM_CHANGE_REASON.BLUEPRT_COMPOSE);
|
||||
// if (dicCompose.targetQuality >= QUALITY_TYPE.ORANGE) {
|
||||
// const { name } = gameData.goods.get(target);
|
||||
// pushNormalItemMsg(roleId, roleName, serverId, MSG_SOURCE.ORANGE_BLUEPRT_COMPOSE, target, name);
|
||||
// }
|
||||
// await checkTask(roleId, sid, TASK_TYPE.COM_BATTLE_BLUEPRT, 1, true, { quality: dicCompose.targetQuality });
|
||||
// await checkActivityTask(serverId, sid, roleId, TASK_TYPE.COM_BATTLE_BLUEPRT, 1, { quality: dicCompose.targetQuality })
|
||||
// return resResult(STATUS.SUCCESS, { goods, costGold: 0 });
|
||||
// }
|
||||
}
|
||||
Reference in New Issue
Block a user