🎈 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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -216,39 +216,39 @@ export const DEFAULT_HERO_LV = 1;
|
||||
export const FIX_SMS_CODE_TELS = ['18855953630', '13911134885', '15167549151', '15618654010', '15167549151', '18342915387', '15000250967'];
|
||||
|
||||
export enum REDIS_KEY {
|
||||
USER_INFO ="userInfo", // 玩家缓存信息
|
||||
TOWER_RANK ="towerRank", // 天梯排行榜
|
||||
COM_TEAM_SEARCH_PRE ='comTeamSerQ', // 匹配中的玩家,按品质分
|
||||
COM_TEAM_CREATED_TEAM ='comTeamCreate', // 匹配中的队伍,按品质分
|
||||
PVP_RANK ="pvpRank", // pvp排行榜
|
||||
GUILD_INFO ="guildInfo", // 公会信息
|
||||
GUILD_ACTIVE_RANK ="guildActiveRank", // 公会周活跃排行榜
|
||||
SERVER ='server', // 服务器列表
|
||||
USER_INFO = "userInfo", // 玩家缓存信息
|
||||
TOWER_RANK = "towerRank", // 天梯排行榜
|
||||
COM_TEAM_SEARCH_PRE = 'comTeamSerQ', // 匹配中的玩家,按品质分
|
||||
COM_TEAM_CREATED_TEAM = 'comTeamCreate', // 匹配中的队伍,按品质分
|
||||
PVP_RANK = "pvpRank", // pvp排行榜
|
||||
GUILD_INFO = "guildInfo", // 公会信息
|
||||
GUILD_ACTIVE_RANK = "guildActiveRank", // 公会周活跃排行榜
|
||||
SERVER = 'server', // 服务器列表
|
||||
SERVER_OPEN_TIME = 'serverOpenTime', // 服务器开服时间
|
||||
ONLINE_USERS ='onlineUsers', // 在线用户情况
|
||||
ONLINE_TIME ='onlineTime', // 玩家在线时间
|
||||
ONLINE_CNT ='onlineCnt', // 在线次数
|
||||
CHANNEL_SERVERS ='chat:channelServers', // 渠道对应的 chat 服务器 Id,
|
||||
USER_GATE_ACTIVITY ='usrGateAct', // 蛮夷入侵玩家排行
|
||||
GATE_ACTIVITY ='gateAct', // 蛮夷入侵军团排行
|
||||
USER_CITY_ACTIVITY ='usrCityAct', // 诸侯混战玩家排行
|
||||
CITY_ACTIVITY ='cityAct', // 诸侯混战军团排行
|
||||
RACE_ACTIVITY ='raceAct', // 粮草先行军团排行
|
||||
TOP_LINEUP_INFO ='topLineInfo', // 最强阵容数据
|
||||
TOP_LINEUP_RANK ='topLineRank', // 最强阵容排行
|
||||
TOP_HERO_RANK ='topHeroRank', // 最强武将排行
|
||||
HERO_INFO ='heroInfo', // 最强武将信息
|
||||
HERO_NUM_RANK ='heroNum', // 武将数量排行
|
||||
USER_LV ='usrLv', // 主公等级排行榜
|
||||
SUM_CE_RANK ='sumCeRank', // 总战力排名
|
||||
DUNGEON_RANK ='dungeonRank', // 秘境排名
|
||||
DUNGEON_LINEUP ='dungeonLineup', // 秘境通关阵容
|
||||
MAIN_RANK ='mainRank', // 主线通关排名
|
||||
MAIN_ELITE_RANK ='mainEliteRank', // 精英通关排名
|
||||
GUILD_LV_RANK ="guildLvRank", // 公会等级排行榜
|
||||
HERO_RANK ="heroRank", // 武将排行榜
|
||||
SHOW_LINEUP ="showLineup", // 展示阵容
|
||||
SYS_SERVER ='sysServer', // 全服connector服
|
||||
ONLINE_USERS = 'onlineUsers', // 在线用户情况
|
||||
ONLINE_TIME = 'onlineTime', // 玩家在线时间
|
||||
ONLINE_CNT = 'onlineCnt', // 在线次数
|
||||
CHANNEL_SERVERS = 'chat:channelServers', // 渠道对应的 chat 服务器 Id,
|
||||
USER_GATE_ACTIVITY = 'usrGateAct', // 蛮夷入侵玩家排行
|
||||
GATE_ACTIVITY = 'gateAct', // 蛮夷入侵军团排行
|
||||
USER_CITY_ACTIVITY = 'usrCityAct', // 诸侯混战玩家排行
|
||||
CITY_ACTIVITY = 'cityAct', // 诸侯混战军团排行
|
||||
RACE_ACTIVITY = 'raceAct', // 粮草先行军团排行
|
||||
TOP_LINEUP_INFO = 'topLineInfo', // 最强阵容数据
|
||||
TOP_LINEUP_RANK = 'topLineRank', // 最强阵容排行
|
||||
TOP_HERO_RANK = 'topHeroRank', // 最强武将排行
|
||||
HERO_INFO = 'heroInfo', // 最强武将信息
|
||||
HERO_NUM_RANK = 'heroNum', // 武将数量排行
|
||||
USER_LV = 'usrLv', // 主公等级排行榜
|
||||
SUM_CE_RANK = 'sumCeRank', // 总战力排名
|
||||
DUNGEON_RANK = 'dungeonRank', // 秘境排名
|
||||
DUNGEON_LINEUP = 'dungeonLineup', // 秘境通关阵容
|
||||
MAIN_RANK = 'mainRank', // 主线通关排名
|
||||
MAIN_ELITE_RANK = 'mainEliteRank', // 精英通关排名
|
||||
GUILD_LV_RANK = "guildLvRank", // 公会等级排行榜
|
||||
HERO_RANK = "heroRank", // 武将排行榜
|
||||
SHOW_LINEUP = "showLineup", // 展示阵容
|
||||
SYS_SERVER = 'sysServer', // 全服connector服
|
||||
PAY_CHANNEL = 'pay', // 支付订阅频道
|
||||
REFUND_CHANNEL = 'refund', // 退款频道
|
||||
TREAT_ROLE_CHANNEL = 'treatRole', // 处理玩家账号名频道
|
||||
@@ -265,19 +265,19 @@ export enum REDIS_KEY {
|
||||
GVG_VESTIGE_MEMBER = 'vestigeUsr', // 玩家一个遗迹的积分
|
||||
GVG_VESTIGE_MEMBER_ALL = 'vestigeUsrAll', // 玩家所有遗迹积分
|
||||
GVG_VESTIGE_LEAGUE = 'vestigeLeague', // 联军所有遗迹积分
|
||||
LEAGUE_INFO ="leagueInfo", // 联军信息
|
||||
GVG_BATTLE_RANK ="gvgBattleUsr", // 激战期个人排行榜
|
||||
GVG_BATTLE_USER_RANK_BY_CITY ="gvgBattleUsrByCity", // 激战期个人排行榜
|
||||
LEAGUE_INFO = "leagueInfo", // 联军信息
|
||||
GVG_BATTLE_RANK = "gvgBattleUsr", // 激战期个人排行榜
|
||||
GVG_BATTLE_USER_RANK_BY_CITY = "gvgBattleUsrByCity", // 激战期个人排行榜
|
||||
GVG_BATTLE_LEAGUE_RANK = "gvgBattleLeague", // 激战期联军排行榜
|
||||
GVG_BATTLE_LEAGUE_RANK_BY_CITY = "gvgBattleLeagueByCity", // 激战期联军排行榜
|
||||
GVG_BATTLE_USR_SETTLE_RANK ="gvgBattleUsrSettle", // 激战期个人积分占领排行榜
|
||||
GVG_BATTLE_USR_SETTLE_RANK_BY_CITY ="gvgBattleUsrSettleByCity", // 激战期个人积分占领排行榜按城池分
|
||||
GVG_HISTORY_AREA ='gvgHisArea', // gvg激战期玩家加入的区域
|
||||
GVG_HISTORY_AREA_TEAM ='gvgHisAreaTeam', // gvg激战期玩家加入的区域
|
||||
GVG_HISTORY_CITY ='gvgHisCity', // gvg激战期玩家进入的城池
|
||||
GVG_SEND_REWARD ='gvgSendReward', // gvg发放奖励
|
||||
GVG_SPINE_CNT ='gvgSpineCnt', // gvg spine的下发数量
|
||||
ACTIVITY_MINI_GAME ='miniGame', // 活动小游戏排行榜
|
||||
GVG_BATTLE_USR_SETTLE_RANK = "gvgBattleUsrSettle", // 激战期个人积分占领排行榜
|
||||
GVG_BATTLE_USR_SETTLE_RANK_BY_CITY = "gvgBattleUsrSettleByCity", // 激战期个人积分占领排行榜按城池分
|
||||
GVG_HISTORY_AREA = 'gvgHisArea', // gvg激战期玩家加入的区域
|
||||
GVG_HISTORY_AREA_TEAM = 'gvgHisAreaTeam', // gvg激战期玩家加入的区域
|
||||
GVG_HISTORY_CITY = 'gvgHisCity', // gvg激战期玩家进入的城池
|
||||
GVG_SEND_REWARD = 'gvgSendReward', // gvg发放奖励
|
||||
GVG_SPINE_CNT = 'gvgSpineCnt', // gvg spine的下发数量
|
||||
ACTIVITY_MINI_GAME = 'miniGame', // 活动小游戏排行榜
|
||||
PUBLIC_ACCOUNT_GIFT = 'pubAccGiftChannel', // 公众号频道
|
||||
SEND_GIFT_CODE = 'sendGiftCodeChannel', // 礼包码频道
|
||||
MAX_ONLINE_USERS = 'maxOnlineUsers', // 最高在线人数限制
|
||||
@@ -288,7 +288,7 @@ export enum REDIS_KEY {
|
||||
|
||||
// 各排行榜对应hash的key
|
||||
export function getInfoKeyByRedisKey(redisKey: REDIS_KEY) {
|
||||
switch(redisKey) {
|
||||
switch (redisKey) {
|
||||
case REDIS_KEY.TOWER_RANK: // 天梯排行榜
|
||||
return { infoKey: REDIS_KEY.USER_INFO, extraKey: [] };
|
||||
case REDIS_KEY.PVP_RANK: // pvp排行榜
|
||||
@@ -311,7 +311,7 @@ export function getInfoKeyByRedisKey(redisKey: REDIS_KEY) {
|
||||
return { infoKey: REDIS_KEY.USER_INFO, extraKey: [] };
|
||||
case REDIS_KEY.HERO_RANK: // 武将排行榜
|
||||
return { infoKey: REDIS_KEY.USER_INFO, extraKey: [REDIS_KEY.HERO_INFO] };
|
||||
|
||||
|
||||
case REDIS_KEY.GUILD_ACTIVE_RANK: // 公会周活跃排行榜
|
||||
return { infoKey: REDIS_KEY.GUILD_INFO, extraKey: [] };
|
||||
case REDIS_KEY.GUILD_LV_RANK: // 公会等级排行榜
|
||||
@@ -378,9 +378,9 @@ export enum RANK_TYPE {
|
||||
|
||||
// 接口中的排行榜类型对应的redis中的key
|
||||
export function getRedisKeyByRankType(rankType: RANK_TYPE, isTimelimit = false) {
|
||||
switch(rankType) {
|
||||
switch (rankType) {
|
||||
case RANK_TYPE.TOP_LINTUP: // 最强阵容战力
|
||||
return isTimelimit? REDIS_KEY.TOP_LINE_SNAPSHOT: REDIS_KEY.TOP_LINEUP_RANK;
|
||||
return isTimelimit ? REDIS_KEY.TOP_LINE_SNAPSHOT : REDIS_KEY.TOP_LINEUP_RANK;
|
||||
case RANK_TYPE.TOP_HERO: // 最强武将
|
||||
return REDIS_KEY.TOP_HERO_RANK;
|
||||
case RANK_TYPE.HERO_NUM: // 武将数量
|
||||
@@ -388,7 +388,7 @@ export function getRedisKeyByRankType(rankType: RANK_TYPE, isTimelimit = false)
|
||||
case RANK_TYPE.USER_LV: // 主公等级
|
||||
return REDIS_KEY.USER_LV;
|
||||
case RANK_TYPE.SUM_CE: // 总战力
|
||||
return isTimelimit? REDIS_KEY.SUM_CE_SNAPSHOT: REDIS_KEY.SUM_CE_RANK;
|
||||
return isTimelimit ? REDIS_KEY.SUM_CE_SNAPSHOT : REDIS_KEY.SUM_CE_RANK;
|
||||
case RANK_TYPE.TOWER: // 镇念塔
|
||||
return REDIS_KEY.TOWER_RANK;
|
||||
case RANK_TYPE.MAIN: // 主线
|
||||
@@ -1244,7 +1244,7 @@ export enum GUILD_QUIT_WAY {
|
||||
}
|
||||
|
||||
export function getAuctionSourceTypeName(sourceType: number) {
|
||||
switch(sourceType) {
|
||||
switch (sourceType) {
|
||||
case 1: return '军团演武';
|
||||
case 2: return '蛮夷入侵';
|
||||
case 3: return '诸侯混战';
|
||||
@@ -1263,7 +1263,7 @@ export enum TRAIN_REWARD_TYPE {
|
||||
SCORE = 1, // 练兵场压制积分
|
||||
ITEM = 2, // 练兵场物品奖励
|
||||
}
|
||||
|
||||
|
||||
export enum GM_API_TYPE {
|
||||
add = 'ad', // 增
|
||||
del = 'del', // 删
|
||||
@@ -1294,7 +1294,7 @@ export enum MEMORY_LOG_TYPE {
|
||||
|
||||
export enum CE_CHANGE_REASON {
|
||||
HERO = 'hero', // 武将
|
||||
|
||||
|
||||
}
|
||||
|
||||
export enum TALENT_RELATION_TYPE {
|
||||
@@ -1340,7 +1340,7 @@ export enum TEAM_TYPE {
|
||||
}
|
||||
|
||||
// 异常战斗封号开关
|
||||
export enum CHECT_BLOCK_TYPE{
|
||||
export enum CHECT_BLOCK_TYPE {
|
||||
OPEN = 0, //开
|
||||
CLOSE = 1, //关
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -19,14 +19,14 @@ export interface DicStone {
|
||||
// 合成消耗
|
||||
readonly composeMaterial: RewardInter[];
|
||||
// 属性提升
|
||||
readonly attribute: {id: number, num: number}[];
|
||||
readonly attribute: { id: number, num: number }[];
|
||||
}
|
||||
|
||||
|
||||
export const dicStone = new Map<number, DicStone>();
|
||||
export function loadStone() {
|
||||
dicStone.clear();
|
||||
|
||||
|
||||
let arr = readFileAndParse(FILENAME.DIC_STONE);
|
||||
|
||||
arr.forEach(o => {
|
||||
@@ -38,14 +38,14 @@ export function loadStone() {
|
||||
}
|
||||
|
||||
function parseAttr(str: string) {
|
||||
let result = new Array<{id: number, num: number}>();
|
||||
if(!str) return result;
|
||||
let result = new Array<{ id: number, num: number }>();
|
||||
if (!str) return result;
|
||||
let decodeArr = decodeArrayListStr(str);
|
||||
for(let [id, num] of decodeArr) {
|
||||
if(isNaN(parseInt(id)) || isNaN(parseInt(num))) {
|
||||
for (let [id, num] of decodeArr) {
|
||||
if (isNaN(parseInt(id)) || isNaN(parseInt(num))) {
|
||||
throw new Error('data table format wrong');
|
||||
}
|
||||
result.push({id: parseInt(id), num: parseInt(num)});
|
||||
result.push({ id: parseInt(id), num: parseInt(num) });
|
||||
}
|
||||
return result
|
||||
}
|
||||
Reference in New Issue
Block a user