✨ feat(gvg): 激战期数据补充、排行榜等
This commit is contained in:
@@ -7,7 +7,7 @@ import { Application, BackendSession, ChannelService, HandlerService, pinus } fr
|
||||
import { resResult, genCode } from "../../../pubUtils/util";
|
||||
import { GVGLeagueModel } from '../../../db/GVGLeague';
|
||||
import { checkGVGPeriod, getGroupIdOfServer, getGVGConfig, getGVGPeriodData, getGVGServerType } from '../../../services/gvg/gvgService';
|
||||
import { addBattleRankScore, battleEndSendMessage, calBattleScoreByCe, checkAreaIsInCity, checkGVGBattleStart, checkMoveStatus, getBattleRanks, getBirthAreaOfCity, getGVGWarId, getOppHeroes, getTechKnifeHurt, getTechReviveMinus, initRobots, pushTeamMoveMessage } from '../../../services/gvg/gvgBattleService';
|
||||
import { redisAddBattleScore, battleEndSendMessage, calBattleScoreByCe, checkAreaIsInCity, checkGVGBattleStart, checkMoveStatus, getBattleRanksByCity, getBirthAreaOfCity, getGVGWarId, getOppHeroes, getTechKnifeHurt, getTechReviveMinus, initRobots, pushTeamMoveMessage, getGVGCitiesInfo } from '../../../services/gvg/gvgBattleService';
|
||||
import { getGVGBattleData } from '../../../services/gvg/gvgBattleMemory';
|
||||
import { GVGBattleRecModel } from '../../../db/GVGBattleRec';
|
||||
import { getFightTimeByPeriod } from '../../../services/gvg/gvgFightService';
|
||||
@@ -15,7 +15,7 @@ import { gameData, getReviveGold } from '../../../pubUtils/data';
|
||||
import { getAllServerName } from '../../../services/redisService';
|
||||
import { checkBattleHeroesByHid } from '../../../services/normalBattleService';
|
||||
import { SaveTeamParam, SaveTeamUpdateParam } from '../../../domain/gvgField/gvgDb';
|
||||
import { GVG_AREA_TYPE, GVG_ITEM, ITEM_CHANGE_REASON, STATUS } from '../../../consts';
|
||||
import { GVG_AREA_TYPE, GVG_ITEM, ITEM_CHANGE_REASON, REDIS_KEY, STATUS } from '../../../consts';
|
||||
import { GVGHeroInfo } from '../../../domain/dbGeneral';
|
||||
import { ArtifactModel } from '../../../db/Artifact';
|
||||
import { getHeroesAttributes } from '../../../services/playerCeService';
|
||||
@@ -25,6 +25,8 @@ import { GVGUserItemModel } from '../../../db/GVGUserItem';
|
||||
import { handleGVGCost } from '../../../services/gvg/gvgItemService';
|
||||
import { getGoldObject, handleCost } from '../../../services/role/rewardService';
|
||||
import { GVGCityAreaPointModel } from '../../../db/GVGCityAreaPoint';
|
||||
import { Rank } from '../../../services/rankService';
|
||||
import { LeagueRankInfo, RoleRankInfo } from '../../../domain/rank';
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
@@ -108,16 +110,20 @@ export class GVGBattleHandler {
|
||||
|
||||
// 获取城池信息
|
||||
async getCity(msg: { cityId: number }, session: BackendSession) {
|
||||
const serverId = session.get('serverId');
|
||||
const guildCode = session.get('guildCode');
|
||||
const { cityId } = msg;
|
||||
let { configId, period } = getGVGPeriodData();
|
||||
let { startFightTime, endFightTime } = getFightTimeByPeriod(period);
|
||||
|
||||
let groupId = await getGroupIdOfServer(serverId);
|
||||
let serverType = await getGVGServerType(serverId);
|
||||
|
||||
let myLeague = await GVGLeagueModel.findLeagueByGuild(guildCode);
|
||||
if(!myLeague) return resResult(STATUS.GVG_LEAGUE_NOT_EXIST);
|
||||
|
||||
const city = await GVGCityModel.findOne({ configId, cityId }).lean();
|
||||
const { guardLeague: leagueCode = '', guardLeagueName: name = '', guardLeagueIcon: icon = 0, players } = city;
|
||||
const city = await GVGCityModel.findByCityId(configId, groupId, serverType, cityId);
|
||||
const { guardLeague: leagueCode = '', guardLeagueName: name = '', guardLeagueIcon: icon = 0, players = [] } = city||{};
|
||||
|
||||
let ourTeamCnt = 0, oppTeamCnt = 0;
|
||||
for(let { leagueCode, teamCnt } of players) {
|
||||
@@ -206,7 +212,7 @@ export class GVGBattleHandler {
|
||||
|
||||
const recs = await GVGRecModel.findByCity(cityId, configId);
|
||||
const teamResult = teams.map(team => new MyTeamInfo(team));
|
||||
const { ranks, myRank } = await getBattleRanks(configId, groupId, serverType, cityId, myLeague);
|
||||
const { ranks, myRank } = await getBattleRanksByCity(configId, groupId, serverType, cityId, myLeague);
|
||||
await leaveGVGCityTeamChannel(roleId, sid);
|
||||
await addRoleToGVGCityChannel(roleId, groupId, serverType, cityId, sid);
|
||||
|
||||
@@ -492,7 +498,8 @@ export class GVGBattleHandler {
|
||||
}
|
||||
if(defenseTeam.curTeamBreak) {
|
||||
let attackScore = calBattleScoreByCe(isSuccess, defenseTeam.lineupCe);
|
||||
await addBattleRankScore(attackTeam, attackScore);
|
||||
attackTeam = await GVGTeamModel.addScore(attackTeam.teamCode, attackScore, 0);
|
||||
await redisAddBattleScore(attackTeam, attackScore);
|
||||
}
|
||||
|
||||
// 更新内存
|
||||
@@ -547,7 +554,7 @@ export class GVGBattleHandler {
|
||||
}
|
||||
if(defenseTeam.curTeamBreak) {
|
||||
let attackScore = calBattleScoreByCe(true, defenseTeam.lineupCe);
|
||||
await addBattleRankScore(attackTeam, attackScore);
|
||||
await redisAddBattleScore(attackTeam, attackScore);
|
||||
}
|
||||
|
||||
// 更新内存
|
||||
@@ -643,6 +650,33 @@ export class GVGBattleHandler {
|
||||
return resResult(STATUS.SUCCESS, { cities: result });
|
||||
}
|
||||
|
||||
// 排行榜
|
||||
async getRanks(msg: {}, session: BackendSession) {
|
||||
const serverId = session.get('serverId');
|
||||
|
||||
let { configId } = getGVGPeriodData();
|
||||
let groupId = await getGroupIdOfServer(serverId);
|
||||
let serverType = await getGVGServerType(serverId);
|
||||
|
||||
let cities = await getGVGCitiesInfo(configId, groupId, serverType);
|
||||
|
||||
let r = new Rank(REDIS_KEY.GVG_BATTLE_LEAGUE_RANK, { configId, groupId, serverType });
|
||||
let leagueRanksRaw = await r.getRankByRange();
|
||||
let leagueRanks = leagueRanksRaw.map(obj => {
|
||||
if(obj instanceof LeagueRankInfo) return { rank: obj.rank, name: obj.name, score: obj.num }
|
||||
});
|
||||
|
||||
let r2 = new Rank(REDIS_KEY.GVG_BATTLE_RANK, { configId, groupId, serverType });
|
||||
let memberRanksRaw = await r2.getRankByRange();
|
||||
let memberRanks = memberRanksRaw.map(obj => {
|
||||
if(obj instanceof RoleRankInfo) return { rank: obj.rank, name: obj.roleName, score: obj.num }
|
||||
})
|
||||
|
||||
return resResult(STATUS.SUCCESS, {
|
||||
cities, leagueRanks, memberRanks
|
||||
})
|
||||
}
|
||||
|
||||
async debugStartSchedule() {
|
||||
await pinus.app.rpc.systimer.systimerRemote.gvgBattleStartSchedule.broadcast();
|
||||
return resResult(STATUS.SUCCESS);
|
||||
|
||||
Reference in New Issue
Block a user