🎈 perf(clear): 格式化
This commit is contained in:
@@ -34,21 +34,21 @@ export class EquipHandler {
|
||||
let serverId: number = session.get('serverId');
|
||||
|
||||
let { hid, ePlaceId } = msg;
|
||||
if(!isNumber(ePlaceId) || ePlaceId > 4 || ePlaceId < 1) return resResult(STATUS.WRONG_PARMS);
|
||||
if (!isNumber(ePlaceId) || ePlaceId > 4 || ePlaceId < 1) return resResult(STATUS.WRONG_PARMS);
|
||||
|
||||
let hero = await HeroModel.findByHidAndRole(hid, roleId);
|
||||
if(!hero) return resResult(STATUS.HERO_NOT_FIND);
|
||||
|
||||
let oldEplace = hero.ePlace||[];
|
||||
let curEquip = oldEplace.find(equip => equip.id == ePlaceId );
|
||||
if(curEquip) return resResult(STATUS.EQUIP_HAS_COMPOSE);
|
||||
if (!hero) return resResult(STATUS.HERO_NOT_FIND);
|
||||
|
||||
let oldEplace = hero.ePlace || [];
|
||||
let curEquip = oldEplace.find(equip => equip.id == ePlaceId);
|
||||
if (curEquip) return resResult(STATUS.EQUIP_HAS_COMPOSE);
|
||||
|
||||
let dicHero = gameData.hero.get(hero.skinId);
|
||||
let dicEquip = getEquipByJobClassAndEPlace(dicHero?.jobClass, ePlaceId);
|
||||
if(!dicEquip) return resResult(STATUS.DIC_DATA_NOT_FOUND);
|
||||
if (!dicEquip) return resResult(STATUS.DIC_DATA_NOT_FOUND);
|
||||
|
||||
let consumeResult = await handleCost(roleId, sid, dicEquip.composeMaterial, ITEM_CHANGE_REASON.EQUIP_COMPOSE);
|
||||
if(!consumeResult) return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
|
||||
if (!consumeResult) return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
|
||||
|
||||
let newEquip = new EPlace(ePlaceId, dicEquip.id);
|
||||
let newEplace = [...oldEplace, newEquip];
|
||||
@@ -67,34 +67,34 @@ export class EquipHandler {
|
||||
}
|
||||
return resResult(STATUS.SUCCESS, { curHero });
|
||||
}
|
||||
|
||||
|
||||
// 装备栏强化
|
||||
public async strengthen(msg: { hid: number, ePlaceId: number, isOneClick: boolean }, session: BackendSession) {
|
||||
let roleId: string = session.get('roleId');
|
||||
// let roleName: string = session.get('roleName');
|
||||
const serverId = session.get('serverId');
|
||||
let sid: string = session.get('sid');
|
||||
|
||||
|
||||
|
||||
let { hid, ePlaceId, isOneClick } = msg;
|
||||
let hero = await HeroModel.findByHidAndRole(hid, roleId);
|
||||
if (!hero) return resResult(STATUS.HERO_NOT_FIND);
|
||||
let oldEplace = hero.ePlace||[];
|
||||
let oldEplace = hero.ePlace || [];
|
||||
let curEquip = oldEplace.find(cur => cur.id == ePlaceId);
|
||||
if(!curEquip) return resResult(STATUS.EQUIP_NOT_FIND);
|
||||
if(curEquip.lv >= hero.lv) return resResult(STATUS.ROLE_EQUIP_REACH_MAX);
|
||||
if (!curEquip) return resResult(STATUS.EQUIP_NOT_FIND);
|
||||
if (curEquip.lv >= hero.lv) return resResult(STATUS.ROLE_EQUIP_REACH_MAX);
|
||||
let fromLv = curEquip.lv;
|
||||
let toLv = isOneClick? hero.lv: fromLv + 1;
|
||||
let toLv = isOneClick ? hero.lv : fromLv + 1;
|
||||
let newLv = fromLv;
|
||||
|
||||
let check = new CheckMeterial(roleId);
|
||||
for (let lv = fromLv + 1; lv <= toLv; lv++) {
|
||||
let dicCost = gameData.equipStrengthenCost.get(lv);
|
||||
let isEnough = await check.decrease(dicCost.consume);
|
||||
if(!isEnough) break; // 消耗不足
|
||||
if (!isEnough) break; // 消耗不足
|
||||
newLv = lv;
|
||||
}
|
||||
if(newLv == fromLv) return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
|
||||
if (newLv == fromLv) return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
|
||||
let consumes = check.getConsume();
|
||||
let result = await handleCost(roleId, sid, consumes, ITEM_CHANGE_REASON.EQUIP_STRENTHEN);
|
||||
if (!result) return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
|
||||
@@ -128,24 +128,24 @@ export class EquipHandler {
|
||||
|
||||
let { ePlace, lv: playerLv } = hero; // 装备栏
|
||||
let fromLv = Math.min(...ePlace.map(cur => cur.lv)); // 最小的等级
|
||||
let toLv = lv < playerLv? lv: playerLv;
|
||||
let toLv = lv < playerLv ? lv : playerLv;
|
||||
|
||||
let eplaceIds = new Map<number, { lv: number }>(); // 更新了的装备栏id
|
||||
let check = new CheckMeterial(roleId);
|
||||
for(let lv = fromLv + 1; lv <= toLv; lv++) {
|
||||
for (let lv = fromLv + 1; lv <= toLv; lv++) {
|
||||
let isBreak = false;
|
||||
for(let equip of ePlace) {
|
||||
if(equip.lv >= lv) continue;
|
||||
for (let equip of ePlace) {
|
||||
if (equip.lv >= lv) continue;
|
||||
let dicCost = gameData.equipStrengthenCost.get(lv);
|
||||
let isEnough = await check.decrease(dicCost.consume);
|
||||
if(!isEnough) { isBreak = true; break; } // 消耗不足
|
||||
if (!isEnough) { isBreak = true; break; } // 消耗不足
|
||||
|
||||
eplaceIds.set(equip.id, { lv });
|
||||
}
|
||||
if(isBreak) break;
|
||||
if (isBreak) break;
|
||||
}
|
||||
|
||||
if(eplaceIds.size <= 0) return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
|
||||
if (eplaceIds.size <= 0) return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
|
||||
let consumes = check.getConsume();
|
||||
let result = await handleCost(roleId, sid, consumes, ITEM_CHANGE_REASON.EQUIP_STRENTHEN);
|
||||
if (!result) return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
|
||||
@@ -174,17 +174,17 @@ export class EquipHandler {
|
||||
let roleName: string = session.get('roleName');
|
||||
const serverId = session.get('serverId');
|
||||
let sid: string = session.get('sid');
|
||||
|
||||
|
||||
let { hid, ePlaceId, isOneClick } = msg;
|
||||
let hero = await HeroModel.findByHidAndRole(hid, roleId);
|
||||
if (!hero) return resResult(STATUS.HERO_NOT_FIND);
|
||||
|
||||
let oldEplace = hero.ePlace||[];
|
||||
let oldEplace = hero.ePlace || [];
|
||||
let curEquip = oldEplace.find(cur => cur.id == ePlaceId);
|
||||
if(!curEquip) return resResult(STATUS.EQUIP_NOT_FIND);
|
||||
|
||||
if (!curEquip) return resResult(STATUS.EQUIP_NOT_FIND);
|
||||
|
||||
let nextEquipQuality = getNextEquipQuality(curEquip.equipId, curEquip.quality, curEquip.qualityStage);
|
||||
if(!nextEquipQuality) return resResult(STATUS.EQUIP_QUALITY_MAX);
|
||||
if (!nextEquipQuality) return resResult(STATUS.EQUIP_QUALITY_MAX);
|
||||
|
||||
let equipUpdate = {
|
||||
quality: curEquip.quality,
|
||||
@@ -192,26 +192,26 @@ export class EquipHandler {
|
||||
}
|
||||
let check = new CheckMeterial(roleId);
|
||||
let count = 0;
|
||||
if(isOneClick) { // 一键升到该品最高点
|
||||
if(nextEquipQuality.quality != curEquip.quality) {
|
||||
if (isOneClick) { // 一键升到该品最高点
|
||||
if (nextEquipQuality.quality != curEquip.quality) {
|
||||
return resResult(STATUS.EQUIP_QUALITYSTAGE_IS_MAX);
|
||||
}
|
||||
while(nextEquipQuality && nextEquipQuality.quality == curEquip.quality) {
|
||||
while (nextEquipQuality && nextEquipQuality.quality == curEquip.quality) {
|
||||
let isEnough = await check.decrease(nextEquipQuality.consume);
|
||||
if(!isEnough) break; // 消耗不足
|
||||
if (!isEnough) break; // 消耗不足
|
||||
equipUpdate.qualityStage++;
|
||||
nextEquipQuality = getNextEquipQuality(curEquip.equipId, equipUpdate.quality, equipUpdate.qualityStage);
|
||||
count++;
|
||||
}
|
||||
} else { // 往下一阶,包括满点之后的升品
|
||||
let isEnough = await check.decrease(nextEquipQuality.consume);
|
||||
if(isEnough) {
|
||||
if (isEnough) {
|
||||
equipUpdate.quality = nextEquipQuality.quality;
|
||||
equipUpdate.qualityStage = nextEquipQuality.point;
|
||||
count++;
|
||||
}
|
||||
}
|
||||
if(equipUpdate.quality == curEquip.quality && equipUpdate.qualityStage == curEquip.qualityStage) {
|
||||
if (equipUpdate.quality == curEquip.quality && equipUpdate.qualityStage == curEquip.qualityStage) {
|
||||
return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
|
||||
}
|
||||
let consumes = check.getConsume();
|
||||
@@ -221,7 +221,7 @@ export class EquipHandler {
|
||||
let isUpQuality = equipUpdate.quality != curEquip.quality;
|
||||
|
||||
let { newEplace, updatedEplace, newEquip } = updateEplace(oldEplace, ePlaceId, equipUpdate);
|
||||
|
||||
|
||||
let update = {
|
||||
ePlace: newEplace,
|
||||
consumes: addConsumeToHero(hero.consumes, consumes),
|
||||
@@ -245,14 +245,14 @@ export class EquipHandler {
|
||||
let roleName: string = session.get('roleName');
|
||||
const serverId = session.get('serverId');
|
||||
let sid: string = session.get('sid');
|
||||
|
||||
|
||||
let { hid, ePlaceId, isOneClick } = msg;
|
||||
let hero = await HeroModel.findByHidAndRole(hid, roleId);
|
||||
if (!hero) return resResult(STATUS.HERO_NOT_FIND);
|
||||
|
||||
let oldEplace = hero.ePlace||[];
|
||||
let oldEplace = hero.ePlace || [];
|
||||
let curEquip = oldEplace.find(cur => cur.id == ePlaceId);
|
||||
if(!curEquip) return resResult(STATUS.EQUIP_NOT_FIND);
|
||||
if (!curEquip) return resResult(STATUS.EQUIP_NOT_FIND);
|
||||
let incEquipStarSum = 0;
|
||||
let equipUpdate = {
|
||||
star: curEquip.star,
|
||||
@@ -261,23 +261,23 @@ export class EquipHandler {
|
||||
|
||||
let check = new CheckMeterial(roleId);
|
||||
let dicEquipStar = getEquipStarIdByEquipId(curEquip.equipId, curEquip.star);
|
||||
if(!dicEquipStar) return resResult(STATUS.DIC_DATA_NOT_FOUND);
|
||||
if (!dicEquipStar) return resResult(STATUS.DIC_DATA_NOT_FOUND);
|
||||
let isUpStar = curEquip.starStage == dicEquipStar.count;
|
||||
let count = 0;
|
||||
|
||||
if(isUpStar) { // 升星
|
||||
if(isOneClick) {
|
||||
if (isUpStar) { // 升星
|
||||
if (isOneClick) {
|
||||
return resResult(STATUS.EQUIP_STARSTAGE_IS_MAX);
|
||||
} else {
|
||||
let nextEquipStar = getNextEquipStar(curEquip.equipId, curEquip.star);
|
||||
if(!nextEquipStar) return resResult(STATUS.EQUIP_STAR_MAX);
|
||||
if (!nextEquipStar) return resResult(STATUS.EQUIP_STAR_MAX);
|
||||
let dicEquipQualityExtra = gameData.equipQualityExtra.get(curEquip.quality);
|
||||
if(!dicEquipQualityExtra || dicEquipQualityExtra.star < nextEquipStar.star) {
|
||||
if (!dicEquipQualityExtra || dicEquipQualityExtra.star < nextEquipStar.star) {
|
||||
return resResult(STATUS.EQUIP_QUALITY_NOT_ENOUGH);
|
||||
}
|
||||
|
||||
|
||||
let isEnough = await check.decrease(dicEquipStar.subConsume);
|
||||
if(isEnough) {
|
||||
if (isEnough) {
|
||||
equipUpdate.star = nextEquipStar.star;
|
||||
equipUpdate.starStage = 0;
|
||||
incEquipStarSum += equipUpdate.star - curEquip.star;
|
||||
@@ -285,16 +285,16 @@ export class EquipHandler {
|
||||
}
|
||||
}
|
||||
} else { // 升小点,包括一键升到满小点和升一个小点
|
||||
let toStage = isOneClick? dicEquipStar.count: curEquip.starStage + 1;
|
||||
for(let stage = curEquip.starStage + 1; stage <= toStage; stage++) {
|
||||
let toStage = isOneClick ? dicEquipStar.count : curEquip.starStage + 1;
|
||||
for (let stage = curEquip.starStage + 1; stage <= toStage; stage++) {
|
||||
let isEnough = await check.decrease(dicEquipStar.mainConsume);
|
||||
if(!isEnough) break; // 消耗不足
|
||||
if (!isEnough) break; // 消耗不足
|
||||
equipUpdate.starStage = stage;
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
if(equipUpdate.star == curEquip.star && equipUpdate.starStage == curEquip.starStage) {
|
||||
if (equipUpdate.star == curEquip.star && equipUpdate.starStage == curEquip.starStage) {
|
||||
return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
|
||||
}
|
||||
let consumes = check.getConsume();
|
||||
@@ -328,39 +328,39 @@ export class EquipHandler {
|
||||
let roleId: string = session.get('roleId');
|
||||
let sid: string = session.get('sid');
|
||||
let serverId: number = session.get('serverId');
|
||||
|
||||
|
||||
let hero = await HeroModel.findByHidAndRole(hid, roleId);
|
||||
if (!hero) return resResult(STATUS.HERO_NOT_FIND);
|
||||
|
||||
let oldEplace = hero.ePlace||[];
|
||||
let oldEplace = hero.ePlace || [];
|
||||
let curEquip = oldEplace.find(cur => cur.id == ePlaceId);
|
||||
if(!curEquip) return resResult(STATUS.EQUIP_NOT_FIND);
|
||||
if (!curEquip) return resResult(STATUS.EQUIP_NOT_FIND);
|
||||
let jewel = await JewelModel.findbySeqId(seqId);
|
||||
if(!jewel) return resResult(STATUS.JEWEL_IS_NOT_FIND);
|
||||
if(curEquip.jewel == seqId) return resResult(STATUS.JEWEL_HAS_SUIT);
|
||||
if(!checkJewelCanPutOnEquip(curEquip, jewel)) {
|
||||
if (!jewel) return resResult(STATUS.JEWEL_IS_NOT_FIND);
|
||||
if (curEquip.jewel == seqId) return resResult(STATUS.JEWEL_HAS_SUIT);
|
||||
if (!checkJewelCanPutOnEquip(curEquip, jewel)) {
|
||||
return resResult(STATUS.EQUIP_NOT_MATCH_JEWEL)
|
||||
}
|
||||
|
||||
let originHeroResult: { hid: number, ePlace: Partial<EPlace>[] };
|
||||
let originJewel = curEquip.jewel? await JewelModel.findbySeqId(curEquip.jewel): null; // 原本自己的天晶石
|
||||
let originJewel = curEquip.jewel ? await JewelModel.findbySeqId(curEquip.jewel) : null; // 原本自己的天晶石
|
||||
let canSentMineToOrigin = false; // 自己的能不能塞到对方身上
|
||||
if(jewel.hid != 0) { // 如果天晶石原本镶嵌在其他武将身上,把自己的给他
|
||||
if (jewel.hid != 0) { // 如果天晶石原本镶嵌在其他武将身上,把自己的给他
|
||||
let originHero = await HeroModel.findByHidAndRole(jewel.hid, roleId);
|
||||
let originEplace = originHero?.ePlace||[];
|
||||
let originEplace = originHero?.ePlace || [];
|
||||
let originEquip = originEplace.find(cur => cur.jewel == seqId);
|
||||
if(originEquip) {
|
||||
if (originEquip) {
|
||||
let canChange = originJewel && checkJewelCanPutOnEquip(originEquip, originJewel);
|
||||
if(canChange) canSentMineToOrigin = true;
|
||||
let { newEplace, updatedEplace } = updateEplace(originEplace, ePlaceId, { jewel: canChange? originJewel.seqId: 0 });
|
||||
await calculateCeWithHero(HERO_SYSTEM_TYPE.EQUIP_JEWEL, roleId, serverId, sid, jewel.hid, { ePlace: newEplace }, { ePlaceId, jewel: canChange? originJewel: null, skinId: originHero.skinId });
|
||||
await checkTaskInPutJewel(serverId, roleId, sid, jewel.hid, originEplace, newEplace, ePlaceId, jewel, canChange? originJewel:null);
|
||||
if (canChange) canSentMineToOrigin = true;
|
||||
let { newEplace, updatedEplace } = updateEplace(originEplace, ePlaceId, { jewel: canChange ? originJewel.seqId : 0 });
|
||||
await calculateCeWithHero(HERO_SYSTEM_TYPE.EQUIP_JEWEL, roleId, serverId, sid, jewel.hid, { ePlace: newEplace }, { ePlaceId, jewel: canChange ? originJewel : null, skinId: originHero.skinId });
|
||||
await checkTaskInPutJewel(serverId, roleId, sid, jewel.hid, originEplace, newEplace, ePlaceId, jewel, canChange ? originJewel : null);
|
||||
|
||||
originHeroResult = { hid: originHero.hid, ePlace: updatedEplace };
|
||||
originHeroResult = { hid: originHero.hid, ePlace: updatedEplace };
|
||||
}
|
||||
}
|
||||
if(originJewel) { // 更新自己的天晶石
|
||||
originJewel = await JewelModel.putOnOrOff(originJewel.seqId, canSentMineToOrigin? jewel.hid: 0, canSentMineToOrigin? ePlaceId: 0);
|
||||
if (originJewel) { // 更新自己的天晶石
|
||||
originJewel = await JewelModel.putOnOrOff(originJewel.seqId, canSentMineToOrigin ? jewel.hid : 0, canSentMineToOrigin ? ePlaceId : 0);
|
||||
}
|
||||
|
||||
// 目标镶嵌上
|
||||
@@ -383,14 +383,14 @@ export class EquipHandler {
|
||||
let roleId: string = session.get('roleId');
|
||||
let sid: string = session.get('sid');
|
||||
let serverId: number = session.get('serverId');
|
||||
|
||||
|
||||
let hero = await HeroModel.findByHidAndRole(hid, roleId);
|
||||
if (!hero) return resResult(STATUS.HERO_NOT_FIND);
|
||||
|
||||
let oldEplace = hero.ePlace||[];
|
||||
let oldEplace = hero.ePlace || [];
|
||||
let curEquip = oldEplace.find(cur => cur.id == ePlaceId);
|
||||
if(!curEquip) return resResult(STATUS.EQUIP_NOT_FIND);
|
||||
if(curEquip.jewel == 0) return resResult(STATUS.JEWEL_NOT_SUIT);
|
||||
if (!curEquip) return resResult(STATUS.EQUIP_NOT_FIND);
|
||||
if (curEquip.jewel == 0) return resResult(STATUS.JEWEL_NOT_SUIT);
|
||||
|
||||
let curJewel = await JewelModel.putOnOrOff(curEquip.jewel, 0, 0);
|
||||
let { newEplace, updatedEplace } = updateEplace(oldEplace, ePlaceId, { jewel: 0 });
|
||||
@@ -416,26 +416,26 @@ export class EquipHandler {
|
||||
let hero = await HeroModel.findByHidAndRole(hid, roleId);
|
||||
if (!hero) return resResult(STATUS.HERO_NOT_FIND);
|
||||
|
||||
let oldEplace = hero.ePlace||[];
|
||||
let oldEplace = hero.ePlace || [];
|
||||
let curEquip = oldEplace.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 (!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)) { // 是否可以镶嵌
|
||||
if (!checkStoneCanPutOnEquip(curEquip, stonesId, gid)) { // 是否可以镶嵌
|
||||
return resResult(STATUS.STONE_CANNOT_SUIT);
|
||||
}
|
||||
|
||||
let updateConsumes = hero.consumes;
|
||||
if(gid > 0) {
|
||||
if (gid > 0) {
|
||||
updateConsumes = addConsumeToHero(updateConsumes, [{ id: gid, count: 1 }]);
|
||||
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) { // 返回石头
|
||||
if (curStone.stone > 0) { // 返回石头
|
||||
updateConsumes = addConsumeToHero(updateConsumes, [{ id: curStone.stone, count: -1 }]);
|
||||
await addItems(roleId, roleName, sid, [{ id: curStone.stone, count: 1 }], ITEM_CHANGE_REASON.EQUIP_FILL_HOLE);
|
||||
}
|
||||
@@ -466,7 +466,7 @@ export class EquipHandler {
|
||||
let sid: string = session.get('sid');
|
||||
|
||||
let jewel = await JewelModel.findbySeqId(seqId);
|
||||
if(!jewel) return resResult(STATUS.JEWEL_NOT_FOUND);
|
||||
if (!jewel) return resResult(STATUS.JEWEL_NOT_FOUND);
|
||||
|
||||
let { randSe } = jewel;
|
||||
if (!randSe || randSe.length <= 0) {
|
||||
@@ -510,16 +510,16 @@ export class EquipHandler {
|
||||
|
||||
let { seqId } = msg;
|
||||
let jewel = await JewelModel.findbySeqId(seqId);
|
||||
if(!jewel) return resResult(STATUS.JEWEL_NOT_FOUND);
|
||||
if (!jewel) return resResult(STATUS.JEWEL_NOT_FOUND);
|
||||
|
||||
let { id, randSe, previewRandSe } = jewel;
|
||||
if(previewRandSe.length <= 0) {
|
||||
if (previewRandSe.length <= 0) {
|
||||
|
||||
let previewRandSe = getRandSeResult(id, randSe);
|
||||
if(!previewRandSe) return resResult(STATUS.DIC_DATA_NOT_FOUND);
|
||||
if (!previewRandSe) return resResult(STATUS.DIC_DATA_NOT_FOUND);
|
||||
|
||||
let lockNum = randSe.reduce((pre, cur) => {
|
||||
return cur.locked? pre + 1: pre;
|
||||
return cur.locked ? pre + 1 : pre;
|
||||
}, 0);
|
||||
|
||||
if (lockNum >= randSe.length) {
|
||||
@@ -556,21 +556,21 @@ export class EquipHandler {
|
||||
|
||||
let { seqId } = msg;
|
||||
let jewel = await JewelModel.findbySeqId(seqId);
|
||||
if(!jewel) return resResult(STATUS.JEWEL_NOT_FOUND);
|
||||
if (!jewel) return resResult(STATUS.JEWEL_NOT_FOUND);
|
||||
|
||||
let { randSe, hid, ePlaceId, previewRandSe } = jewel;
|
||||
if(!previewRandSe || previewRandSe.length <= 0) { // 没预览过
|
||||
if (!previewRandSe || previewRandSe.length <= 0) { // 没预览过
|
||||
return resResult(STATUS.EQUIP_RESTRENGTHEN_NOT_PREVIEW);
|
||||
}
|
||||
|
||||
let newJewel = await JewelModel.updateInfo(seqId, { previewRandSe: [], randSe: previewRandSe });
|
||||
// 更新战力
|
||||
if(hid > 0) {
|
||||
if (hid > 0) {
|
||||
const hero = await HeroModel.findByHidAndRole(hid, roleId);
|
||||
await calculateCeWithHero(HERO_SYSTEM_TYPE.JEWEL_RESET_RANDSE, roleId, serverId, sid, hid, { ePlace: hero.ePlace }, { ePlaceId, jewel: newJewel, skinId: hero.skinId });
|
||||
}
|
||||
|
||||
await checkTaskInEquipReset(serverId, roleId, sid);
|
||||
await checkTaskInEquipReset(serverId, roleId, sid);
|
||||
return resResult(STATUS.SUCCESS, { curJewel: pick(newJewel, ['seqId', 'id', 'hid', 'ePlaceId', 'randSe', 'previewRandSe']) });
|
||||
|
||||
}
|
||||
@@ -580,14 +580,14 @@ export class EquipHandler {
|
||||
|
||||
let { seqId } = msg;
|
||||
let jewel = await JewelModel.findbySeqId(seqId);
|
||||
if(!jewel) return resResult(STATUS.JEWEL_NOT_FOUND);
|
||||
if (!jewel) return resResult(STATUS.JEWEL_NOT_FOUND);
|
||||
|
||||
let { randSe, previewRandSe } = jewel;
|
||||
if (!randSe || randSe.length <= 0) {
|
||||
return resResult(STATUS.JEWEL_HAVE_NO_RANDSE);
|
||||
}
|
||||
|
||||
if(!previewRandSe) { // 没预览过
|
||||
if (!previewRandSe) { // 没预览过
|
||||
return resResult(STATUS.JEWEL_NOT_PREVIEW);
|
||||
}
|
||||
|
||||
@@ -602,7 +602,7 @@ export class EquipHandler {
|
||||
|
||||
let { seqId, randSeId } = msg;
|
||||
let jewel = await JewelModel.findbySeqId(seqId);
|
||||
if(!jewel) return resResult(STATUS.JEWEL_NOT_FOUND);
|
||||
if (!jewel) return resResult(STATUS.JEWEL_NOT_FOUND);
|
||||
|
||||
let { randSe } = jewel;
|
||||
if (!randSe || randSe.length <= 0) {
|
||||
@@ -610,10 +610,10 @@ export class EquipHandler {
|
||||
}
|
||||
|
||||
let quenchedSe = randSe.find(cur => cur.quenched);
|
||||
if(!!quenchedSe) return resResult(STATUS.JEWEL_HAS_CHOOSEN_QUENCH);
|
||||
if (!!quenchedSe) return resResult(STATUS.JEWEL_HAS_CHOOSEN_QUENCH);
|
||||
|
||||
let curRandSe = randSe.find(cur => cur.id == randSeId);
|
||||
if(!curRandSe) return resResult(STATUS.JEWEL_HAVE_NO_CUR_RANDSE);
|
||||
if (!curRandSe) return resResult(STATUS.JEWEL_HAVE_NO_CUR_RANDSE);
|
||||
|
||||
let jewelResult = await JewelModel.chooseQuench(seqId, randSeId);
|
||||
|
||||
@@ -625,34 +625,34 @@ export class EquipHandler {
|
||||
let roleId: string = session.get('roleId');
|
||||
let serverId: number = session.get('serverId');
|
||||
let sid: string = session.get('sid');
|
||||
|
||||
|
||||
let { seqId } = msg;
|
||||
let jewel = await JewelModel.findbySeqId(seqId);
|
||||
if(!jewel) return resResult(STATUS.JEWEL_NOT_FOUND);
|
||||
if (!jewel) return resResult(STATUS.JEWEL_NOT_FOUND);
|
||||
|
||||
let { randSe, hid, ePlaceId } = jewel;
|
||||
if (!randSe || randSe.length <= 0) {
|
||||
return resResult(STATUS.JEWEL_HAVE_NO_RANDSE);
|
||||
}
|
||||
let quenchedSe = randSe.find(cur => cur.quenched);
|
||||
if(!quenchedSe) return resResult(STATUS.JEWEL_NOT_CHOOSEN_QUENCH);
|
||||
if (!quenchedSe) return resResult(STATUS.JEWEL_NOT_CHOOSEN_QUENCH);
|
||||
|
||||
let dicJewel = gameData.jewel.get(jewel.id);
|
||||
if(!dicJewel) return resResult(STATUS.DIC_DATA_NOT_FOUND);
|
||||
if (!dicJewel) return resResult(STATUS.DIC_DATA_NOT_FOUND);
|
||||
|
||||
let consumeResult = await handleCost(roleId, sid, dicJewel.quenchConsume, ITEM_CHANGE_REASON.EQUIP_QUENCH);
|
||||
if(!consumeResult) return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
|
||||
if (!consumeResult) return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
|
||||
|
||||
let newRandSe = getJewelRandSe(quenchedSe.id, quenchedSe.seid);
|
||||
let isSuccess = newRandSe.rand >= quenchedSe.rand;
|
||||
let newJewel = await JewelModel.quench(seqId, isSuccess, newRandSe.rand);
|
||||
// 更新战力
|
||||
if(isSuccess && hid > 0) {
|
||||
if (isSuccess && hid > 0) {
|
||||
const hero = await HeroModel.findByHidAndRole(hid, roleId);
|
||||
await calculateCeWithHero(HERO_SYSTEM_TYPE.JEWEL_QUENCH, roleId, serverId, sid, hid, { ePlace: hero.ePlace }, { ePlaceId, jewel: newJewel, skinId: hero.skinId });
|
||||
}
|
||||
|
||||
await checkTaskInEquipQuench(serverId, roleId, sid, isSuccess);
|
||||
await checkTaskInEquipQuench(serverId, roleId, sid, isSuccess);
|
||||
return resResult(STATUS.SUCCESS, { isSuccess, curJewel: pick(newJewel, ['seqId', 'id', 'hid', 'ePlaceId', 'randSe', 'previewRandSe']) });
|
||||
|
||||
}
|
||||
@@ -671,13 +671,13 @@ export class EquipHandler {
|
||||
if (!dicGoods.decomposeItem || dicGoods.decomposeItem.length <= 0) return resResult(STATUS.CONSUME_TYPE_ERR);
|
||||
if (count < 0) return resResult(STATUS.WRONG_PARMS);
|
||||
|
||||
for(let result of dicGoods.decomposeItem) {
|
||||
for (let result of dicGoods.decomposeItem) {
|
||||
goods.push({ id: result.id, count: result.count * count });
|
||||
}
|
||||
}
|
||||
|
||||
let costResult = await handleCost(roleId, sid, origin, ITEM_CHANGE_REASON.EQUIP_PIECE_DECOMPOSE);
|
||||
if(!costResult) return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
|
||||
if (!costResult) return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
|
||||
let result = await addItems(roleId, roleName, sid, goods, ITEM_CHANGE_REASON.EQUIP_PIECE_DECOMPOSE);
|
||||
return resResult(STATUS.SUCCESS, { goods: combineItems(result) });
|
||||
}
|
||||
@@ -688,7 +688,7 @@ export class EquipHandler {
|
||||
let roleId: string = session.get('roleId');
|
||||
let roleName: string = session.get('roleName');
|
||||
let sid: string = session.get('sid');
|
||||
if(origin.length > BAG.BAG_RESOLVE_UPLIMITED) {
|
||||
if (origin.length > BAG.BAG_RESOLVE_UPLIMITED) {
|
||||
return resResult(STATUS.EQUIP_DECOMPOSE_IS_UPLIMIT);
|
||||
}
|
||||
let jewels = await JewelModel.findbySeqIds(origin);
|
||||
@@ -697,8 +697,8 @@ export class EquipHandler {
|
||||
let goods: RewardInter[] = [];
|
||||
let cost: ItemInter[] = [];
|
||||
|
||||
for(let jewel of jewels) {
|
||||
if(jewel.hid > 0) {
|
||||
for (let jewel of jewels) {
|
||||
if (jewel.hid > 0) {
|
||||
return resResult(STATUS.JEWEL_IS_EQUIPED);
|
||||
}
|
||||
let dicGoods = gameData.goods.get(jewel.id);
|
||||
@@ -707,7 +707,7 @@ export class EquipHandler {
|
||||
}
|
||||
|
||||
let costResult = await handleCost(roleId, sid, cost, ITEM_CHANGE_REASON.EQUIP_DECOMPOSE); // 删掉装备
|
||||
if(!costResult) return resResult(STATUS.BATTLE_CONSUMES_NOT_ENOUGH);
|
||||
if (!costResult) return resResult(STATUS.BATTLE_CONSUMES_NOT_ENOUGH);
|
||||
|
||||
let result = await addItems(roleId, roleName, sid, goods, ITEM_CHANGE_REASON.EQUIP_DECOMPOSE);
|
||||
return resResult(STATUS.SUCCESS, { goods: combineItems(result) });
|
||||
@@ -720,15 +720,15 @@ export class EquipHandler {
|
||||
let roleName: string = session.get('roleName');
|
||||
let sid: string = session.get('sid');
|
||||
let serverId: number = session.get('serverId');
|
||||
|
||||
|
||||
let check = new CheckMeterial(roleId);
|
||||
let isEnough = await check.composeStone(id, count);
|
||||
if(!isEnough) return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
|
||||
if (!isEnough) return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
|
||||
|
||||
let consumes = check.getConsume();
|
||||
let costResult = await handleCost(roleId, sid, consumes, ITEM_CHANGE_REASON.COMPOSE_STONE);
|
||||
if (!costResult) return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
|
||||
|
||||
|
||||
let goods = await addItems(roleId, roleName, sid, [{ id, count }], ITEM_CHANGE_REASON.COMPOSE_STONE);
|
||||
|
||||
await checkTaskInComposeStone(serverId, roleId, sid, count);
|
||||
@@ -742,39 +742,39 @@ export class EquipHandler {
|
||||
let serverId: number = session.get('serverId');
|
||||
|
||||
let originJewel = await JewelModel.findbySeqId(originJewelId);
|
||||
if(!originJewel || originJewel.roleId != roleId) return resResult(STATUS.JEWEL_IS_NOT_FIND);
|
||||
if(originJewel.hid > 0) return resResult(STATUS.JEWEL_HAS_EQUPED);
|
||||
if (!originJewel || originJewel.roleId != roleId) return resResult(STATUS.JEWEL_IS_NOT_FIND);
|
||||
if (originJewel.hid > 0) return resResult(STATUS.JEWEL_HAS_EQUPED);
|
||||
|
||||
let targetJewel = await JewelModel.findbySeqId(targetJewelId);
|
||||
if(!targetJewel || targetJewel.roleId != roleId) return resResult(STATUS.JEWEL_IS_NOT_FIND);
|
||||
if (!targetJewel || targetJewel.roleId != roleId) return resResult(STATUS.JEWEL_IS_NOT_FIND);
|
||||
|
||||
if (isLocked(targetJewel.randSe)) return resResult(STATUS.JEWEL_LOCKED_CANNOT_INHERIT);
|
||||
|
||||
if(isLocked(targetJewel.randSe)) return resResult(STATUS.JEWEL_LOCKED_CANNOT_INHERIT);
|
||||
|
||||
let dicOldJewel = gameData.jewel.get(originJewel.id);
|
||||
if(!dicOldJewel) return resResult(STATUS.DIC_DATA_NOT_FOUND);
|
||||
if (!dicOldJewel) return resResult(STATUS.DIC_DATA_NOT_FOUND);
|
||||
let dicJewel = gameData.jewel.get(targetJewel.id);
|
||||
if(!dicJewel) return resResult(STATUS.DIC_DATA_NOT_FOUND);
|
||||
if(dicJewel.eplaceId != dicOldJewel.eplaceId || dicJewel.lv < dicOldJewel.lv) {
|
||||
if (!dicJewel) return resResult(STATUS.DIC_DATA_NOT_FOUND);
|
||||
if (dicJewel.eplaceId != dicOldJewel.eplaceId || dicJewel.lv < dicOldJewel.lv) {
|
||||
return resResult(STATUS.JEWEL_CANNOT_INHERIT);
|
||||
}
|
||||
|
||||
// 消耗
|
||||
let consumeResult = await handleCost(roleId, sid, [
|
||||
{ id: originJewel.id, seqId: originJewel.seqId},
|
||||
{ id: originJewel.id, seqId: originJewel.seqId },
|
||||
...dicJewel.inheritConsume
|
||||
], ITEM_CHANGE_REASON.JEWEL_INHERIT);
|
||||
if(!consumeResult) return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
|
||||
if (!consumeResult) return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
|
||||
|
||||
let newRandSe = getRandSeResult(targetJewel.id, targetJewel.randSe, originJewel.randSe, originJewel.id);
|
||||
let newJewel = await JewelModel.updateInfo(targetJewel.seqId, { previewRandSe: [], randSe: newRandSe });
|
||||
// 更新战力
|
||||
if(targetJewel.hid > 0) {
|
||||
if (targetJewel.hid > 0) {
|
||||
const hero = await HeroModel.findByHidAndRole(targetJewel.hid, roleId);
|
||||
await calculateCeWithHero(HERO_SYSTEM_TYPE.JEWEL_RESET_RANDSE, roleId, serverId, sid, targetJewel.hid, { ePlace: hero.ePlace }, { ePlaceId: targetJewel.ePlaceId, jewel: newJewel, skinId: hero.skinId });
|
||||
|
||||
}
|
||||
|
||||
await checkTaskInEquipReset(serverId, roleId, sid);
|
||||
await checkTaskInEquipReset(serverId, roleId, sid);
|
||||
return resResult(STATUS.SUCCESS, { curJewel: pick(newJewel, ['seqId', 'id', 'hid', 'ePlaceId', 'randSe', 'previewRandSe']) });
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -18,19 +18,19 @@ export class CheckMeterial {
|
||||
|
||||
constructor(roleId: string, role?: RoleType, items?: ItemType[]) {
|
||||
this.roleId = roleId;
|
||||
if(role) {
|
||||
if (role) {
|
||||
this.itemsIndb.set(this.goldId, role.gold);
|
||||
this.itemsIndb.set(this.coinId, role.coin);
|
||||
}
|
||||
if(items && items.length) {
|
||||
for(let {id, count} of items) {
|
||||
if (items && items.length) {
|
||||
for (let { id, count } of items) {
|
||||
this.itemsIndb.set(id, count);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private pushToNotEnoughItems(id: number, count: number) {
|
||||
if(!this.notEnoughItems.has(id)) {
|
||||
if (!this.notEnoughItems.has(id)) {
|
||||
this.notEnoughItems.set(id, 0);
|
||||
}
|
||||
this.notEnoughItems.set(id, this.notEnoughItems.get(id) + count);
|
||||
@@ -38,21 +38,21 @@ export class CheckMeterial {
|
||||
|
||||
public getNotEnoughItems() {
|
||||
let map = new Map<number, number>();
|
||||
for(let [ id, count ] of this.notEnoughItems) {
|
||||
for (let [id, count] of this.notEnoughItems) {
|
||||
map.set(id, count);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
public async decrease(goods: {id: number, count: number}[]) {
|
||||
public async decrease(goods: { id: number, count: number }[]) {
|
||||
this.tempConsumes.splice(0, this.tempConsumes.length);
|
||||
this.notEnoughItems.clear();
|
||||
let { items, gold, coin } = sortItems(goods, HANDLE_REWARD_TYPE.COST);
|
||||
for(let { id, count} of items) {
|
||||
for (let { id, count } of items) {
|
||||
let notEnoughCount = await this.decreaseItem(id, count);
|
||||
if(notEnoughCount > 0) {
|
||||
if (notEnoughCount > 0) {
|
||||
let isEnough = await this.checkReplaceItem(id, notEnoughCount);
|
||||
if(isEnough) {
|
||||
if (isEnough) {
|
||||
this.tempConsumes.push({ id, count: count - notEnoughCount });
|
||||
} else {
|
||||
return false;
|
||||
@@ -60,29 +60,29 @@ export class CheckMeterial {
|
||||
}
|
||||
}
|
||||
|
||||
if(gold.length > 0) {
|
||||
if (gold.length > 0) {
|
||||
let isEnough = await this.decreaseGold(gold);
|
||||
if(!isEnough) return false;
|
||||
if (!isEnough) return false;
|
||||
}
|
||||
if(coin.length > 0) {
|
||||
if (coin.length > 0) {
|
||||
let isEnough = await this.decreaseCoin(coin);
|
||||
if(!isEnough) return false;
|
||||
if (!isEnough) return false;
|
||||
}
|
||||
this.consumes.push(...this.tempConsumes);
|
||||
return true;
|
||||
}
|
||||
|
||||
// 当消耗不足的时候,不提前返回,也不去算元宝和铜币
|
||||
public async decreaseItemsContinue(goods: {id: number, count: number}[]) {
|
||||
public async decreaseItemsContinue(goods: { id: number, count: number }[]) {
|
||||
this.tempConsumes.splice(0, this.tempConsumes.length);
|
||||
this.notEnoughItems.clear();
|
||||
let { items } = sortItems(goods, HANDLE_REWARD_TYPE.COST);
|
||||
let itemIsEnough = true;
|
||||
for(let { id, count} of items) {
|
||||
for (let { id, count } of items) {
|
||||
let notEnoughCount = await this.decreaseItem(id, count);
|
||||
if(notEnoughCount > 0) {
|
||||
if (notEnoughCount > 0) {
|
||||
let isEnough = await this.checkReplaceItem(id, notEnoughCount);
|
||||
if(isEnough) {
|
||||
if (isEnough) {
|
||||
this.tempConsumes.push({ id, count: count - notEnoughCount });
|
||||
} else {
|
||||
itemIsEnough = false;
|
||||
@@ -98,15 +98,15 @@ export class CheckMeterial {
|
||||
}
|
||||
|
||||
private async decreaseItem(id: number, count: number) {
|
||||
if(!this.itemsIndb.has(id)) {
|
||||
if (!this.itemsIndb.has(id)) {
|
||||
let item = await ItemModel.findbyRoleAndGid(this.roleId, id);
|
||||
if(!item) {
|
||||
if (!item) {
|
||||
this.pushToNotEnoughItems(id, count);
|
||||
return count;
|
||||
}
|
||||
this.itemsIndb.set(id, item.count);
|
||||
}
|
||||
if(this.itemsIndb.get(id) < count) {
|
||||
if (this.itemsIndb.get(id) < count) {
|
||||
let notEnoughCount = count - this.itemsIndb.get(id);
|
||||
this.pushToNotEnoughItems(id, notEnoughCount);
|
||||
this.itemsIndb.set(id, 0);
|
||||
@@ -119,12 +119,12 @@ export class CheckMeterial {
|
||||
}
|
||||
|
||||
private async checkReplaceItem(id: number, count: number) {
|
||||
if(!this.canReplace) return false;
|
||||
if (!this.canReplace) return false;
|
||||
|
||||
let relationGoodId = gameData.relationGoods.get(id);
|
||||
if(!relationGoodId) return false;
|
||||
if (!relationGoodId) return false;
|
||||
|
||||
if(relationGoodId == this.goldId) {
|
||||
if (relationGoodId == this.goldId) {
|
||||
return await this.decreaseGold([{ count }]);
|
||||
} else if (relationGoodId == this.coinId) {
|
||||
return await this.decreaseCoin([count]);
|
||||
@@ -136,13 +136,13 @@ export class CheckMeterial {
|
||||
|
||||
private async decreaseGold(gold: { count: number }[]) {
|
||||
|
||||
if(!this.itemsIndb.has(this.goldId)) {
|
||||
if (!this.itemsIndb.has(this.goldId)) {
|
||||
let role = await RoleModel.findByRoleId(this.roleId, 'gold coin');
|
||||
this.itemsIndb.set(this.goldId, role.gold);
|
||||
this.itemsIndb.set(this.coinId, role.coin);
|
||||
}
|
||||
let goldCost = gold.reduce((pre, cur) => { return pre + cur.count }, 0);
|
||||
if(this.itemsIndb.get(this.goldId) < goldCost) {
|
||||
if (this.itemsIndb.get(this.goldId) < goldCost) {
|
||||
this.pushToNotEnoughItems(this.goldId, goldCost - this.itemsIndb.get(this.goldId));
|
||||
this.itemsIndb.set(this.goldId, 0);
|
||||
return false;
|
||||
@@ -154,13 +154,13 @@ export class CheckMeterial {
|
||||
|
||||
private async decreaseCoin(coin: number[]) {
|
||||
|
||||
if(!this.itemsIndb.has(this.coinId)) {
|
||||
if (!this.itemsIndb.has(this.coinId)) {
|
||||
let role = await RoleModel.findByRoleId(this.roleId, 'gold coin');
|
||||
this.itemsIndb.set(this.goldId, role.gold);
|
||||
this.itemsIndb.set(this.coinId, role.coin);
|
||||
}
|
||||
let coinCost = coin.reduce((pre, cur) => pre + cur, 0);
|
||||
if(this.itemsIndb.get(this.coinId) < coinCost) {
|
||||
if (this.itemsIndb.get(this.coinId) < coinCost) {
|
||||
this.pushToNotEnoughItems(this.coinId, coinCost - this.itemsIndb.get(this.coinId));
|
||||
this.itemsIndb.set(this.coinId, 0);
|
||||
return false;
|
||||
@@ -172,8 +172,8 @@ export class CheckMeterial {
|
||||
|
||||
private getMaterialEnough(materials: RewardInter[], notEnoughItems: Map<number, number>) {
|
||||
let newMaterials: RewardInter[] = [];
|
||||
for(let {id, count} of materials) {
|
||||
if(notEnoughItems.has(id)) {
|
||||
for (let { id, count } of materials) {
|
||||
if (notEnoughItems.has(id)) {
|
||||
newMaterials.push({ id, count: count - notEnoughItems.get(id) });
|
||||
} else {
|
||||
newMaterials.push({ id, count });
|
||||
@@ -185,19 +185,19 @@ export class CheckMeterial {
|
||||
// 检查地玉石是否可以合成
|
||||
public async composeStone(id: number, count: number) {
|
||||
let dicStone = gameData.stone.get(id);
|
||||
if(!dicStone || dicStone.composeMaterial.length <= 0) return false; // 1阶石头不能再从下合成返回不行
|
||||
let materials = dicStone.composeMaterial.map(cur => ({...cur, count: cur.count * count }));
|
||||
if (!dicStone || dicStone.composeMaterial.length <= 0) return false; // 1阶石头不能再从下合成返回不行
|
||||
let materials = dicStone.composeMaterial.map(cur => ({ ...cur, count: cur.count * count }));
|
||||
let isEnough = await this.decrease(materials);
|
||||
if(!isEnough) {
|
||||
if (!isEnough) {
|
||||
let notEnoughItems = this.getNotEnoughItems();
|
||||
let newMaterials = this.getMaterialEnough(materials, notEnoughItems);
|
||||
let isEnough = await this.decrease(newMaterials); // 消耗掉除了不足的部分以外的其他部分
|
||||
if(!isEnough) return false;
|
||||
if (!isEnough) return false;
|
||||
|
||||
let isAllOK = true; // 如果有石头不足,向下补充,isAllOK标识不足的都能补充上
|
||||
for(let [id, count] of notEnoughItems) {
|
||||
for (let [id, count] of notEnoughItems) {
|
||||
let isEnough = await this.composeStone(id, count);
|
||||
if(!isEnough) {
|
||||
if (!isEnough) {
|
||||
isAllOK = false; break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user