From e4e692458b3e949c12bf7c2a43f5b2ee7b75d580 Mon Sep 17 00:00:00 2001 From: zhangxk Date: Thu, 12 Oct 2023 21:17:49 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9E=20fix(=E5=85=B1=E9=B8=A3=E7=B3=BB?= =?UTF-8?q?=E7=BB=9F):=20=E4=BF=AE=E6=94=B9=E9=B8=A3=E4=B8=BB=E6=8E=92?= =?UTF-8?q?=E5=BA=8F=EF=BC=8C=E4=BF=AE=E6=94=B9=E9=B8=A3=E4=B8=BB=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E5=B1=95=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/servers/role/handler/heroHandler.ts | 7 ++ .../servers/role/handler/resonanceHandler.ts | 2 +- .../app/services/role/resonanceService.ts | 111 +++++++++++------- shared/consts/statusCode.ts | 4 + 4 files changed, 78 insertions(+), 46 deletions(-) diff --git a/game-server/app/servers/role/handler/heroHandler.ts b/game-server/app/servers/role/handler/heroHandler.ts index 6e54cf5e4..d399b5612 100644 --- a/game-server/app/servers/role/handler/heroHandler.ts +++ b/game-server/app/servers/role/handler/heroHandler.ts @@ -617,6 +617,9 @@ export class HeroHandler { let { hid } = msg; if(!isNumber(hid) && !hid) return resResult(STATUS.WRONG_PARMS); + let { dbResonanceMap } = await getResonanceDataMap(roleId); + if(dbResonanceMap.has(hid)) return resResult(STATUS.RESONANCE__HID_NOT_REBIRTH); + // 武将初始,但是皮肤这里不初始 let hero = await HeroModel.findByHidAndRole(hid, roleId); if(!hero) return resResult(STATUS.HERO_NOT_FIND); @@ -831,6 +834,10 @@ export class HeroHandler { const { originHid, targetHid } = msg; + let { dbResonanceMap } = await getResonanceDataMap(roleId); + if(dbResonanceMap.has(originHid) || dbResonanceMap.has(targetHid)) return resResult(STATUS.RESONANCE__HID_NOT_REBIRTH); + + let dbHeros = await HeroModel.findByHidsAndRole(roleId, [originHid, targetHid]); if (dbHeros.length != 2) return resResult(STATUS.HERO_NOT_FIND); const heroMap = dbHeros.reduce((map, obj) => { map.set(obj.hid, obj); return map; }, new Map()); diff --git a/game-server/app/servers/role/handler/resonanceHandler.ts b/game-server/app/servers/role/handler/resonanceHandler.ts index f2264e064..8d8ada9e1 100644 --- a/game-server/app/servers/role/handler/resonanceHandler.ts +++ b/game-server/app/servers/role/handler/resonanceHandler.ts @@ -164,7 +164,7 @@ export class HeroHandler { const resonances = await refreshResonanceData(roleId, serverId, sid); return resResult(STATUS.SUCCESS, { - curHero: { ...pick(new HeroParam(curHero), ['hid', 'seqId', 'lv', 'exp', 'job', 'jobStage', 'skinId', 'skins', 'talent', 'usedTalentPoint', 'totalTalentPoint', 'connections', 'ePlace', 'ce']) }, + curHero: { isResonance: false, ...pick(new HeroParam(curHero), ['hid', 'seqId', 'lv', 'exp', 'job', 'jobStage', 'skinId', 'skins', 'talent', 'usedTalentPoint', 'totalTalentPoint', 'connections', 'ePlace', 'ce']) }, ...resonances, }) } diff --git a/game-server/app/services/role/resonanceService.ts b/game-server/app/services/role/resonanceService.ts index 899b8b1a0..9c6c4730e 100644 --- a/game-server/app/services/role/resonanceService.ts +++ b/game-server/app/services/role/resonanceService.ts @@ -23,7 +23,12 @@ export async function refreshResonanceData(roleId: string, serverId: number, sid let resonanceLv = {}, resonanceJob = {}, resonanceCon = [], resonanceEquip = [], resonanceEpQuality = [], resonanceEpStar = [], resonanceJewel = [], resonanceStone = []; let dbHeroes: HeroType[] = await HeroModel.findByRole(roleId, [{ field: 'ce', sortBy: -1 }]); - if (dbHeroes.length < LINEUP_NUM) return { resonanceDatas }; + let role = await RoleModel.findByRoleId(roleId); + let topLineHeroes: HeroType[] = []; + for (let top of role.topLineup) { + topLineHeroes.push(dbHeroes.find(cur => cur.hid == top.hid)); + } + if (topLineHeroes.length < LINEUP_NUM || dbHeroes.length < LINEUP_NUM) return { resonanceDatas }; let { dbResonanceMap, newPositionArr } = await getResonanceDataMap(roleId); @@ -35,7 +40,7 @@ export async function refreshResonanceData(roleId: string, serverId: number, sid let dbJewelMap = await getJewelDataMap(dbHeroes); // 武将等级 - let topLineHero: HeroType = sortData(dbResonanceMap, dbHeroes, RESONANCE_SORT_TYPE.LV); + let topLineHero: HeroType = sortData(dbResonanceMap, topLineHeroes, RESONANCE_SORT_TYPE.LV); resonanceLv = { hid: topLineHero.hid, lv: topLineHero.lv }; for (let [hid] of dbResonanceMap) { let hero = dbHeroes.find(cur => cur.hid == hid); @@ -44,7 +49,7 @@ export async function refreshResonanceData(roleId: string, serverId: number, sid } // 职业(职阶、天赋) - topLineHero = sortData(dbResonanceMap, dbHeroes, RESONANCE_SORT_TYPE.JOBSTAGE); + topLineHero = sortData(dbResonanceMap, topLineHeroes, RESONANCE_SORT_TYPE.JOBSTAGE); resonanceJob = { hid: topLineHero.hid, job: topLineHero.job, jobStage: topLineHero.jobStage }; for (let [hid] of dbResonanceMap) { let hero = dbHeroes.find(cur => cur.hid == hid); @@ -60,21 +65,22 @@ export async function refreshResonanceData(roleId: string, serverId: number, sid // 羁绊1, 2, 3 for (let index = 1; index <= FRIENDSHIP_INDEX.THREE; index++) { - topLineHero = sortData(dbResonanceMap, dbHeroes, RESONANCE_SORT_TYPE.CONNECT, index); + topLineHero = sortData(dbResonanceMap, topLineHeroes, RESONANCE_SORT_TYPE.CONNECT, index); + resonanceCon.push({ hid: topLineHero.hid, index, level: topLineHero.connections[index]?.level || 0 }); + + const topDicShipId = gameData.friendShipByIndex.get(`${topLineHero.hid}_${index}`); + const topShipData = topLineHero.connections.find(cur => cur.shipId == topDicShipId); + if (!topShipData) continue; + for (let [hid] of dbResonanceMap) { let hero = dbHeroes.find(cur => cur.hid == hid); - const topDicShipId = gameData.friendShipByIndex.get(`${topLineHero.hid}_${index}`); - const topShipData = topLineHero.connections.find(cur => cur.shipId == topDicShipId); - if (!topShipData) continue; const dicShipId = gameData.friendShipByIndex.get(`${hero.hid}_${index}`) let shipData = hero.connections.find(cur => cur.shipId == dicShipId); - if (!shipData) hero.connections.push({ shipId: dicShipId, level: topShipData.level, exp: topShipData.exp }); - else { - shipData.exp = topShipData.exp; - shipData.level = topShipData.level; - } + if (!shipData) continue; //hero.connections.push({ shipId: dicShipId, level: topShipData.level, exp: topShipData.exp }); + shipData.exp = topShipData.exp; + shipData.level = topShipData.level; let tempCon = resonanceCon.find(cur => cur.index == index); tempCon.level = topShipData.level; } @@ -84,13 +90,17 @@ export async function refreshResonanceData(roleId: string, serverId: number, sid for (let id = 1; id <= EQUIP_EPLACEID.SHOE_ID; id++) { //装备强化 - topLineHero = sortData(dbResonanceMap, dbHeroes, RESONANCE_SORT_TYPE.EQUIP_LV, id); - resonanceEquip.push({ hid: topLineHero.hid, id, lv: topLineHero.ePlace.find(cur => cur.id == id)?.lv || 0 }); - for (let [hid] of dbResonanceMap) { - let hero = dbHeroes.find(cur => cur.hid == hid); - const topLineHeroEplace = topLineHero.ePlace.find(cur => cur.id == id); - if (!topLineHeroEplace || !topLineHeroEplace.lv) continue; + topLineHero = sortData(dbResonanceMap, topLineHeroes, RESONANCE_SORT_TYPE.EQUIP_LV, id); + let topLineHeroEplace = topLineHero.ePlace.find(cur => cur.id == id); + resonanceEquip.push({ hid: topLineHero.hid, id, lv: 0 }); + if (topLineHeroEplace) + resonanceEquip.push({ hid: topLineHero.hid, id, lv: topLineHeroEplace?.lv || 0 }); + + + for (let [hid] of dbResonanceMap) { + if (!topLineHeroEplace || !topLineHeroEplace.lv) continue; + let hero = dbHeroes.find(cur => cur.hid == hid); let ePlaceData = hero.ePlace.find(cur => cur.id == id); if (!ePlaceData) { hero.ePlace.push({ ...await getInitEplace(id, hero.skinId) }); @@ -100,55 +110,60 @@ export async function refreshResonanceData(roleId: string, serverId: number, sid } //装备升品 - topLineHero = sortData(dbResonanceMap, dbHeroes, RESONANCE_SORT_TYPE.EQUIP_QUALITY, id); - resonanceEpQuality.push({ hid: topLineHero.hid, id, quality: topLineHero.quality, qualityStage: topLineHero.quality }) - for (let [hid] of dbResonanceMap) { - let hero = dbHeroes.find(cur => cur.hid == hid); - const topLineHeroEplace = topLineHero.ePlace.find(cur => cur.id == id); - if (!topLineHeroEplace || !topLineHeroEplace.quality) continue; + topLineHero = sortData(dbResonanceMap, topLineHeroes, RESONANCE_SORT_TYPE.EQUIP_QUALITY, id); + topLineHeroEplace = topLineHero.ePlace.find(cur => cur.id == id); + resonanceEpQuality.push({ hid: topLineHero.hid, id, quality: 0, qualityStage: 0 }) + if (topLineHeroEplace) + resonanceEpQuality.push({ hid: topLineHero.hid, id, quality: topLineHeroEplace?.quality || 0, qualityStage: topLineHeroEplace?.qualityStage || 0 }) + + + for (let [hid] of dbResonanceMap) { + if (!topLineHeroEplace && !topLineHeroEplace.quality || !topLineHeroEplace.qualityStage) continue; + let hero = dbHeroes.find(cur => cur.hid == hid); let ePlaceData = hero.ePlace.find(cur => cur.id == id); if (!ePlaceData) { hero.ePlace.push({ ...await getInitEplace(id, hero.skinId) }); ePlaceData = hero.ePlace.find(cur => cur.id == id); }; - ePlaceData.quality = topLineHeroEplace.quality; - ePlaceData.qualityStage = topLineHeroEplace.qualityStage; } //装备精练 - topLineHero = sortData(dbResonanceMap, dbHeroes, RESONANCE_SORT_TYPE.EQUIP_STAR, id); - resonanceEpStar.push({ hid: topLineHero.hid, id, star: topLineHero.star, starStage: topLineHero.starStage }) - for (let [hid] of dbResonanceMap) { - let hero = dbHeroes.find(cur => cur.hid == hid); - const topLineHeroEplace = topLineHero.ePlace.find(cur => cur.id == id); - if (!topLineHeroEplace || !topLineHeroEplace.star) continue; + topLineHero = sortData(dbResonanceMap, topLineHeroes, RESONANCE_SORT_TYPE.EQUIP_STAR, id); + topLineHeroEplace = topLineHero.ePlace.find(cur => cur.id == id); + resonanceEpStar.push({ hid: topLineHero.hid, id, star: 0, starStage: 0 }) + if (topLineHeroEplace) + resonanceEpStar.push({ hid: topLineHero.hid, id, star: topLineHeroEplace?.star || 0, starStage: topLineHeroEplace?.starStage || 0 }) + + for (let [hid] of dbResonanceMap) { + if (!topLineHeroEplace || !topLineHeroEplace.star || !topLineHeroEplace.starStage) continue; + let hero = dbHeroes.find(cur => cur.hid == hid); let ePlaceData = hero.ePlace.find(cur => cur.id == id); if (!ePlaceData) { hero.ePlace.push({ ...await getInitEplace(id, hero.skinId) }); ePlaceData = hero.ePlace.find(cur => cur.id == id); }; - ePlaceData.star = topLineHeroEplace.star; - ePlaceData.starStage = topLineHeroEplace.starStage; } //天晶 if (RESONANCE.JEWEL) { - topLineHero = sortData(dbResonanceMap, dbHeroes, RESONANCE_SORT_TYPE.JEWEL, id, dbJewelMap); - resonanceJewel.push({ hid: topLineHero.hid, id, jewel: topLineHero.ePlace.find(cur => cur.id == id)?.jewel || 0 }) + topLineHero = sortData(dbResonanceMap, topLineHeroes, RESONANCE_SORT_TYPE.JEWEL, id, dbJewelMap); + topLineHeroEplace = topLineHero.ePlace.find(cur => cur.id == id); + + resonanceJewel.push({ hid: topLineHero.hid, id, jewel: 0 }); + if (topLineHeroEplace) + resonanceJewel.push({ hid: topLineHero.hid, id, jewel: topLineHeroEplace?.jewel || 0 }); + //破,御,护,命 for (let [hid] of dbResonanceMap) { - let hero = dbHeroes.find(cur => cur.hid == hid); - const topLineHeroEplace = topLineHero.ePlace.find(cur => cur.id == id); if (!topLineHeroEplace || !topLineHeroEplace.jewel) continue; - + let hero = dbHeroes.find(cur => cur.hid == hid); let ePlaceData = hero.ePlace.find(cur => cur.id == id); if (!ePlaceData) { hero.ePlace.push({ ...await getInitEplace(id, hero.skinId) }); ePlaceData = hero.ePlace.find(cur => cur.id == id); }; - ePlaceData.jewel = topLineHeroEplace.jewel; } } @@ -157,23 +172,29 @@ export async function refreshResonanceData(roleId: string, serverId: number, sid //破,御,护,命 1,2,3 resonanceStone.push({ id, stones: [] }); for (let index = 1; index <= EQUIP_STONE.THREE; index++) { - topLineHero = sortData(dbResonanceMap, dbHeroes, RESONANCE_SORT_TYPE.STONE, id, null, index); + topLineHero = sortData(dbResonanceMap, topLineHeroes, RESONANCE_SORT_TYPE.STONE, id, null, index); + const topLineHeroEplace = topLineHero.ePlace.find(cur => cur.id == id); + resonanceStone.find(cur => cur.id == id).stones.push({ hid: topLineHero.hid, id: index, stone: 0 }); + if (topLineHeroEplace && topLineHeroEplace.stones) { + const topLineHeroStone = topLineHeroEplace.stones.find(cur => cur.id == index); + if (topLineHeroStone) + resonanceStone.find(cur => cur.id == id).stones.find(cur => cur.id == index).stone = topLineHeroStone.stone; + } + for (let [hid] of dbResonanceMap) { - let hero = dbHeroes.find(cur => cur.hid == hid); - const topLineHeroEplace = topLineHero.ePlace.find(cur => cur.id == id); - if (!topLineHeroEplace || !topLineHeroEplace.stones) continue; + if (!topLineHeroEplace && !topLineHeroEplace.stones) continue; const topLineHeroStone = topLineHeroEplace.stones.find(cur => cur.id == index); if (!topLineHeroStone || !topLineHeroStone.stone) continue; + let hero = dbHeroes.find(cur => cur.hid == hid); let ePlaceData = hero.ePlace.find(cur => cur.id == id); if (!ePlaceData) { hero.ePlace.push({ ...await getInitEplace(id, hero.skinId) }); ePlaceData = hero.ePlace.find(cur => cur.id == id); }; ePlaceData.stones.find(cur => cur.id == index).stone = topLineHeroStone.stone; - resonanceStone.find(cur => cur.id == id).stones.find(cur => cur.id == index).stone = topLineHeroStone.stone; } } } diff --git a/shared/consts/statusCode.ts b/shared/consts/statusCode.ts index 9c972dded..46d385ed0 100644 --- a/shared/consts/statusCode.ts +++ b/shared/consts/statusCode.ts @@ -846,6 +846,10 @@ export const STATUS = { RESONANCE_NOT_PUT_POSITION: { code: 81013, simStr: '该武将未在阵中' }, RESONANCE_OFF_POSITION_FAIL: { code: 81014, simStr: '该武将下阵失败' }, RESONANCE__HID_NOT_CAN: { code: 81015, simStr: '共鸣武将不可养成' }, + RESONANCE__HID_NOT_REBIRTH: { code: 81015, simStr: '共鸣武将不可重生' }, + RESONANCE__HID_NOT_REBORN: { code: 81015, simStr: '共鸣武将不可传承' }, + +