🐞 fix(gvg): 激战期有时areaId为0
This commit is contained in:
@@ -61,7 +61,7 @@ export class GVGBattleHandler {
|
||||
const serverId = session.get('serverId');
|
||||
const roleName = session.get('roleName');
|
||||
const guildCode = session.get('guildCode');
|
||||
const { index, head, spine, frame, lineup } = msg;
|
||||
const { cityId, index, head, spine, frame, lineup } = msg;
|
||||
|
||||
let { configId, period } = getGVGPeriodData();
|
||||
// if (period != GVG_PERIOD.BATTLE) return resResult(STATUS.GVG_NOT_BATTLE_PERIOD); // TODO 测试临时注
|
||||
@@ -99,11 +99,20 @@ export class GVGBattleHandler {
|
||||
updateParam.lineup = newLineup;
|
||||
updateParam.lineupCe = lineupCe;
|
||||
}
|
||||
|
||||
let originTeam = await GVGTeamModel.findByRoleAndIndex(roleId, index, 'cityId');
|
||||
if(!originTeam && cityId > 0) {
|
||||
let city = await GVGCityModel.increaseTeam(configId, groupKey, cityId, roleId);
|
||||
updateParam.cityId = cityId;
|
||||
updateParam.areaId = getBirthAreaOfCity(city, leagueCode)
|
||||
}
|
||||
const team = await GVGTeamModel.saveTeam(roleId, index, updateParam, { roleName, serverId, leagueCode, leagueName, durability, maxDurability: durability });
|
||||
if (!team) {
|
||||
return resResult(STATUS.GVG_SAVE_TEAM_FAILED);
|
||||
}
|
||||
if(cityId > 0) {
|
||||
let teamObj = getGVGBattleData(groupKey);
|
||||
teamObj.enterCity(team);
|
||||
}
|
||||
return resResult(STATUS.SUCCESS, { curTeam: new MyTeamSimpleInfo(team) });
|
||||
}
|
||||
|
||||
@@ -199,8 +208,7 @@ export class GVGBattleHandler {
|
||||
|
||||
gvgUserData = await GVGUserDataModel.changeCity(configId, myLeague.leagueCode, roleId, cityId);
|
||||
let areaId = getBirthAreaOfCity(city, myLeague.leagueCode);
|
||||
await GVGTeamModel.enterCity(roleId, cityId, areaId, groupKey);
|
||||
teams = await GVGTeamModel.findByRole(roleId, '-_id');
|
||||
teams = await GVGTeamModel.enterCity(roleId, cityId, areaId, groupKey);
|
||||
// 更新内存队伍信息
|
||||
let teamObj = getGVGBattleData(groupKey);
|
||||
teamObj.enterCity(...teams);
|
||||
|
||||
@@ -106,6 +106,7 @@ export function guild(session: Session, msg: any, app: Application, cb: (err: Er
|
||||
'guild.gvgBattleHandler.getAreaTeams',
|
||||
'guild.gvgBattleHandler.useItem',
|
||||
'guild.gvgBattleHandler.reviveTeam',
|
||||
'guild.gvgBattleHandler.saveTeam',
|
||||
].indexOf(arg.route) !== -1) {
|
||||
if (arg.body.cityId) {
|
||||
needDispatch = true;
|
||||
|
||||
@@ -59,6 +59,12 @@ export default class GVGCity extends BaseModel {
|
||||
return city;
|
||||
}
|
||||
|
||||
// 添加人数
|
||||
public static async increaseTeam(configId: number, groupKey: string, cityId: number, roleId: string) {
|
||||
const city: GVGCityType = await GVGCityModel.findOneAndUpdate({ configId, groupKey, cityId, 'players.roleId': roleId }, { $inc: { 'players.$.teamCnt': 1 }}, { new: true }).lean();
|
||||
return city;
|
||||
}
|
||||
|
||||
// 查询联军驻守情况
|
||||
public static async findGuardCityByLeague(configId: number, leagueCode: string, select = '') {
|
||||
const cities: GVGCityType[] = await GVGCityModel.find({ configId, guardLeague: leagueCode, hasGuard: true }).select(select).lean();
|
||||
|
||||
@@ -134,8 +134,13 @@ export default class GVGTeam extends BaseModel {
|
||||
|
||||
// 玩家切换城池更新队伍信息
|
||||
public static async enterCity(roleId: string, cityId: number, areaId: number, groupKey: string) {
|
||||
const res = await GVGTeamModel.updateMany({ roleId }, { cityId, areaId, fromAreaId: areaId, pointId: 0, groupKey }).lean();
|
||||
return !!res['ok'];
|
||||
let teams = await GVGTeamModel.findByRole(roleId, '-_id')
|
||||
let result: GVGTeamType[] = [];
|
||||
for(let targetTeam of teams) {
|
||||
let team: GVGTeamType = await GVGTeamModel.findOneAndUpdate({ teamCode: targetTeam.teamCode }, { $set: { cityId, areaId, fromAreaId: areaId, pointId: 0, groupKey } }, { new: true }).lean();
|
||||
result.push(team);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// 查找角色队伍数
|
||||
@@ -150,6 +155,12 @@ export default class GVGTeam extends BaseModel {
|
||||
return teams;
|
||||
}
|
||||
|
||||
// 获取我的编队
|
||||
public static async findByRoleAndIndex(roleId: string, index: number, select = '') {
|
||||
const teams: GVGTeamType = await GVGTeamModel.findOne({ roleId, index }).select(select).lean();
|
||||
return teams;
|
||||
}
|
||||
|
||||
// 获取某个玩家的某个的编队
|
||||
public static async findMyTeamByCode(roleId: string, teamCode: string, select = '') {
|
||||
const res: GVGTeamType = await GVGTeamModel.findOne({ roleId, teamCode }).select(select).lean();
|
||||
|
||||
@@ -251,6 +251,7 @@ export class OppDetailData{
|
||||
}
|
||||
|
||||
export interface SaveTeamParam {
|
||||
cityId: number;
|
||||
index: number;
|
||||
head: number;
|
||||
frame: number;
|
||||
@@ -267,6 +268,8 @@ export interface SaveTeamUpdateParam {
|
||||
groupKey: string;
|
||||
lineup?: GVGHeroInfo[];
|
||||
lineupCe?: number;
|
||||
cityId?: number;
|
||||
areaId?: number;
|
||||
}
|
||||
|
||||
export interface InitTeamParam {
|
||||
|
||||
@@ -15,6 +15,6 @@
|
||||
"periodType": 3,
|
||||
"day": "6&",
|
||||
"startTime": "17:00:00",
|
||||
"endTime": "20:00:00"
|
||||
"endTime": "22:00:00"
|
||||
}
|
||||
]
|
||||
Reference in New Issue
Block a user