🐞 fix(gvg): 修复零散小问题
This commit is contained in:
@@ -134,10 +134,19 @@ export class GVGBattleHandler {
|
|||||||
// 进入城池之前的检查
|
// 进入城池之前的检查
|
||||||
async checkMyTeam(msg: { cityId: number }, session: BackendSession) {
|
async checkMyTeam(msg: { cityId: number }, session: BackendSession) {
|
||||||
const roleId = session.get('roleId');
|
const roleId = session.get('roleId');
|
||||||
|
const serverId = session.get('serverId');
|
||||||
|
const guildCode = session.get('guildCode');
|
||||||
|
|
||||||
const { cityId } = msg;
|
const { cityId } = msg;
|
||||||
let hasSettled = false, otherCityId = 0;
|
let hasSettled = false, otherCityId = 0;
|
||||||
const teams = await GVGTeamModel.findByRole(roleId, 'cityId');
|
let { configId, period } = getGVGPeriodData();
|
||||||
|
if (period != GVG_PERIOD.BATTLE) return resResult(STATUS.GVG_NOT_BATTLE_PERIOD);
|
||||||
|
|
||||||
|
let myLeague = await GVGLeagueModel.findLeagueByGuild(guildCode);
|
||||||
|
if(!myLeague) return resResult(STATUS.GVG_LEAGUE_NOT_EXIST);
|
||||||
|
|
||||||
|
let groupKey = await getGroupKey(serverId);
|
||||||
|
let teams = await refreshTeams(configId, groupKey, roleId, myLeague);
|
||||||
// 玩家队伍信息中城池id不一致,说明玩家已经进入了其他城池
|
// 玩家队伍信息中城池id不一致,说明玩家已经进入了其他城池
|
||||||
for(let { cityId: teamCityId } of teams) {
|
for(let { cityId: teamCityId } of teams) {
|
||||||
if(teamCityId > 0 && teamCityId != cityId) {
|
if(teamCityId > 0 && teamCityId != cityId) {
|
||||||
@@ -384,6 +393,9 @@ export class GVGBattleHandler {
|
|||||||
|
|
||||||
// addTeamSettleRec(curTeam);
|
// addTeamSettleRec(curTeam);
|
||||||
|
|
||||||
|
await sendMessageToGVGAreaByTeamWithSuc(groupKey, curTeam.areaId, PUSH_ROUTE.GVG_AREA_POINT_CHANGE, {
|
||||||
|
cityId: curTeam.cityId, areaId: curTeam.areaId, point: new GVGTeamInListOnPoint(curTeam.pointId, true, curTeam)
|
||||||
|
});
|
||||||
return resResult(STATUS.SUCCESS, { curTeam: new MyTeamInfo(curTeam) });
|
return resResult(STATUS.SUCCESS, { curTeam: new MyTeamInfo(curTeam) });
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -408,6 +420,9 @@ export class GVGBattleHandler {
|
|||||||
let teamObj = getGVGBattleData(groupKey);
|
let teamObj = getGVGBattleData(groupKey);
|
||||||
teamObj.teamSettle(roleId, teamCode, 0);
|
teamObj.teamSettle(roleId, teamCode, 0);
|
||||||
|
|
||||||
|
await sendMessageToGVGAreaByTeamWithSuc(groupKey, curTeam.areaId, PUSH_ROUTE.GVG_AREA_POINT_CHANGE, {
|
||||||
|
cityId: curTeam.cityId, areaId: curTeam.areaId, point: new GVGTeamInListOnPoint(myTeam.pointId, true, curTeam)
|
||||||
|
});
|
||||||
return resResult(STATUS.SUCCESS, { curTeam: new MyTeamInfo(curTeam) });
|
return resResult(STATUS.SUCCESS, { curTeam: new MyTeamInfo(curTeam) });
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -474,7 +489,9 @@ export class GVGBattleHandler {
|
|||||||
}
|
}
|
||||||
if(defenseTeam.curTeamBreak) {
|
if(defenseTeam.curTeamBreak) {
|
||||||
let attackScore = calBattleScoreByCe(isSuccess, defenseTeam.lineupCe);
|
let attackScore = calBattleScoreByCe(isSuccess, defenseTeam.lineupCe);
|
||||||
|
let attackCurTeamBreak = attackTeam.curTeamBreak;
|
||||||
attackTeam = await GVGTeamModel.addScore(attackTeam.teamCode, attackScore, 0);
|
attackTeam = await GVGTeamModel.addScore(attackTeam.teamCode, attackScore, 0);
|
||||||
|
attackTeam.curTeamBreak = attackCurTeamBreak;
|
||||||
await redisAddBattleScore(attackTeam, attackScore);
|
await redisAddBattleScore(attackTeam, attackScore);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -170,12 +170,12 @@ class GVGBattleData {
|
|||||||
return teams;
|
return teams;
|
||||||
}
|
}
|
||||||
|
|
||||||
public findSettledPointMapByLeague() {
|
public findSettledPointMapByLeague(cityId: number) {
|
||||||
let pointByLeague = new Map<string, number[]>();
|
let pointByLeague = new Map<string, number[]>();
|
||||||
for(let [_roleId, pointIds] of this.rolePoints) {
|
for(let [_roleId, pointIds] of this.rolePoints) {
|
||||||
for(let [pointId, teamCode] of pointIds) {
|
for(let [pointId, teamCode] of pointIds) {
|
||||||
let team = this.teams.get(teamCode);
|
let team = this.teams.get(teamCode);
|
||||||
if(pointId > 0 && team && team.leagueCode) {
|
if(pointId > 0 && team && team.leagueCode && team.cityId == cityId) {
|
||||||
if(!pointByLeague.has(team.leagueCode)) pointByLeague.set(team.leagueCode, []);
|
if(!pointByLeague.has(team.leagueCode)) pointByLeague.set(team.leagueCode, []);
|
||||||
pointByLeague.get(team.leagueCode).push(team.pointId);
|
pointByLeague.get(team.leagueCode).push(team.pointId);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -404,10 +404,10 @@ export async function catapultHurt() {
|
|||||||
cityId: catapult.cityId, areaId, attackType: GVG_ATTACK_TYPE.CATAPULT, teams: myTeams
|
cityId: catapult.cityId, areaId, attackType: GVG_ATTACK_TYPE.CATAPULT, teams: myTeams
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
await sendMessageToGVGCityWithSuc(teamObj.groupKey, catapult.cityId, PUSH_ROUTE.GVG_SPINE_ATTACKED, {
|
|
||||||
cityId: catapult.cityId, areaId, teamCode: catapult.teamCode, attackType: GVG_ATTACK_TYPE.CATAPULT, spines: teams.map(team => new GVGAttackSpine(team, catapult.captapultAtk))
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
await sendMessageToGVGCityWithSuc(teamObj.groupKey, catapult.cityId, PUSH_ROUTE.GVG_SPINE_ATTACKED, {
|
||||||
|
cityId: catapult.cityId, areaId, teamCode: catapult.teamCode, attackType: GVG_ATTACK_TYPE.CATAPULT, spines: teams.map(team => new GVGAttackSpine(team, catapult.captapultAtk))
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -440,7 +440,7 @@ export async function redisAddSettleScore(gvgTeam: GVGTeamType, incScore: number
|
|||||||
// 获取排行榜
|
// 获取排行榜
|
||||||
export async function getBattleRanksByCity(configId: number, groupKey: string, cityId: number, myLeague?: GVGLeagueType) {
|
export async function getBattleRanksByCity(configId: number, groupKey: string, cityId: number, myLeague?: GVGLeagueType) {
|
||||||
let teamObj = getGVGBattleData(groupKey);
|
let teamObj = getGVGBattleData(groupKey);
|
||||||
let pointByLeague = teamObj.findSettledPointMapByLeague();
|
let pointByLeague = teamObj.findSettledPointMapByLeague(cityId);
|
||||||
let r = new Rank(REDIS_KEY.GVG_BATTLE_LEAGUE_RANK_BY_CITY, { configId, groupKey, cityId });
|
let r = new Rank(REDIS_KEY.GVG_BATTLE_LEAGUE_RANK_BY_CITY, { configId, groupKey, cityId });
|
||||||
r.setGenerFieldsFun((obj => {
|
r.setGenerFieldsFun((obj => {
|
||||||
if(obj instanceof LeagueRankInfo) {
|
if(obj instanceof LeagueRankInfo) {
|
||||||
@@ -591,7 +591,6 @@ async function addGuardCity(configId: number, groupKey: string, cityId: number,
|
|||||||
await GVGCityModel.guardCity(configId, groupKey, cityId, league);
|
await GVGCityModel.guardCity(configId, groupKey, cityId, league);
|
||||||
await sendMailToLeagueByContent(MAIL_TYPE.GVG_GUARD_CITY_REWARD, leagueCode, { params: [dicCity.cityName], goods: dicCityAdd.occupyReward }, league);
|
await sendMailToLeagueByContent(MAIL_TYPE.GVG_GUARD_CITY_REWARD, leagueCode, { params: [dicCity.cityName], goods: dicCityAdd.occupyReward }, league);
|
||||||
await addCityGuardMessage(league, cityId);
|
await addCityGuardMessage(league, cityId);
|
||||||
await GVGLeagueModel.removeAuto(leagueCode);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// —————————— 定时器相关 end —————————— //
|
// —————————— 定时器相关 end —————————— //
|
||||||
|
|||||||
@@ -43,7 +43,8 @@ export async function createNewGVGConfig() {
|
|||||||
let autoLeagues = await GVGLeagueModel.findAutoCreateLeague();
|
let autoLeagues = await GVGLeagueModel.findAutoCreateLeague();
|
||||||
let needDissmissLeagueId: string[] = [], needDissmissLeagueCodes: string[] = [];
|
let needDissmissLeagueId: string[] = [], needDissmissLeagueCodes: string[] = [];
|
||||||
for(let league of autoLeagues) {
|
for(let league of autoLeagues) {
|
||||||
if(!await GVGCityModel.checkLeagueHasGuard(config.configId, league.leagueCode)) {
|
let groupKey = await getGroupKey(league.serverId);
|
||||||
|
if(!await GVGCityModel.checkLeagueHasGuard(config.configId, groupKey, league.leagueCode)) {
|
||||||
needDissmissLeagueId.push(league._id);
|
needDissmissLeagueId.push(league._id);
|
||||||
needDissmissLeagueCodes.push(league.leagueCode);
|
needDissmissLeagueCodes.push(league.leagueCode);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -78,8 +78,8 @@ export default class GVGCity extends BaseModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 查询联军驻守情况
|
// 查询联军驻守情况
|
||||||
public static async checkLeagueHasGuard(configId: number, leagueCode: string) {
|
public static async checkLeagueHasGuard(configId: number, groupKey: string, leagueCode: string) {
|
||||||
return await GVGCityModel.exists({ configId, guardLeague: leagueCode, hasGuard: true });
|
return await GVGCityModel.exists({ configId: { $lte: configId }, groupKey, guardLeague: leagueCode, hasGuard: true });
|
||||||
}
|
}
|
||||||
|
|
||||||
// 查询联军驻守情况
|
// 查询联军驻守情况
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ export default class GVGCityAreaPoint extends BaseModel {
|
|||||||
|
|
||||||
public static async settlePoint(cityId: number, areaId: number, pointId: number, team: GVGTeamType) {
|
public static async settlePoint(cityId: number, areaId: number, pointId: number, team: GVGTeamType) {
|
||||||
let { configId, groupKey, leagueCode, leagueName, roleId, roleName, teamCode } = team;
|
let { configId, groupKey, leagueCode, leagueName, roleId, roleName, teamCode } = team;
|
||||||
|
await GVGCityAreaPointModel.updateMany({ configId, groupKey, teamCode }, { $set: { teamCode: '', roleId: '', roleName: '', leagueCode: '', leagueName: '' } });
|
||||||
await GVGCityAreaPointModel.findOneAndUpdate({ configId, groupKey, pointId }, { $setOnInsert: { teamCode: '' }}, { upsert: true });
|
await GVGCityAreaPointModel.findOneAndUpdate({ configId, groupKey, pointId }, { $setOnInsert: { teamCode: '' }}, { upsert: true });
|
||||||
let result: GVGCityAreaPointType = await GVGCityAreaPointModel.findOneAndUpdate(
|
let result: GVGCityAreaPointType = await GVGCityAreaPointModel.findOneAndUpdate(
|
||||||
{ configId, groupKey, pointId, teamCode: '' },
|
{ configId, groupKey, pointId, teamCode: '' },
|
||||||
|
|||||||
@@ -199,11 +199,6 @@ export default class GVGLeague extends BaseModel {
|
|||||||
let leagues: GVGLeagueType[] = await GVGLeagueModel.find({ isAuto: true, status: 1 }).lean();
|
let leagues: GVGLeagueType[] = await GVGLeagueModel.find({ isAuto: true, status: 1 }).lean();
|
||||||
return leagues
|
return leagues
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async removeAuto(leagueCode: string) {
|
|
||||||
let league: GVGLeagueType = await GVGLeagueModel.findOneAndUpdate({ leagueCode }, { $set: { isAuto: false } }).lean();
|
|
||||||
return league
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const GVGLeagueModel = getModelForClass(GVGLeague);
|
export const GVGLeagueModel = getModelForClass(GVGLeague);
|
||||||
|
|||||||
@@ -689,6 +689,7 @@ export class GVGAreaInMap {
|
|||||||
// 地图右边列表上的队伍信息
|
// 地图右边列表上的队伍信息
|
||||||
export class GVGTeamInList {
|
export class GVGTeamInList {
|
||||||
areaId: number;
|
areaId: number;
|
||||||
|
pointId: number;
|
||||||
teamCode: string;
|
teamCode: string;
|
||||||
roleName: string;
|
roleName: string;
|
||||||
head: number;
|
head: number;
|
||||||
@@ -705,6 +706,7 @@ export class GVGTeamInList {
|
|||||||
constructor(team: GVGTeamType) {
|
constructor(team: GVGTeamType) {
|
||||||
if(!team) return;
|
if(!team) return;
|
||||||
this.areaId = team.areaId;
|
this.areaId = team.areaId;
|
||||||
|
this.pointId = team.pointId;
|
||||||
this.teamCode = team.teamCode;
|
this.teamCode = team.teamCode;
|
||||||
this.roleName = team.roleName;
|
this.roleName = team.roleName;
|
||||||
this.head = team.head;
|
this.head = team.head;
|
||||||
|
|||||||
Reference in New Issue
Block a user