From 5a2a01218a09f4dbbfc924b8f2f7decb5d8e0e85 Mon Sep 17 00:00:00 2001 From: mamengke01 <794347210@qq.com> Date: Wed, 23 Dec 2020 14:49:46 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A3=85=E5=A4=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- game-server/app/services/equipService.ts | 37 ++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 game-server/app/services/equipService.ts diff --git a/game-server/app/services/equipService.ts b/game-server/app/services/equipService.ts new file mode 100644 index 000000000..39ef07c34 --- /dev/null +++ b/game-server/app/services/equipService.ts @@ -0,0 +1,37 @@ +import { ITID, CONSUME_TYPE, getCurNameById, ITEM_TABLE } from './../consts'; +import { EquipModel } from './../db/Equip'; +import { resResult, deepCopy, mergeSameGoods } from '../pubUtils/util'; +import { getGoodById } from '../pubUtils/gamedata'; +import { RoleModel } from '../db/Role'; +importĀ { setAp } from './actionPointService'; +import { calAllHeroCe } from './playerCeService'; +import { ItemModel } from '../db/Item'; +import { STATUS } from '../consts/statusCode'; +import { pinus } from 'pinus'; +import { addEquips, addBags, addSkins } from '../pubUtils/itemUtils'; +import { EquipInter, ItemInter, BagInter } from '../pubUtils/interface'; +import { gameData, getJewelById } from '../pubUtils/data'; +const _ = require('underscore'); + +export function checkMaterialEnough(consumes:Array<{id: number, count: number}>, jewel: number, jewelCount: number) { + consumes = mergeSameGoods(consumes); + let comJewelMap = {}; + let needConsumes: Array<{id: number, count: number}> = []; + for (let { id, count } of consumes) { + let jewelInfo = getJewelById(id); + if (!jewelInfo) + continue; + let comcount = Math.floor((count + (comJewelMap[jewelInfo.good_id] || 0)) / jewelInfo.count); + if (comcount < 1) { + return false; + } + needConsumes.push({ id, count }); + if (!!jewelInfo.specialMaterial.ids.length) + needConsumes.push({ id: jewelInfo.specialMaterial.ids[0], count: jewelInfo.specialMaterial.count}); + delete comJewelMap[jewelInfo.good_id]; + comJewelMap[jewelInfo.nextJewelId] = comcount + (comJewelMap[jewelInfo.nextJewelId] || 0); + } + if (comJewelMap[jewel] != jewelCount || Object.keys(comJewelMap).length != 1) + return false; + return needConsumes; +}