🐞 fix(gvg): 修复gvg显示问题

This commit is contained in:
luying
2023-02-22 21:04:21 +08:00
parent 1190d64d24
commit c9e9184567
6 changed files with 21 additions and 11 deletions

View File

@@ -9,6 +9,7 @@ import { RoleModel } from '../../../db/Role';
import { getFriendRelationType } from '../../../services/friendService'; import { getFriendRelationType } from '../../../services/friendService';
import { GVGLeagueModel } from '../../../db/GVGLeague'; import { GVGLeagueModel } from '../../../db/GVGLeague';
import { getGroupIdOfServer } from '../../../services/gvg/gvgService'; import { getGroupIdOfServer } from '../../../services/gvg/gvgService';
import { getGuildCodeString } from '../../../services/gvg/gvgRecService';
export default function (app: Application) { export default function (app: Application) {
@@ -35,7 +36,7 @@ export class ChatHandler {
const guildCode = session.get('guildCode'); const guildCode = session.get('guildCode');
const sid = session.get('sid'); const sid = session.get('sid');
let channelId = ''; let channelId = '', otherInfo = '';
if (channel === CHANNEL_PREFIX.WORLD) channelId = `${serverId}`; if (channel === CHANNEL_PREFIX.WORLD) channelId = `${serverId}`;
if (channel === CHANNEL_PREFIX.GUILD) channelId = guildCode; if (channel === CHANNEL_PREFIX.GUILD) channelId = guildCode;
if (channel === CHANNEL_PREFIX.GVG) { if (channel === CHANNEL_PREFIX.GVG) {
@@ -46,8 +47,9 @@ export class ChatHandler {
let myLeague = await GVGLeagueModel.findLeagueByGuild(guildCode); let myLeague = await GVGLeagueModel.findLeagueByGuild(guildCode);
if(!myLeague) return resResult(STATUS.GVG_NOT_JOIN_LEAGUE); if(!myLeague) return resResult(STATUS.GVG_NOT_JOIN_LEAGUE);
channelId = myLeague.leagueCode; channelId = myLeague.leagueCode;
otherInfo = getGuildCodeString(myLeague);
} }
const msgData = await createGroupMsg(roleId, roleName, channel, channelId, type, MSG_SOURCE.ROLE_SEND_TEXT, content, targetRoleId, targetMsgCode); const msgData = await createGroupMsg(roleId, roleName, channel, channelId, type, MSG_SOURCE.ROLE_SEND_TEXT, content, targetRoleId, targetMsgCode, otherInfo);
if (!msgData) return resResult(STATUS.WRONG_PARMS); if (!msgData) return resResult(STATUS.WRONG_PARMS);
await pushGroupMsgToRoom(msgData); await pushGroupMsgToRoom(msgData);

View File

@@ -6,7 +6,7 @@ import { GVGCityModel } from '../../../db/GVGCity';
import { Application, BackendSession, ChannelService, HandlerService, pinus } from "pinus"; import { Application, BackendSession, ChannelService, HandlerService, pinus } from "pinus";
import { resResult, genCode } from "../../../pubUtils/util"; import { resResult, genCode } from "../../../pubUtils/util";
import { GVGLeagueModel } from '../../../db/GVGLeague'; import { GVGLeagueModel } from '../../../db/GVGLeague';
import { getGroupKey, getGVGConfig, getGVGPeriodData } from '../../../services/gvg/gvgService'; import { getGroupKey, getGVGConfig, getGVGPeriodData, getGVGServerType } from '../../../services/gvg/gvgService';
import { redisAddBattleScore, battleEndSendMessage, calBattleScoreByCe, checkAreaIsInCity, checkGVGBattleStart, checkMoveStatus, getBattleRanksByCity, getBirthAreaOfCity, getGVGWarId, getOppHeroes, getTechKnifeHurt, getTechReviveMinus, initRobots, pushTeamMoveMessage, getGVGCitiesInfo, leaveCity } from '../../../services/gvg/gvgBattleService'; import { redisAddBattleScore, battleEndSendMessage, calBattleScoreByCe, checkAreaIsInCity, checkGVGBattleStart, checkMoveStatus, getBattleRanksByCity, getBirthAreaOfCity, getGVGWarId, getOppHeroes, getTechKnifeHurt, getTechReviveMinus, initRobots, pushTeamMoveMessage, getGVGCitiesInfo, leaveCity } from '../../../services/gvg/gvgBattleService';
import { getGVGBattleData } from '../../../services/gvg/gvgBattleMemory'; import { getGVGBattleData } from '../../../services/gvg/gvgBattleMemory';
import { GVGBattleRecModel } from '../../../db/GVGBattleRec'; import { GVGBattleRecModel } from '../../../db/GVGBattleRec';
@@ -214,7 +214,7 @@ export class GVGBattleHandler {
teamObj.enterCity(...teams); teamObj.enterCity(...teams);
} }
const recs = await GVGRecModel.findBattleRecByCity(configId, groupKey, cityId); // const recs = await GVGRecModel.findBattleRecByCity(configId, groupKey, cityId);
const teamResult = teams.map(team => new MyTeamInfo(team)); const teamResult = teams.map(team => new MyTeamInfo(team));
const { ranks, myRank } = await getBattleRanksByCity(configId, groupKey, cityId, myLeague); const { ranks, myRank } = await getBattleRanksByCity(configId, groupKey, cityId, myLeague);
await leaveGVGCityTeamChannel(roleId, sid); await leaveGVGCityTeamChannel(roleId, sid);
@@ -223,7 +223,7 @@ export class GVGBattleHandler {
return resResult(STATUS.SUCCESS, { return resResult(STATUS.SUCCESS, {
cityId, cityId,
ranks, myRank, ranks, myRank,
recs, recs: [],
teams: teamResult, teams: teamResult,
}); });
} }
@@ -624,12 +624,14 @@ export class GVGBattleHandler {
let { configId } = getGVGPeriodData(); let { configId } = getGVGPeriodData();
let groupKey = await getGroupKey(serverId); let groupKey = await getGroupKey(serverId);
let serverType = await getGVGServerType(serverId);
const cities = await GVGCityModel.findByConfig(configId, groupKey); const cities = await GVGCityModel.findByConfig(configId, groupKey);
const points = await GVGCityAreaPointModel.findByConfig(configId, groupKey); const points = await GVGCityAreaPointModel.findByConfig(configId, groupKey);
let result: { cityId: number, guardLeagueName: string, areas: { areaId: number, points: { pointId: number, guardLeagueName: string }[] }[] }[] = []; let result: { cityId: number, guardLeagueName: string, areas: { areaId: number, points: { pointId: number, guardLeagueName: string }[] }[] }[] = [];
for(let [ cityId, { areaIds }] of gameData.gvgCity) { for(let [ cityId, { mapType, areaIds }] of gameData.gvgCity) {
if(mapType != serverType) continue;
let areas: { areaId: number, points: {pointId: number, guardLeagueName: string }[]}[] = []; let areas: { areaId: number, points: {pointId: number, guardLeagueName: string }[]}[] = [];
for(let areaId of areaIds) { for(let areaId of areaIds) {
let dicArea = gameData.gvgArea.get(areaId); let dicArea = gameData.gvgArea.get(areaId);

View File

@@ -20,9 +20,10 @@ import { GVGUserTaskModel } from "../../db/GVGUserTask";
import { getMyAuth } from "./gvgTeamService"; import { getMyAuth } from "./gvgTeamService";
import { pick } from "underscore"; import { pick } from "underscore";
import { calFighterContribute, calProducerContribute } from "./gvgPrepareService"; import { calFighterContribute, calProducerContribute } from "./gvgPrepareService";
import { calVestigeLeagueBoxRewards } from "./gvgFightService"; import { calVestigeLeagueBoxRewards, getFightTimeByPeriod } from "./gvgFightService";
import { GVGVestigeLeagueRankModel } from "../../db/GVGVestigeLeagueRank"; import { GVGVestigeLeagueRankModel } from "../../db/GVGVestigeLeagueRank";
import { GVGVestigeSumRankModel } from "../../db/GVGVestigeSumRank"; import { GVGVestigeSumRankModel } from "../../db/GVGVestigeSumRank";
import { GVGTeamModel } from "../../db/GVGTeam";
// 定时器相关 // 定时器相关
export async function createNewGVGConfig() { export async function createNewGVGConfig() {
@@ -213,6 +214,7 @@ export async function getGVGInfoInGuild(roleId: string, guild: GuildType) {
let hasLeague = !!guild.leagueCode; let hasLeague = !!guild.leagueCode;
let serverId = guild.serverId; let serverId = guild.serverId;
let { configId, period, countdownTime } = getGVGPeriodData(); let { configId, period, countdownTime } = getGVGPeriodData();
let { startFightTime, endFightTime } = getFightTimeByPeriod(period);
let type = await getGVGServerType(serverId); let type = await getGVGServerType(serverId);
if(hasLeague && configId > 0) { if(hasLeague && configId > 0) {
@@ -223,11 +225,14 @@ export async function getGVGInfoInGuild(roleId: string, guild: GuildType) {
applyCnt: await getApplyCnt(guild.leagueCode), applyCnt: await getApplyCnt(guild.leagueCode),
...await getMainData(roleId, guild.leagueCode, configId, period, countdownTime, type), ...await getMainData(roleId, guild.leagueCode, configId, period, countdownTime, type),
leagueDetailRank: await getLeagueRankBox(configId, guild.leagueCode, roleId), leagueDetailRank: await getLeagueRankBox(configId, guild.leagueCode, roleId),
myTeamCnt: await GVGTeamModel.getTeamCntByRole(roleId),
startFightTime, endFightTime
} }
} else { } else {
return { return {
hasLeague, hasLeague,
configId, period, countdownTime, configId, period, countdownTime,
startFightTime, endFightTime,
type, type,
invitationCnt: await getInviteCnt(guild.code) invitationCnt: await getInviteCnt(guild.code)
} }

View File

@@ -84,7 +84,7 @@ export default class GVGCity extends BaseModel {
// 查询联军驻守情况 // 查询联军驻守情况
public static async findGuardCity(configId: number, groupKey: string, select = '') { public static async findGuardCity(configId: number, groupKey: string, select = '') {
let cities: GVGCityType[] = await GVGCityModel.find({ configId: configId + 1, groupKey, hasGuard: true }).select(select).lean(); let cities: GVGCityType[] = await GVGCityModel.find({ configId: configId + 1, groupKey, hasGuard: true }).select(select).lean();
if(cities) cities = await GVGCityModel.find({ configId, groupKey }).select(select).lean(); if(cities.length <= 0) cities = await GVGCityModel.find({ configId, groupKey }).select(select).lean();
return cities return cities
} }

View File

@@ -26,7 +26,7 @@ export interface DicGVGArea {
} }
export const dicGVGArea = new Map<number, DicGVGArea>(); export const dicGVGArea = new Map<number, DicGVGArea>();
export const dicGVGCity = new Map<number, { cityType: number, areaIds: number[], defenseBirth: number, attackBirth: number, cityName: string }>(); export const dicGVGCity = new Map<number, { cityType: number, mapType: number, areaIds: number[], defenseBirth: number, attackBirth: number, cityName: string }>();
export function loadGVGArea() { export function loadGVGArea() {
dicGVGArea.clear(); dicGVGArea.clear();
dicGVGCity.clear(); dicGVGCity.clear();
@@ -35,7 +35,7 @@ export function loadGVGArea() {
arr.forEach(o => { arr.forEach(o => {
o.relateArea = parseNumberList(o.relateArea); o.relateArea = parseNumberList(o.relateArea);
if(!dicGVGCity.has(o.cityId)) { if(!dicGVGCity.has(o.cityId)) {
dicGVGCity.set(o.cityId, { cityType: o.cityType, areaIds: [], defenseBirth: 0, attackBirth: 0, cityName: o.cityName }); dicGVGCity.set(o.cityId, { cityType: o.cityType, mapType: o.mapType, areaIds: [], defenseBirth: 0, attackBirth: 0, cityName: o.cityName });
} }
dicGVGCity.get(o.cityId)?.areaIds.push(o.areaId); dicGVGCity.get(o.cityId)?.areaIds.push(o.areaId);
if(o.areaType == 1) dicGVGCity.get(o.cityId).defenseBirth = o.areaId; if(o.areaType == 1) dicGVGCity.get(o.cityId).defenseBirth = o.areaId;

View File

@@ -1,7 +1,7 @@
// GVG城池 // GVG城池
import { FILENAME } from '../../consts' import { FILENAME } from '../../consts'
import { RewardInter } from '../interface'; import { RewardInter } from '../interface';
import { readFileAndParse } from '../util' import { parseGoodStr, readFileAndParse } from '../util'
export interface DicGVGCityAdd { export interface DicGVGCityAdd {
// 城池类型 1-大城 2-中城 3-小城 // 城池类型 1-大城 2-中城 3-小城
@@ -22,6 +22,7 @@ export function loadGVGCityAdd() {
let arr = readFileAndParse(FILENAME.DIC_GVG_CITY_ADD); let arr = readFileAndParse(FILENAME.DIC_GVG_CITY_ADD);
arr.forEach(o => { arr.forEach(o => {
o.occupyReward = parseGoodStr(o.occupyReward);
dicGVGCityAdd.set(o.cityType, o); dicGVGCityAdd.set(o.cityType, o);
}); });
arr = undefined; arr = undefined;