🐞 fix(gvg): 修复零散小问题
This commit is contained in:
@@ -134,10 +134,19 @@ export class GVGBattleHandler {
|
||||
// 进入城池之前的检查
|
||||
async checkMyTeam(msg: { cityId: number }, session: BackendSession) {
|
||||
const roleId = session.get('roleId');
|
||||
const serverId = session.get('serverId');
|
||||
const guildCode = session.get('guildCode');
|
||||
|
||||
const { cityId } = msg;
|
||||
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不一致,说明玩家已经进入了其他城池
|
||||
for(let { cityId: teamCityId } of teams) {
|
||||
if(teamCityId > 0 && teamCityId != cityId) {
|
||||
@@ -384,6 +393,9 @@ export class GVGBattleHandler {
|
||||
|
||||
// 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) });
|
||||
}
|
||||
|
||||
@@ -408,6 +420,9 @@ export class GVGBattleHandler {
|
||||
let teamObj = getGVGBattleData(groupKey);
|
||||
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) });
|
||||
}
|
||||
|
||||
@@ -474,7 +489,9 @@ export class GVGBattleHandler {
|
||||
}
|
||||
if(defenseTeam.curTeamBreak) {
|
||||
let attackScore = calBattleScoreByCe(isSuccess, defenseTeam.lineupCe);
|
||||
let attackCurTeamBreak = attackTeam.curTeamBreak;
|
||||
attackTeam = await GVGTeamModel.addScore(attackTeam.teamCode, attackScore, 0);
|
||||
attackTeam.curTeamBreak = attackCurTeamBreak;
|
||||
await redisAddBattleScore(attackTeam, attackScore);
|
||||
}
|
||||
|
||||
|
||||
@@ -170,12 +170,12 @@ class GVGBattleData {
|
||||
return teams;
|
||||
}
|
||||
|
||||
public findSettledPointMapByLeague() {
|
||||
public findSettledPointMapByLeague(cityId: number) {
|
||||
let pointByLeague = new Map<string, number[]>();
|
||||
for(let [_roleId, pointIds] of this.rolePoints) {
|
||||
for(let [pointId, teamCode] of pointIds) {
|
||||
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, []);
|
||||
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
|
||||
});
|
||||
}
|
||||
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) {
|
||||
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 });
|
||||
r.setGenerFieldsFun((obj => {
|
||||
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 sendMailToLeagueByContent(MAIL_TYPE.GVG_GUARD_CITY_REWARD, leagueCode, { params: [dicCity.cityName], goods: dicCityAdd.occupyReward }, league);
|
||||
await addCityGuardMessage(league, cityId);
|
||||
await GVGLeagueModel.removeAuto(leagueCode);
|
||||
}
|
||||
|
||||
// —————————— 定时器相关 end —————————— //
|
||||
|
||||
@@ -43,7 +43,8 @@ export async function createNewGVGConfig() {
|
||||
let autoLeagues = await GVGLeagueModel.findAutoCreateLeague();
|
||||
let needDissmissLeagueId: string[] = [], needDissmissLeagueCodes: string[] = [];
|
||||
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);
|
||||
needDissmissLeagueCodes.push(league.leagueCode);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user