From 121f5de8fdedec1aa5a628dbc7d627da2170d648 Mon Sep 17 00:00:00 2001 From: zhangxk Date: Fri, 13 Oct 2023 22:28:46 +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=E7=BE=81=E7=BB=8A=E3=80=81?= =?UTF-8?q?=E5=A4=A9=E6=99=B6=E7=BB=B4=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/services/role/resonanceService.ts | 74 +++++++++++++++---- 1 file changed, 58 insertions(+), 16 deletions(-) diff --git a/game-server/app/services/role/resonanceService.ts b/game-server/app/services/role/resonanceService.ts index 19248ce75..093c5d7bb 100644 --- a/game-server/app/services/role/resonanceService.ts +++ b/game-server/app/services/role/resonanceService.ts @@ -67,10 +67,9 @@ export async function refreshResonanceData(roleId: string, serverId: number, sid for (let index = 1; index <= FRIENDSHIP_INDEX.THREE; 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); + const topShipData = (topLineHero.connections || []).find(cur => cur.shipId == topDicShipId); + resonanceCon.push({ hid: topLineHero.hid, index, level: topShipData?.level || 0 }); if (!topShipData) continue; for (let [hid] of dbResonanceMap) { @@ -78,11 +77,27 @@ export async function refreshResonanceData(roleId: string, serverId: number, sid const dicShipId = gameData.friendShipByIndex.get(`${hero.hid}_${index}`) let shipData = hero.connections.find(cur => cur.shipId == dicShipId); - 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; + console.log('x-x-x-x-x- hid', hid) + console.log('x-x-x-x-x- dicShipId', dicShipId) + console.log('x-x-x-x-x- shipData?.shipId', shipData?.shipId) + console.log('x-x-x-x-x- shipData?.level', shipData?.level) + + const dicShipData = gameData.friendShipsByLv.get(`${hid}_${dicShipId}_${topShipData?.level || 0}`); + let sign = true; + for (let hi of dicShipData?.hids || []) { + if (!dbHeroes.find(cur => cur.hid == hi)) { + sign = false; + break; + } + } + if (!sign) continue; + if (!shipData) hero.connections.push({ shipId: dicShipId, level: topShipData?.level || 0, exp: topShipData?.exp || 0 }); + else { + shipData.shipId = dicShipId + shipData.exp = topShipData?.exp || 0; + shipData.level = topShipData?.level || 0; + } + } } @@ -118,13 +133,15 @@ export async function refreshResonanceData(roleId: string, serverId: number, sid 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; + 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; } //装备精练 @@ -137,13 +154,15 @@ export async function refreshResonanceData(roleId: string, serverId: number, sid 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; + 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; } //天晶 @@ -165,6 +184,7 @@ export async function refreshResonanceData(roleId: string, serverId: number, sid hero.ePlace.push({ ...await getInitEplace(id, hero.skinId) }); ePlaceData = hero.ePlace.find(cur => cur.id == id); }; + ePlaceData.jewel = topLineHeroEplace.jewel; } } @@ -244,8 +264,11 @@ export function sortData(dbResonanceMap: Map, heroes: Her case RESONANCE_SORT_TYPE.JOBSTAGE: { heroes.sort((a, b) => { - if (a.job != b.job) { - return b.job - a.job; + let gradeA = gameData.job.get(a.job)?.grade || 0; + let gradeB = gameData.job.get(b.job)?.grade || 0; + + if (gradeA != gradeB) { + return gradeB - gradeA; } else if (a.jobStage !== b.jobStage) { return b.jobStage - a.jobStage; @@ -280,6 +303,9 @@ export function sortData(dbResonanceMap: Map, heroes: Her case RESONANCE_SORT_TYPE.JEWEL: { heroes = sortByEquipJewel(heroes, findType, jewelMap); + // if (findType == 3) { + // console.log('-x-x--x-x-x-x-x-x-x-x-x- topLineHeroes', util.inspect(heroes, { depth: null })); + // } break; } case RESONANCE_SORT_TYPE.STONE: @@ -383,7 +409,7 @@ export function sortByEquipJewel(heroes: HeroType[], eplaceId: number, jewelMap: let dicRandomEffectPool = gameData.randomEffectPool.get(seid); if (!dicRandomEffectPool) continue; if (!dicRandomEffectPool.Max) dicRandomEffectPool = gameData.randomEffectPool.get(1); - if (!dicRandomEffectPool || (dicRandomEffectPool?.Max || 0 == 0)) continue; + if (!dicRandomEffectPool || ((dicRandomEffectPool?.Max || 0) == 0)) continue; valA += rand / (dicRandomEffectPool.Max); } } @@ -392,7 +418,7 @@ export function sortByEquipJewel(heroes: HeroType[], eplaceId: number, jewelMap: let dicRandomEffectPool = gameData.randomEffectPool.get(seid); if (!dicRandomEffectPool) continue; if (!dicRandomEffectPool.Max) dicRandomEffectPool = gameData.randomEffectPool.get(1); - if (!dicRandomEffectPool || (dicRandomEffectPool?.Max || 0 == 0)) continue; + if (!dicRandomEffectPool || ((dicRandomEffectPool?.Max || 0) == 0)) continue; valA += rand / (dicRandomEffectPool.Max); } } @@ -406,9 +432,10 @@ export function sortByEquipJewel(heroes: HeroType[], eplaceId: number, jewelMap: if (jewelBData.randSe && jewelBData.randSe.length > 0) { for (let { seid, rand } of jewelBData.randSe) { let dicRandomEffectPool = gameData.randomEffectPool.get(seid); + if (!dicRandomEffectPool) continue; if (!dicRandomEffectPool.Max) dicRandomEffectPool = gameData.randomEffectPool.get(1); - if (!dicRandomEffectPool || (dicRandomEffectPool?.Max || 0 == 0)) continue; + if (!dicRandomEffectPool || (dicRandomEffectPool?.Max || 0) == 0) continue; valB += rand / (dicRandomEffectPool.Max); } } @@ -417,11 +444,26 @@ export function sortByEquipJewel(heroes: HeroType[], eplaceId: number, jewelMap: let dicRandomEffectPool = gameData.randomEffectPool.get(seid); if (!dicRandomEffectPool) continue; if (!dicRandomEffectPool.Max) dicRandomEffectPool = gameData.randomEffectPool.get(1); - if (!dicRandomEffectPool || (dicRandomEffectPool?.Max || 0 == 0)) continue; + if (!dicRandomEffectPool || (dicRandomEffectPool?.Max || 0) == 0) continue; valB += rand / (dicRandomEffectPool.Max); } } } + // if (eplaceId == 3) { + // console.log('-------------------------------------------------------------------'); + + // console.log('--------------------------------hid', a.hid); + // console.log('--------------------------------dicJewelALv', dicJewelALv); + // console.log('--------------------------------valA', valA); + // console.log('--------------------------------ceA', a.ce); + // console.log('-------------------------------------------------------------------'); + + // console.log('--------------------------------hid', b.hid); + // console.log('--------------------------------dicJewelBLv', dicJewelBLv); + // console.log('--------------------------------valB', valB); + // console.log('--------------------------------ceB', b.ce); + // } + if (dicJewelALv != dicJewelBLv) { return dicJewelBLv - dicJewelALv;