🐞 fix(gvg): 添加个人积分排行榜

This commit is contained in:
luying
2023-07-05 17:16:16 +08:00
parent 84e4f22af2
commit d4ec0ab92a
9 changed files with 103 additions and 7 deletions
+15 -1
View File
@@ -1,6 +1,6 @@
// 动态
import { CHANNEL_PREFIX, GVG_REC_ID, GVG_REC_TYPE, GVG_RESOURCE_TYPE, MSG_SOURCE, MSG_TYPE } from "../../consts";
import { CHANNEL_PREFIX, GVG_REC_ID, GVG_REC_TYPE, GVG_RESOURCE_TYPE, MSG_SOURCE, MSG_TYPE, PUSH_ROUTE } from "../../consts";
import { GVGBattleRecType } from "../../db/GVGBattleRec";
import { GVGLeagueModel, GVGLeagueType } from "../../db/GVGLeague";
import { GVGRecModel, GVGRecUpdate } from "../../db/GVGRec";
@@ -8,6 +8,7 @@ import { GVGVestigeRecType } from "../../db/GVGVestigeRec";
import { gameData } from "../../pubUtils/data";
import { nowSeconds } from "../../pubUtils/timeUtil";
import { createGroupMsg, pushGroupMsgToRoom } from "../chatService";
import { sendMessageToUserWithSuc } from "../pushService";
import { getGVGConfig } from "./gvgService";
// 加入军团
@@ -96,6 +97,10 @@ export async function addBattleEndRec(rec: GVGBattleRecType) {
}
await GVGRecModel.addRecs(params.getUpdateParam());
let mapByRoleId = params.getMapByRoleId();
for(let [roleId, recs] of mapByRoleId) {
if(recs.length > 0) sendMessageToUserWithSuc(roleId, PUSH_ROUTE.GVG_REC_ADD, { recs });
}
}
class GVGRecUpArr {
@@ -122,6 +127,15 @@ class GVGRecUpArr {
public getUpdateParam() {
return this.arr;
}
public getMapByRoleId() {
let map = new Map<string, { recId: number, params: string[] }[]>();
for(let { roleId, recId, params } of this.arr) {
if(!map.has(roleId)) map.set(roleId, []);
map.get(roleId).push({ recId, params });
}
return map
}
}
function getPointName(pointId: number) {