宝石类型

This commit is contained in:
mamengke01
2020-12-18 18:30:19 +08:00
parent 009537d1c7
commit f01ef54240
5 changed files with 30 additions and 15 deletions
@@ -7,7 +7,7 @@ import { EquipModel, RandSe } from "../../../db/Equip";
import { HeroModel, EPlace } from "../../../db/Hero";
import Role from "../../../db/Role";
import { calPlayerCeAndSave } from "../../../services/playerCeService";
import { getGoodById, gameData } from "../../../pubUtils/data";
import { getGoodById, gameData, getJewelById } from "../../../pubUtils/data";
import { EQUIP } from "../../../pubUtils/dicParam";
import { ITID } from "../../../consts/constModules/itemConst";
@@ -430,9 +430,18 @@ export class EquipHandler {
if (!goodInfo.composeMaterial)
return resResult(STATUS.WRONG_PARMS);
//检查宝石消耗是否合法TODO
let comJewelMap = {};
for (let {id, count} of goodInfo.composeMaterial) {
let jewel = getJewelById(id);
if (!jewel) {
return resResult(STATUS.WRONG_PARMS);
}
count = (jewel.count + (comJewelMap[jewel.good_id]||0))/count;
delete comJewelMap[jewel.good_id];
comJewelMap[jewel.nextJewelId] = count + (comJewelMap[jewel.nextJewelId]||0);
}
if (comJewelMap[jewel] != count || Object.keys(comJewelMap).length != 1)
return resResult(STATUS.WRONG_PARMS);
let res = await handleCost(roleId, sid, consumes);
if (!res)
return resResult(STATUS.BATTLE_CONSUMES_NOT_ENOUGH);