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