feat(玉石一键合成): 新增玉石一键合成

This commit is contained in:
zhangxk
2023-07-13 19:31:41 +08:00
committed by luying
parent 9c10f33401
commit fc440afe83
7 changed files with 237 additions and 9 deletions

View File

@@ -1,5 +1,5 @@
import { Application, BackendSession, HandlerService, } from "pinus";
import { STATUS, HERO_SYSTEM_TYPE, ITEM_CHANGE_REASON, TASK_TYPE } from "../../../consts";
import { STATUS, HERO_SYSTEM_TYPE, ITEM_CHANGE_REASON, TASK_TYPE, CONSUME_TYPE } from "../../../consts";
import { ItemInter, RewardInter } from "../../../pubUtils/interface";
import { resResult, parseGoodStr } from "../../../pubUtils/util";
@@ -9,14 +9,17 @@ import { gameData, getEquipByJobClassAndEPlace, getNextEquipQuality, getEquipSta
import { BAG, EQUIP } from "../../../pubUtils/dicParam";
import { getRandSeResult, updateEplace, updateEplaces, checkJewelCanPutOnEquip, updateStone, checkStoneCanPutOnEquip, isLocked } from "../../../services/equipService";
import { isNumber, pick } from 'underscore';
import { clone, isNumber, max, min, pick } from 'underscore';
import { JewelModel, RandSe } from "../../../db/Jewel";
import { checkTaskInComposeEquip, checkTaskInEquipLvUp, checkTaskInComposeStone, checkTaskInEquipReset, checkTaskInEquipQuench, checkTaskInEquipQualityUp, checkTaskInEquipStarUp, checkTaskInPutJewel, checkTaskInPutStone } from '../../../services/task/taskService';
import { pushEquipQualityMax, pushEquipStarMax } from "../../../services/sysChatService";
import { addConsumeToHero } from "../../../services/roleService";
import { CheckMeterial } from "../../../services/role/checkMaterial";
import { CheckMeterial, getComposeStoneCostAndAdd, getCurItem } from "../../../services/role/checkMaterial";
import { combineItems } from "../../../services/role/util";
import { calculateCeWithHero } from "../../../services/playerCeService";
import { ItemModel } from "../../../db/Item";
import { index } from "typegoose";
import { all } from "bluebird";
export default function (app: Application) {
new HandlerService(app, {});
@@ -735,6 +738,43 @@ export class EquipHandler {
return resResult(STATUS.SUCCESS, { goods });
}
public async composeStoneByItId(msg: { itId: number }, session: BackendSession) {
let { itId } = msg;
let roleId: string = session.get('roleId');
let roleName: string = session.get('roleName');
let sid: string = session.get('sid');
let serverId: number = session.get('serverId');
let curItem = await getCurItem(roleId, itId);
if (curItem.size == 0) {
// console.log("---composeStoneByItId-- curItem=%s", curItem);
return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
}
let { allCostItem, allAddItem } = await getComposeStoneCostAndAdd(curItem, itId)
if (allCostItem.size == 0 || allAddItem.size == 0) {
// console.log("---composeStoneByItId-- allCostItem=%s, allAddItem=%s", allCostItem, allAddItem);
return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
}
let costResult = await handleCost(roleId, sid, [...allCostItem].map(([id, count]) => ({ id, count })), ITEM_CHANGE_REASON.COMPOSE_STONE);
if (!costResult) return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
let arrAddItem = [];
let total = 0;
for (const [id, count] of allAddItem) {
if (count == 0) continue;
arrAddItem.push({ id, count });
total += count;
}
let goods = await addItems(roleId, roleName, sid, arrAddItem, ITEM_CHANGE_REASON.COMPOSE_STONE);
await checkTaskInComposeStone(serverId, roleId, sid, total);
return resResult(STATUS.SUCCESS, { goods });
}
public async inheritJewel(msg: { originJewel: number, targetJewel: number }, session: BackendSession) {
let { originJewel: originJewelId, targetJewel: targetJewelId } = msg;
let roleId: string = session.get('roleId');