✨ feat(gvg): 组建期聊天和邮件
This commit is contained in:
@@ -17,6 +17,7 @@ import { sendMessageToAllWithSuc, sendMessageToCityWithSuc, sendMessageToGuildWi
|
||||
import { comBtlLvInvalid } from './comBattleService';
|
||||
import { gameData } from '../pubUtils/data';
|
||||
import { RegionModel } from '../db/Region';
|
||||
import { getGroupIdOfServer, getServersByGroupId } from './gvg/gvgService';
|
||||
|
||||
export * from './chatChannelService';
|
||||
export * from './sysChatService';
|
||||
@@ -163,6 +164,12 @@ export async function pushGroupMsgToRoom(msg: GroupMessageType) {
|
||||
} else if (msg.channel == CHANNEL_PREFIX.CITY) {
|
||||
let arr = msg.channelId.split('_');
|
||||
await sendMessageToCityWithSuc(parseInt(arr[0]), parseInt(arr[1]), PUSH_ROUTE.GROUP_MSG, { ...msg, roleInfo });
|
||||
} else if (msg.channel == CHANNEL_PREFIX.GVG) {
|
||||
let groupId = parseInt(msg.channelId);
|
||||
let serverIds = await getServersByGroupId(groupId);
|
||||
for(let serverId of serverIds) {
|
||||
await sendMessageToServerWithSuc(serverId, PUSH_ROUTE.GROUP_MSG, { ...msg, roleInfo });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -215,6 +222,20 @@ async function recentGroupMsgs(roomId: string, count?: number) {
|
||||
return result.filter(cur => cur) || [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 获取最近的战区聊天消息
|
||||
* @export
|
||||
* @param {number} serverId 用区服编号做房间标识
|
||||
* @param {number} [count]
|
||||
* @returns
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 获取最近的世界聊天消息
|
||||
* @export
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* entry触发后引起的下发
|
||||
*/
|
||||
import { getMails } from './mailService';
|
||||
import { recentGuildMsgs, recentPrivateChatInfos, recentSysMsgs, recentWorldMsgs } from './chatService';
|
||||
import { recentGuildMsgs, recentPrivateChatInfos, recentServerGroupMsgs, recentSysMsgs, recentWorldMsgs } from './chatService';
|
||||
import { getCurTask, getPvpTask } from './task/taskService';
|
||||
|
||||
import { RoleType } from '../db/Role';
|
||||
@@ -203,8 +203,9 @@ export async function getModuleData(type: string, data: { role: RoleType, sessio
|
||||
const worldMsgs = await recentWorldMsgs(serverId);
|
||||
const sysMsgs = await recentSysMsgs(serverId);
|
||||
const guildMsgs = await recentGuildMsgs(guildCode);
|
||||
const gvgMsgs = await recentServerGroupMsgs(serverId);
|
||||
const recentPrivateChats = await recentPrivateChatInfos(roleId, roleName);
|
||||
return { worldMsgs, sysMsgs, guildMsgs, recentPrivateChats };
|
||||
return { worldMsgs, sysMsgs, guildMsgs, gvgMsgs, recentPrivateChats };
|
||||
case 'event':
|
||||
return await getEvent(role.eventStatus, roleId, roleName);
|
||||
case 'battle':
|
||||
|
||||
@@ -19,6 +19,8 @@ export async function createNewGVGConfig() {
|
||||
setGVGConfigToRemote(config);
|
||||
// TODO 每周自动解散一些联军
|
||||
await pinus.app.rpc.guild.guildRemote.setGVGServerGroup.broadcast();
|
||||
await pinus.app.rpc.chat.chatRemote.setGVGServerGroup.broadcast();
|
||||
await pinus.app.rpc.connector.connectorRemote.setGVGServerGroup.broadcast();
|
||||
return config;
|
||||
}
|
||||
|
||||
@@ -157,12 +159,16 @@ export async function getServersOfSameGroup(type: GVG_SERVER_TYPE, id: number) {
|
||||
if(type == GVG_SERVER_TYPE.SINGLE) return [id];
|
||||
|
||||
let groupId = await getGroupIdOfServer(id);
|
||||
return await getServersByGroupId(groupId);
|
||||
}
|
||||
|
||||
export async function getServersByGroupId(groupId: number) {
|
||||
let arr: { serverId: number; groupId: number }[] = pinus.app.get('gvgServerGroup')||[];
|
||||
let serverCreateTimes = await getAllServerCreateTime();
|
||||
|
||||
return arr.filter(obj => {
|
||||
let openTime = parseInt(serverCreateTimes[obj.serverId]);
|
||||
return obj.groupId == groupId && getServerTypeByTime(openTime) == type;
|
||||
return obj.groupId == groupId && getServerTypeByTime(openTime) == GVG_SERVER_TYPE.MULTI;
|
||||
}).map(obj => obj.serverId);
|
||||
}
|
||||
|
||||
|
||||
@@ -190,11 +190,13 @@ function getAuthFromManageType(type: LEAGUE_MANAGE_TYPE) {
|
||||
case LEAGUE_MANAGE_TYPE.KICK:
|
||||
case LEAGUE_MANAGE_TYPE.DISSMISS:
|
||||
case LEAGUE_MANAGE_TYPE.ABDICATE:
|
||||
case LEAGUE_MANAGE_TYPE.RERUIT:
|
||||
return [LEAGUE_AUTH.LEADER];
|
||||
case LEAGUE_MANAGE_TYPE.QUIT:
|
||||
case LEAGUE_MANAGE_TYPE.BE_ABDICATED:
|
||||
return [LEAGUE_AUTH.SUB_LEADER];
|
||||
case LEAGUE_MANAGE_TYPE.SET_INFO:
|
||||
case LEAGUE_MANAGE_TYPE.SEND_MAIL:
|
||||
return [LEAGUE_AUTH.LEADER, LEAGUE_AUTH.SUB_LEADER];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -901,8 +901,9 @@ export async function initGVGConfigSchedule() {
|
||||
let config = await GVGConfigModel.findConfig();
|
||||
if(!config) {
|
||||
config = await createNewGVGConfig();
|
||||
} else {
|
||||
setGVGConfigToRemote(config);
|
||||
}
|
||||
setGVGConfigToRemote(config);
|
||||
|
||||
if(nowSeconds() > config.scheduleTime) {
|
||||
config = await createNewGVGConfig();
|
||||
|
||||
Reference in New Issue
Block a user