✨ feat(gvgBattle): getCity返回正确的结构
This commit is contained in:
@@ -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, // ! 总数是否直接存储在城池中,或有其它更好的方案
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user