|
|
|
|
@@ -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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|