装备
This commit is contained in:
37
game-server/app/services/equipService.ts
Normal file
37
game-server/app/services/equipService.ts
Normal file
@@ -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;
|
||||
}
|
||||
Reference in New Issue
Block a user