diff --git a/game-server/app/servers/chat/handler/chatHandler.ts b/game-server/app/servers/chat/handler/chatHandler.ts index 73c41ff0f..d7645a500 100644 --- a/game-server/app/servers/chat/handler/chatHandler.ts +++ b/game-server/app/servers/chat/handler/chatHandler.ts @@ -2,11 +2,12 @@ import { CHANNEL_PREFIX, MSG_SOURCE, getChannelType } from './../../../consts/co import { Application, BackendSession, HandlerService, } from 'pinus'; import { resResult } from '../../../pubUtils/util'; import { DEFAULT_MSG_PER_PAGE, STATUS, TASK_TYPE } from '../../../consts'; -import { createAccuseData, createGroupMsg, createPrivateMsg, getPrivateMessages, pushGroupMsgToRoom, pushMsgToRole, updatePrivateMsgReadInfo, recentPrivateChatInfos, recentWorldMsgs, recentSysMsgs, recentGuildMsgs, updatePrivateMsgIsTop, delPrivateMsg, recentServerGroupMsgs } from '../../../services/chatService'; +import { createAccuseData, createGroupMsg, createPrivateMsg, getPrivateMessages, pushGroupMsgToRoom, pushMsgToRole, updatePrivateMsgReadInfo, recentPrivateChatInfos, recentWorldMsgs, recentSysMsgs, recentGuildMsgs, updatePrivateMsgIsTop, delPrivateMsg, recentServerGroupMsgs, recentLeagueMsgs } from '../../../services/chatService'; import { getSimpleRoleInfo } from '../../../services/roleService'; import { checkTask } from '../../../services/task/taskService'; import { RoleModel } from '../../../db/Role'; import { getFriendRelationType } from '../../../services/friendService'; +import { GVGLeagueModel } from '../../../db/GVGLeague'; export default function (app: Application) { @@ -36,6 +37,11 @@ export class ChatHandler { let channelId = ''; if (channel === CHANNEL_PREFIX.WORLD) channelId = `${serverId}`; if (channel === CHANNEL_PREFIX.GUILD) channelId = guildCode; + if (channel == CHANNEL_PREFIX.LEAGUE) { + let myLeague = await GVGLeagueModel.findLeagueByGuild(guildCode); + if(!myLeague) return resResult(STATUS.GVG_NOT_JOIN_LEAGUE); + channelId = myLeague.leagueCode; + } const msgData = await createGroupMsg(roleId, roleName, channel, channelId, type, MSG_SOURCE.ROLE_SEND_TEXT, content, targetRoleId, targetMsgCode); if (!msgData) return resResult(STATUS.WRONG_PARMS); await pushGroupMsgToRoom(msgData); @@ -108,8 +114,9 @@ export class ChatHandler { const sysMsgs = await recentSysMsgs(serverId); const guildMsgs = await recentGuildMsgs(guildCode); const gvgMsgs = await recentServerGroupMsgs(serverId); + const leagueMsgs = await recentLeagueMsgs(guildCode); - return resResult(STATUS.SUCCESS, { worldMsgs, sysMsgs, guildMsgs, gvgMsgs }) + return resResult(STATUS.SUCCESS, { worldMsgs, sysMsgs, guildMsgs, gvgMsgs, leagueMsgs }) } /** diff --git a/game-server/app/servers/guild/handler/gvgBattleHandler.ts b/game-server/app/servers/guild/handler/gvgBattleHandler.ts index 97d8f5b1e..949052f72 100644 --- a/game-server/app/servers/guild/handler/gvgBattleHandler.ts +++ b/game-server/app/servers/guild/handler/gvgBattleHandler.ts @@ -599,11 +599,11 @@ export class GVGBattleHandler { // 获取战报 // type: 战报类型 - async getRecs(msg: { type: number, cityId: number }, session: BackendSession) { + async getRecs(msg: { type: number }, session: BackendSession) { const roleId = session.get('roleId'); const serverId = session.get('serverId'); const guildCode = session.get('guildCode'); - const { type, cityId } = msg; + const { type } = msg; // 根据 type 获取战报 let { configId, period } = getGVGPeriodData(); let groupKey = await getGroupKey(serverId); @@ -613,7 +613,7 @@ export class GVGBattleHandler { let recs: GVGRecType[] = []; if(type == GVG_REC_TYPE.BATTLE_BY_CITY) { - recs = await GVGRecModel.findBattleRecByCity(configId, groupKey, cityId); + recs = await GVGRecModel.findBattleRecByGroup(configId, groupKey); } 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) { diff --git a/game-server/app/servers/guild/handler/gvgHandler.ts b/game-server/app/servers/guild/handler/gvgHandler.ts index f7ba48cbe..42a47657f 100644 --- a/game-server/app/servers/guild/handler/gvgHandler.ts +++ b/game-server/app/servers/guild/handler/gvgHandler.ts @@ -24,6 +24,7 @@ import { checkGVGTask } from "../../../services/task/taskService"; import { getFightTimeByPeriod, getMyVestiges, getVestiges } from "../../../services/gvg/gvgFightService"; import { getSeconds } from "../../../pubUtils/timeUtil"; import { GVGVestigeRankModel } from "../../../db/GVGVestigeRank"; +import { addTechActivateMessage, addTechUnlockMessage } from "../../../services/gvg/gvgRecService"; export default function (app: Application) { new HandlerService(app, {}); @@ -344,6 +345,7 @@ export class GVGHandler { // 千机阁解锁 async unlockTech(msg: { techId: number }, session: BackendSession) { const roleId = session.get('roleId'); + const roleName = session.get('roleName'); const guildCode = session.get('guildCode'); const { techId } = msg; @@ -383,6 +385,8 @@ export class GVGHandler { } res.releaseCallback(); + addTechUnlockMessage(roleId, roleName, myLeague, techId); + return resResult(STATUS.SUCCESS, { queue: leaguePrepare?.techQueue||[] }); @@ -392,6 +396,7 @@ export class GVGHandler { async activate(msg: { techId: number, battleFeats: number }, session: BackendSession) { const serverId = session.get('serverId'); const roleId = session.get('roleId'); + const roleName = session.get('roleName'); const guildCode = session.get('guildCode'); const sid = session.get('sid'); const { techId, battleFeats } = msg; @@ -436,6 +441,7 @@ export class GVGHandler { await addGVGReward(roleId, '', myLeague.leagueCode, null, [{ id: GVG_ITEM.KNIFE, count: dicTech.param[1] }], [], ITEM_CHANGE_REASON.GVG_TECH_SEND_KNIFE); } } + addTechActivateMessage(roleId, roleName, myLeague, techId); } // 添加 活跃 diff --git a/game-server/app/servers/guild/handler/gvgManageHandler.ts b/game-server/app/servers/guild/handler/gvgManageHandler.ts index 88b0185e1..23a037c01 100644 --- a/game-server/app/servers/guild/handler/gvgManageHandler.ts +++ b/game-server/app/servers/guild/handler/gvgManageHandler.ts @@ -16,7 +16,7 @@ import { GVGLeaguePrepareModel } from "../../../db/GVGLeaguePrepare"; import { createGroupMsg, pushGroupMsgToRoom } from "../../../services/chatService"; import { sendMailByContent, sendMailToGuildByContent, sendMailToLeagueByContent } from "../../../services/mailService"; import { getGVGCities } from "../../../services/gvg/gvgBattleService"; -import { guildQuitLeagueRecord } from "../../../services/gvg/gvgRecService"; +import { changeNoticeMessage, guildQuitLeagueRecord } from "../../../services/gvg/gvgRecService"; import { LeagueLeader } from "../../../domain/rank"; export default function (app: Application) { @@ -587,6 +587,7 @@ export class GVGManageHandler { // 设置联军信息 async setLeagueInfo(msg: { leagueCode: string, name: string, notice: string, icon: number }, session: BackendSession) { const roleId = session.get('roleId'); + const roleName = session.get('roleName'); const guildCode = session.get('guildCode'); const { leagueCode: targetLeagueCode, name, notice, icon } = msg; @@ -611,6 +612,9 @@ export class GVGManageHandler { if(icon != undefined) { await updateUserInfo(REDIS_KEY.LEAGUE_INFO, myLeague.leagueCode, [{ field: 'icon', value: name }]); } + if(notice != undefined) { + await changeNoticeMessage(roleId, roleName, myLeague, notice); + } // 返回 return resResult(STATUS.SUCCESS, { diff --git a/game-server/app/servers/guild/handler/gvgProduceHandler.ts b/game-server/app/servers/guild/handler/gvgProduceHandler.ts index a69ccc864..11a295f9d 100644 --- a/game-server/app/servers/guild/handler/gvgProduceHandler.ts +++ b/game-server/app/servers/guild/handler/gvgProduceHandler.ts @@ -227,7 +227,7 @@ export class GVGProduceHandler { // 计算产量 const { foodSum, rewardSum, leagueRewardSum, activeSum } = await sumOutputByResults(myResultFields); // 资源 - let resourceResult = await addResource(myLeague.leagueCode, roleId, roleName, GVG_RESOURCE_TYPE.FOOD, foodSum)||{}; + let resourceResult = await addResource(myLeague, roleId, roleName, GVG_RESOURCE_TYPE.FOOD, foodSum)||{}; // 相关物品 let leagueGoods = await addGVGReward(roleId, roleName, myLeague.leagueCode, sid, leagueRewardSum, rewardSum, ITEM_CHANGE_REASON.HARVEST) // 活跃 @@ -282,7 +282,7 @@ export class GVGProduceHandler { // 计算产量 const { foodSum, rewardSum, leagueRewardSum, activeSum } = await sumOutputByResults(resultField); // 资源 - await addResource(myLeague.leagueCode, targetRoleId, resultField[0].lockRoleName, GVG_RESOURCE_TYPE.FOOD, foodSum)||{}; + await addResource(myLeague, targetRoleId, resultField[0].lockRoleName, GVG_RESOURCE_TYPE.FOOD, foodSum)||{}; await sendMailByContent(MAIL_TYPE.HELP_HARVEST, targetRoleId, { sendName: roleName, goods: rewardSum }); // 相关物品 await addGVGReward(targetRoleId, roleName, myLeague.leagueCode, targetOnlineInfo.sid, leagueRewardSum, [], ITEM_CHANGE_REASON.HARVEST) @@ -368,7 +368,7 @@ export class GVGProduceHandler { let { reward, leagueReward, leagueConsume } = dicGVGItem; let produceCoin = getProduceCoinCnt(leagueConsume); // 资源 - let resourceResult = await addResource(myLeague.leagueCode, roleId, roleName, GVG_RESOURCE_TYPE.MINERAL, output)||{}; + let resourceResult = await addResource(myLeague, roleId, roleName, GVG_RESOURCE_TYPE.MINERAL, output)||{}; // 相关物品 let leagueGoods = await addGVGReward(roleId, roleName, myLeague.leagueCode, sid, leagueReward, reward, ITEM_CHANGE_REASON.HARVEST) // 活跃 @@ -489,7 +489,7 @@ export class GVGProduceHandler { let { reward, leagueReward, leagueConsume } = dicGVGItem; let produceCoin = getProduceCoinCnt(leagueConsume); // 资源 - let resourceResult = await addResource(myLeague.leagueCode, roleId, roleName, GVG_RESOURCE_TYPE.WOOD, output)||{}; + let resourceResult = await addResource(myLeague, roleId, roleName, GVG_RESOURCE_TYPE.WOOD, output)||{}; // 相关物品 let leagueGoods = await addGVGReward(roleId, roleName, myLeague.leagueCode, sid, leagueReward, reward, ITEM_CHANGE_REASON.HARVEST) // 活跃 @@ -514,7 +514,7 @@ export class GVGProduceHandler { let myLeague = await GVGLeagueModel.findLeagueByGuild(guildCode); if(!myLeague) return resResult(STATUS.GVG_LEAGUE_NOT_EXIST); - let resourceResult = await addResource(myLeague.leagueCode, roleId, roleName, type, count); + let resourceResult = await addResource(myLeague, roleId, roleName, type, count); if(!resourceResult) return resResult(STATUS.WRONG_PARMS); return resResult(STATUS.SUCCESS, resourceResult); diff --git a/game-server/app/services/chatService.ts b/game-server/app/services/chatService.ts index 53beb2ef9..3175f915c 100644 --- a/game-server/app/services/chatService.ts +++ b/game-server/app/services/chatService.ts @@ -18,6 +18,7 @@ import { comBtlLvInvalid } from './comBattleService'; import { gameData } from '../pubUtils/data'; import { RegionModel } from '../db/Region'; import { getGroupIdOfServer, getServersByGroupId } from './gvg/gvgService'; +import { GVGLeagueModel } from '../db/GVGLeague'; export * from './chatChannelService'; export * from './sysChatService'; @@ -75,8 +76,8 @@ async function createPrivateMsgData(roleId: string, roleName: string, type: numb /** * @description 生成群聊消息数据 */ -async function createGroupMsgData(roleId: string, roleName: string, channel: string, channelId: string, type: number, source: number, content: string, targetRoleId: string, targetMsgCode: string) { - const result: GroupMessageParam = {roleId, roleName, channel, channelId, type, source, content, targetRoleId, targetMsgCode}; +async function createGroupMsgData(roleId: string, roleName: string, channel: string, channelId: string, type: number, source: number, content: string, targetRoleId: string, targetMsgCode: string, otherInfo = '') { + const result: GroupMessageParam = {roleId, roleName, channel, channelId, type, source, content, targetRoleId, targetMsgCode, otherInfo }; result.roomId = groupRoomId(channel, channelId); await setupBaseMsgParm(result); return result; @@ -120,8 +121,8 @@ export async function createPrivateMsg(roleId: string, roleName: string, type: n * @param {string} targetMsgCode * @returns */ -export async function createGroupMsg(roleId: string, roleName: string, channel: string, channelId: string, type: number, source: number, content: string, targetRoleId: string, targetMsgCode: string) { - const msgData: GroupMessageParam = await createGroupMsgData(roleId, roleName, channel, channelId, type, source, content, targetRoleId, targetMsgCode); +export async function createGroupMsg(roleId: string, roleName: string, channel: string, channelId: string, type: number, source: number, content: string, targetRoleId: string, targetMsgCode: string, otherInfo = '') { + const msgData: GroupMessageParam = await createGroupMsgData(roleId, roleName, channel, channelId, type, source, content, targetRoleId, targetMsgCode, otherInfo); const result: GroupMessageType = await GroupMessageModel.createMsg(msgData); return result; } @@ -170,7 +171,12 @@ export async function pushGroupMsgToRoom(msg: GroupMessageType) { for(let serverId of serverIds) { await sendMessageToServerWithSuc(serverId, PUSH_ROUTE.GROUP_MSG, { ...msg, roleInfo }); } - } + } else if (msg.channel == CHANNEL_PREFIX.LEAGUE) { + let guildCodes = msg.otherInfo? msg.otherInfo.split('|'): []; + for(let guildCode of guildCodes) { + await sendMessageToGuildWithSuc(guildCode, PUSH_ROUTE.GROUP_MSG, { ...msg, roleInfo }); + } + } } export async function pushGroupMsgToAll(msg: GroupMessageType, filterCb?: ({ lv, topLineupCe }) => boolean) { @@ -231,7 +237,6 @@ async function recentGroupMsgs(roomId: string, count?: number) { */ export async function recentServerGroupMsgs(serverId: number, count?: number) { let groupId = await getGroupIdOfServer(serverId); - console.log('####', groupId); const result = await recentGroupMsgs(groupRoomId(CHANNEL_PREFIX.GVG, groupId), count); return result; } @@ -273,6 +278,21 @@ export async function recentGuildMsgs(guildCode: string, count?: number) { return result; } +/** + * @description 获取最近的联军聊天消息 + * @export + * @param {string} guildCode 用区服编号做房间标识 + * @param {number} [count] + * @returns + */ +export async function recentLeagueMsgs(guildCode: string, count?: number) { + if(!guildCode) return []; + let myLeague = await GVGLeagueModel.findLeagueByGuild(guildCode); + if(!myLeague) return []; + const result = await recentGroupMsgs(groupRoomId(CHANNEL_PREFIX.LEAGUE, myLeague.leagueCode), count); + return result; +} + /** * @description 创建新的私聊记录 * @param {boolean} sender 给发送者还是接收者创建,发送者发消息的时候也阅读了消息 diff --git a/game-server/app/services/connectorService.ts b/game-server/app/services/connectorService.ts index 0c449ef88..37197213a 100644 --- a/game-server/app/services/connectorService.ts +++ b/game-server/app/services/connectorService.ts @@ -2,7 +2,7 @@ * entry触发后引起的下发 */ import { getMails } from './mailService'; -import { recentGuildMsgs, recentPrivateChatInfos, recentServerGroupMsgs, recentSysMsgs, recentWorldMsgs } from './chatService'; +import { recentGuildMsgs, recentLeagueMsgs, recentPrivateChatInfos, recentServerGroupMsgs, recentSysMsgs, recentWorldMsgs } from './chatService'; import { getCurTask, getPvpTask } from './task/taskService'; import { RoleType } from '../db/Role'; @@ -204,8 +204,9 @@ export async function getModuleData(type: string, data: { role: RoleType, sessio const sysMsgs = await recentSysMsgs(serverId); const guildMsgs = await recentGuildMsgs(guildCode); const gvgMsgs = await recentServerGroupMsgs(serverId); + const leagueMsgs = await recentLeagueMsgs(guildCode); const recentPrivateChats = await recentPrivateChatInfos(roleId, roleName); - return { worldMsgs, sysMsgs, guildMsgs, gvgMsgs, recentPrivateChats }; + return { worldMsgs, sysMsgs, guildMsgs, gvgMsgs, leagueMsgs, recentPrivateChats }; case 'event': return await getEvent(role.eventStatus, roleId, roleName); case 'battle': diff --git a/game-server/app/services/gvg/gvgBattleService.ts b/game-server/app/services/gvg/gvgBattleService.ts index a0a4e88de..76f1fb17e 100644 --- a/game-server/app/services/gvg/gvgBattleService.ts +++ b/game-server/app/services/gvg/gvgBattleService.ts @@ -1,5 +1,5 @@ import { GVGTeamMem } from "../../domain/battleField/gvgBattle"; -import { GVGLeagueType } from "../../db/GVGLeague"; +import { GVGLeagueModel, GVGLeagueType } from "../../db/GVGLeague"; import { GVGTeamModel, GVGTeamType, GVGTeamUpdate } from "../../db/GVGTeam"; import { GVGCityModel, GVGCityType } from "../../db/GVGCity"; import { gameData, getGVGBattleRankReward } from "../../pubUtils/data"; @@ -20,6 +20,7 @@ import { findKeys, getAllServerName } from "../redisService"; import { sendMessageToGVGAreaByTeamWithSuc, sendMessageToGVGAreaWithSuc, sendMessageToGVGCityWithSuc } from "../pushService"; import { sendMailToLeagueByContent } from "../mailService"; import { GVGCityAreaPointModel } from "../../db/GVGCityAreaPoint"; +import { addCityGuardMessage } from "./gvgRecService"; /** @@ -380,7 +381,9 @@ export async function gvgBattleEnd() { if(cnt < GVG.GVG_CITY_OCCUPIED_NUMBER) { await GVGCityModel.guardCity(configId, groupKey, cityId, rankInfo); let dicCityAdd = gameData.gvgCityAdd.get(dicCity.cityType); - await sendMailToLeagueByContent(MAIL_TYPE.GVG_GUARD_CITY_REWARD, rankInfo.code, { params: [dicCity.cityName], goods: dicCityAdd.occupyReward }); + let league = await GVGLeagueModel.findByCodeWithoutPopulate(rankInfo.code); + await sendMailToLeagueByContent(MAIL_TYPE.GVG_GUARD_CITY_REWARD, rankInfo.code, { params: [dicCity.cityName], goods: dicCityAdd.occupyReward }, league); + await addCityGuardMessage(league, cityId); guardLeagueCnt.set(rankInfo.code, cnt + 1); break; } diff --git a/game-server/app/services/gvg/gvgFightService.ts b/game-server/app/services/gvg/gvgFightService.ts index 80f205cd0..0b8b0036d 100644 --- a/game-server/app/services/gvg/gvgFightService.ts +++ b/game-server/app/services/gvg/gvgFightService.ts @@ -27,8 +27,8 @@ import { getHeroesAttributes } from "../playerCeService"; import { Rank } from "../rankService"; import { findKeys, getAllServerName, redisClient } from "../redisService"; import { combinePushItem } from "./gvgItemService"; -import { addVestigeLeagueRankRec } from "./gvgRecService"; -import { getGroupIdOfServer, getGroupKey, getGVGServerType } from "./gvgService"; +import { addVestigeLeagueRankRec, addVestigeRankMessage } from "./gvgRecService"; +import { getGroupIdOfServer, getGroupKey, getGVGServerType, getPeriodByTime } from "./gvgService"; // 备战期的遗迹和激战期的开始结束战斗时间 export function getFightTimeByPeriod(period: GVG_PERIOD, time?: number) { @@ -390,6 +390,8 @@ export async function getVestigeRank(redisKey: REDIS_KEY, isSimple: boolean, key // systimer 服 export async function saveVestigeRankSchedule() { let config = await GVGConfigModel.findConfig(); + let period = getPeriodByTime(config.teamTime, config.prepareTime, config.battleTime, config.scheduleTime); + if(period != GVG_PERIOD.PREPARE) return; let day = getDayKeyInfo(); let keys = await findKeys(`${REDIS_KEY.GVG_VESTIGE_LEAGUE}:${day}:`); for(let key of keys) { @@ -398,6 +400,7 @@ export async function saveVestigeRankSchedule() { let ranks = await r.getRankByRangeRaw(); await GVGVestigeLeagueRankModel.saveRank(groupKey, ranks); await addVestigeLeagueRankRec(config.configId, groupKey, ranks); + await addVestigeRankMessage(ranks); } let memberKeys = await findKeys(`${REDIS_KEY.GVG_VESTIGE_MEMBER_ALL}:${day}:`); @@ -416,14 +419,14 @@ export function calVestigeLeagueBoxRewards(canReceiveRanks: GVGVestigeLeagueRank for(let { rank } of canReceiveRanks) { let dicRank = getGVGVestigeLeagueRank(rank); if(!dicRank) { console.error('dic_zyz_GVGVestigeLeagueRank error'); continue; } - console.log('###### league', rank, dicRank) + // console.log('###### league', rank, dicRank) combinePushItem(rewards, dicRank.rankReward); combinePushItem(leagueReward, dicRank.rankLeagueReward); } for(let { rank } of canReceivePlayerRanks) { let dicRank = getGVGVestigePlayerRank(rank); if(!dicRank) { console.error('dic_zyz_GVGVestigPlayerRank error'); continue; } - console.log('###### player', rank, dicRank) + // console.log('###### player', rank, dicRank) combinePushItem(rewards, dicRank.rankPlayerReward); combinePushItem(leagueReward, dicRank.rankPlayerLeagueReward); } diff --git a/game-server/app/services/gvg/gvgPrepareService.ts b/game-server/app/services/gvg/gvgPrepareService.ts index 4bb241c2d..4e9576cdb 100644 --- a/game-server/app/services/gvg/gvgPrepareService.ts +++ b/game-server/app/services/gvg/gvgPrepareService.ts @@ -15,7 +15,8 @@ import { addGVGReward } from "./gvgItemService"; import { getGVGConfig } from "./gvgService"; import { getProduceCoinCnt } from "./gvgItemService"; import { GVGVestigeRankModel } from "../../db/GVGVestigeRank"; -import { addResourceRecord } from "./gvgRecService"; +import { addLeagueLvUpMessage, addResourceRecord } from "./gvgRecService"; +import { GVGLeagueType } from "../../db/GVGLeague"; export function checkPreTech(techId: number, activeQueue: number[], techQueue: Tech[]) { const dicTech = gameData.gvgTech.get(techId); @@ -116,7 +117,8 @@ export function getMyContribute(userDailyData: GVGUserDailyDataType, myRanks: {v * @param count 数量 * @returns */ -export async function addResource(leagueCode: string, roleId: string, roleName: string, resourceType: GVG_RESOURCE_TYPE, count: number) { +export async function addResource(myLeague: GVGLeagueType, roleId: string, roleName: string, resourceType: GVG_RESOURCE_TYPE, count: number) { + let { leagueCode } = myLeague; let { configId } = getGVGConfig(); let resources = getResourceCnt(resourceType, count); if(!resources) return false; @@ -124,6 +126,7 @@ export async function addResource(leagueCode: string, roleId: string, roleName: // 联军更新资源 let league = await GVGLeaguePrepareModel.addResource(configId, leagueCode, food, mineral, wood); + let originLv = league?.lv||1; // 联军升级 let lv = calLeagueLv(league.resources); league = await GVGLeaguePrepareModel.setLv(configId, leagueCode, lv); @@ -135,6 +138,7 @@ export async function addResource(leagueCode: string, roleId: string, roleName: let myContribute = getMyContribute(userDailyData, myRanks); addResourceRecord(roleId, roleName, leagueCode, resourceType, count); + if(lv > originLv) addLeagueLvUpMessage(roleId, roleName, myLeague, lv); return { resources: league.resources, leagueLv: league.lv, myContribute } } diff --git a/game-server/app/services/gvg/gvgRecService.ts b/game-server/app/services/gvg/gvgRecService.ts index bcdd8f908..f7856d0b3 100644 --- a/game-server/app/services/gvg/gvgRecService.ts +++ b/game-server/app/services/gvg/gvgRecService.ts @@ -1,12 +1,14 @@ // 动态 -import { GVG_REC_ID, GVG_REC_TYPE, GVG_RESOURCE_TYPE } from "../../consts"; +import { CHANNEL_PREFIX, GVG_REC_ID, GVG_REC_TYPE, GVG_RESOURCE_TYPE, MSG_SOURCE, MSG_TYPE } from "../../consts"; import { GVGBattleRecType } from "../../db/GVGBattleRec"; +import { GVGLeagueModel, GVGLeagueType } from "../../db/GVGLeague"; 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"; +import { createGroupMsg, pushGroupMsgToRoom } from "../chatService"; import { getGVGConfig } from "./gvgService"; // 加入军团 @@ -114,4 +116,47 @@ export async function addTeamSettleRec(team: GVGTeamType) { export async function addTeamLeaveRec(team: GVGTeamType, pointId: number) { let { roleId, roleName, leagueCode, configId, cityId, groupKey } = team; await GVGRecModel.addRec({ roleId, leagueCode, configId, cityId, groupKey, type: GVG_REC_TYPE.BATTLE_BY_LEAGUE, recId: GVG_REC_ID.LEAGUE_TEAM_LEAVE, createTime: nowSeconds(), params: [`${roleName}`, getPointName(pointId)] }); +} + + +// —————— 频道消息 —————— +export async function addLeagueLvUpMessage(roleId: string, roleName: string, myLeague: GVGLeagueType, lv: number) { + const msgData = await createGroupMsg(roleId, roleName, CHANNEL_PREFIX.LEAGUE, myLeague.leagueCode, MSG_TYPE.RICH_TEXT, MSG_SOURCE.GVG_LV_UP, JSON.stringify({ leagueCode: myLeague.leagueCode, name: myLeague.name, lv }), '', '', getGuildCodeString(myLeague)); + await pushGroupMsgToRoom(msgData); +} + +export async function changeNoticeMessage(roleId: string, roleName: string, myLeague: GVGLeagueType, notice: string) { + const msgData = await createGroupMsg(roleId, roleName, CHANNEL_PREFIX.GVG, myLeague.leagueCode, MSG_TYPE.RICH_TEXT, MSG_SOURCE.GVG_NOTICE, JSON.stringify({ leagueCode: myLeague.leagueCode, name: myLeague.name, notice }), '', '', getGuildCodeString(myLeague)); + await pushGroupMsgToRoom(msgData); +} + +export function getGuildCodeString(myLeague: GVGLeagueType) { + let guildCodes = myLeague?.guildCodes||[]; + return guildCodes.join('|') +} + +export async function addTechActivateMessage(roleId: string, roleName: string, myLeague: GVGLeagueType, techId: number) { + const msgData = await createGroupMsg(roleId, roleName, CHANNEL_PREFIX.LEAGUE, myLeague.leagueCode, MSG_TYPE.RICH_TEXT, MSG_SOURCE.GVG_LV_UP, JSON.stringify({ leagueCode: myLeague.leagueCode, name: myLeague.name, techId }), '', '', getGuildCodeString(myLeague)); + await pushGroupMsgToRoom(msgData); +} + +export async function addTechUnlockMessage(roleId: string, roleName: string, myLeague: GVGLeagueType, techId: number) { + const msgData = await createGroupMsg(roleId, roleName, CHANNEL_PREFIX.LEAGUE, myLeague.leagueCode, MSG_TYPE.RICH_TEXT, MSG_SOURCE.GVG_LV_UP, JSON.stringify({ leagueCode: myLeague.leagueCode, name: myLeague.name, techId }), '', '', getGuildCodeString(myLeague)); + await pushGroupMsgToRoom(msgData); +} + +export async function addVestigeRankMessage(ranks: { rank: number, field: string }[]) { + let leagueCodes = ranks.map(cur => cur.field); + let leagues = await GVGLeagueModel.findByCodesWithoutPopulate(leagueCodes, 'leagueCode name guildCodes'); + for(let { rank, field: leagueCode } of ranks) { + let league = leagues.find(cur => cur.leagueCode == leagueCode); + if(!league) continue; + const msgData = await createGroupMsg('', '', CHANNEL_PREFIX.LEAGUE, leagueCode, MSG_TYPE.RICH_TEXT, MSG_SOURCE.GVG_LV_UP, JSON.stringify({ leagueCode: league.leagueCode, name: league.name, rank }), '', '', getGuildCodeString(league)); + await pushGroupMsgToRoom(msgData); + } +} + +export async function addCityGuardMessage(myLeague: GVGLeagueType, cityId: number) { + const msgData = await createGroupMsg('', '', CHANNEL_PREFIX.LEAGUE, myLeague.leagueCode, MSG_TYPE.RICH_TEXT, MSG_SOURCE.GVG_LV_UP, JSON.stringify({ leagueCode: myLeague.leagueCode, name: myLeague.name, cityId }), '', '', getGuildCodeString(myLeague)); + await pushGroupMsgToRoom(msgData); } \ No newline at end of file diff --git a/game-server/app/services/gvg/gvgService.ts b/game-server/app/services/gvg/gvgService.ts index 48c29572a..8b24a3d57 100644 --- a/game-server/app/services/gvg/gvgService.ts +++ b/game-server/app/services/gvg/gvgService.ts @@ -148,6 +148,10 @@ export function getGVGPeriodData() { export function getCurPeriod() { let { teamTime, prepareTime, battleTime, scheduleTime } = getGVGConfig(); + return getPeriodByTime(teamTime, prepareTime, battleTime, scheduleTime) +} + +export function getPeriodByTime(teamTime: number, prepareTime: number, battleTime: number, scheduleTime: number) { let now = nowSeconds(); if(now >= teamTime && now < prepareTime) { return GVG_PERIOD.TEAM; diff --git a/shared/consts/constModules/chatConst.ts b/shared/consts/constModules/chatConst.ts index 1e1631ca8..ddbea7e8b 100644 --- a/shared/consts/constModules/chatConst.ts +++ b/shared/consts/constModules/chatConst.ts @@ -26,6 +26,7 @@ export const CHANNEL_PREFIX = { GVG_AREAS: 'gvgAreas', // 大地图界面 GVG_AREA_BY_TEAM: 'gvgTeam', // 选中玩家队伍后加入频道 GVG_CITY: 'gvgCity', // 玩家进入城池 + LEAGUE: 'league', // 联军 } export const getChannelType = function(prefix: string) { @@ -42,6 +43,8 @@ export const getChannelType = function(prefix: string) { return 5; case CHANNEL_PREFIX.GVG: return 6; + case CHANNEL_PREFIX.LEAGUE: + return 7; } } @@ -90,6 +93,12 @@ export const MSG_SOURCE = { LADDER_FIRST_CHANGE: 27, GET_UR_HERO: 28, GVG_RECURIT: 29, + GVG_LV_UP: 30, + GVG_NOTICE: 31, + GVG_TECH_ACTIVATE: 32, + GVG_TECH_UNLOCK: 33, + GVG_VESTIGE_ACCOUNT: 34, + GVG_OCCUPY_CITY: 35, } export const DEFAULT_MSG_PER_PAGE = 10; diff --git a/shared/consts/statusCode.ts b/shared/consts/statusCode.ts index f44496eba..0ea11d586 100644 --- a/shared/consts/statusCode.ts +++ b/shared/consts/statusCode.ts @@ -344,6 +344,7 @@ export const STATUS = { GVG_USER_NOT_IN_CITY: { code: 21338, simStr: '您不在该城池中' }, GVG_NOT_BATTLE_PERIOD: { code: 21339, simStr: '您只能在激战期进行此操作' }, GVG_FIELD_HAS_PLANT: { code: 21340, simStr: '该田已种植' }, + GVG_NOT_JOIN_LEAGUE: { code: 21341, simStr: '您未加入联军' }, // GVG征战中原 GVG_VESTIGE_ERR: { code: 21350, simStr: '今日未开放该遗迹' }, diff --git a/shared/db/GVGLeague.ts b/shared/db/GVGLeague.ts index 3789f81c9..cf6c15536 100644 --- a/shared/db/GVGLeague.ts +++ b/shared/db/GVGLeague.ts @@ -120,6 +120,11 @@ export default class GVGLeague extends BaseModel { return leagues } + public static async findByCodesWithoutPopulate(leagueCodes: string[], select = '') { + const leagues: GVGLeagueType[] = await GVGLeagueModel.find({ leagueCode: { $in: leagueCodes }, status: 1 }).select(select).lean(); + return leagues + } + public static async joinGuild(leagueCode: string, guild: GuildType) { const { code, memberCnt, leader, members } = guild; let _leader = leader; diff --git a/shared/db/GVGRec.ts b/shared/db/GVGRec.ts index a59511a02..fc02429db 100644 --- a/shared/db/GVGRec.ts +++ b/shared/db/GVGRec.ts @@ -49,10 +49,15 @@ export default class GVGRec extends BaseModel { // 查询城池战报 public static async findBattleRecByCity(configId: number, groupKey: string, cityId: number) { - const result: GVGRecType[] = await GVGRecModel.find({ cityId, configId, groupKey, type: GVG_REC_TYPE.BATTLE_BY_CITY }, { _id: 0, recId: 1, params: 1, createTime: 1 }).sort({ createTime: -1 }).limit(50).lean(); + const result: GVGRecType[] = await GVGRecModel.find({ configId, groupKey, type: GVG_REC_TYPE.BATTLE_BY_CITY, cityId }, { _id: 0, recId: 1, params: 1, createTime: 1 }).sort({ createTime: -1 }).limit(50).lean(); return result; } + public static async findBattleRecByGroup(configId: number, groupKey: string) { + const result: GVGRecType[] = await GVGRecModel.find({ configId, groupKey, 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; diff --git a/shared/db/GroupMessage.ts b/shared/db/GroupMessage.ts index 9741dbede..716f1f8c7 100644 --- a/shared/db/GroupMessage.ts +++ b/shared/db/GroupMessage.ts @@ -42,6 +42,9 @@ export default class GroupMessage extends BaseModel { @prop({ required: true, default: '' }) content: string; // 消息内容 + @prop({ required: true, default: '' }) + otherInfo: string; // 其他信息 + public static async createMsg(data: GroupMessageParam) { const result = await GroupMessageModel.findOneAndUpdate({ msgCode: data.msgCode }, {...data}, {upsert: true, new: true}).lean(); return result; diff --git a/shared/resource/jsons/dic_zyz_GVGPeriod.json b/shared/resource/jsons/dic_zyz_GVGPeriod.json index 6afac5dcb..e92487f26 100644 --- a/shared/resource/jsons/dic_zyz_GVGPeriod.json +++ b/shared/resource/jsons/dic_zyz_GVGPeriod.json @@ -14,7 +14,7 @@ { "periodType": 3, "day": "6&", - "startTime": "20:55:00", - "endTime": "23:00:00" + "startTime": "17:00:00", + "endTime": "20:00:00" } ] \ No newline at end of file diff --git a/shared/resource/jsons/dic_zyz_chat_system.json b/shared/resource/jsons/dic_zyz_chat_system.json index 6466184b1..949c24143 100644 --- a/shared/resource/jsons/dic_zyz_chat_system.json +++ b/shared/resource/jsons/dic_zyz_chat_system.json @@ -3,7 +3,7 @@ "id": 0, "name": "ROLE_SEND_TEXT", "mean": "玩家发送消息", - "type": "2&3&4&5", + "type": "2&3&4&5&6&7", "template": "%d", "worldchat": "%d", "bubble": "%d", @@ -74,9 +74,9 @@ "name": "GUILD_STRUCTURE_LV_UP", "mean": "军团升级建筑", "type": "3&", - "template": "恭喜主公,军团%d已升至%d级", - "worldchat": "恭喜各位小主公,军团%d已升至%d级", - "bubble": "恭喜各位小主公,军团%d已升至%d", + "template": "恭喜百家传人,军团%d已升至%d级", + "worldchat": "恭喜各位百家传人,军团%d已升至%d级", + "bubble": "恭喜各位百家传人,军团%d已升至%d", "comments": "1:%d(军团名);2:%d(军团升级后的等级数)" }, { @@ -94,9 +94,9 @@ "name": "GUILD_BOSS_SUC", "mean": "军团BOSS胜利", "type": "3&", - "template": "恭喜主公,军团BOSS%d被成功压制,海量拍品已加入拍卖行", - "worldchat": "恭喜各位小主公,军团BOSS%d被成功压制,海量拍品已加入拍卖行", - "bubble": "恭喜各位小主公,军团BOSS%d被成功压制,拍卖行即将开启", + "template": "恭喜百家传人,军团BOSS%d被成功压制,海量拍品已加入拍卖行", + "worldchat": "恭喜各位百家传人,军团BOSS%d被成功压制,海量拍品已加入拍卖行", + "bubble": "恭喜各位百家传人,军团BOSS%d被成功压制,拍卖行即将开启", "comments": "1:%d(BOSS名)" }, { @@ -298,5 +298,65 @@ "worldchat": "%d正在扩充兵马:%d,欢迎各军团加入建设", "bubble": "%d正在扩充兵马:%d,欢迎各军团加入建设", "comments": "1:%d(联军名);2:%d(联军招募内容)" + }, + { + "id": 30, + "name": "GVG_LV_UP", + "mean": "联军升级", + "type": "7&", + "template": "恭喜百家传人,联军%d已升至%d级", + "worldchat": "恭喜各位百家传人,联军%d已升至%d级", + "bubble": "恭喜各位百家传人,联军%d已升至%d", + "comments": "1:%d(联军名);2:%d(联军升级后的等级数)" + }, + { + "id": 31, + "name": "GVG_NOTICE", + "mean": "联军修改公告", + "type": "7&", + "template": "公告:%d", + "worldchat": "公告:%d", + "bubble": "公告:%d", + "comments": "%d:玩家发送的消息内容" + }, + { + "id": 32, + "name": "GVG_TECH_ACTIVATE", + "mean": "联军千机阁激活", + "type": "7&", + "template": "恭喜百家传人,联军%d已成功激活千机阁%d神机", + "worldchat": "恭喜各位百家传人,联军%d已成功激活千机阁%d神机:%d", + "bubble": "恭喜各位百家传人,联军%d已成功激活千机阁%d神机", + "comments": "1:%d(联军名);2:%d(激活的神机名); 3:%d(激活的神机内容)" + }, + { + "id": 33, + "name": "GVG_TECH_UNLOCK", + "mean": "联军千机阁解锁", + "type": "7&", + "template": "各位百家传人,联军管理%d已解锁千机阁%d神机,可进行捐献激活", + "worldchat": "各位百家传人,联军管理%d已解锁千机阁%d神机,可进行捐献激活", + "bubble": "各位百家传人,%d神机已解锁", + "comments": "1:%d(激活的神机名)" + }, + { + "id": 34, + "name": "GVG_VESTIGE_ACCOUNT", + "mean": "联军遗迹每日22:00结算", + "type": "7&", + "template": "各位百家传人,联军%d今日遗迹驻扎排名:%d,奖励已发送至遗迹奖励宝箱", + "worldchat": "各位百家传人,联军%d今日遗迹驻扎排名:%d,奖励已发送至遗迹奖励宝箱", + "bubble": "各位百家传人,联军%d今日遗迹驻扎排名:%d", + "comments": "1:%d(联军名);2:%d(第X名/未上榜)" + }, + { + "id": 35, + "name": "GVG_OCCUPY_CITY", + "mean": "联军城池占领", + "type": "6&7&", + "template": "联军%d上下一心,成功占领%d", + "worldchat": "联军%d上下一心,成功占领%d", + "bubble": "联军%d上下一心,成功占领%d", + "comments": "1:%d(联军名);2:%d(城池名)" } ] \ No newline at end of file