🐞 fix(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 { getGroupKey, getGVGConfig, getGVGPeriodData, getGVGServerType } from '../../../services/gvg/gvgService';
|
||||
import { redisAddBattleScore, battleEndSendMessage, calBattleScoreByCe, checkAreaIsInCity, checkGVGBattleStart, checkMoveStatus, getBattleRanksByCity, getBirthAreaOfCity, getGVGWarId, getOppHeroes, getTechKnifeHurt, getTechReviveMinus, initRobots, pushTeamMoveMessage, getGVGCitiesInfo, leaveCity, refreshTeams } from '../../../services/gvg/gvgBattleService';
|
||||
import { redisAddBattleScore, battleEndSendMessage, calBattleScoreByCe, checkAreaIsInCity, checkGVGBattleStart, checkMoveStatus, getBattleRanksByCity, getBirthAreaOfCity, getGVGWarId, getOppHeroes, getTechKnifeHurt, getTechReviveMinus, initRobots, pushTeamMoveMessage, getGVGCitiesInfo, leaveCity, refreshTeams, checkEnterCityTime } from '../../../services/gvg/gvgBattleService';
|
||||
import { getGVGBattleData } from '../../../services/gvg/gvgBattleMemory';
|
||||
import { GVGBattleRecModel } from '../../../db/GVGBattleRec';
|
||||
import { getFightTimeByPeriod } from '../../../services/gvg/gvgFightService';
|
||||
@@ -182,19 +182,21 @@ export class GVGBattleHandler {
|
||||
if (period != GVG_PERIOD.BATTLE) return resResult(STATUS.GVG_NOT_BATTLE_PERIOD);
|
||||
|
||||
let groupKey = await getGroupKey(serverId);
|
||||
let city = await GVGCityModel.findByCityId(configId, groupKey, cityId);
|
||||
|
||||
let myLeague = await GVGLeagueModel.findLeagueByGuild(guildCode);
|
||||
if(!myLeague) return resResult(STATUS.GVG_LEAGUE_NOT_EXIST);
|
||||
|
||||
if(!checkEnterCityTime(city, myLeague.leagueCode)) return resResult(STATUS.GVG_NOT_ENTER_CITY_TIME);
|
||||
|
||||
// 初始化本城池的守擂机器人
|
||||
await initRobots(configId, groupKey, cityId);
|
||||
await initRobots(configId, groupKey, city||{ cityId, guardLeague: '' });
|
||||
// 每赛季初自己的几支队伍恢复耐久、城市、顺便更新一下自己的玩家名、联军
|
||||
let teams = await refreshTeams(configId, groupKey, roleId, roleName, guildCode, myLeague);
|
||||
|
||||
let gvgUserData = await GVGUserDataModel.findByRole(configId, myLeague.leagueCode, roleId);
|
||||
let originCityId = gvgUserData?.cityId||0;
|
||||
// 检测是否已经在城池中,玩家不在这个城池中时进行处理
|
||||
let city: GVGCityType;
|
||||
if (originCityId != cityId) {
|
||||
let gvgUserData = await GVGUserDataModel.findByRole(configId, myLeague.leagueCode, roleId);
|
||||
if(gvgUserData?.cityId > 0) { // 如果leaveCity没有退出成功,玩家还遗留在上一座城中,做一下处理
|
||||
@@ -213,7 +215,6 @@ export class GVGBattleHandler {
|
||||
teamResult.push(new MyTeamInfo(team));
|
||||
continue;
|
||||
};
|
||||
if(!city) city = await GVGCityModel.findByCityId(configId, groupKey, cityId);
|
||||
let areaId = getBirthAreaOfCity(city, myLeague.leagueCode);
|
||||
team = await GVGTeamModel.enterCity(team.teamCode, cityId, areaId, groupKey);
|
||||
if(!team) continue;
|
||||
@@ -299,12 +300,13 @@ export class GVGBattleHandler {
|
||||
const { cityId, teamCode } = msg;
|
||||
|
||||
let groupKey = await getGroupKey(serverId);
|
||||
let { configId } = getGVGPeriodData();
|
||||
|
||||
let myTeam = await GVGTeamModel.findMyTeamByCode(roleId, teamCode);
|
||||
if(!myTeam) return resResult(STATUS.GVG_TEAM_NOT_FOUND);
|
||||
if(myTeam.cityId != cityId) return resResult(STATUS.GVG_BATTLE_IS_NOT_IN_CITY);
|
||||
|
||||
let teams = await GVGTeamModel.findByAreaId(groupKey, cityId, myTeam.areaId);
|
||||
let teams = await GVGTeamModel.findByAreaId(configId, groupKey, cityId, myTeam.areaId);
|
||||
let points: GVGTeamInListOnPoint[] = [], players: GVGTeamInList[] = [];
|
||||
let pointIds = gameData.gvgPointByAreaId.get(myTeam.areaId)||[];
|
||||
for(let pointId of pointIds) {
|
||||
@@ -439,6 +441,8 @@ export class GVGBattleHandler {
|
||||
|
||||
let { configId, period } = getGVGPeriodData();
|
||||
if (period != GVG_PERIOD.BATTLE) return resResult(STATUS.GVG_NOT_BATTLE_PERIOD);
|
||||
let { startFightTime } = getFightTimeByPeriod(period);
|
||||
if(startFightTime > nowSeconds()) return resResult(STATUS.GVG_NOT_BATTLE_TIME);
|
||||
|
||||
let groupKey = await getGroupKey(serverId);
|
||||
|
||||
@@ -636,7 +640,7 @@ export class GVGBattleHandler {
|
||||
let groupKey = await getGroupKey(serverId);
|
||||
let serverType = await getGVGServerType(serverId);
|
||||
|
||||
const cities = await GVGCityModel.findByConfig(configId, groupKey);
|
||||
const cities = await GVGCityModel.findByConfigAndGroup(configId, groupKey);
|
||||
const points = await GVGCityAreaPointModel.findByConfig(configId, groupKey);
|
||||
|
||||
let result: { cityId: number, guardLeagueName: string, areas: { areaId: number, points: { pointId: number, guardLeagueName: string }[] }[] }[] = [];
|
||||
|
||||
Reference in New Issue
Block a user