🐞 fix(gvg): 激战期城池排行榜添加积分增速
This commit is contained in:
@@ -154,6 +154,20 @@ class GVGBattleData {
|
|||||||
return teams;
|
return teams;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public findSettledPointMapByLeague() {
|
||||||
|
let pointByLeague = new Map<string, number[]>();
|
||||||
|
for(let [_roleId, pointIds] of this.rolePoints) {
|
||||||
|
for(let [pointId, teamCode] of pointIds) {
|
||||||
|
let team = this.teams.get(teamCode);
|
||||||
|
if(pointId > 0 && team && team.leagueCode) {
|
||||||
|
if(!pointByLeague.has(team.leagueCode)) pointByLeague.set(team.leagueCode, []);
|
||||||
|
pointByLeague.get(team.leagueCode).push(team.pointId);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return pointByLeague;
|
||||||
|
}
|
||||||
|
|
||||||
public findAreas() {
|
public findAreas() {
|
||||||
return this.areaToTeams.keys();
|
return this.areaToTeams.keys();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -318,17 +318,22 @@ export async function redisAddSettleScore(gvgTeam: GVGTeamType, incScore: number
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 获取排行榜
|
// 获取排行榜
|
||||||
export async function getBattleRanksByCity(configId: number, groupKey: string, cityId: number, myLeague: GVGLeagueType) {
|
export async function getBattleRanksByCity(configId: number, groupKey: string, cityId: number, myLeague?: GVGLeagueType) {
|
||||||
|
let teamObj = getGVGBattleData(groupKey);
|
||||||
|
let pointByLeague = teamObj.findSettledPointMapByLeague();
|
||||||
let r = new Rank(REDIS_KEY.GVG_BATTLE_LEAGUE_RANK_BY_CITY, { configId, groupKey, cityId });
|
let r = new Rank(REDIS_KEY.GVG_BATTLE_LEAGUE_RANK_BY_CITY, { configId, groupKey, cityId });
|
||||||
r.setGenerFieldsFun((obj => {
|
r.setGenerFieldsFun((obj => {
|
||||||
if(obj instanceof LeagueRankInfo) {
|
if(obj instanceof LeagueRankInfo) {
|
||||||
return { rank: obj.rank, leagueCode: obj.code, leagueName: obj.name, score: obj.num }
|
let pointIds = pointByLeague.get(obj.code)||[];
|
||||||
|
let incScore = 0;
|
||||||
|
for(let pointId of pointIds) incScore += gameData.gvgAreaPoint.get(pointId)?.score||0;
|
||||||
|
return { rank: obj.rank, leagueCode: obj.code, leagueName: obj.name, score: obj.num, incScore }
|
||||||
}
|
}
|
||||||
return obj
|
return obj
|
||||||
}));
|
}));
|
||||||
|
|
||||||
let { ranks, myRank } = await r.getRankListWithMyRank({ leagueCode: myLeague.leagueCode });
|
let { ranks, myRank } = await r.getRankListWithMyRank({ leagueCode: myLeague?.leagueCode });
|
||||||
if (!myRank) {
|
if (myLeague && !myRank) {
|
||||||
myRank = await r.generMyRankWithLeague(myLeague.leagueCode, 0, 0, myLeague);
|
myRank = await r.generMyRankWithLeague(myLeague.leagueCode, 0, 0, myLeague);
|
||||||
}
|
}
|
||||||
return { ranks, myRank }
|
return { ranks, myRank }
|
||||||
@@ -362,16 +367,8 @@ export async function gvgBattleSeconds() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for(let { groupKey, cityId } of keys) {
|
for(let { groupKey, cityId } of keys) {
|
||||||
let r = new Rank(REDIS_KEY.GVG_BATTLE_LEAGUE_RANK_BY_CITY, { configId, groupKey, cityId });
|
let { ranks } = await getBattleRanksByCity(configId, groupKey, 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(groupKey, cityId, PUSH_ROUTE.GVG_CITY_RANK_UPDATE, { cityId, ranks });
|
await sendMessageToGVGCityWithSuc(groupKey, cityId, PUSH_ROUTE.GVG_CITY_RANK_UPDATE, { cityId, ranks });
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user