🐞 fix(gvg): 可能可以修好据点锁问题
This commit is contained in:
@@ -417,11 +417,15 @@ export class GVGBattleHandler {
|
||||
|
||||
let myTeam = await GVGTeamModel.findMyTeamByCode(roleId, teamCode);
|
||||
if(!myTeam) return resResult(STATUS.GVG_TEAM_NOT_FOUND);
|
||||
|
||||
let checkResult = checkSettleStatus(myTeam);
|
||||
if(checkResult.code != 0) return resResult(checkResult);
|
||||
|
||||
let dicAreaPoint = gameData.gvgAreaPoint.get(pointId);
|
||||
if(dicAreaPoint.areaId != myTeam.areaId) return resResult(STATUS.GVG_POINT_NOT_AREA);
|
||||
|
||||
const curTeam = await GVGTeamModel.settlePoint(teamCode, 0);
|
||||
await GVGCityAreaPointModel.leavePoint(configId, groupKey, pointId);
|
||||
await GVGCityAreaPointModel.leavePoint(configId, groupKey, teamCode);
|
||||
let teamObj = getGVGBattleData(groupKey);
|
||||
teamObj.teamSettle(roleId, teamCode, 0);
|
||||
|
||||
@@ -490,11 +494,11 @@ export class GVGBattleHandler {
|
||||
let settleResult = await GVGCityAreaPointModel.settlePoint(cityId, attackTeam.areaId, defenseTeam.originPointId, attackTeam, defenseTeam.isRobot? '': defenseTeam.teamCode);
|
||||
if(settleResult) attackTeam = await GVGTeamModel.settlePoint(attackTeam.teamCode, defenseTeam.originPointId);
|
||||
} else {
|
||||
await GVGCityAreaPointModel.leavePoint(configId, groupKey, defenseTeam.originPointId);
|
||||
await GVGCityAreaPointModel.leavePoint(configId, groupKey, defenseTeam.teamCode);
|
||||
}
|
||||
}
|
||||
if(attackTeam.curTeamBreak && attackTeam.originPointId) {
|
||||
await GVGCityAreaPointModel.leavePoint(configId, groupKey, attackTeam.originPointId);
|
||||
await GVGCityAreaPointModel.leavePoint(configId, groupKey, attackTeam.teamCode);
|
||||
}
|
||||
if(defenseTeam.curTeamBreak) {
|
||||
let attackScore = calBattleScoreByCe(isSuccess, defenseTeam.lineupCe);
|
||||
@@ -552,7 +556,7 @@ export class GVGBattleHandler {
|
||||
let settleResult = await GVGCityAreaPointModel.settlePoint(cityId, attackTeam.areaId, defenseTeam.originPointId, attackTeam, defenseTeam.isRobot? '': defenseTeam.teamCode);
|
||||
if(settleResult) attackTeam = await GVGTeamModel.settlePoint(attackTeam.teamCode, defenseTeam.originPointId);
|
||||
} else {
|
||||
await GVGCityAreaPointModel.leavePoint(configId, groupKey, defenseTeam.originPointId);
|
||||
await GVGCityAreaPointModel.leavePoint(configId, groupKey, defenseTeam.teamCode);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -739,17 +743,20 @@ export class GVGBattleHandler {
|
||||
|
||||
let fun = async () => {
|
||||
let teams = teamObj.findTeamsByRole('test');
|
||||
for(let teamMem of teams) {
|
||||
let fromAreaId = teamMem.areaId;
|
||||
let dicArea = gameData.gvgArea.get(fromAreaId);
|
||||
// 更新内存数据
|
||||
let toAreaId = getRandSingleEelm(dicArea.relateArea);
|
||||
let team = await GVGTeamModel.startMove(teamMem.teamCode, toAreaId, fromAreaId);
|
||||
|
||||
// 更新内存数据
|
||||
let teamObj = getGVGBattleData(groupKey);
|
||||
teamObj.move(teamMem.teamCode, toAreaId, team.fromAreaId, team.startMoveTime, team.stopMoveTime);
|
||||
await pushTeamMoveMessage(team);
|
||||
for(let i = 0; i < teams.length; i++) {
|
||||
let teamMem = teams[i];
|
||||
setTimeout(async () => {
|
||||
let fromAreaId = teamMem.areaId;
|
||||
let dicArea = gameData.gvgArea.get(fromAreaId);
|
||||
// 更新内存数据
|
||||
let toAreaId = getRandSingleEelm(dicArea.relateArea);
|
||||
let team = await GVGTeamModel.startMove(teamMem.teamCode, toAreaId, fromAreaId);
|
||||
|
||||
// 更新内存数据
|
||||
let teamObj = getGVGBattleData(groupKey);
|
||||
teamObj.move(teamMem.teamCode, toAreaId, team.fromAreaId, team.startMoveTime, team.stopMoveTime);
|
||||
await pushTeamMoveMessage(team);
|
||||
}, i * 100);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@@ -398,7 +398,7 @@ export async function catapultHurt() {
|
||||
for(let team of teams) {
|
||||
await pushTeamBeHurtMessage(team);
|
||||
if(team.curTeamBreak && team.originPointId > 0) {
|
||||
await GVGCityAreaPointModel.leavePoint(configId, teamObj.groupKey, team.originPointId);
|
||||
await GVGCityAreaPointModel.leavePoint(configId, teamObj.groupKey, team.teamCode);
|
||||
}
|
||||
if(!roleToTeams.has(team.roleId)) roleToTeams.set(team.roleId, []);
|
||||
roleToTeams.get(team.roleId).push(new GVGTeamInList(team));
|
||||
@@ -674,9 +674,9 @@ export async function battleEndSendMessage(groupKey: string, cityId: number, def
|
||||
export async function pushTeamBeHurtMessage(team: GVGTeamType, replaceTeam?: GVGTeamType) {
|
||||
if(team.curTeamBreak && team.originPointId > 0) {
|
||||
await sendMessageToGVGAreaByTeamWithSuc(team.groupKey, team.fromAreaId, PUSH_ROUTE.GVG_AREA_POINT_CHANGE, {
|
||||
cityId: team.cityId, areaId: team.fromAreaId, targetPointId: team.originPointId, originPointId: replaceTeam?.originPointId??0, point: new GVGTeamInListOnPoint(replaceTeam.pointId||team.pointId, true, replaceTeam||team)
|
||||
cityId: team.cityId, areaId: team.fromAreaId, targetPointId: team.originPointId, originPointId: replaceTeam?.originPointId??0, point: new GVGTeamInListOnPoint(replaceTeam?.pointId||team.pointId, true, replaceTeam||team)
|
||||
});
|
||||
if(!replaceTeam.curTeamBreak && replaceTeam.originPointId > 0) {
|
||||
if(replaceTeam && !replaceTeam.curTeamBreak && replaceTeam.originPointId > 0) {
|
||||
await sendMessageToGVGAreaByTeamWithSuc(replaceTeam.groupKey, replaceTeam.fromAreaId, PUSH_ROUTE.GVG_AREA_POINT_CHANGE, {
|
||||
cityId: replaceTeam.cityId, areaId: replaceTeam.fromAreaId, targetPointId: replaceTeam.originPointId, originPointId: 0, point: new GVGTeamInListOnPoint(replaceTeam.pointId, true, replaceTeam)
|
||||
});
|
||||
|
||||
@@ -388,7 +388,7 @@ export const STATUS = {
|
||||
GVG_BATTLE_TEAM_LOCK: { code: 21422, simStr: '正在有玩家挑战您,请等待' },
|
||||
GVG_BATTLE_TEAM_HAS_SELLTED: { code: 21423, simStr: '该编队已驻守据点了' },
|
||||
GVG_BATTLE_TEAM_LOCK_ENTERY_CITY: { code: 21424, simStr: '正在有玩家挑战您,请稍后切换城池' },
|
||||
GVG_POINT_TYPE_ERR: { code: 21425, simStr: '改积分点不可驻守' },
|
||||
GVG_POINT_TYPE_ERR: { code: 21425, simStr: '该积分点不可驻守' },
|
||||
|
||||
// 通用 30000 - 30099
|
||||
DIC_DATA_NOT_FOUND: { code: 30000, simStr: '数据表未找到' },
|
||||
|
||||
@@ -46,9 +46,8 @@ export default class GVGCityAreaPoint extends BaseModel {
|
||||
return result;
|
||||
}
|
||||
|
||||
public static async leavePoint(configId: number, groupKey: string, pointId: number) {
|
||||
let result: GVGCityAreaPointType = await GVGCityAreaPointModel.findOneAndUpdate({ configId, groupKey, pointId }, { $set: { teamCode: '', roleId: '', roleName: '', leagueCode: '', leagueName: '' }}, { new: true }).lean();
|
||||
return result;
|
||||
public static async leavePoint(configId: number, groupKey: string, teamCode: string) {
|
||||
await GVGCityAreaPointModel.updateMany({ configId, groupKey, teamCode }, { $set: { teamCode: '', roleId: '', roleName: '', leagueCode: '', leagueName: '' }}, { new: true }).lean();
|
||||
}
|
||||
|
||||
public static async playerLeave(configId: number, groupKey: string, roleId: string) {
|
||||
|
||||
Reference in New Issue
Block a user