feat(gvg): 优化血量继承、实时刷新、遗迹天数、系统播报 6267076fc
This commit is contained in:
@@ -7,7 +7,7 @@ import { Application, BackendSession, ChannelService, HandlerService, pinus } fr
|
||||
import { resResult, genCode, getRandSingleEelm } from "../../../pubUtils/util";
|
||||
import { GVGLeagueModel } from '../../../db/GVGLeague';
|
||||
import { getGroupKey, getGVGConfig, getGVGPeriodData, getGVGServerType } from '../../../services/gvg/gvgService';
|
||||
import { redisAddBattleScore, battleEndSendMessage, calBattleScoreByCe, checkAreaIsInCity, checkGVGBattleStart, checkMoveStatus, getBattleRanksByCity, getBirthAreaOfCity, getGVGWarId, getOppHeroes, getTechKnifeHurt, getTechReviveMinus, initRobots, pushTeamMoveMessage, getAllGVGCitiesInfo, leaveCity, refreshTeams, checkEnterCityTime, generNewLineup, getBattleRank, checkSettleStatus, getSpineCnt, getPlayerRanksByCity, getPlayerSettleRanksByCity, checkGVGLineupWhenSave } from '../../../services/gvg/gvgBattleService';
|
||||
import { redisAddBattleScore, battleEndSendMessage, calBattleScoreByCe, checkAreaIsInCity, checkGVGBattleStart, checkMoveStatus, getBattleRanksByCity, getBirthAreaOfCity, getGVGWarId, getOppHeroes, getTechKnifeHurt, getTechReviveMinus, initRobots, pushTeamMoveMessage, getAllGVGCitiesInfo, leaveCity, refreshTeams, checkEnterCityTime, generNewLineup, getBattleRank, checkSettleStatus, getSpineCnt, getPlayerRanksByCity, getPlayerSettleRanksByCity, checkGVGLineupWhenSave, sendWinStreakMessage, getNewLineup, sendAreaPointChange } from '../../../services/gvg/gvgBattleService';
|
||||
import { getGVGBattleData } from '../../../services/memoryCache/gvgBattleData';
|
||||
import { GVGBattleRecModel } from '../../../db/GVGBattleRec';
|
||||
import { getFightTimeByPeriod } from '../../../services/gvg/gvgFightService';
|
||||
@@ -30,6 +30,7 @@ import { EXTERIOR, GVG } from '../../../pubUtils/dicParam';
|
||||
import { sendMessageToGuildWithSuc, sendMessageToGVGAreaByTeamWithSuc, sendMessageToUserWithSuc } from '../../../services/pushService';
|
||||
import { checkLeagueAuth } from '../../../services/gvg/gvgTeamService';
|
||||
import { GVGLeaguePrepareModel } from '../../../db/GVGLeaguePrepare';
|
||||
import { gvgEndParamInter } from '../../../pubUtils/interface';
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
@@ -69,7 +70,7 @@ export class GVGBattleHandler {
|
||||
let { configId, period } = getGVGPeriodData();
|
||||
if (period != GVG_PERIOD.BATTLE) return resResult(STATUS.GVG_NOT_BATTLE_PERIOD);
|
||||
|
||||
let checkLineupResult = await checkGVGLineupWhenSave(roleId, index, lineup);
|
||||
let checkLineupResult = await checkGVGLineupWhenSave(roleId, index, lineup||[]);
|
||||
if(checkLineupResult.code != 0) return resResult(checkLineupResult);
|
||||
|
||||
let myLeague = await GVGLeagueModel.findLeagueByGuild(guildCode);
|
||||
@@ -307,11 +308,22 @@ export class GVGBattleHandler {
|
||||
result.push(new GVGTeamSpineInMap(team, serverNames))
|
||||
}
|
||||
}
|
||||
// 加入频道
|
||||
|
||||
return resResult(STATUS.SUCCESS, { cityId, spines: result });
|
||||
}
|
||||
|
||||
// 加入频道
|
||||
async addAreaChannel(msg: { cityId: number, areaIds: number[] }, session: BackendSession) {
|
||||
const roleId = session.get('roleId');
|
||||
const sid = session.get('sid');
|
||||
const serverId = session.get('serverId');
|
||||
const { areaIds } = msg;
|
||||
let groupKey = await getGroupKey(serverId);
|
||||
|
||||
await leaveGVGAreaChannel(roleId, sid);
|
||||
await addRoleToAreaChannel(roleId, groupKey, areaIds, sid);
|
||||
|
||||
return resResult(STATUS.SUCCESS, { cityId, spines: result });
|
||||
return resResult(STATUS.SUCCESS);
|
||||
}
|
||||
|
||||
// 点击自己的编队获取区域列表
|
||||
@@ -431,10 +443,7 @@ export class GVGBattleHandler {
|
||||
teamObj.teamSettle(roleId, teamCode, pointId);
|
||||
|
||||
// addTeamSettleRec(curTeam);
|
||||
|
||||
await sendMessageToGVGAreaByTeamWithSuc(groupKey, curTeam.areaId, PUSH_ROUTE.GVG_AREA_POINT_CHANGE, {
|
||||
cityId: curTeam.cityId, areaId: curTeam.areaId, targetPointId: pointId, originPointId: myTeam.pointId, point: new GVGTeamInListOnPoint(curTeam.pointId, true, curTeam)
|
||||
});
|
||||
await sendAreaPointChange(groupKey, curTeam.areaId, curTeam.cityId, pointId, myTeam.pointId, curTeam);
|
||||
return resResult(STATUS.SUCCESS, { curTeam: new MyTeamInfo(curTeam) });
|
||||
}
|
||||
|
||||
@@ -463,9 +472,7 @@ 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, targetPointId: pointId, originPointId: myTeam.pointId, point: new GVGTeamInListOnPoint(curTeam.pointId, true, curTeam)
|
||||
});
|
||||
await sendAreaPointChange(groupKey, curTeam.areaId, curTeam.cityId, pointId, myTeam.pointId, curTeam);
|
||||
return resResult(STATUS.SUCCESS, { curTeam: new MyTeamInfo(curTeam) });
|
||||
}
|
||||
|
||||
@@ -504,9 +511,9 @@ export class GVGBattleHandler {
|
||||
}
|
||||
|
||||
// 队伍停止攻击
|
||||
async battleEnd(msg: { cityId: number, battleCode: string, isSuccess: boolean }, session: BackendSession) {
|
||||
async battleEnd(msg: { cityId: number, battleCode: string, isSuccess: boolean, myHeroes: gvgEndParamInter[], oppHeroes: gvgEndParamInter[] }, session: BackendSession) {
|
||||
const serverId = session.get('serverId');
|
||||
const { cityId, battleCode, isSuccess } = msg;
|
||||
const { cityId, battleCode, isSuccess, myHeroes = [], oppHeroes = [] } = msg;
|
||||
|
||||
let { configId, period } = getGVGPeriodData();
|
||||
let { startFightTime, endFightTime } = getFightTimeByPeriod(period);
|
||||
@@ -526,8 +533,8 @@ export class GVGBattleHandler {
|
||||
|
||||
// 计算并更新两支队伍耐久
|
||||
let { win, fail } = gameData.gvgBattleDurabilityMinus;
|
||||
attackTeam = await GVGTeamModel.battleEndAttack(attackTeam.teamCode, isSuccess? -win: -fail, getBirthAreaOfCity(city, attackTeam.leagueCode), await getTechReviveMinus(groupKey, configId, attackTeam.leagueCode));
|
||||
defenseTeam = await GVGTeamModel.battleEndDefense(defenseTeam.teamCode, isSuccess? -fail: -win, getBirthAreaOfCity(city, defenseTeam.leagueCode), GVG.GVG_DEFAULT_DEFENSE_CD, await getTechReviveMinus(groupKey, configId, defenseTeam.leagueCode));
|
||||
attackTeam = await GVGTeamModel.battleEndAttack(attackTeam.teamCode, isSuccess? -win: -fail, getBirthAreaOfCity(city, attackTeam.leagueCode), await getTechReviveMinus(groupKey, configId, attackTeam.leagueCode), getNewLineup(attackTeam, myHeroes));
|
||||
defenseTeam = await GVGTeamModel.battleEndDefense(defenseTeam.teamCode, isSuccess? -fail: -win, getBirthAreaOfCity(city, defenseTeam.leagueCode), GVG.GVG_DEFAULT_DEFENSE_CD, await getTechReviveMinus(groupKey, configId, defenseTeam.leagueCode), getNewLineup(defenseTeam, oppHeroes));
|
||||
if(defenseTeam.curTeamBreak && defenseTeam.originPointId > 0 && !defenseTeam.isCatapult) { // 打败的对手原来占领着一个位置,现在这个位置是你的了
|
||||
if(!attackTeam.curTeamBreak) {
|
||||
let settleResult = await GVGCityAreaPointModel.settlePoint(cityId, attackTeam.areaId, defenseTeam.originPointId, attackTeam, defenseTeam.isRobot? '': defenseTeam.teamCode);
|
||||
@@ -554,6 +561,8 @@ export class GVGBattleHandler {
|
||||
let rec = await GVGBattleRecModel.battleEnd(battleCode, isSuccess, attackTeam, defenseTeam);
|
||||
await battleEndSendMessage(groupKey, cityId, defenseTeam, {...attackTeam, originPointId: attackOriginId}, GVG_ATTACK_TYPE.PLAYER);
|
||||
addBattleEndRec(rec);
|
||||
// 连胜邮件
|
||||
sendWinStreakMessage(groupKey, cityId, attackTeam, defenseTeam, isSuccess);
|
||||
|
||||
return resResult(STATUS.SUCCESS, { curTeam: new MyTeamInfo(attackTeam), oppTeam: new MyTeamInfo(defenseTeam) });
|
||||
}
|
||||
@@ -821,6 +830,16 @@ export class GVGBattleHandler {
|
||||
})
|
||||
}
|
||||
|
||||
// 获取我的编队信息
|
||||
async getOppTeam(msg: { cityId: number, teamCode: string }, session: BackendSession) {
|
||||
let { teamCode } = msg;
|
||||
const team = await GVGTeamModel.findByCode(teamCode)
|
||||
if (!team) return resResult(STATUS.GVG_TEAM_NOT_FOUND);
|
||||
const warId = getGVGWarId(team);
|
||||
|
||||
return resResult(STATUS.SUCCESS, { warId, oppTeam: new MyTeamInfo(team) });
|
||||
}
|
||||
|
||||
async debugStartSchedule() {
|
||||
let { countdownTime } = getGVGPeriodData();
|
||||
pinus.app.rpc.guild.guildRemote.setPeriodTime.broadcast(nowSeconds(), countdownTime);
|
||||
@@ -845,7 +864,7 @@ export class GVGBattleHandler {
|
||||
const areaIds = gameData.gvgCity.get(cityId)?.areaIds||[];
|
||||
for(let i = 0; i < teamCnt; i++) {
|
||||
let areaId = getRandSingleEelm(areaIds);
|
||||
teams.push({ configId, groupKey, roleId: 'test', roleName: 'test' + i, serverId, lv: 100, teamCode: genCode(8), index: 3, leagueCode: 'test', leagueName: 'test' + i, guildCode: 'test', areaId, cityId, pointId: 0, head: EXTERIOR.EXTERIOR_FACE, frame: EXTERIOR.EXTERIOR_FACECASE, spine: EXTERIOR.EXTERIOR_APPEARANCE, durability: 100, maxDurability: 100, restartTime: nowSeconds(), attackTime: nowSeconds(), lockTime: nowSeconds(), startMoveTime: nowSeconds(), stopMoveTime: nowSeconds(), moveCdTime: nowSeconds(), defenseTime: nowSeconds(), lineupCe: 100000 })
|
||||
teams.push({ configId, confirmConfigId: configId, title: 1, groupKey, roleId: 'test', roleName: 'test' + i, serverId, lv: 100, teamCode: genCode(8), index: 3, leagueCode: 'test', leagueName: 'test' + i, guildCode: 'test', areaId, cityId, pointId: 0, head: EXTERIOR.EXTERIOR_FACE, frame: EXTERIOR.EXTERIOR_FACECASE, spine: EXTERIOR.EXTERIOR_APPEARANCE, durability: 100, maxDurability: 100, restartTime: nowSeconds(), attackTime: nowSeconds(), lockTime: nowSeconds(), startMoveTime: nowSeconds(), stopMoveTime: nowSeconds(), moveCdTime: nowSeconds(), defenseTime: nowSeconds(), lineupCe: 100000 })
|
||||
}
|
||||
await GVGTeamModel.insertMany(teams);
|
||||
teamObj.enterCity(...teams);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { isArray, isBoolean, isNumber, isString } from "underscore";
|
||||
import { BLOCK_OPEATE, DEBUG_MAGIC_WORD, GM_MAIL_TYPE, GUILD_AUTH, GUILD_STRUCTURE, GVG_RESOURCE_TYPE, GVG_SEED_TYPE, LEAGUE_JOB, LINEUP_NUM, MSG_TYPE } from "../consts";
|
||||
import { pvpEndParamInter } from "../pubUtils/interface";
|
||||
import { gvgEndParamInter, pvpEndParamInter } from "../pubUtils/interface";
|
||||
import { isDevelopEnv } from "./utilService";
|
||||
|
||||
export function checkRouteParam(route: string, msg: any) {
|
||||
@@ -1779,6 +1779,8 @@ export function checkRouteParam(route: string, msg: any) {
|
||||
{
|
||||
if (!checkNaturalStrings(msg.battleCode)) return false;
|
||||
if (!checkBoolean(msg.isSuccess)) return false;
|
||||
if (!checkGvgEndHeroFormat(msg.myHeroes)) return false;
|
||||
if (!checkGvgEndHeroFormat(msg.oppHeroes)) return false;
|
||||
break;
|
||||
}
|
||||
case "guild.gvgBattleHandler.useItem":
|
||||
@@ -1818,6 +1820,12 @@ export function checkRouteParam(route: string, msg: any) {
|
||||
if (!checkStringIfExist(msg.notice)) return false;
|
||||
break;
|
||||
}
|
||||
case "guild.gvgBattleHandler.getOppTeam":
|
||||
{
|
||||
if (!checkNaturalNumbers(msg.cityId)) return false;
|
||||
if (!checkNaturalStrings(msg.teamCode)) return false;
|
||||
break;
|
||||
}
|
||||
case "order.orderHandler.applyOrder":
|
||||
{
|
||||
let { productID, payType, activityId, paramStr, useVoucher } = msg;
|
||||
@@ -2619,6 +2627,17 @@ function checkPvpEndHeroFormat(...params: pvpEndParamInter[][]) {
|
||||
return true;
|
||||
}
|
||||
|
||||
function checkGvgEndHeroFormat(...params: gvgEndParamInter[][]) {
|
||||
for (let param of params) {
|
||||
if (!checkArrayCanEmpty(param)) return false;
|
||||
for (let { actorId, hp, others } of param) {
|
||||
if (!checkNaturalNumbers(actorId, hp)) return false;
|
||||
if (!checkStringIfExist(others)) return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function checkIsInEnum<T>(someEnum: T, value: T) {
|
||||
return Object.values(someEnum).includes(value)
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import { COUNTER, GVG_AREA_TYPE, GVG_ATTACK_TYPE, GVG_BATTLE_RANK_TYPE, GVG_PERI
|
||||
import { getTimeFun, nowSeconds } from "../../pubUtils/timeUtil";
|
||||
import { DicGVGAreaPoint } from "../../pubUtils/dictionary/DicGVGAreaPoint";
|
||||
import { getGVGBattleData, getGVGBattleMap } from "../memoryCache/gvgBattleData";
|
||||
import { GVGAttackSpine, GVGCityMapInfo, GVGTeamInList, GVGTeamInListOnPoint, GVGTeamSpineInMap } from "../../domain/gvgField/returnData";
|
||||
import { GVGAttackSpine, GVGCityMapInfo, GVGEnemies, GVGTeamInList, GVGTeamInListOnPoint, GVGTeamSpineInMap, GVGTeamSpineInfo, GVGWinStreakInfo } from "../../domain/gvgField/returnData";
|
||||
import { GVG } from "../../pubUtils/dicParam";
|
||||
import { GVGHeroInfo, PvpEnemies, PvpHeroInfo } from "../../domain/dbGeneral";
|
||||
import { getGroupKey, getGVGConfig, getGVGConfigFromRemote, getGVGPeriodData, getGVGServerType } from "./gvgService";
|
||||
@@ -16,7 +16,7 @@ import { pinus } from "pinus";
|
||||
import { dispatch } from "../../pubUtils/dispatcher";
|
||||
import { Rank } from "../rankService";
|
||||
import { KeyNameParam, LeagueRankInfo, myIdInter, RoleRankInfo } from "../../domain/rank";
|
||||
import { findKeys, getAllServerName, redisClient } from "../redisService";
|
||||
import { findKeys, getAllServerName, getServerName, redisClient } from "../redisService";
|
||||
import { sendMessageToGVGAreaByTeamWithSuc, sendMessageToGVGAreaWithSuc, sendMessageToGVGCityWithSuc, sendMessageToUserWithSuc } from "../pushService";
|
||||
import { sendMailByContent, sendMailToLeagueByContent } from "../mailService";
|
||||
import { GVGCityAreaPointModel } from "../../db/GVGCityAreaPoint";
|
||||
@@ -24,13 +24,14 @@ import { addCityGuardMessage } from "./gvgRecService";
|
||||
import { GVGUserDataModel } from "../../db/GVGUserData";
|
||||
import { RoleModel } from "../../db/Role";
|
||||
import { getFightTimeByPeriod } from "./gvgFightService";
|
||||
import { getRandSingleEelm } from "../../pubUtils/util";
|
||||
import { getRandSingleEelm, parseNumberList } from "../../pubUtils/util";
|
||||
import { HeroModel, HeroType } from "../../db/Hero";
|
||||
import { ArtifactModel } from "../../db/Artifact";
|
||||
import { getHeroesAttributes } from "../playerCeService";
|
||||
import { CounterModel } from "../../db/Counter";
|
||||
import { getGroupIdOfServer } from "../serverService";
|
||||
import { LineupHero } from "../../domain/roleField/hero";
|
||||
import { gvgEndParamInter } from "../../pubUtils/interface";
|
||||
|
||||
/**
|
||||
* 获取本联军上周占领的城池
|
||||
@@ -253,9 +254,7 @@ export async function leaveCity(isForce: boolean, roleId: string, serverId: numb
|
||||
await pinus.app.rpc.guild.guildRemote.leaveCityMem.broadcast(groupKey, roleId);
|
||||
for(let team of teams) {
|
||||
if(team.cityId > 0 && team.areaId > 0) {
|
||||
await sendMessageToGVGAreaByTeamWithSuc(groupKey, team.areaId, PUSH_ROUTE.GVG_PLAYER_LEAVE_AREA, {
|
||||
cityId: team.cityId, areaId: team.areaId, teamCode: team.teamCode
|
||||
});
|
||||
await sendAreaLeaveMsg(groupKey, team.areaId, team.cityId, team.teamCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -310,7 +309,7 @@ export function getGVGWarId(defenseTeam: GVGTeamType) {
|
||||
|
||||
// guild.gvgBattleHandler.battleStart 里的heroes返回
|
||||
export function getOppHeroes(warId: number, isRobot: boolean, lineup: GVGHeroInfo[]) {
|
||||
let heroes: PvpEnemies[] = [];
|
||||
let heroes: GVGEnemies[] = [];
|
||||
const dicWar = gameData.war.get(warId);
|
||||
if(!dicWar) { console.error(`warId ${warId} not found`); return [] }
|
||||
const dicWarJson = gameData.warJson.get(dicWar.dispatchJsonId)||[];
|
||||
@@ -318,15 +317,15 @@ export function getOppHeroes(warId: number, isRobot: boolean, lineup: GVGHeroInf
|
||||
if(!isRobot) {
|
||||
let heroInfo = lineup.find(cur => cur.dataId == warJson.dataId);
|
||||
if(!heroInfo) continue;
|
||||
let hero = new PvpEnemies(warJson, heroInfo);
|
||||
let hero = new GVGEnemies(warJson, heroInfo);
|
||||
heroes.push(hero);
|
||||
} else {
|
||||
if(warJson.relation == 2) {
|
||||
let dicHero = gameData.hero.get(warJson.actorId);
|
||||
if(!dicHero) continue;
|
||||
let heroInfo = new PvpHeroInfo();
|
||||
let heroInfo = new GVGHeroInfo();
|
||||
heroInfo.setRobotInfo(dicHero, warJson.lv);
|
||||
let hero = new PvpEnemies(warJson, heroInfo);
|
||||
let hero = new GVGEnemies(warJson, heroInfo);
|
||||
heroes.push(hero);
|
||||
}
|
||||
}
|
||||
@@ -354,6 +353,38 @@ export function checkGVGBattleStart(roleId: string, attackTeam: GVGTeamType, def
|
||||
return STATUS.SUCCESS;
|
||||
}
|
||||
|
||||
export function getNewLineup(team: GVGTeamType, newInfo: gvgEndParamInter[]) {
|
||||
if (team.isRobot) return { isAllDead: false, newLineup: team.lineup};
|
||||
let isAllDead = team.curTeamBreak || checkAllDead(team.lineup, newInfo);
|
||||
let newLineup: GVGHeroInfo[] = [];
|
||||
for(let hero of team.lineup) {
|
||||
if (isAllDead) {
|
||||
hero.hp = "max";
|
||||
hero.maxHp = "max";
|
||||
hero.others = '';
|
||||
} else {
|
||||
let info = newInfo.find(cur => cur.actorId == hero.actorId);
|
||||
if (info) {
|
||||
hero.hp = info.hp;
|
||||
hero.maxHp = info.maxHp;
|
||||
hero.others = info.others;
|
||||
}
|
||||
}
|
||||
|
||||
newLineup.push(hero);
|
||||
}
|
||||
return { isAllDead, newLineup };
|
||||
}
|
||||
|
||||
// 检查本场战斗武将是否死光了
|
||||
export function checkAllDead(oldLineup: GVGHeroInfo[], newInfo: gvgEndParamInter[]) {
|
||||
for(let hero of oldLineup) {
|
||||
let curInfo = newInfo.find(cur => cur.actorId == hero.actorId);
|
||||
if (!curInfo || curInfo.hp > 0) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// —————————— 定时器相关 —————————— //
|
||||
// gvg激战期开始定时器
|
||||
export async function gvgBattleStart() {
|
||||
@@ -553,9 +584,9 @@ export async function getPlayerRanksByCity(configId: number, groupKey: string, c
|
||||
export async function gvgBattleSeconds() {
|
||||
const { configId, period } = getGVGPeriodData();
|
||||
let { startFightTime, endFightTime } = getFightTimeByPeriod(period);
|
||||
const serverNames = await getAllServerName();
|
||||
// const serverNames = await getAllServerName();
|
||||
|
||||
let spineCnt = await getSpineCnt();
|
||||
// let spineCnt = await getSpineCnt();
|
||||
let keys: { groupKey: string, cityId: number }[] = []
|
||||
for(let [_key, teamObj] of getGVGBattleMap()) {
|
||||
// console.log('#### gvgBattleSeconds groupKey: ', _key, 'areas', teamObj.findAreas(), 'appid', pinus.app.getServerId());
|
||||
@@ -571,19 +602,19 @@ export async function gvgBattleSeconds() {
|
||||
}
|
||||
|
||||
// 向下推送区域数据
|
||||
let spinesByCity = new Map<number, GVGTeamSpineInMap[]>();
|
||||
// let spinesByCity = new Map<number, GVGTeamSpineInMap[]>();
|
||||
for(let areaId of teamObj.findAreas()) {
|
||||
let dicArea = gameData.gvgArea.get(areaId);
|
||||
let teams = teamObj.findTeamsByArea(areaId, spineCnt);
|
||||
let spines = teams.map(team => new GVGTeamSpineInMap(team, serverNames));
|
||||
if(!spinesByCity.has(dicArea.cityId)) spinesByCity.set(dicArea.cityId, []);
|
||||
spinesByCity.get(dicArea.cityId).push(...spines);
|
||||
// let teams = teamObj.findTeamsByArea(areaId, spineCnt);
|
||||
// let spines = teams.map(team => new GVGTeamSpineInMap(team, serverNames));
|
||||
// if(!spinesByCity.has(dicArea.cityId)) spinesByCity.set(dicArea.cityId, []);
|
||||
// spinesByCity.get(dicArea.cityId).push(...spines);
|
||||
let index = keys.findIndex(cur => cur.cityId == dicArea.cityId && cur.groupKey == teamObj.groupKey);
|
||||
if(index == -1) keys.push({ groupKey: teamObj.groupKey, cityId: dicArea.cityId });
|
||||
}
|
||||
for(let [cityId, spines] of spinesByCity) {
|
||||
if(spines.length > 0) await sendMessageToGVGCityWithSuc(teamObj.groupKey, cityId, PUSH_ROUTE.GVG_AREA_SPINE_CHANGE, { cityId, spines });
|
||||
}
|
||||
// for(let [cityId, spines] of spinesByCity) {
|
||||
// if(spines.length > 0) await sendMessageToGVGCityWithSuc(teamObj.groupKey, cityId, PUSH_ROUTE.GVG_AREA_SPINE_CHANGE, { cityId, spines });
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
@@ -768,23 +799,39 @@ export async function battleEndSendMessage(groupKey: string, cityId: number, def
|
||||
});
|
||||
if(!defenseTeam.isRobot) {
|
||||
await sendMessageToUserWithSuc(defenseTeam.roleId, PUSH_ROUTE.GVG_MY_TEAM_ATTACKED, {
|
||||
cityId, areaId, attackType, teams: [new GVGTeamInList(defenseTeam)]
|
||||
cityId, areaId, attackType, teams: [new GVGTeamInList(defenseTeam, true)]
|
||||
});
|
||||
}
|
||||
await pushTeamBeHurtMessage(defenseTeam, attackTeam);
|
||||
await pushTeamBeHurtMessage(attackTeam);
|
||||
}
|
||||
|
||||
export async function sendWinStreakMessage(groupKey: string, cityId: number, attackTeam: GVGTeamType, defenseTeam: GVGTeamType, isSuccess: boolean) {
|
||||
if (attackTeam && !attackTeam.isRobot) {
|
||||
let result = await GVGUserDataModel.setWinStreak(attackTeam.configId, attackTeam.leagueCode, attackTeam.roleId, isSuccess);
|
||||
if (needSendMsg(result.winStreak)) {
|
||||
await sendMessageToGVGCityWithSuc(groupKey, cityId, PUSH_ROUTE.GVG_WIN_STREAK, new GVGWinStreakInfo(attackTeam, result.winStreak));
|
||||
}
|
||||
}
|
||||
if (defenseTeam && !defenseTeam.isRobot) {
|
||||
let result = await GVGUserDataModel.setWinStreak(defenseTeam.configId, defenseTeam.leagueCode, defenseTeam.roleId, !isSuccess);
|
||||
if (needSendMsg(result.winStreak)) {
|
||||
await sendMessageToGVGCityWithSuc(groupKey, cityId, PUSH_ROUTE.GVG_WIN_STREAK, new GVGWinStreakInfo(defenseTeam, result.winStreak));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function needSendMsg(winStreak: number) {
|
||||
let arr = parseNumberList(GVG.WIN_STREAK_REPORT_LIMIT);
|
||||
return arr.includes(winStreak);
|
||||
}
|
||||
|
||||
// 队伍移动
|
||||
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)
|
||||
});
|
||||
await sendAreaPointChange(team.groupKey, team.fromAreaId, team.cityId, team.originPointId, replaceTeam?.originPointId??0, replaceTeam||team);
|
||||
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)
|
||||
});
|
||||
await sendAreaPointChange(replaceTeam.groupKey, replaceTeam.fromAreaId, replaceTeam.cityId, replaceTeam.originPointId, 0, replaceTeam);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -792,28 +839,45 @@ export async function pushTeamBeHurtMessage(team: GVGTeamType, replaceTeam?: GVG
|
||||
await pushTeamMoveMessage(team);
|
||||
}
|
||||
if(team.isRobot && team.isBroken) {
|
||||
await sendMessageToGVGAreaByTeamWithSuc(team.groupKey, team.fromAreaId, PUSH_ROUTE.GVG_PLAYER_LEAVE_AREA, {
|
||||
cityId: team.cityId, areaId: team.fromAreaId, teamCode: team.teamCode
|
||||
});
|
||||
await sendAreaLeaveMsg(team.groupKey, team.fromAreaId, team.cityId, team.teamCode);
|
||||
}
|
||||
}
|
||||
|
||||
export async function pushTeamMoveMessage(team: GVGTeamType) {
|
||||
if(team.fromAreaId != team.areaId) {
|
||||
if(team.fromAreaId > 0) {
|
||||
await sendMessageToGVGAreaByTeamWithSuc(team.groupKey, team.fromAreaId, PUSH_ROUTE.GVG_PLAYER_LEAVE_AREA, {
|
||||
cityId: team.cityId, areaId: team.fromAreaId, teamCode: team.teamCode
|
||||
});
|
||||
}
|
||||
if(team.areaId > 0) {
|
||||
await sendMessageToGVGAreaByTeamWithSuc(team.groupKey, team.areaId, PUSH_ROUTE.GVG_PLAYER_AREA_ADD, {
|
||||
cityId: team.cityId, areaId: team.areaId, fromAreaId: team.fromAreaId, player: new GVGTeamInList(team)
|
||||
});
|
||||
}
|
||||
if(team.fromAreaId > 0) await sendAreaLeaveMsg(team.groupKey, team.fromAreaId, team.cityId, team.teamCode);
|
||||
if(team.areaId > 0) await sendAreaAddMsg(team.groupKey, team.areaId, team.fromAreaId, team.cityId, team);
|
||||
}
|
||||
}
|
||||
// —————————— 推送相关 end —————————— //
|
||||
|
||||
export async function sendAreaLeaveMsg(groupKey: string, areaId: number, cityId: number, teamCode: string) {
|
||||
await sendMessageToGVGAreaByTeamWithSuc(groupKey, areaId, PUSH_ROUTE.GVG_PLAYER_LEAVE_AREA, {
|
||||
cityId, areaId, teamCode
|
||||
});
|
||||
await sendMessageToGVGAreaWithSuc(groupKey, areaId, PUSH_ROUTE.GVG_SPINE_AREA_LEAVE, {
|
||||
cityId, areaId, teamCode
|
||||
});
|
||||
}
|
||||
|
||||
export async function sendAreaAddMsg(groupKey: string, areaId: number, fromAreaId: number, cityId: number, team: GVGTeamType) {
|
||||
await sendMessageToGVGAreaByTeamWithSuc(groupKey, areaId, PUSH_ROUTE.GVG_PLAYER_AREA_ADD, {
|
||||
cityId, areaId, fromAreaId, player: new GVGTeamInList(team)
|
||||
});
|
||||
await sendMessageToGVGAreaWithSuc(groupKey, areaId, PUSH_ROUTE.GVG_SPINE_AREA_ADD, {
|
||||
cityId, areaId, fromAreaId, spine: new GVGTeamSpineInfo(team, await getServerName(team.serverId))
|
||||
});
|
||||
}
|
||||
|
||||
export async function sendAreaPointChange(groupKey: string, areaId: number, cityId: number, targetPointId: number, originPointId: number, team: GVGTeamType) {
|
||||
await sendMessageToGVGAreaByTeamWithSuc(groupKey, areaId, PUSH_ROUTE.GVG_AREA_POINT_CHANGE, {
|
||||
cityId, areaId, targetPointId, originPointId, point: new GVGTeamInListOnPoint(team.pointId, true, team)
|
||||
});
|
||||
await sendMessageToGVGAreaWithSuc(groupKey, areaId, PUSH_ROUTE.GVG_SPINE_POINT_CHANGE, {
|
||||
cityId, areaId, targetPointId, originPointId, spine: new GVGTeamSpineInfo(team, await getServerName(team.serverId))
|
||||
})
|
||||
}
|
||||
|
||||
// 外面页面上的排行榜
|
||||
export async function getBattleRank(redisKey: REDIS_KEY, keyParam: KeyNameParam, myId: myIdInter) {
|
||||
let r = new Rank(redisKey, keyParam);
|
||||
|
||||
@@ -20,7 +20,7 @@ import { KeyNameParam, LeagueRankInfo, myIdInter, RoleRankInfo } from "../../dom
|
||||
import { gameData, getGVGVestigeLeagueRank, getGVGVestigePlayerRank, getGVGVestigeRange } from "../../pubUtils/data";
|
||||
import { GVG } from "../../pubUtils/dicParam";
|
||||
import { RewardInter } from "../../pubUtils/interface";
|
||||
import { getTimeFun, nowSeconds } from "../../pubUtils/timeUtil";
|
||||
import { getCurDay, getTimeFun, nowSeconds } from "../../pubUtils/timeUtil";
|
||||
import { getRandEelm } from "../../pubUtils/util";
|
||||
import { getNumberArr, uniqueArr } from "../ladderService";
|
||||
import { sendMailByContent } from "../mailService";
|
||||
@@ -77,8 +77,11 @@ export async function getVestiges(serverId: number) {
|
||||
let vestige = await GVGVestigeModel.getVestige(groupKey);
|
||||
if(!vestige) {
|
||||
let dicGVGVestige = gameData.gvgVestigeByServerType.get(serverType)||[];
|
||||
let day = getCurDay(true);
|
||||
let pool = dicGVGVestige.filter(cur => cur.openday.includes(day));
|
||||
|
||||
let cnt = gameData.gvgVestigeCntByServerType.get(serverType)||0;
|
||||
let randResult = getRandEelm(dicGVGVestige, cnt);
|
||||
let randResult = getRandEelm(pool, cnt);
|
||||
vestige = await GVGVestigeModel.initTodayVestige(groupKey, randResult);
|
||||
}
|
||||
return vestige.vestiges||[];
|
||||
|
||||
@@ -10,9 +10,7 @@ import { isDevelopEnv } from "./utilService";
|
||||
import { gameData } from "../pubUtils/data";
|
||||
import { pushMsg37 } from "./sdkService";
|
||||
import { RoleModel, RoleType } from "../db/Role";
|
||||
import { nowSeconds } from "../pubUtils/timeUtil";
|
||||
import { GVGLeagueModel } from "../db/GVGLeague";
|
||||
import { resolve } from "bluebird";
|
||||
|
||||
export async function sendMessageToAllWithSuc(route: string, data: any, filterCb?: ({ lv, topLineupCe }) => boolean) {
|
||||
await sendMessageToAll(route, resResult(STATUS.SUCCESS, data), filterCb);
|
||||
@@ -262,12 +260,15 @@ function checkNotEncryptRoute(event: string) {
|
||||
PUSH_ROUTE.GUILD_BOSS_ENCOURAGE, // onGuildBossEncourage 鼓舞
|
||||
PUSH_ROUTE.GVG_TEAM_ATTACKED, // onTeamAttacked 当队伍受到攻击
|
||||
PUSH_ROUTE.GVG_MY_TEAM_ATTACKED, // onMyTeamAttacked 当队伍受到攻击
|
||||
PUSH_ROUTE.GVG_AREA_SPINE_CHANGE, // onAreaSpinesChange 可见区域内spine的变动,每隔5秒会下发
|
||||
// PUSH_ROUTE.GVG_AREA_SPINE_CHANGE, // onAreaSpinesChange 可见区域内spine的变动,每隔5秒会下发
|
||||
PUSH_ROUTE.GVG_AREA_POINT_CHANGE, // onMyAreaPointChange 积分点上的驻守人变更
|
||||
PUSH_ROUTE.GVG_PLAYER_AREA_ADD, // onPlayerAddToArea 积分点上的驻守人变更
|
||||
PUSH_ROUTE.GVG_PLAYER_LEAVE_AREA, // onPlayerLeaveArea 积分点上的驻守人变更
|
||||
PUSH_ROUTE.GVG_CITY_RANK_UPDATE, // onGVGCityRankUpdate 城池积分排名
|
||||
PUSH_ROUTE.GVG_SPINE_ATTACKED, // onSpinesAttacked 队伍在地图上受到攻击
|
||||
PUSH_ROUTE.GVG_SPINE_AREA_ADD,
|
||||
PUSH_ROUTE.GVG_SPINE_AREA_LEAVE,
|
||||
PUSH_ROUTE.GVG_SPINE_POINT_CHANGE,
|
||||
].indexOf(event) != -1
|
||||
}
|
||||
|
||||
|
||||
@@ -128,6 +128,7 @@ export async function guild(session: Session, msg: any, app: Application, cb: (e
|
||||
'guild.gvgBattleHandler.leaveCity',
|
||||
'guild.gvgBattleHandler.getRankByCity',
|
||||
'guild.gvgBattleHandler.getAreaOfMyTeam',
|
||||
'guild.gvgBattleHandler.getOppTeam',
|
||||
'guild.gvgBattleHandler.debugAddRobots',
|
||||
'guild.gvgBattleHandler.debugMoveRobots',
|
||||
'guild.gvgBattleHandler.debugStopMoveRobot',
|
||||
|
||||
Reference in New Issue
Block a user