🐞 fix(共鸣系统):修改数据下发
This commit is contained in:
@@ -146,8 +146,9 @@ export async function getModuleData(type: string, data: { role: RoleType, sessio
|
||||
let { dbResonanceMap } = await getResonanceDataMap(role.roleId);
|
||||
|
||||
role['heros'] = heros.map(hero => new HeroParam(hero));
|
||||
for(let hero of role['heros']){
|
||||
if(dbResonanceMap.has(hero.hid)){
|
||||
for (let hero of role['heros']) {
|
||||
hero.isResonance = false;
|
||||
if (dbResonanceMap.has(hero.hid)) {
|
||||
hero.isResonance = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -518,9 +518,12 @@ export async function calculateCes(type: HERO_SYSTEM_TYPE, roleId: string, serve
|
||||
}
|
||||
let { heroCe, roleInc } = calCe.getCeInc(); // 计算战力,获得有变化的武将战力
|
||||
let changeHids: number[] = [];
|
||||
let pushHeros = new Array<{ hid: number, ce: number, incHeroCe: number }>();
|
||||
let pushHeros = new Array<{ hid: number, ce: number, incHeroCe: number, isResonance:boolean }>();
|
||||
let heroes: HeroType[] = [];
|
||||
|
||||
const { dbResonanceMap } = await getResonanceDataMap(roleId);
|
||||
let isResonance = false
|
||||
|
||||
for(let [hid, heroUpdate] of heroUpdates) {
|
||||
if(heroCe.has(hid)) {
|
||||
let { ce, inc } = heroCe.get(hid);
|
||||
@@ -531,7 +534,8 @@ export async function calculateCes(type: HERO_SYSTEM_TYPE, roleId: string, serve
|
||||
await PvpDefenseModel.updateCe(roleId, hid, ce); // 更新pvp防守阵战力
|
||||
await LadderMatchModel.updateCe(roleId, hid, ce);
|
||||
await GVGVestigeRankModel.updateCe(roleId, hid, ce);
|
||||
pushHeros.push({ hid, ce, incHeroCe: inc });
|
||||
if(dbResonanceMap.has(hid)) isResonance = true;
|
||||
pushHeros.push({ hid, ce, incHeroCe: inc, isResonance });
|
||||
} else {
|
||||
let hero = await HeroModel.updateHeroInfo(roleId, hid, heroUpdate);
|
||||
heroes.push(hero);
|
||||
@@ -543,11 +547,11 @@ export async function calculateCes(type: HERO_SYSTEM_TYPE, roleId: string, serve
|
||||
await PvpDefenseModel.updateCe(roleId, hid, ce); // 更新pvp防守阵战力
|
||||
await LadderMatchModel.updateCe(roleId, hid, ce);
|
||||
await GVGVestigeRankModel.updateCe(roleId, hid, ce);
|
||||
pushHeros.push({ hid, ce: hero.ce, incHeroCe: inc });
|
||||
if(dbResonanceMap.has(hid)) isResonance = true;
|
||||
pushHeros.push({ hid, ce: hero.ce, incHeroCe: inc, isResonance });
|
||||
}
|
||||
}
|
||||
|
||||
const { dbResonanceMap } = await getResonanceDataMap(roleId);
|
||||
let { topLineup, topLineupCe, hasTopCeChange } = calCe.getTopLineupNew(dbResonanceMap);
|
||||
let roleCeUpdate: RoleCeUpdate = calCe.getRoleCeTable();
|
||||
if(topLineupCe > (roleCe?.historyLineupCe||0)) {
|
||||
@@ -560,6 +564,7 @@ export async function calculateCes(type: HERO_SYSTEM_TYPE, roleId: string, serve
|
||||
|
||||
saveCeChangeLog(role, roleInc, role.ce, type, ceChangeTxt);
|
||||
updateRank(roleId, serverId, topLineupCe, role, pushHeros, guild);
|
||||
|
||||
sendMessageToUserWithSuc(roleId, PUSH_ROUTE.PLAYER_CE_UPDATE, { ce: role.ce, heros: pushHeros, topLineupCe, topLineup }, sid);
|
||||
if(hasTopCeChange) await updateRoleOnlineInfo(roleId, { topLineupCe });
|
||||
if(guild) {
|
||||
|
||||
@@ -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 };
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -223,4 +223,5 @@ export interface ReturnResonanceParam {
|
||||
connections?: ResonanceConnection[]; // 羁绊
|
||||
ePlace?: ResonanceEplace[];
|
||||
ce?: number; //战力
|
||||
isResonance?: boolean
|
||||
}
|
||||
Reference in New Issue
Block a user