feat(gvgBattle): getCity返回正确的结构

This commit is contained in:
liangtongchuan
2023-02-11 21:48:59 +08:00
committed by luying
parent b9b030e693
commit b1cf6b7637
2 changed files with 27 additions and 4 deletions

View File

@@ -9,7 +9,7 @@ import { DEBUG_MAGIC_WORD, GVG_PERIOD, STATUS } from "../../../consts";
import { LineupHero } from "../../../domain/roleField/hero";
import { resResult, genCode } from "../../../pubUtils/util";
import { GVGLeagueModel } from '../../../db/GVGLeague';
import { checkGVGPeriod, getGroupIdOfServer, getGVGPeriodData, getGVGServerType } from '../../../services/gvg/gvgService';
import { checkGVGPeriod, getGroupIdOfServer, getGVGConfig, getGVGPeriodData, getGVGServerType } from '../../../services/gvg/gvgService';
import { checkMoveStatus, getBirthAreaOfCity, initRobots } from '../../../services/gvg/gvgBattleService';
import { getGVGBattleData } from '../../../services/gvg/gvgBattleMemory';
import { nowSeconds } from '../../../pubUtils/timeUtil';
@@ -56,14 +56,26 @@ export class GVGBattleHandler {
// 获取城池信息
async getCity(msg: { cityId: number }, session: BackendSession) {
const guildCode = session.get('guildCode');
const { cityId } = msg;
let { configId } = getGVGPeriodData();
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 } = city;
const { battleTime: startTime, scheduleTime } = getGVGConfig();
const cityTeamCnt = await GVGTeamModel.getTeamCntByCity(cityId);
const leagueTeamCnt = await GVGTeamModel.getTeamCntByCity(cityId, myLeague.leagueCode);
return resResult(STATUS.SUCCESS, {
cityId,
guardLeague: city.guardLeague
guardLeague: { leagueCode, name, icon },
startTime,
endTime: scheduleTime, // ! endTime 修正
ourTeamCnt: leagueTeamCnt,
oppTeamCnt: cityTeamCnt - leagueTeamCnt, // ! 总数是否直接存储在城池中,或有其它更好的方案
});
}