🐞 fix(gvg): 修复激战期离开战场逻辑

This commit is contained in:
luying
2023-02-22 11:01:09 +08:00
parent e2e901dc1b
commit cfed1f1430
5 changed files with 40 additions and 16 deletions

View File

@@ -21,6 +21,7 @@ import { sendMessageToGVGAreaByTeamWithSuc, sendMessageToGVGAreaWithSuc, sendMes
import { sendMailToLeagueByContent } from "../mailService";
import { GVGCityAreaPointModel } from "../../db/GVGCityAreaPoint";
import { addCityGuardMessage } from "./gvgRecService";
import { GVGUserDataModel } from "../../db/GVGUserData";
/**
@@ -130,6 +131,26 @@ export function calBattleScoreByCe(isSuccess: boolean, lineupCe: number) {
return isSuccess? winScore: 0;
}
export async function leaveCity(roleId: string, isForce: boolean) {
let teams = await GVGTeamModel.findByRole(roleId);
let hasPoint = false, myTeam: GVGTeamType;
for(let team of teams) {
if(team.pointId > 0) hasPoint = true;
myTeam = team;
}
if(isForce || !hasPoint) {
let leaveResult = await GVGTeamModel.leaveCity(roleId);
if(leaveResult) {
await GVGCityModel.decreasePlayer(myTeam.configId, myTeam.groupKey, myTeam.cityId, roleId);
await GVGUserDataModel.changeCity(myTeam.configId, myTeam.leagueCode, roleId, 0);
// 处理内存数据
let teamObj = getGVGBattleData(myTeam.groupKey);
teamObj.leaveCity(roleId);
}
}
}
// 复活cd
export async function getTechReviveMinus(configId: number, leagueCode: string) {
let leaguePrepare = await GVGLeaguePrepareModel.findByLeague(configId, leagueCode);