装备:天晶石洗练
This commit is contained in:
@@ -30,29 +30,29 @@ export class EquipHandler {
|
||||
constructor(private app: Application) {
|
||||
}
|
||||
|
||||
public async composeEquip(msg: { hid: number, eplaceId: number }, session: BackendSession) {
|
||||
public async composeEquip(msg: { hid: number, ePlaceId: number }, session: BackendSession) {
|
||||
let roleId: string = session.get('roleId');
|
||||
let sid: string = session.get('sid');
|
||||
let { hid, eplaceId } = msg;
|
||||
if(!isNumber(eplaceId) || eplaceId > 4 || eplaceId < 1) return resResult(STATUS.WRONG_PARMS);
|
||||
let { hid, ePlaceId } = msg;
|
||||
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 curEquip = hero.ePlace?.find(equip => equip.id == eplaceId );
|
||||
let curEquip = hero.ePlace?.find(equip => equip.id == ePlaceId );
|
||||
if(curEquip) return resResult(STATUS.EQUIP_HAS_COMPOSE);
|
||||
|
||||
let dicHero = gameData.hero.get(hid);
|
||||
let dicEquip = getEquipByJobClassAndEPlace(dicHero?.jobClass, eplaceId);
|
||||
let dicEquip = getEquipByJobClassAndEPlace(dicHero?.jobClass, ePlaceId);
|
||||
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.BATTLE_CONSUMES_NOT_ENOUGH);
|
||||
|
||||
let newEquip = new EPlace(eplaceId, dicEquip.id);
|
||||
let newEquip = new EPlace(ePlaceId, dicEquip.id);
|
||||
let newEplace = hero.ePlace? [...hero.ePlace, newEquip]: [newEquip];
|
||||
|
||||
hero = await calPlayerCeAndSave(HERO_SYSTEM_TYPE.COMPOSE_EQUIP, sid, roleId, hero, { ePlace: newEplace }, [eplaceId]);
|
||||
hero = await calPlayerCeAndSave(HERO_SYSTEM_TYPE.COMPOSE_EQUIP, sid, roleId, hero, { ePlace: newEplace }, [ePlaceId]);
|
||||
|
||||
return resResult(STATUS.SUCCESS, {
|
||||
curHero: {
|
||||
@@ -63,18 +63,18 @@ export class EquipHandler {
|
||||
}
|
||||
|
||||
// 装备栏强化
|
||||
public async strengthen(msg: { hid: number, eplaceId: number, isOneClick: boolean }, session: BackendSession) {
|
||||
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 { hid, ePlaceId, isOneClick } = msg;
|
||||
let hero = await HeroModel.findByHidAndRole(hid, roleId);
|
||||
if (!hero) return resResult(STATUS.HERO_NOT_FIND);
|
||||
|
||||
let curEquip = hero.ePlace?.find(cur => cur.id == eplaceId);
|
||||
let curEquip = hero.ePlace?.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);
|
||||
let fromLv = curEquip.lv;
|
||||
@@ -93,9 +93,9 @@ export class EquipHandler {
|
||||
let result = await handleCost(roleId, sid, consumes, ITEM_CHANGE_REASON.EQUIP_STRENTHEN);
|
||||
if (!result) return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
|
||||
|
||||
let { newEplace, updatedEplace } = updateEplace(hero.ePlace, eplaceId, { lv: newLv });
|
||||
let { newEplace, updatedEplace } = updateEplace(hero.ePlace, ePlaceId, { lv: newLv });
|
||||
|
||||
hero = await calPlayerCeAndSave(HERO_SYSTEM_TYPE.EQUIP_STRENGTH, sid, roleId, hero, { ePlace: newEplace }, [eplaceId]);
|
||||
hero = await calPlayerCeAndSave(HERO_SYSTEM_TYPE.EQUIP_STRENGTH, sid, roleId, hero, { ePlace: newEplace }, [ePlaceId]);
|
||||
|
||||
// TODO 任务
|
||||
|
||||
@@ -157,17 +157,17 @@ export class EquipHandler {
|
||||
|
||||
|
||||
// 装备升品
|
||||
public async qualityUp(msg: { hid: number, eplaceId: number, isOneClick: boolean }, session: BackendSession) {
|
||||
public async qualityUp(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 { hid, ePlaceId, isOneClick } = msg;
|
||||
let hero = await HeroModel.findByHidAndRole(hid, roleId);
|
||||
if (!hero) return resResult(STATUS.HERO_NOT_FIND);
|
||||
|
||||
let curEquip = hero.ePlace?.find(cur => cur.id == eplaceId);
|
||||
let curEquip = hero.ePlace?.find(cur => cur.id == ePlaceId);
|
||||
if(!curEquip) return resResult(STATUS.EQUIP_NOT_FIND);
|
||||
|
||||
let nextEquipQuality = getNextEquipQuality(curEquip.equipId, curEquip.quality, curEquip.qualityStage);
|
||||
@@ -200,8 +200,8 @@ export class EquipHandler {
|
||||
}
|
||||
let isUpQuality = update.quality != curEquip.quality;
|
||||
|
||||
let { newEplace, updatedEplace } = updateEplace(hero.ePlace, eplaceId, update);
|
||||
hero = await calPlayerCeAndSave(HERO_SYSTEM_TYPE.EQUIP_QUALITY, sid, roleId, hero, { ePlace: newEplace }, [eplaceId]);
|
||||
let { newEplace, updatedEplace } = updateEplace(hero.ePlace, ePlaceId, update);
|
||||
hero = await calPlayerCeAndSave(HERO_SYSTEM_TYPE.EQUIP_QUALITY, sid, roleId, hero, { ePlace: newEplace }, [ePlaceId]);
|
||||
|
||||
// TODO 任务
|
||||
const curHero = {
|
||||
@@ -214,17 +214,17 @@ export class EquipHandler {
|
||||
}
|
||||
|
||||
// 装备升星
|
||||
public async starUp(msg: { hid: number, eplaceId: number, isOneClick: boolean }, session: BackendSession) {
|
||||
public async starUp(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 { hid, ePlaceId, isOneClick } = msg;
|
||||
let hero = await HeroModel.findByHidAndRole(hid, roleId);
|
||||
if (!hero) return resResult(STATUS.HERO_NOT_FIND);
|
||||
|
||||
let curEquip = hero.ePlace?.find(cur => cur.id == eplaceId);
|
||||
let curEquip = hero.ePlace?.find(cur => cur.id == ePlaceId);
|
||||
if(!curEquip) return resResult(STATUS.EQUIP_NOT_FIND);
|
||||
|
||||
let update = {
|
||||
@@ -266,8 +266,8 @@ export class EquipHandler {
|
||||
return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
|
||||
}
|
||||
|
||||
let { newEplace, updatedEplace } = updateEplace(hero.ePlace, eplaceId, update);
|
||||
hero = await calPlayerCeAndSave(HERO_SYSTEM_TYPE.EQUIP_STAR, sid, roleId, hero, { ePlace: newEplace }, [eplaceId]);
|
||||
let { newEplace, updatedEplace } = updateEplace(hero.ePlace, ePlaceId, update);
|
||||
hero = await calPlayerCeAndSave(HERO_SYSTEM_TYPE.EQUIP_STAR, sid, roleId, hero, { ePlace: newEplace }, [ePlaceId]);
|
||||
|
||||
// TODO 任务
|
||||
|
||||
@@ -281,15 +281,15 @@ export class EquipHandler {
|
||||
}
|
||||
|
||||
//镶嵌天晶石
|
||||
public async putOnJewel(msg: { hid: number, eplaceId: number, jewel: number }, session: BackendSession) {
|
||||
let { hid, eplaceId, jewel: seqId } = msg;
|
||||
public async putOnJewel(msg: { hid: number, ePlaceId: number, jewel: number }, session: BackendSession) {
|
||||
let { hid, ePlaceId, jewel: seqId } = msg;
|
||||
let roleId: string = session.get('roleId');
|
||||
let sid: string = session.get('sid');
|
||||
|
||||
let hero = await HeroModel.findByHidAndRole(hid, roleId);
|
||||
if (!hero) return resResult(STATUS.HERO_NOT_FIND);
|
||||
|
||||
let curEquip = hero.ePlace?.find(cur => cur.id == eplaceId);
|
||||
let curEquip = hero.ePlace?.find(cur => cur.id == ePlaceId);
|
||||
if(!curEquip) return resResult(STATUS.EQUIP_NOT_FIND);
|
||||
let jewel = await JewelModel.findbySeqId(seqId);
|
||||
if(!jewel) return resResult(STATUS.JEWEL_IS_NOT_FIND);
|
||||
@@ -307,19 +307,19 @@ export class EquipHandler {
|
||||
if(originEquip) {
|
||||
let canChange = originJewel && checkJewelCanPutOnEquip(originEquip, originJewel);
|
||||
if(canChange) canSentMineToOrigin = true;
|
||||
let { newEplace, updatedEplace } = updateEplace(originHero.ePlace, eplaceId, { jewel: canChange? originJewel.seqId: 0 });
|
||||
await calPlayerCeAndSave(HERO_SYSTEM_TYPE.EQUIP_JEWEL, sid, roleId, originHero, { ePlace: newEplace }, [eplaceId]);
|
||||
let { newEplace, updatedEplace } = updateEplace(originHero.ePlace, ePlaceId, { jewel: canChange? originJewel.seqId: 0 });
|
||||
await calPlayerCeAndSave(HERO_SYSTEM_TYPE.EQUIP_JEWEL, sid, roleId, originHero, { ePlace: newEplace }, [ePlaceId], { oldJewel: jewel, newJewel: canChange? originJewel:null });
|
||||
originHeroResult = { hid: originHero.hid, ePlace: updatedEplace };
|
||||
}
|
||||
}
|
||||
if(originJewel) { // 更新自己的天晶石
|
||||
await JewelModel.putOnOrOff(originJewel.seqId, canSentMineToOrigin? jewel.hid: 0, canSentMineToOrigin? eplaceId: 0);
|
||||
await JewelModel.putOnOrOff(originJewel.seqId, canSentMineToOrigin? jewel.hid: 0, canSentMineToOrigin? ePlaceId: 0);
|
||||
}
|
||||
|
||||
// 目标镶嵌上
|
||||
let curJewel = await JewelModel.putOnOrOff(seqId, hid, eplaceId);
|
||||
let { newEplace, updatedEplace } = updateEplace(hero.ePlace, eplaceId, { jewel: seqId });
|
||||
await calPlayerCeAndSave(HERO_SYSTEM_TYPE.EQUIP_JEWEL, sid, roleId, hero, { ePlace: newEplace }, [eplaceId]);
|
||||
let curJewel = await JewelModel.putOnOrOff(seqId, hid, ePlaceId);
|
||||
let { newEplace, updatedEplace } = updateEplace(hero.ePlace, ePlaceId, { jewel: seqId });
|
||||
await calPlayerCeAndSave(HERO_SYSTEM_TYPE.EQUIP_JEWEL, sid, roleId, hero, { ePlace: newEplace }, [ePlaceId], { oldJewel: originJewel, newJewel: curJewel });
|
||||
let curHero = {
|
||||
hid,
|
||||
eplace: updatedEplace
|
||||
@@ -329,21 +329,21 @@ export class EquipHandler {
|
||||
}
|
||||
|
||||
// 卸下天晶石
|
||||
public async putOffJewel(msg: { hid: number, eplaceId: number }, session: BackendSession) {
|
||||
let { hid, eplaceId } = msg;
|
||||
public async putOffJewel(msg: { hid: number, ePlaceId: number }, session: BackendSession) {
|
||||
let { hid, ePlaceId } = msg;
|
||||
let roleId: string = session.get('roleId');
|
||||
let sid: string = session.get('sid');
|
||||
|
||||
let hero = await HeroModel.findByHidAndRole(hid, roleId);
|
||||
if (!hero) return resResult(STATUS.HERO_NOT_FIND);
|
||||
|
||||
let curEquip = hero.ePlace?.find(cur => cur.id == eplaceId);
|
||||
let curEquip = hero.ePlace?.find(cur => cur.id == ePlaceId);
|
||||
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(hero.ePlace, eplaceId, { jewel: 0 });
|
||||
await calPlayerCeAndSave(HERO_SYSTEM_TYPE.EQUIP_JEWEL, sid, roleId, hero, { ePlace: newEplace }, [eplaceId]);
|
||||
let { newEplace, updatedEplace } = updateEplace(hero.ePlace, ePlaceId, { jewel: 0 });
|
||||
await calPlayerCeAndSave(HERO_SYSTEM_TYPE.EQUIP_JEWEL, sid, roleId, hero, { ePlace: newEplace }, [ePlaceId]);
|
||||
let curHero = {
|
||||
hid,
|
||||
eplace: updatedEplace
|
||||
@@ -353,8 +353,8 @@ export class EquipHandler {
|
||||
}
|
||||
|
||||
// 装备或卸载地玉石
|
||||
public async putOnOrOffStone(msg: { hid: number, eplaceId: number, stonesId: number, gid: number }, session: BackendSession) {
|
||||
let { hid, eplaceId, stonesId, gid } = msg;
|
||||
public async putOnOrOffStone(msg: { hid: number, ePlaceId: number, stonesId: number, gid: number }, session: BackendSession) {
|
||||
let { hid, ePlaceId, stonesId, gid } = msg;
|
||||
let roleId: string = session.get('roleId');
|
||||
let roleName: string = session.get('roleName');
|
||||
let sid: string = session.get('sid');
|
||||
@@ -362,7 +362,7 @@ export class EquipHandler {
|
||||
let hero = await HeroModel.findByHidAndRole(hid, roleId);
|
||||
if (!hero) return resResult(STATUS.HERO_NOT_FIND);
|
||||
|
||||
let curEquip = hero.ePlace?.find(cur => cur.id == eplaceId);
|
||||
let curEquip = hero.ePlace?.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 };
|
||||
@@ -381,8 +381,9 @@ export class EquipHandler {
|
||||
}
|
||||
|
||||
let newStone = updateStone(curEquip.stones, stonesId, gid);
|
||||
let { newEplace, updatedEplace } = updateEplace(hero.ePlace, eplaceId, { stones: newStone });
|
||||
await calPlayerCeAndSave(HERO_SYSTEM_TYPE.EQUIP_STONE, sid, roleId, hero, { ePlace: newEplace }, [eplaceId]);
|
||||
let { newEplace, updatedEplace } = updateEplace(hero.ePlace, ePlaceId, { stones: newStone });
|
||||
let jewel = await JewelModel.findbySeqId(curEquip.jewel);
|
||||
await calPlayerCeAndSave(HERO_SYSTEM_TYPE.EQUIP_STONE, sid, roleId, hero, { ePlace: newEplace }, [ePlaceId], { jewel });
|
||||
let curHero = {
|
||||
hid,
|
||||
eplace: updatedEplace
|
||||
@@ -390,160 +391,155 @@ export class EquipHandler {
|
||||
|
||||
return resResult(STATUS.SUCCESS, { curHero });
|
||||
}
|
||||
|
||||
|
||||
// // 装备洗炼锁定
|
||||
// public async lockRandSe(msg: { eid: number, id: number, lock: boolean }, session: BackendSession) {
|
||||
// let roleId: string = session.get('roleId');
|
||||
// // let roleName: string = session.get('roleName');
|
||||
// let sid: string = session.get('sid');
|
||||
// 随机属性锁定
|
||||
public async lockRandSe(msg: { seqId: number, randSeId: number, type: number }, session: BackendSession) {
|
||||
let { seqId, randSeId, type } = msg;
|
||||
let roleId: string = session.get('roleId');
|
||||
let roleName: string = session.get('roleName');
|
||||
let sid: string = session.get('sid');
|
||||
|
||||
// let { eid, id, lock } = msg;
|
||||
// let equip = await EquipModel.findbySeqId(eid);
|
||||
// if (!equip) return resResult(STATUS.EQUIP_NOT_FIND);
|
||||
let jewel = await JewelModel.findbySeqId(seqId);
|
||||
if(!jewel) return resResult(STATUS.JEWEL_NOT_FOUND);
|
||||
|
||||
// let { randSe } = equip;
|
||||
// if (!randSe || randSe.length <= 0) {
|
||||
// return resResult(STATUS.ROLE_EQUIP_HAVE_NO_RANDSE);
|
||||
// }
|
||||
// let curSe = randSe.find(cur => cur.id == id);
|
||||
// if (!curSe || lock == curSe.locked) {
|
||||
// return resResult(STATUS.ROLE_EQUIP_DUPLICATE_LOCK);
|
||||
// }
|
||||
let { randSe } = jewel;
|
||||
if (!randSe || randSe.length <= 0) {
|
||||
return resResult(STATUS.JEWEL_HAVE_NO_RANDSE);
|
||||
}
|
||||
let curSe = randSe.find(cur => cur.id == randSeId);
|
||||
if (!curSe || (type == 1 && curSe.locked)) {
|
||||
return resResult(STATUS.JEWEL_DUPLICATE_LOCK);
|
||||
}
|
||||
|
||||
// if (lock) { // 仅在上锁时消耗,根据已有的锁的数量判断消耗
|
||||
// let lockNum = randSe.filter(cur => cur.locked).length;
|
||||
// let consumes: Array<{ id: number, count: number }> = [];
|
||||
// if (lockNum == 0) {
|
||||
// consumes = parseGoodStr(EQUIP.EQUIP_ONE_LOCKED);
|
||||
// } else if (lockNum == 1) {
|
||||
// consumes = parseGoodStr(EQUIP.EQUIP_TWO_LOCKED);
|
||||
// } else if (lockNum == 2) {
|
||||
// consumes = parseGoodStr(EQUIP.EQUIP_THREE_LOCKED);
|
||||
// } else {
|
||||
// return resResult(STATUS.ROLE_ALL_SE_LOCK);
|
||||
// }
|
||||
// let result = await handleCost(roleId, sid, consumes, ITEM_CHANGE_REASON.EQUIP_LOCK_RANDSE);
|
||||
// if (!result) return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
|
||||
// }
|
||||
if (type == 1) { // 仅在上锁时消耗,根据已有的锁的数量判断消耗
|
||||
let lockNum = randSe.filter(cur => cur.locked).length;
|
||||
let consumes: Array<{ id: number, count: number }> = [];
|
||||
if (lockNum == 0) {
|
||||
consumes = parseGoodStr(EQUIP.EQUIP_ONE_LOCKED);
|
||||
} else if (lockNum == 1) {
|
||||
consumes = parseGoodStr(EQUIP.EQUIP_TWO_LOCKED);
|
||||
} else if (lockNum == 2) {
|
||||
consumes = parseGoodStr(EQUIP.EQUIP_THREE_LOCKED);
|
||||
} else {
|
||||
return resResult(STATUS.ROLE_ALL_SE_LOCK);
|
||||
}
|
||||
let result = await handleCost(roleId, sid, consumes, ITEM_CHANGE_REASON.EQUIP_LOCK_RANDSE);
|
||||
if (!result) return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
|
||||
}
|
||||
|
||||
// let result = await EquipModel.lock(roleId, eid, id, lock);
|
||||
// if (!result) {
|
||||
// return resResult(STATUS.ROLE_EQUIP_HAVE_NO_RANDSE);
|
||||
// }
|
||||
// return resResult(STATUS.SUCCESS, { curEquip: result });
|
||||
let result = await JewelModel.lock(seqId, randSeId, type == 1);
|
||||
if (!result) {
|
||||
return resResult(STATUS.JEWEL_HAVE_NO_RANDSE);
|
||||
}
|
||||
return resResult(STATUS.SUCCESS, { curJewel: pick(result, ['seqId', 'id', 'hid', 'ePlaceId', 'randSe']) });
|
||||
|
||||
// }
|
||||
}
|
||||
|
||||
// // 装备洗炼预览
|
||||
// public async previewStrengthen(msg: { eid: number }, session: BackendSession) {
|
||||
// 装备洗炼预览
|
||||
public async previewRandSe(msg: { seqId: number }, session: BackendSession) {
|
||||
|
||||
// let roleId: string = session.get('roleId');
|
||||
// // let roleName: string = session.get('roleName');
|
||||
// let sid: string = session.get('sid');
|
||||
let roleId: string = session.get('roleId');
|
||||
// let roleName: string = session.get('roleName');
|
||||
let sid: string = session.get('sid');
|
||||
|
||||
// let { eid } = msg;
|
||||
// let equip = await EquipModel.findbySeqId(eid);
|
||||
// if (!equip) return resResult(STATUS.EQUIP_NOT_FIND);
|
||||
let { seqId } = msg;
|
||||
let jewel = await JewelModel.findbySeqId(seqId);
|
||||
if(!jewel) return resResult(STATUS.JEWEL_NOT_FOUND);
|
||||
|
||||
// let { id, randSe, previewRandSe } = equip;
|
||||
// if(previewRandSe.length <= 0) {
|
||||
let { id, randSe, previewRandSe } = jewel;
|
||||
if(previewRandSe.length <= 0) {
|
||||
|
||||
// if (!randSe || randSe.length <= 0) {
|
||||
// return resResult(STATUS.ROLE_EQUIP_HAVE_NO_RANDSE);
|
||||
// }
|
||||
// let previewRandSe = getRandSeResult(id, randSe);
|
||||
// if(!previewRandSe) return resResult(STATUS.DIC_DATA_NOT_FOUND);
|
||||
if (!randSe || randSe.length <= 0) {
|
||||
return resResult(STATUS.ROLE_EQUIP_HAVE_NO_RANDSE);
|
||||
}
|
||||
let previewRandSe = getRandSeResult(id, randSe);
|
||||
if(!previewRandSe) return resResult(STATUS.DIC_DATA_NOT_FOUND);
|
||||
|
||||
// let lockNum = randSe.reduce((pre, cur) => {
|
||||
// return cur.locked? pre + 1: pre;
|
||||
// }, 0);
|
||||
let lockNum = randSe.reduce((pre, cur) => {
|
||||
return cur.locked? pre + 1: pre;
|
||||
}, 0);
|
||||
|
||||
// if (lockNum >= randSe.length) {
|
||||
// return resResult(STATUS.ROLE_EQUIP_CANNOT_RESTRENGTHEN);
|
||||
// }
|
||||
// // 消耗
|
||||
// let consumes: Array<{ id: number, count: number }> = [];
|
||||
// if (lockNum == 0) {
|
||||
// consumes = parseGoodStr(EQUIP.EQUIP_ONE_REFORGED);
|
||||
// } else if (lockNum == 1) {
|
||||
// consumes = parseGoodStr(EQUIP.EQUIP_TWO_REFORGED);
|
||||
// } else if (lockNum == 2) {
|
||||
// consumes = parseGoodStr(EQUIP.EQUIP_THREE_REFORGED);
|
||||
// } else {
|
||||
// consumes = parseGoodStr(EQUIP.EQUIP_FOUR_REFORGED);
|
||||
// }
|
||||
if (lockNum >= randSe.length) {
|
||||
return resResult(STATUS.ROLE_EQUIP_CANNOT_RESTRENGTHEN);
|
||||
}
|
||||
// 消耗
|
||||
let consumes: Array<{ id: number, count: number }> = [];
|
||||
if (lockNum == 0) {
|
||||
consumes = parseGoodStr(EQUIP.EQUIP_ONE_REFORGED);
|
||||
} else if (lockNum == 1) {
|
||||
consumes = parseGoodStr(EQUIP.EQUIP_TWO_REFORGED);
|
||||
} else if (lockNum == 2) {
|
||||
consumes = parseGoodStr(EQUIP.EQUIP_THREE_REFORGED);
|
||||
} else {
|
||||
consumes = parseGoodStr(EQUIP.EQUIP_FOUR_REFORGED);
|
||||
}
|
||||
|
||||
// let result = await handleCost(roleId, sid, consumes, ITEM_CHANGE_REASON.EQUIP_RESTRENGTHEN);
|
||||
// if (!result) return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
|
||||
let result = await handleCost(roleId, sid, consumes, ITEM_CHANGE_REASON.EQUIP_RESTRENGTHEN);
|
||||
if (!result) return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
|
||||
|
||||
// equip = await EquipModel.updateEquipInfo(eid, { previewRandSe });
|
||||
// }
|
||||
jewel = await JewelModel.updateInfo(seqId, { previewRandSe });
|
||||
}
|
||||
|
||||
|
||||
// return resResult(STATUS.SUCCESS, { curEquip: pick(equip, ['seqId', 'id', 'randSe', 'previewRandSe']) });
|
||||
return resResult(STATUS.SUCCESS, { curEquip: pick(jewel, ['seqId', 'id', 'hid', 'ePlaceId', 'randSe', 'previewRandSe']) });
|
||||
|
||||
// }
|
||||
}
|
||||
|
||||
// // 装备洗炼
|
||||
// public async reStrengthen(msg: { eid: number }, session: BackendSession) {
|
||||
// let roleId: string = session.get('roleId');
|
||||
// // let roleName: string = session.get('roleName');
|
||||
// let sid: string = session.get('sid');
|
||||
// 装备洗炼
|
||||
public async resetRandSe(msg: { seqId: number }, session: BackendSession) {
|
||||
let roleId: string = session.get('roleId');
|
||||
// let roleName: string = session.get('roleName');
|
||||
let sid: string = session.get('sid');
|
||||
|
||||
|
||||
// let { eid } = msg;
|
||||
// let equip = await EquipModel.findbySeqId(eid);
|
||||
// if (!equip) return resResult(STATUS.EQUIP_NOT_FIND);
|
||||
let { seqId } = msg;
|
||||
let jewel = await JewelModel.findbySeqId(seqId);
|
||||
if(!jewel) return resResult(STATUS.JEWEL_NOT_FOUND);
|
||||
|
||||
// let { randSe, hid, ePlaceId, previewRandSe } = equip;
|
||||
// if (!randSe || randSe.length <= 0) {
|
||||
// return resResult(STATUS.ROLE_EQUIP_HAVE_NO_RANDSE);
|
||||
// }
|
||||
let { randSe, hid, ePlaceId, previewRandSe } = jewel;
|
||||
if (!randSe || randSe.length <= 0) {
|
||||
return resResult(STATUS.JEWEL_HAVE_NO_RANDSE);
|
||||
}
|
||||
|
||||
// if(!previewRandSe) { // 没预览过
|
||||
// return resResult(STATUS.EQUIP_RESTRENGTHEN_NOT_PREVIEW);
|
||||
// }
|
||||
if(!previewRandSe) { // 没预览过
|
||||
return resResult(STATUS.EQUIP_RESTRENGTHEN_NOT_PREVIEW);
|
||||
}
|
||||
|
||||
// let removeSeidList = randSe.reduce((pre, cur) => {
|
||||
// return [...pre, cur.seid];
|
||||
// }, <number[]>[]);
|
||||
let newJewel = await JewelModel.updateInfo(seqId, { previewRandSe: [], randSe: previewRandSe });
|
||||
// 更新战力
|
||||
if(hid > 0) {
|
||||
const hero = await HeroModel.findByHidAndRole(hid, roleId);
|
||||
await calPlayerCeAndSave(HERO_SYSTEM_TYPE.JEWEL_RESET_RANDSE, sid, roleId, hero, {}, [ePlaceId], { oldJewel: jewel, newJewel });
|
||||
}
|
||||
|
||||
// let equipResult = await EquipModel.updateEquipInfo(eid, { randSe: previewRandSe, previewRandSe: [] })
|
||||
|
||||
// // 更新战力
|
||||
// if(hid > 0) {
|
||||
// const hero = await HeroModel.findByHidAndRoleWithEquip(hid, roleId);
|
||||
// await calPlayerCeAndSave(HERO_SYSTEM_TYPE.RESTRENGTHEN, sid, roleId, hero, {}, [ePlaceId, ...removeSeidList]);
|
||||
// }
|
||||
|
||||
// await checkTask(roleId, sid, TASK_TYPE.EQUIP_RESTRENGTHEN, 1, true, {});
|
||||
// TODO 任务
|
||||
// await checkTask(roleId, sid, TASK_TYPE.EQUIP_RESTRENGTHEN, 1, true, {});
|
||||
|
||||
// return resResult(STATUS.SUCCESS, { curEquip: pick(equipResult, ['seqId', 'id', 'randSe', 'previewRandSe']) });
|
||||
return resResult(STATUS.SUCCESS, { curJewel: pick(newJewel, ['seqId', 'id', 'hid', 'ePlaceId', 'randSe', 'previewRandSe']) });
|
||||
|
||||
// }
|
||||
}
|
||||
|
||||
// // 放弃这条洗练
|
||||
// public async giveupStrengthen(msg: { eid: number }, session: BackendSession) {
|
||||
// 放弃这条洗练
|
||||
public async giveupPreview(msg: { seqId: number }, session: BackendSession) {
|
||||
|
||||
// let { eid } = msg;
|
||||
// let equip = await EquipModel.findbySeqId(eid);
|
||||
// if (!equip) return resResult(STATUS.EQUIP_NOT_FIND);
|
||||
let { seqId } = msg;
|
||||
let jewel = await JewelModel.findbySeqId(seqId);
|
||||
if(!jewel) return resResult(STATUS.JEWEL_NOT_FOUND);
|
||||
|
||||
// let { randSe, previewRandSe } = equip;
|
||||
// if (!randSe || randSe.length <= 0) {
|
||||
// return resResult(STATUS.ROLE_EQUIP_HAVE_NO_RANDSE);
|
||||
// }
|
||||
let { randSe, previewRandSe } = jewel;
|
||||
if (!randSe || randSe.length <= 0) {
|
||||
return resResult(STATUS.JEWEL_HAVE_NO_RANDSE);
|
||||
}
|
||||
|
||||
// if(!previewRandSe) { // 没预览过
|
||||
// return resResult(STATUS.EQUIP_RESTRENGTHEN_NOT_PREVIEW);
|
||||
// }
|
||||
if(!previewRandSe) { // 没预览过
|
||||
return resResult(STATUS.JEWEL_NOT_PREVIEW);
|
||||
}
|
||||
|
||||
// let equipResult = await EquipModel.updateEquipInfo(eid, { previewRandSe: [] })
|
||||
let jewelResult = await JewelModel.updateInfo(seqId, { previewRandSe: [] })
|
||||
|
||||
// return resResult(STATUS.SUCCESS, { curEquip: pick(equipResult, ['seqId', 'id', 'randSe', 'previewRandSe']) });
|
||||
return resResult(STATUS.SUCCESS, { curJewel: pick(jewelResult, ['seqId', 'id', 'hid', 'ePlaceId', 'randSe', 'previewRandSe']) });
|
||||
|
||||
// }
|
||||
}
|
||||
|
||||
// // 淬火
|
||||
// public async quench(msg: { eid: number, type: QUENCH_TYPE }, session: BackendSession) {
|
||||
|
||||
Reference in New Issue
Block a user