✨ feat(gvg): 添加激战期动态
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { GVGRecModel } from '../../../db/GVGRec';
|
||||
import { GVGRecModel, GVGRecType } from '../../../db/GVGRec';
|
||||
import { GVGAreaInMap, GVGTeamInList, GVGTeamInListOnPoint, GVGTeamSpineInMap, LeagueGood, MyTeamInfo, MyTeamSimpleInfo } from '../../../domain/gvgField/returnData';
|
||||
import { GVGTeamModel, GVGTeamType, GVGTeamUpdate } from '../../../db/GVGTeam';
|
||||
import { GVGUserDataModel } from '../../../db/GVGUserData';
|
||||
@@ -15,7 +15,7 @@ import { gameData, getReviveGold } from '../../../pubUtils/data';
|
||||
import { getAllServerName } from '../../../services/redisService';
|
||||
import { checkBattleHeroesByHid } from '../../../services/normalBattleService';
|
||||
import { SaveTeamParam, SaveTeamUpdateParam } from '../../../domain/gvgField/gvgDb';
|
||||
import { GVG_AREA_TYPE, GVG_ITEM, ITEM_CHANGE_REASON, REDIS_KEY, STATUS } from '../../../consts';
|
||||
import { GVG_AREA_TYPE, GVG_ITEM, GVG_REC_TYPE, ITEM_CHANGE_REASON, REDIS_KEY, STATUS } from '../../../consts';
|
||||
import { GVGHeroInfo } from '../../../domain/dbGeneral';
|
||||
import { ArtifactModel } from '../../../db/Artifact';
|
||||
import { getHeroesAttributes } from '../../../services/playerCeService';
|
||||
@@ -27,6 +27,7 @@ import { getGoldObject, handleCost } from '../../../services/role/rewardService'
|
||||
import { GVGCityAreaPointModel } from '../../../db/GVGCityAreaPoint';
|
||||
import { Rank } from '../../../services/rankService';
|
||||
import { LeagueRankInfo, RoleRankInfo } from '../../../domain/rank';
|
||||
import { addBattleEndRec, addTeamSettleRec } from '../../../services/gvg/gvgRecService';
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
@@ -210,7 +211,7 @@ export class GVGBattleHandler {
|
||||
teamObj.enterCity(...teams);
|
||||
}
|
||||
|
||||
const recs = await GVGRecModel.findByCity(cityId, configId);
|
||||
const recs = await GVGRecModel.findBattleRecByCity(configId, groupId, serverType, cityId);
|
||||
const teamResult = teams.map(team => new MyTeamInfo(team));
|
||||
const { ranks, myRank } = await getBattleRanksByCity(configId, groupId, serverType, cityId, myLeague);
|
||||
await leaveGVGCityTeamChannel(roleId, sid);
|
||||
@@ -407,6 +408,9 @@ export class GVGBattleHandler {
|
||||
|
||||
let teamObj = getGVGBattleData(groupId, serverType);
|
||||
teamObj.teamSettle(roleId, teamCode, pointId);
|
||||
|
||||
addTeamSettleRec(curTeam);
|
||||
|
||||
return resResult(STATUS.SUCCESS, { curTeam: new MyTeamInfo(curTeam) });
|
||||
}
|
||||
|
||||
@@ -506,8 +510,9 @@ export class GVGBattleHandler {
|
||||
let teamObj = getGVGBattleData(groupId, serverType);
|
||||
teamObj.battleEnd([attackTeam, defenseTeam]);
|
||||
// 更新rec
|
||||
await GVGBattleRecModel.battleEnd(battleCode, isSuccess);
|
||||
let rec = await GVGBattleRecModel.battleEnd(battleCode, isSuccess);
|
||||
await battleEndSendMessage(groupId, serverType, cityId, defenseTeam, attackTeam);
|
||||
addBattleEndRec(rec);
|
||||
|
||||
return resResult(STATUS.SUCCESS, { curTeam: new MyTeamInfo(attackTeam) });
|
||||
}
|
||||
@@ -611,10 +616,27 @@ export class GVGBattleHandler {
|
||||
|
||||
// 获取战报
|
||||
// type: 战报类型
|
||||
async getRecs(msg: { type: number }, session: BackendSession) {
|
||||
const { type } = msg;
|
||||
async getRecs(msg: { type: number, cityId: number }, session: BackendSession) {
|
||||
const roleId = session.get('roleId');
|
||||
const serverId = session.get('serverId');
|
||||
const guildCode = session.get('guildCode');
|
||||
const { type, cityId } = msg;
|
||||
// 根据 type 获取战报
|
||||
const recs = await GVGRecModel.find({ type }).limit(20).lean();
|
||||
let { configId, period } = getGVGPeriodData();
|
||||
let groupId = await getGroupIdOfServer(serverId);
|
||||
let serverType = await getGVGServerType(serverId);
|
||||
|
||||
let myLeague = await GVGLeagueModel.findLeagueByGuild(guildCode);
|
||||
if(!myLeague) return resResult(STATUS.GVG_LEAGUE_NOT_EXIST);
|
||||
|
||||
let recs: GVGRecType[] = [];
|
||||
if(type == GVG_REC_TYPE.BATTLE_BY_CITY) {
|
||||
recs = await GVGRecModel.findBattleRecByCity(configId, groupId, serverType, cityId);
|
||||
} else if (type == GVG_REC_TYPE.BATTLE_BY_LEAGUE) {
|
||||
recs = await GVGRecModel.findBattleRecByLeague(configId, myLeague.leagueCode);
|
||||
} else if (type == GVG_REC_TYPE.BATTLE_BY_ROLE) {
|
||||
recs = await GVGRecModel.findBattleRecByRole(configId, roleId, myLeague.leagueCode);
|
||||
}
|
||||
return resResult(STATUS.SUCCESS, { recs });
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
|
||||
// 动态
|
||||
import { GVG_REC_ID, GVG_REC_TYPE, GVG_RESOURCE_TYPE } from "../../consts";
|
||||
import { GVGBattleRecType } from "../../db/GVGBattleRec";
|
||||
import { GVGRecModel } from "../../db/GVGRec";
|
||||
import { GVGTeamType } from "../../db/GVGTeam";
|
||||
import { GVGVestigeRecType } from "../../db/GVGVestigeRec";
|
||||
import { gameData } from "../../pubUtils/data";
|
||||
import { nowSeconds } from "../../pubUtils/timeUtil";
|
||||
@@ -64,4 +66,49 @@ export async function addVestigeLeagueRankRec(configId: number, ranks: { rank: n
|
||||
let params = [ `第${rank}名`];
|
||||
return { leagueCode, configId, type: GVG_REC_TYPE.PREPARE, recId: GVG_REC_ID.VESTIGE_RANK, createTime: nowSeconds(), params };
|
||||
}));
|
||||
}
|
||||
|
||||
export async function addBattleEndRec(rec: GVGBattleRecType) {
|
||||
let { isSuccess, attackTeam, defenseTeam, configId } = rec;
|
||||
let { roleId, leagueCode, cityId, index, curTeamBreak, originPointId } = defenseTeam;
|
||||
if(!defenseTeam.isRobot) { // 防守的不是机器
|
||||
if(isSuccess) {
|
||||
await GVGRecModel.addRec({ roleId, leagueCode, configId, cityId, type: GVG_REC_TYPE.BATTLE_BY_ROLE, recId: GVG_REC_ID.TEAM_BE_HIT, createTime: nowSeconds(), params: [`${attackTeam.roleName}`, `队伍${index}`] });
|
||||
if(curTeamBreak && originPointId > 0 ) {
|
||||
await GVGRecModel.addRec({ roleId, leagueCode, configId, cityId, type: GVG_REC_TYPE.BATTLE_BY_ROLE, recId: GVG_REC_ID.TEAM_LOST_POINT, createTime: nowSeconds(), params: [`${attackTeam.roleName}`, `队伍${index}`, getPointName(originPointId)] });
|
||||
await GVGRecModel.addRec({ roleId, leagueCode, configId, cityId, type: GVG_REC_TYPE.BATTLE_BY_CITY, recId: GVG_REC_ID.CITY_OCCUPY_CHANGE, createTime: nowSeconds(), params: [`${attackTeam.roleName}`, `${defenseTeam.roleName}`, getPointName(originPointId)] });
|
||||
await GVGRecModel.addRec({ roleId, leagueCode, configId, cityId, type: GVG_REC_TYPE.BATTLE_BY_LEAGUE, recId: GVG_REC_ID.LEAGUE_OCCUPY_CHANGE, createTime: nowSeconds(), params: [`${attackTeam.roleName}`, `${defenseTeam.roleName}`, getPointName(originPointId)] });
|
||||
}
|
||||
} else {
|
||||
await GVGRecModel.addRec({ roleId, leagueCode, configId, cityId, type: GVG_REC_TYPE.BATTLE_BY_ROLE, recId: GVG_REC_ID.TEAM_GUARD_SUCCESS, createTime: nowSeconds(), params: [`${attackTeam.roleName}`, `队伍${index}`] });
|
||||
|
||||
}
|
||||
}
|
||||
if(defenseTeam.isRobot && defenseTeam.isCatapult) {
|
||||
await GVGRecModel.addRec({ roleId, leagueCode, configId, cityId, type: GVG_REC_TYPE.BATTLE_BY_CITY, recId: GVG_REC_ID.CITY_CATAPULT, createTime: nowSeconds(), params: [`${attackTeam.roleName}`, getCityName(cityId)] });
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function getPointName(pointId: number) {
|
||||
let dicAreaPoint = gameData.gvgAreaPoint.get(pointId);
|
||||
let dicArea = gameData.gvgArea.get(dicAreaPoint?.areaId);
|
||||
if(!dicArea) return '';
|
||||
return dicArea.areaName||'';
|
||||
}
|
||||
|
||||
function getCityName(cityId: number) {
|
||||
let dicCity = gameData.gvgCity.get(cityId);
|
||||
return dicCity?.cityName||'';
|
||||
}
|
||||
|
||||
export async function addTeamSettleRec(team: GVGTeamType) {
|
||||
let { roleId, roleName, leagueCode, configId, cityId, pointId } = team;
|
||||
await GVGRecModel.addRec({ roleId, leagueCode, configId, cityId, type: GVG_REC_TYPE.BATTLE_BY_CITY, recId: GVG_REC_ID.CITY_TEAM_SETTLE, createTime: nowSeconds(), params: [`${roleName}`, getPointName(pointId)] });
|
||||
await GVGRecModel.addRec({ roleId, leagueCode, configId, cityId, type: GVG_REC_TYPE.BATTLE_BY_LEAGUE, recId: GVG_REC_ID.LEAGUE_TEAM_SETTLE, createTime: nowSeconds(), params: [`${roleName}`, getPointName(pointId)] });
|
||||
}
|
||||
|
||||
export async function addTeamLeaveRec(team: GVGTeamType, pointId: number) {
|
||||
let { roleId, roleName, leagueCode, configId, cityId } = team;
|
||||
await GVGRecModel.addRec({ roleId, leagueCode, configId, cityId, type: GVG_REC_TYPE.BATTLE_BY_LEAGUE, recId: GVG_REC_ID.LEAGUE_TEAM_LEAVE, createTime: nowSeconds(), params: [`${roleName}`, getPointName(pointId)] });
|
||||
}
|
||||
@@ -117,6 +117,16 @@ export enum GVG_REC_ID {
|
||||
VESTIGE_RANK = 5, // 联军每日的征战排名
|
||||
LEAGUE_JOIN_GUILD = 6, // 军团加入联军
|
||||
LEAGUE_QUIT_GUILD = 7, // 军团退出联军
|
||||
TEAM_BE_HIT = 8, // 队伍被击败
|
||||
TEAM_GUARD_SUCCESS = 9, // 队伍防守成功
|
||||
TEAM_LOST_POINT = 10, // 队伍失去积分点
|
||||
CITY_TEAM_SETTLE = 12, // 入驻据点
|
||||
CITY_OCCUPY_CHANGE = 13,// 城池据点交替
|
||||
CITY_CATAPULT = 15, // 投石车被打掉
|
||||
LEAGUE_TEAM_SETTLE = 16, // 队伍入驻据点
|
||||
LEAGUE_TEAM_LEAVE = 17, // 队伍离开据点
|
||||
LEAGUE_OCCUPY_CHANGE = 18, // 联军据点交替
|
||||
|
||||
}
|
||||
|
||||
// 遗迹选择对手状态
|
||||
|
||||
@@ -10,6 +10,9 @@ class TeamInfo {
|
||||
@prop({ required: true })
|
||||
roleId: string; // 玩家id
|
||||
|
||||
@prop({ required: true })
|
||||
roleName: string; // 玩家id
|
||||
|
||||
@prop({ required: true })
|
||||
teamCode: string; // 玩家队伍唯一标识
|
||||
|
||||
@@ -45,6 +48,18 @@ class TeamInfo {
|
||||
|
||||
@prop({ required: true, type: () => GVGHeroInfo, _id: false })
|
||||
lineup: GVGHeroInfo[]
|
||||
|
||||
@prop({ required: true, default: 0 })
|
||||
isRobot: boolean; // 是否是机器人
|
||||
|
||||
@prop({ required: true, default: 0 })
|
||||
isCatapult: boolean; // 是否是投石车
|
||||
|
||||
@prop({ required: true, default: 0 })
|
||||
originPointId: number;
|
||||
|
||||
@prop({ required: true, default: 0 })
|
||||
curTeamBreak: boolean;
|
||||
}
|
||||
|
||||
@index({ battleCode: 1 })
|
||||
|
||||
@@ -45,11 +45,20 @@ export default class GVGRec extends BaseModel {
|
||||
}
|
||||
|
||||
// 查询城池战报
|
||||
public static async findByCity(cityId: number, configId: number) {
|
||||
const result: GVGRecType[] = await GVGRecModel.find({ cityId, configId }, { _id: 0, recId: 1, params: 1, createTime: 1 }).sort({ createTime: -1 }).limit(50).lean();
|
||||
public static async findBattleRecByCity(configId: number, groupId: number, serverType: number, cityId: number) {
|
||||
const result: GVGRecType[] = await GVGRecModel.find({ cityId, configId, groupId, serverType, type: GVG_REC_TYPE.BATTLE_BY_CITY }, { _id: 0, recId: 1, params: 1, createTime: 1 }).sort({ createTime: -1 }).limit(50).lean();
|
||||
return result;
|
||||
}
|
||||
|
||||
public static async findBattleRecByLeague(configId: number, leagueCode: string) {
|
||||
const result: GVGRecType[] = await GVGRecModel.find({ configId, leagueCode, type: GVG_REC_TYPE.BATTLE_BY_LEAGUE }, { _id: 0, recId: 1, params: 1, createTime: 1 }).sort({ createTime: -1 }).limit(50).lean();
|
||||
return result;
|
||||
}
|
||||
|
||||
public static async findBattleRecByRole(configId: number, roleId: string, leagueCode: string) {
|
||||
const result: GVGRecType[] = await GVGRecModel.find({ configId, roleId, leagueCode, type: GVG_REC_TYPE.BATTLE_BY_ROLE }, { _id: 0, recId: 1, params: 1, createTime: 1 }).sort({ createTime: -1 }).limit(50).lean();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
export const GVGRecModel = getModelForClass(GVGRec);
|
||||
|
||||
@@ -5,6 +5,8 @@ import { parseNumberList, readFileAndParse } from '../util'
|
||||
export interface DicGVGArea {
|
||||
// 区域id
|
||||
readonly areaId: number;
|
||||
// 区域名
|
||||
readonly areaName: string;
|
||||
// 大地图id
|
||||
readonly mapId: string
|
||||
// 大地图类型 1-单服 2-跨服
|
||||
|
||||
Reference in New Issue
Block a user