feat(gvg): 添加城池排行榜定时推送

This commit is contained in:
luying
2023-02-17 13:53:01 +08:00
parent 0e68ee466f
commit b0e0c83fcd
10 changed files with 149 additions and 70 deletions

View File

@@ -7,8 +7,7 @@ import { GVG_AREA_TYPE, GVG_BATTLE_RANK_TYPE, GVG_TECH_TYPE, MAIL_TYPE, PUSH_ROU
import { nowSeconds } from "../../pubUtils/timeUtil";
import { DicGVGAreaPoint } from "../../pubUtils/dictionary/DicGVGAreaPoint";
import { getGVGBattleData, getGVGBattleMap } from "./gvgBattleMemory";
import { GVGAreaInMap, GVGCityMapInfo, GVGTeamInList, GVGTeamInListOnPoint, GVGTeamSpineInMap } from "../../domain/gvgField/returnData";
import { pick } from "underscore";
import { GVGCityMapInfo, GVGTeamInList, GVGTeamInListOnPoint, GVGTeamSpineInMap } from "../../domain/gvgField/returnData";
import { GVG } from "../../pubUtils/dicParam";
import { GVGHeroInfo, PvpEnemies, PvpHeroInfo } from "../../domain/dbGeneral";
import { getGVGConfig } from "./gvgService";
@@ -18,7 +17,7 @@ import { dispatch } from "../../pubUtils/dispatcher";
import { Rank } from "../rankService";
import { LeagueRankInfo, RoleRankInfo } from "../../domain/rank";
import { findKeys, getAllServerName } from "../redisService";
import { sendMessageToChannel, sendMessageToGVGAreaByTeamWithSuc, sendMessageToGVGAreaWithSuc } from "../pushService";
import { sendMessageToChannel, sendMessageToCityWithSuc, sendMessageToGVGAreaByTeamWithSuc, sendMessageToGVGAreaWithSuc, sendMessageToGVGCityWithSuc } from "../pushService";
import { sendMailToLeagueByContent } from "../mailService";
@@ -266,7 +265,9 @@ export async function getBattleRanks(configId: number, groupId: number, serverTy
// 每5秒一次结算
export async function gvgBattleSeconds() {
const { configId } = getGVGConfig();
const serverNames = await getAllServerName();
let keys: { groupId: number, serverType: number, cityId: number }[] = []
for(let [_key, teamObj] of getGVGBattleMap()) {
// 每5秒给据点上的人加积分
let teams = teamObj.findSettledPoint();
@@ -281,11 +282,27 @@ export async function gvgBattleSeconds() {
let dicArea = gameData.gvgArea.get(areaId);
let teams = teamObj.findTeamsByArea(areaId);
let result = teams.map(team => new GVGTeamSpineInMap(team, serverNames));
sendMessageToGVGAreaWithSuc(teamObj.groupId, teamObj.serverType, areaId, PUSH_ROUTE.GVG_AREA_SPINE_CHANGE, { cityId: dicArea.cityId, areaId, spines: result });
await sendMessageToGVGAreaWithSuc(teamObj.groupId, teamObj.serverType, areaId, PUSH_ROUTE.GVG_AREA_SPINE_CHANGE, { cityId: dicArea.cityId, areaId, spines: result });
let index = keys.findIndex(cur => cur.cityId == dicArea.cityId && cur.groupId == teamObj.groupId && cur.serverType == teamObj.serverType);
if(index == -1) keys.push({ groupId: teamObj.groupId, serverType: teamObj.serverType, cityId: dicArea.cityId });
}
}
for(let { groupId, serverType, cityId } of keys) {
let r = new Rank(REDIS_KEY.GVG_BATTLE_LEAGUE_RANK, { configId, groupId, serverType, cityId });
let rawRanks = await r.getRankByRange();
let ranks = rawRanks.map(obj => {
if(obj instanceof LeagueRankInfo) {
return { rank: obj.rank, leagueCode: obj.code, leagueName: obj.name, score: obj.num }
}
return obj
})
await sendMessageToGVGCityWithSuc(groupId, serverType, cityId, PUSH_ROUTE.GVG_CITY_RANK_UPDATE, { cityId, ranks });
}
}
export async function gvgBattleEnd() {