🐞 fix(共鸣系统):修改数据下发
This commit is contained in:
@@ -20,7 +20,7 @@ import * as util from 'util';
|
||||
|
||||
export async function refreshResonanceData(roleId: string, serverId: number, sid: string) {
|
||||
let resonanceDatas: ReturnResonanceParam[] = [];
|
||||
let resonanceLv = {}, resonanceJob = {}, resonanceCon = [], resonanceEquip = [];
|
||||
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 };
|
||||
@@ -30,7 +30,7 @@ export async function refreshResonanceData(roleId: string, serverId: number, sid
|
||||
for (let position of newPositionArr) {
|
||||
resonanceDatas.push({ position });
|
||||
}
|
||||
if (dbResonanceMap.size == 0) return { resonanceDatas };
|
||||
// if (dbResonanceMap.size == 0) return { resonanceDatas };
|
||||
|
||||
let dbJewelMap = await getJewelDataMap(dbHeroes);
|
||||
|
||||
@@ -101,6 +101,7 @@ 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);
|
||||
@@ -117,6 +118,7 @@ export async function refreshResonanceData(roleId: string, serverId: number, sid
|
||||
|
||||
//装备精练
|
||||
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);
|
||||
@@ -134,6 +136,7 @@ export async function refreshResonanceData(roleId: string, serverId: number, sid
|
||||
//天晶
|
||||
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 })
|
||||
//破,御,护,命
|
||||
for (let [hid] of dbResonanceMap) {
|
||||
let hero = dbHeroes.find(cur => cur.hid == hid);
|
||||
@@ -152,8 +155,11 @@ export async function refreshResonanceData(roleId: string, serverId: number, sid
|
||||
//地玉
|
||||
if (RESONANCE.STONE) {
|
||||
//破,御,护,命 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);
|
||||
resonanceStone.find(cur => cur.id == id).stones.push({ hid: topLineHero.hid, id: index, stone: 0 });
|
||||
|
||||
for (let [hid] of dbResonanceMap) {
|
||||
let hero = dbHeroes.find(cur => cur.hid == hid);
|
||||
const topLineHeroEplace = topLineHero.ePlace.find(cur => cur.id == id);
|
||||
@@ -167,6 +173,7 @@ export async function refreshResonanceData(roleId: string, serverId: number, sid
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -184,17 +191,19 @@ export async function refreshResonanceData(roleId: string, serverId: number, sid
|
||||
await HeroModel.bulkWriteUpdate(updateHeroes)
|
||||
|
||||
// 重新计算战力
|
||||
let artifacts = await ArtifactModel.findbyHids(roleId, newHeroIds);
|
||||
let { heroes } = await calculateCeWithHeroes(HERO_SYSTEM_TYPE.REBORN_CAL, roleId, serverId, sid, newHeroes, { jewels: [...dbJewelMap.values()], heroes: newHeroes, artifacts });
|
||||
|
||||
for (let hero of (heroes || [])) {
|
||||
const { hid } = hero;
|
||||
const heroResult = new HeroParam(hero);
|
||||
if (!dbResonanceMap.has(hid)) continue;
|
||||
resonanceDatas.push({ position: dbResonanceMap.get(hid).position, ...pick(heroResult, ['hid', 'seqId', 'lv', 'exp', 'job', 'jobStage', 'talent', 'usedTalentPoint', 'totalTalentPoint', 'connections', 'ePlace', 'ce']) });
|
||||
if (newHeroes.length > 0) {
|
||||
let artifacts = await ArtifactModel.findbyHids(roleId, newHeroIds);
|
||||
let { heroes } = await calculateCeWithHeroes(HERO_SYSTEM_TYPE.RESONANCE_CAL, roleId, serverId, sid, newHeroes, { jewels: [...dbJewelMap.values()], heroes: newHeroes, artifacts });
|
||||
for (let hero of (heroes || [])) {
|
||||
const { hid } = hero;
|
||||
const heroResult = new HeroParam(hero);
|
||||
if (!dbResonanceMap.has(hid)) continue;
|
||||
resonanceDatas.push({ isResonance: true, position: dbResonanceMap.get(hid).position, ...pick(heroResult, ['hid', 'seqId', 'lv', 'exp', 'job', 'jobStage', 'talent', 'usedTalentPoint', 'totalTalentPoint', 'connections', 'ePlace', 'ce']) });
|
||||
}
|
||||
}
|
||||
|
||||
return { resonanceDatas, resonanceLv, resonanceJob, resonanceCon, resonanceEquip };
|
||||
|
||||
return { resonanceDatas, resonanceLv, resonanceJob, resonanceCon, resonanceEquip, resonanceEpQuality, resonanceEpStar, resonanceJewel, resonanceStone };
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user