✨ feat(共鸣系统): 添加最强6人推送,不可养成拦截

This commit is contained in:
zhangxk
2023-10-09 20:49:24 +08:00
parent ffcdb7c0bc
commit dac8ac07a6
10 changed files with 109 additions and 42 deletions
+4 -2
View File
@@ -22,6 +22,7 @@ import { LadderMatchModel } from '../db/LadderMatch';
import { ArtifactModelType } from '../db/Artifact';
import { GVGVestigeRankModel } from '../db/GVGVestigeRank';
import { AuthorBookType } from '../db/AuthorBook';
import { getResonanceDataMap } from './role/resonanceService';
interface Param {
isInitRole?: boolean,
@@ -546,7 +547,8 @@ export async function calculateCes(type: HERO_SYSTEM_TYPE, roleId: string, serve
}
}
let { topLineup, topLineupCe, hasTopCeChange } = calCe.getTopLineup();
const { dbResonanceMap } = await getResonanceDataMap(roleId);
let { topLineup, topLineupCe, hasTopCeChange } = calCe.getTopLineupNew(dbResonanceMap);
let roleCeUpdate: RoleCeUpdate = calCe.getRoleCeTable();
if(topLineupCe > (roleCe?.historyLineupCe||0)) {
roleCeUpdate = { ...roleCeUpdate, historyLineupCe: topLineupCe };
@@ -558,7 +560,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 }, sid);
sendMessageToUserWithSuc(roleId, PUSH_ROUTE.PLAYER_CE_UPDATE, { ce: role.ce, heros: pushHeros, topLineupCe, topLineup }, sid);
if(hasTopCeChange) await updateRoleOnlineInfo(roleId, { topLineupCe });
if(guild) {
await updateUserInfo(REDIS_KEY.GUILD_INFO, guild.code, [{ field: 'guildCe', value: guild.guildCe }]);
+18
View File
@@ -3,6 +3,7 @@ import { ArtifactModelType } from "../../db/Artifact";
import { AuthorBookType } from "../../db/AuthorBook";
import { Connect, EPlace, HeroSkin, HeroType, HeroUpdate, Stone, Talent } from "../../db/Hero";
import { JewelType } from "../../db/Jewel";
import { ResonanceType } from "../../db/Resonance";
import { RoleUpdate, Teraph } from "../../db/Role";
import { AttrCell, Attribute, EquipAttr, HeroAttr, RoleCeType, SchoolAttr, ScrollAttr } from "../../db/RoleCe";
import { TopHero } from "../../domain/dbGeneral";
@@ -137,6 +138,23 @@ export class CalCe {
return { topLineup, topLineupCe, hasTopCeChange: topLineupCe == this.originTopHeroCe };
}
public getTopLineupNew(dbResonanceMap: Map<number, ResonanceType>) {
let topLineup: TopHero[] = [], topLineupCe = 0;
let arr = this.getResultCeArr();
for (let obj of arr) {
if (topLineup.length >= LINEUP_NUM) break;
let { hid, ce } = obj;
if (dbResonanceMap.has(hid)) continue;
topLineup.push({
hid, ce, hero: this.data.heroObjectId.get(hid)
});
topLineupCe += ce;
}
return { topLineup, topLineupCe, hasTopCeChange: topLineupCe == this.originTopHeroCe };
}
// 玩家等级
public setRoleLv(lv: number) {
this.data.roleLv = lv;
@@ -1,4 +1,4 @@
import { EQUIP_EPLACEID, EQUIP_STONE, FRIENDSHIP_INDEX, HERO_SYSTEM_TYPE, RESONANCE_SORT_TYPE } from "../../consts";
import { EQUIP_EPLACEID, EQUIP_STONE, FRIENDSHIP_INDEX, HERO_SYSTEM_TYPE, LINEUP_NUM, RESONANCE, RESONANCE_SORT_TYPE } from "../../consts";
import { ArtifactModel } from "../../db/Artifact";
import { EPlace, HeroModel, HeroType, HeroUpdate } from "../../db/Hero";
import { JewelModel, JewelType } from "../../db/Jewel";
@@ -6,24 +6,23 @@ import { ResonanceModel, ResonanceType } from "../../db/Resonance";
import { RoleModel } from "../../db/Role";
import { HeroParam } from "../../domain/roleField/hero";
import { gameData, getEquipByJobClassAndEPlace } from "../../pubUtils/data";
import { RESONANCE } from "../../pubUtils/dicParam";
import { ReturnResonanceParam } from "../../pubUtils/interface";
import { calculateCeWithHeroes } from "../playerCeService";
import { initSkinTalent } from "../roleService";
import { pick } from 'underscore';
import * as util from 'util';
export async function getStartLimt(roleId: string) {
const role = await RoleModel.findByRoleId(roleId);
if (!role || !role.mainWarId || role.mainWarId < RESONANCE.START_MAIN_WARId) return false;
return true;
}
// export async function getStartLimt(roleId: string) {
// const role = await RoleModel.findByRoleId(roleId);
// if (!role || !role.mainWarId || role.mainWarId < RESONANCE.START_MAIN_WARId) return false;
// return true;
// }
export async function refreshResonanceData(roleId: string, serverId: number, sid: string) {
let resonances: ReturnResonanceParam[] = [];
let dbHeroes: HeroType[] = await HeroModel.findByRole(roleId, [{ field: 'ce', sortBy: -1 }]);
if (dbHeroes.length < RESONANCE.HOSTER) return resonances;
if (dbHeroes.length < LINEUP_NUM) return resonances;
let { dbResonanceMap, newPositionArr } = await getResonanceDataMap(roleId);
@@ -86,8 +85,8 @@ export async function refreshResonanceData(roleId: string, serverId: number, sid
let ePlaceData = hero.ePlace.find(cur => cur.id == id);
if (!ePlaceData) {
ePlaceData = await getInitEplace(id, hero.skinId);
hero.ePlace.push({ ...ePlaceData });
hero.ePlace.push({ ...await getInitEplace(id, hero.skinId) });
ePlaceData = hero.ePlace.find(cur => cur.id == id);
}
ePlaceData.lv = topLineHeroEplace.lv;
}
@@ -101,8 +100,8 @@ export async function refreshResonanceData(roleId: string, serverId: number, sid
let ePlaceData = hero.ePlace.find(cur => cur.id == id);
if (!ePlaceData) {
ePlaceData = await getInitEplace(id, hero.skinId);
hero.ePlace.push({ ...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;
@@ -117,8 +116,8 @@ export async function refreshResonanceData(roleId: string, serverId: number, sid
let ePlaceData = hero.ePlace.find(cur => cur.id == id);
if (!ePlaceData) {
ePlaceData = await getInitEplace(id, hero.skinId);
hero.ePlace.push({ ...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;
@@ -135,8 +134,8 @@ export async function refreshResonanceData(roleId: string, serverId: number, sid
let ePlaceData = hero.ePlace.find(cur => cur.id == id);
if (!ePlaceData) {
ePlaceData = await getInitEplace(id, hero.skinId);
hero.ePlace.push({ ...ePlaceData });
hero.ePlace.push({ ...await getInitEplace(id, hero.skinId) });
ePlaceData = hero.ePlace.find(cur => cur.id == id);
};
ePlaceData.jewel = topLineHeroEplace.jewel;
}
@@ -156,8 +155,8 @@ export async function refreshResonanceData(roleId: string, serverId: number, sid
let ePlaceData = hero.ePlace.find(cur => cur.id == id);
if (!ePlaceData) {
ePlaceData = await getInitEplace(id, hero.skinId);
hero.ePlace.push({ ...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;
}
@@ -251,12 +250,12 @@ export function sortData(dbResonanceMap: Map<number, ResonanceType>, heroes: Her
let topLineHeroes: HeroType[] = [];
for (let hero of heroes) {
const { hid } = hero;
if (!dbResonanceMap.has(hid) && topLineHeroes.length < RESONANCE.HOSTER) {
if (!dbResonanceMap.has(hid) && topLineHeroes.length < LINEUP_NUM) {
topLineHeroes.push(hero);
}
}
return topLineHeroes[RESONANCE.HOSTER - 1];
return topLineHeroes[1 - 1];
}
export function sortByConnect(heroes: HeroType[], index: number) {