装备:镶嵌或卸载地玉石

This commit is contained in:
luying
2022-02-16 18:11:47 +08:00
parent e0bf64a35e
commit 925468ae64
5 changed files with 103 additions and 2 deletions

View File

@@ -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 } from "../../../services/equipService";
import { checkMaterialEnough, 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";
@@ -351,7 +351,47 @@ export class EquipHandler {
return resResult(STATUS.SUCCESS, { curHero, curJewel });
}
// 装备或卸载地玉石
public async putOnOrOffStone(msg: { hid: number, eplaceId: number, stonesId: number, gid: number }, session: BackendSession) {
let { hid, eplaceId, stonesId, gid } = msg;
let roleId: string = session.get('roleId');
let roleName: string = session.get('roleName');
let sid: string = session.get('sid');
let hero = await HeroModel.findByHidAndRole(hid, roleId);
if (!hero) return resResult(STATUS.HERO_NOT_FIND);
let curEquip = hero.ePlace?.find(cur => cur.id == eplaceId);
if(!curEquip) return resResult(STATUS.EQUIP_NOT_FIND);
let curStone = curEquip.stones?.find(cur => cur.id == stonesId)||{ id: stonesId, stone: 0 };
if(curStone.stone == gid) {
return resResult(gid == 0? STATUS.STONE_NOT_SUIT: STATUS.STONE_HAS_SUIT);
}
if(!checkStoneCanPutOnEquip(curEquip, stonesId, gid)) { // 是否可以镶嵌
return resResult(STATUS.STONE_CANNOT_SUIT);
}
let consumeResult = await handleCost(roleId, sid, [{ id: gid, count: 1 }], ITEM_CHANGE_REASON.EQUIP_FILL_HOLE);
if (!consumeResult) return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
if(curStone.stone > 0) { // 返回石头
await addItems(roleId, roleName, sid, [{ id: curStone.stone, count: 1 }], ITEM_CHANGE_REASON.EQUIP_FILL_HOLE);
}
let newStone = updateStone(curEquip.stones, stonesId, gid);
let { newEplace, updatedEplace } = updateEplace(hero.ePlace, eplaceId, { stones: newStone });
await calPlayerCeAndSave(HERO_SYSTEM_TYPE.EQUIP_STONE, sid, roleId, hero, { ePlace: newEplace }, [eplaceId]);
let curHero = {
hid,
eplace: updatedEplace
}
return resResult(STATUS.SUCCESS, { curHero });
}
// // 装备洗炼锁定
// public async lockRandSe(msg: { eid: number, id: number, lock: boolean }, session: BackendSession) {
// let roleId: string = session.get('roleId');