优化:抽象推送方法
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { ACTIVITY_TYPE, STATUS } from '../../consts';
|
||||
import { ACTIVITY_TYPE, PUSH_ROUTE, STATUS } from '../../consts';
|
||||
import { getPlayerFirstGiftDataShow } from './firstGiftService';
|
||||
import { getPlayerSignInData, } from './signInService';
|
||||
import { getPlayerGrowthFundData, } from './growthFundService';
|
||||
@@ -40,6 +40,7 @@ import { addTaskPassPoint, getTaskPassDataShow } from './taskPassService';
|
||||
import { getGuildChannelSid } from '../chatService';
|
||||
import { getGuildPayDataShow } from './guildPayService';
|
||||
import { PopUpShopItemShow } from '../../domain/activityField/popUpShopField';
|
||||
import { sendMessageToGuildWithSuc } from '../pushService';
|
||||
|
||||
/**
|
||||
* 获取活动数据
|
||||
@@ -433,13 +434,5 @@ export async function pushActivities(arr: pushActivityInter[], roleId: string, s
|
||||
}
|
||||
|
||||
export async function pushActivitiesToGuild(arr: pushActivityInter[], guildCode: string) {
|
||||
let chatSid = await getGuildChannelSid(guildCode);
|
||||
console.log('####', chatSid, arr)
|
||||
if(!!chatSid && arr.length > 0) {
|
||||
pinus.app.rpc.chat.guildRemote.pushActivityToGuild.toServer(chatSid, guildCode, 'onActivityUpdate',
|
||||
resResult(STATUS.SUCCESS, {
|
||||
activities: arr
|
||||
}),
|
||||
);
|
||||
}
|
||||
if(arr.length > 0) await sendMessageToGuildWithSuc(guildCode, PUSH_ROUTE.ACTIVITY_UPDATE, { activities: arr })
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
import { DividendModel } from './../db/Dividend';
|
||||
import { LOT_CODE_LEN, AUCTION_STAGE, AUCTION_TIME, DIVIDEND_CODE_LEN, DIVIDEND_STATUS, LOT_STATUS, MAIL_TYPE, CURRENCY_BY_TYPE, CURRENCY_TYPE, DIVIDENDMAXRATIO, DIVIDENDPOSITIONMAXRATIO, ROLE_RECEIVE_STATUS, AUCTION_BID_STATUS, DEBUG_MAGIC_WORD, AUCTION_SOURCE, TA_EVENT, getAuctionSourceTypeName } from './../consts';
|
||||
import { LOT_CODE_LEN, AUCTION_STAGE, AUCTION_TIME, DIVIDEND_CODE_LEN, DIVIDEND_STATUS, LOT_STATUS, MAIL_TYPE, CURRENCY_BY_TYPE, CURRENCY_TYPE, DIVIDENDMAXRATIO, DIVIDENDPOSITIONMAXRATIO, ROLE_RECEIVE_STATUS, AUCTION_BID_STATUS, DEBUG_MAGIC_WORD, AUCTION_SOURCE, TA_EVENT, getAuctionSourceTypeName, PUSH_ROUTE } from './../consts';
|
||||
import { DividendRec, ItemReward } from "../domain/dbGeneral";
|
||||
import { genCode, getRandSingleEelm } from '../pubUtils/util';
|
||||
import { LotModel, LotParam, LotType } from '../db/Lot';
|
||||
@@ -12,8 +12,9 @@ import { participants } from './guildActivity/guildActivityService';
|
||||
import { Member } from '../domain/battleField/guildActivity';
|
||||
import * as dicParam from '../pubUtils/dicParam';
|
||||
import { RewardInter } from '../pubUtils/interface';
|
||||
import { getGuildAuctionChannelSid, getGuildChannelSid, getWorldAuctionChannelSid, pushCurrentTime } from './chatService';
|
||||
import { reportTAEvent } from './sdkService';
|
||||
import { getAllServers } from './redisService';
|
||||
import { sendMessageToGuildWithSuc, sendMessageToServer, sendMessageToServerWithSuc } from './pushService';
|
||||
|
||||
// ! 获取底价,假数据
|
||||
export function getBasePrice(gid: number, count: number) {
|
||||
@@ -222,8 +223,8 @@ export async function genAuction(guildCode: string, sourceType: number, sourceCo
|
||||
}),
|
||||
};
|
||||
const dividend = await DividendModel.createDividend(dividendData);
|
||||
let channelSid = await getGuildChannelSid(guildCode);
|
||||
pinus.app.rpc.chat.guildRemote.pushAuctionAdd.toServer(channelSid, guildCode, { lots, dividends: [dividend] });
|
||||
await sendMessageToGuildWithSuc(guildCode, PUSH_ROUTE.AUCTION_ADD, { lots });
|
||||
await sendMessageToGuildWithSuc(guildCode, PUSH_ROUTE.DIVIDEND_ADD, { dividends: [dividend] });
|
||||
return { lots, dividend };
|
||||
}
|
||||
|
||||
@@ -360,6 +361,14 @@ export async function stopAuction() {
|
||||
}
|
||||
}
|
||||
|
||||
// debug函数,修改客户端当前时间
|
||||
export async function pushCurrentTime(time: number) {
|
||||
let serverlists = await getAllServers()
|
||||
for(let serverId of serverlists) {
|
||||
await sendMessageToServer(serverId, PUSH_ROUTE.PUSH_CURRENT_TIME, { time });
|
||||
}
|
||||
}
|
||||
|
||||
async function debugDividends() {
|
||||
const begin = await yestodayGuildBegin();
|
||||
const dividends = await DividendModel.findDividendsByBegin(begin);
|
||||
@@ -455,11 +464,9 @@ export async function getAuction(guildCode: string, session: FrontendOrBackendSe
|
||||
|
||||
export async function pushAuctionOver(lot: LotType) {
|
||||
if(lot.auctionStage == AUCTION_STAGE.GUILD) {
|
||||
let chatSid = await getGuildChannelSid(lot.guildCode);
|
||||
pinus.app.rpc.chat.chatRemote.sendGuildAuction.toServer(chatSid, lot.guildCode, lot);
|
||||
await sendMessageToGuildWithSuc(lot.guildCode, PUSH_ROUTE.AUCTION_OVER, { lot });
|
||||
} else if (lot.auctionStage == AUCTION_STAGE.WORLD) {
|
||||
let chatSid = await getWorldAuctionChannelSid(lot.serverId);
|
||||
pinus.app.rpc.chat.chatRemote.sendWorldAuction.toServer(chatSid, lot.serverId, lot);
|
||||
await sendMessageToServerWithSuc(lot.serverId, PUSH_ROUTE.AUCTION_OVER, { lot });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -476,8 +483,7 @@ export async function pushAuctionUpdate(lots: LotType[], dividends: DividendType
|
||||
}
|
||||
|
||||
for(let [guildCode, lots] of lotsResult) {
|
||||
let channelSid = await getGuildChannelSid(guildCode);
|
||||
pinus.app.rpc.chat.guildRemote.pushAuctionUpdate.toServer(channelSid, guildCode, { lots });
|
||||
await sendMessageToGuildWithSuc(guildCode, PUSH_ROUTE.AUCTION_UPDATE, { lots });
|
||||
}
|
||||
|
||||
} else {
|
||||
@@ -491,8 +497,7 @@ export async function pushAuctionUpdate(lots: LotType[], dividends: DividendType
|
||||
}
|
||||
|
||||
for(let [serverId, lots] of lotsResult) {
|
||||
let channelSid = await getWorldAuctionChannelSid(serverId);
|
||||
pinus.app.rpc.chat.chatRemote.sendAuctionUpdate.toServer(channelSid, serverId, { lots });
|
||||
await sendMessageToServerWithSuc(serverId, PUSH_ROUTE.AUCTION_UPDATE, { lots });
|
||||
}
|
||||
}
|
||||
let dividendsResult = new Map<string, DividendType[]>();
|
||||
@@ -503,8 +508,7 @@ export async function pushAuctionUpdate(lots: LotType[], dividends: DividendType
|
||||
dividendsResult.get(dividend.guildCode).push(dividend);
|
||||
}
|
||||
for(let [guildCode, dividends] of dividendsResult) {
|
||||
let channelSid = await getGuildChannelSid(guildCode);
|
||||
pinus.app.rpc.chat.guildRemote.pushAuctionUpdate.toServer(channelSid, guildCode, { dividends });
|
||||
await sendMessageToGuildWithSuc(guildCode, PUSH_ROUTE.DIVIDEND_UPDATE, { dividends })
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ export async function addRoleToGuildAuctionChannel(roleId: string, sid: string,
|
||||
}
|
||||
|
||||
export async function addRoleToWorldAuctionChannel(roleId: string, sid: string, serverId: number) {
|
||||
const roomId = groupRoomId(CHANNEL_PREFIX.GUILD_AUCTION, serverId);
|
||||
const roomId = groupRoomId(CHANNEL_PREFIX.WORLD_AUCTION, serverId);
|
||||
await addRoleToChannel(roomId, roleId, sid);
|
||||
}
|
||||
|
||||
@@ -110,8 +110,8 @@ export async function getCityChannelSid(cityId: number) {
|
||||
return channelSid;
|
||||
}
|
||||
|
||||
export async function getGuildAuctionChannelSid(guildCpde: string) {
|
||||
const roomId = groupRoomId(CHANNEL_PREFIX.GUILD_AUCTION, guildCpde);
|
||||
export async function getGuildAuctionChannelSid(guildCode: string) {
|
||||
const roomId = groupRoomId(CHANNEL_PREFIX.GUILD_AUCTION, guildCode);
|
||||
const channelSid = await channelServer(roomId);
|
||||
return channelSid;
|
||||
}
|
||||
@@ -120,4 +120,15 @@ export async function getWorldAuctionChannelSid(serverId: number) {
|
||||
const roomId = groupRoomId(CHANNEL_PREFIX.CITY, serverId);
|
||||
const channelSid = await channelServer(roomId);
|
||||
return channelSid;
|
||||
}
|
||||
|
||||
async function delChannel(roomId: string) {
|
||||
const channelSid = await channelServer(roomId);
|
||||
await pinus.app.rpc.chat.chatRemote.deleteChannel.toServer(channelSid, roomId);
|
||||
}
|
||||
|
||||
export async function delGuildChannel(guildCode: string) {
|
||||
if (!guildCode) return;
|
||||
const roomId = groupRoomId(CHANNEL_PREFIX.GUILD, guildCode);
|
||||
await delChannel(roomId);
|
||||
}
|
||||
@@ -8,12 +8,12 @@ import { PrivateMessageModel, PrivateMessageParam, PrivateMessageType } from './
|
||||
import { GroupMessageParam, GroupMessageType } from '../db/GroupMessage';
|
||||
import { genCode, resResult } from '../pubUtils/util';
|
||||
import { pinus } from 'pinus';
|
||||
import { CHANNEL_PREFIX, MSG_CODE_LEN, MSG_STATUS, ON_PRIVATE_MSG_ROUTE, MSG_TYPE, MSG_SOURCE } from '../consts';
|
||||
import { getAllServers, getRoleOnlineInfo } from './redisService';
|
||||
import { CHANNEL_PREFIX, MSG_CODE_LEN, MSG_STATUS, ON_PRIVATE_MSG_ROUTE, MSG_TYPE, MSG_SOURCE, PUSH_ROUTE } from '../consts';
|
||||
import { getRoleOnlineInfo } from './redisService';
|
||||
import { ChatInfoModel } from '../db/ChatInfo';
|
||||
import { channelServer } from './chatChannelService';
|
||||
import { AccuseRecModel, AccueseParam } from '../db/AccuseRec';
|
||||
import { getSimpleRoleInfo, getSimpleRoleInfos } from './roleService';
|
||||
import { sendMessageToCityWithSuc, sendMessageToGuildWithSuc, sendMessageToServerWithSuc, sendMessageToTeam } from './pushService';
|
||||
|
||||
export * from './chatChannelService';
|
||||
export * from './sysChatService';
|
||||
@@ -142,10 +142,20 @@ export async function pushMsgToRole(msg: PrivateMessageType | GroupMessageType)
|
||||
*/
|
||||
export async function pushGroupMsgToRoom(msg: GroupMessageType) {
|
||||
if (!msg) return;
|
||||
const roomId = msg.roomId!;
|
||||
const channelSid = await channelServer(roomId);
|
||||
const roleInfo = await getSimpleRoleInfo(msg.roleId);
|
||||
await pinus.app.rpc.chat.chatRemote.sendGroupMsg.toServer(channelSid, roomId, { ...msg, roleInfo });
|
||||
if(msg.channel == CHANNEL_PREFIX.WORLD || msg.channel == CHANNEL_PREFIX.SYS || msg.channel == CHANNEL_PREFIX.WORLD_AUCTION) {
|
||||
let serverId = parseInt(msg.channelId);
|
||||
await sendMessageToServerWithSuc(serverId, PUSH_ROUTE.GROUP_MSG, { ...msg, roleInfo });
|
||||
} else if(msg.channel == CHANNEL_PREFIX.GUILD || msg.channel == CHANNEL_PREFIX.GUILD_AUCTION) {
|
||||
let guildCode = msg.channelId;
|
||||
await sendMessageToGuildWithSuc(guildCode, PUSH_ROUTE.GROUP_MSG, { ...msg, roleInfo })
|
||||
} else if (msg.channel == CHANNEL_PREFIX.TEAM) {
|
||||
let teamCode = msg.channelId;
|
||||
await sendMessageToTeam(teamCode, PUSH_ROUTE.GROUP_MSG, { ...msg, roleInfo });
|
||||
} else if (msg.channel == CHANNEL_PREFIX.CITY) {
|
||||
let cityId = parseInt(msg.channelId);
|
||||
await sendMessageToCityWithSuc(cityId, PUSH_ROUTE.GROUP_MSG, { ...msg, roleInfo });
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -354,11 +364,15 @@ export async function delPrivateMsg(roleId: string, targetRoleId: string) {
|
||||
* @description 发送组队一键邀请消息
|
||||
* @param {string} teamCode 队伍唯一标识
|
||||
*/
|
||||
export async function pushTeamInviteMsg(roleId: string, roleName: string, serverId: number, teamCode: string, blueprtId: number) {
|
||||
const msgDataWorld = await createGroupMsg(roleId, roleName, CHANNEL_PREFIX.WORLD, `${serverId}`, MSG_TYPE.RICH_TEXT, MSG_SOURCE.TEAM_INVITE, JSON.stringify({ roleName, teamCode, blueprtId }), null, null);
|
||||
const msgDataGuild = await createGroupMsg(roleId, roleName, CHANNEL_PREFIX.GUILD, `${serverId}`, MSG_TYPE.RICH_TEXT, MSG_SOURCE.TEAM_INVITE, JSON.stringify({ roleName, teamCode, blueprtId }), null, null);
|
||||
export async function pushTeamInviteMsg(roleId: string, roleName: string, serverId: number, guildCode: string, teamCode: string, blueprtId: number) {
|
||||
let msgDataWorld = await createGroupMsg(roleId, roleName, CHANNEL_PREFIX.WORLD, `${serverId}`, MSG_TYPE.RICH_TEXT, MSG_SOURCE.TEAM_INVITE, JSON.stringify({ roleName, teamCode, blueprtId }), null, null);
|
||||
await pushGroupMsgToRoom(msgDataWorld);
|
||||
await pushGroupMsgToRoom(msgDataGuild);
|
||||
|
||||
let msgDataGuild: GroupMessageType;
|
||||
if(guildCode) {
|
||||
msgDataGuild = await createGroupMsg(roleId, roleName, CHANNEL_PREFIX.GUILD, `${guildCode}`, MSG_TYPE.RICH_TEXT, MSG_SOURCE.TEAM_INVITE, JSON.stringify({ roleName, teamCode, blueprtId }), null, null);
|
||||
await pushGroupMsgToRoom(msgDataGuild);
|
||||
}
|
||||
return { msgDataWorld, msgDataGuild };
|
||||
}
|
||||
|
||||
@@ -404,13 +418,3 @@ export async function checkFilterWords(word: string) {
|
||||
return hasBlock;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
export async function pushCurrentTime(time: number) {
|
||||
let serverlists = await getAllServers()
|
||||
for(let serverId of serverlists) {
|
||||
let roomId = groupRoomId(CHANNEL_PREFIX.WORLD, serverId);
|
||||
const channelSid = await channelServer(roomId);
|
||||
await pinus.app.rpc.chat.chatRemote.pushCurrentTime.toServer(channelSid, serverId, time);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
import { MemComBtlTeam } from './../domain/battleField/ComBattleTeamField';
|
||||
import { ItemModel } from './../db/Item';
|
||||
import { ITEM_CHANGE_REASON, IT_TYPE } from './../consts';
|
||||
import { ITEM_CHANGE_REASON, IT_TYPE, PUSH_ROUTE } from './../consts';
|
||||
import { FriendRelationModel } from './../db/FriendRelation';
|
||||
import { RoleModel, RoleType } from './../db/Role';
|
||||
import { EquipPrintDropType, EquipPrintDropModel } from './../db/EquipPrintDrop';
|
||||
@@ -14,11 +14,10 @@ import { TREASURE, EXTERIOR } from '../pubUtils/dicParam';
|
||||
import { getFriendLvAdd } from './friendService';
|
||||
import { getRoleIds } from '../pubUtils/friendUtil';
|
||||
import { getTeamSearchByLv, rmRoleFromQueue } from './redisService';
|
||||
import { addUserToChannel } from './roleService';
|
||||
import { ChannelUser } from '../domain/ChannelUser';
|
||||
import { getRewardByBlueprtId, gameData, getBossHpByBlueprtId, getDicBlueprtById } from '../pubUtils/data';
|
||||
import { getZeroPointD, nowSeconds } from '../pubUtils/timeUtil';
|
||||
import { handleCost } from './role/rewardService';
|
||||
import { addUserToTeamChannel, delTeamChannel, sendMessageToTeam, sendMessageToUsersWithSuc } from './pushService';
|
||||
|
||||
/**
|
||||
* 在给定的品质列表中随机返回一定数量的藏宝图Id
|
||||
@@ -213,7 +212,7 @@ function updateRobotKilled(bossHp: number, roleSt: RoleStatus) {
|
||||
}
|
||||
}
|
||||
|
||||
export async function handleComBtlProgress(teamStatus: MemComBtlTeam, robotHurtTimer: Map<string, NodeJS.Timer>, teamMap: Map<string, MemComBtlTeam>, channel: Channel) {
|
||||
export async function handleComBtlProgress(teamStatus: MemComBtlTeam, robotHurtTimer: Map<string, NodeJS.Timer>, teamMap: Map<string, MemComBtlTeam>) {
|
||||
const { teamCode } = teamStatus;
|
||||
// 判断战斗是否结束
|
||||
let battleSt = checkComBattleResult(teamStatus);
|
||||
@@ -233,18 +232,12 @@ export async function handleComBtlProgress(teamStatus: MemComBtlTeam, robotHurtT
|
||||
|
||||
// 战斗胜利队长扣减藏宝图
|
||||
if (result && teamStatus.capId != 'robot') {
|
||||
const { sid } = channel.getMember(teamStatus.capId);
|
||||
let res = await handleCost(teamStatus.capId, sid, [{ id: teamStatus.blueprtId, count: 1 }], ITEM_CHANGE_REASON.COM_BATTLE_USE_BLUEPRT);
|
||||
let res = await handleCost(teamStatus.capId, teamStatus.sid, [{ id: teamStatus.blueprtId, count: 1 }], ITEM_CHANGE_REASON.COM_BATTLE_USE_BLUEPRT);
|
||||
if (res === false) return resResult(STATUS.COM_BATTLE_BLUEPRT_NOT_ENOUGH);
|
||||
}
|
||||
// // 为了背包显示,队长藏宝图在创建队伍的时候就扣掉了,如果输了,返还藏宝图
|
||||
// if (!result && teamStatus.capId != 'robot') {
|
||||
// const { sid } = channel.getMember(teamStatus.capId);
|
||||
// await addItems(teamStatus.capId, teamStatus.capId, sid, [{ id: teamStatus.blueprtId, count: 1 }]);
|
||||
// }
|
||||
|
||||
clearRobotHurtTimer(teamStatus, robotHurtTimer);
|
||||
channel.pushMessage('onTeamComplete', resResult(STATUS.SUCCESS, { teamCode, result }));
|
||||
sendMessageToTeam(teamCode, PUSH_ROUTE.TEAM_COMPLETE, { teamCode, result });
|
||||
|
||||
teamMap.delete(teamCode);
|
||||
}
|
||||
@@ -256,7 +249,7 @@ export async function handleComBtlProgress(teamStatus: MemComBtlTeam, robotHurtT
|
||||
* @param {*} teamStatus 要更新的队伍信息
|
||||
* @param {RoleStatus} roleSt 要更新的玩家信息
|
||||
*/
|
||||
export function updateRobotHurt(teamStatus: MemComBtlTeam, roleSt: RoleStatus, channel: Channel) {
|
||||
export function updateRobotHurt(teamStatus: MemComBtlTeam, roleSt: RoleStatus) {
|
||||
// 机器人的伤害为:boss 血量的一定比例,平均到一定回合数内,再平均到每个敌军,上下浮动一定比例
|
||||
let eachHurtHp = robotEachHurt(teamStatus.bossHp, teamStatus.bossHpArr.length);
|
||||
let robotTotalHurt = 0;
|
||||
@@ -277,7 +270,7 @@ export function updateRobotHurt(teamStatus: MemComBtlTeam, roleSt: RoleStatus, c
|
||||
teamStatus.bossCurHp -= robotTotalHurt;
|
||||
roleSt.totalDmg += robotTotalHurt;
|
||||
updateRobotKilled(teamStatus.bossHp, roleSt);
|
||||
channel.pushMessage('onTeammateAct', resResult(STATUS.SUCCESS, { teamCode: teamStatus.teamCode, bossCurHp: teamStatus.bossCurHp, bossHpArr: teamStatus.bossHpArr, roleStatus: teamStatus.roleStatus, actRoleId: roleSt.roleId, actBossHurts }));
|
||||
sendMessageToTeam(teamStatus.teamCode, PUSH_ROUTE.TEAMMATE_ACT, { teamCode: teamStatus.teamCode, bossCurHp: teamStatus.bossCurHp, bossHpArr: teamStatus.bossHpArr, roleStatus: teamStatus.roleStatus, actRoleId: roleSt.roleId, actBossHurts });
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -289,13 +282,13 @@ export function updateRobotHurt(teamStatus: MemComBtlTeam, roleSt: RoleStatus, c
|
||||
* @param {Channel} channel
|
||||
* @param {Map<string, NodeJS.Timer>} robotHurtTimer
|
||||
*/
|
||||
export function updateRobotHurtByTime(teamStatus: MemComBtlTeam, roleSt: RoleStatus, interval: number, channel: Channel, robotHurtTimer: Map<string, NodeJS.Timer>, teamMap: Map<string, MemComBtlTeam>) {
|
||||
export function updateRobotHurtByTime(teamStatus: MemComBtlTeam, roleSt: RoleStatus, interval: number, robotHurtTimer: Map<string, NodeJS.Timer>, teamMap: Map<string, MemComBtlTeam>) {
|
||||
const timerKey = `${teamStatus.teamCode}_${roleSt.roleId}`;
|
||||
const robotTimer = setInterval(() => {
|
||||
const robotTotalHurt = teamStatus.bossHp * COM_BTL_CONST.ROBOT_HURT_RATIO;
|
||||
if (roleSt.totalDmg < robotTotalHurt && teamStatus.bossCurHp > 0 && teamMap.has(teamStatus.teamCode)) {
|
||||
updateRobotHurt(teamStatus, roleSt, channel);
|
||||
handleComBtlProgress(teamStatus, robotHurtTimer, teamMap, channel);
|
||||
updateRobotHurt(teamStatus, roleSt);
|
||||
handleComBtlProgress(teamStatus, robotHurtTimer, teamMap);
|
||||
} else {
|
||||
clearInterval(robotTimer);
|
||||
}
|
||||
@@ -337,7 +330,7 @@ export function comBtlLvInvalid(playerLv: number, blueprtLvs: number[]) {
|
||||
return true
|
||||
}
|
||||
|
||||
export async function dismissTeam(teamStatus: MemComBtlTeam, teamMap: Map<string, MemComBtlTeam>, roleId: string, teamDisTimer: Map<string, NodeJS.Timer>, channel) {
|
||||
export async function dismissTeam(teamStatus: MemComBtlTeam, teamMap: Map<string, MemComBtlTeam>, roleId: string, teamDisTimer: Map<string, NodeJS.Timer>) {
|
||||
const { teamCode } = teamStatus;
|
||||
if (!teamStatus || !teamStatus.roleIds || teamStatus.roleIds.indexOf(roleId) === -1) return resResult(STATUS.COM_BATTLE_TEAM_INVALID);
|
||||
if (teamStatus.status !== COM_TEAM_STATUS.DEFAULT) return resResult(STATUS.COM_BATTLE_DISSMISS_ERR);
|
||||
@@ -349,17 +342,17 @@ export async function dismissTeam(teamStatus: MemComBtlTeam, teamMap: Map<string
|
||||
let rmSt = teamMap.delete(teamCode);
|
||||
if (!rmSt) return resResult(STATUS.COM_BATTLE_DISSMISS_ERR);
|
||||
|
||||
channel.pushMessage('onTeamDismiss', resResult(STATUS.SUCCESS, { teamCode }));
|
||||
channel.destroy();
|
||||
sendMessageToTeam(teamCode, PUSH_ROUTE.TEAM_DISMISS, { teamCode });
|
||||
delTeamChannel(teamCode);
|
||||
clearComBtlTimer(teamCode, teamDisTimer); // 队伍解散停止解散计时
|
||||
return resResult(STATUS.SUCCESS);
|
||||
}
|
||||
|
||||
export function setDismissTimer(teamStatus: MemComBtlTeam, teamMap: Map<string, MemComBtlTeam>, roleId: string, teamDisTimer: Map<string, NodeJS.Timer>, channel) {
|
||||
export function setDismissTimer(teamStatus: MemComBtlTeam, teamMap: Map<string, MemComBtlTeam>, roleId: string, teamDisTimer: Map<string, NodeJS.Timer>) {
|
||||
if (teamIsFullToStart(teamStatus)) {
|
||||
clearComBtlTimer(teamStatus.teamCode, teamDisTimer);
|
||||
let timer = setTimeout(async () => {
|
||||
await dismissTeam(teamStatus, teamMap, roleId, teamDisTimer, channel);
|
||||
await dismissTeam(teamStatus, teamMap, roleId, teamDisTimer);
|
||||
}, COM_BTL_CONST.CAP_START_TIME);
|
||||
teamDisTimer.set(teamStatus.teamCode, timer);
|
||||
}
|
||||
@@ -563,7 +556,7 @@ export function addRoleStToTeam(comTeam: MemComBtlTeam, roleSt: RoleStatus) {
|
||||
* @param {string} sid 当前用户 sid
|
||||
* @returns
|
||||
*/
|
||||
export async function addValidSearchingRoles(comTeam: MemComBtlTeam, channelService: ChannelService) {
|
||||
export async function addValidSearchingRoles(comTeam: MemComBtlTeam) {
|
||||
const { lv } = getDicBlueprtById(comTeam.blueprtId);
|
||||
let teammates = await getTeamSearchByLv(lv);
|
||||
if (teammates && teammates.length) {
|
||||
@@ -573,10 +566,9 @@ export async function addValidSearchingRoles(comTeam: MemComBtlTeam, channelServ
|
||||
if (!st) continue;
|
||||
await rmRoleFromQueue(teammateRoleId, sid); // 匹配成功后删除redis中该用户的匹配记录
|
||||
addRoleStToTeam(comTeam, st);
|
||||
const channel = channelService.getChannel(comTeam.teamCode, false);
|
||||
addUserToChannel(channel, new ChannelUser(teammateRoleId, sid));
|
||||
addUserToTeamChannel(comTeam.teamCode, false, teammateRoleId, sid);
|
||||
}
|
||||
channelService.pushMessageByUids('onTeamJoin', resResult(STATUS.SUCCESS, { teamInfo: comTeam }), teammates.map(t => { return { uid: t.roleId, sid: t.sid } }));
|
||||
sendMessageToUsersWithSuc(PUSH_ROUTE.TEAM_JOIN, { teamInfo: comTeam }, teammates.map(t => { return { uid: t.roleId, sid: t.sid } }));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -609,7 +601,7 @@ export function teamIsFullToStart(comTeam: MemComBtlTeam) {
|
||||
* @param {number} roleLv 真实玩家等级,用来做机器人等级基准
|
||||
* @param {number} [count=1]
|
||||
*/
|
||||
export async function addRobotsToTeam(comTeam: MemComBtlTeam, roleId: string, roleCe: number, roleLv: number, teamMap: Map<string, MemComBtlTeam>, teamDisTimer: Map<string, NodeJS.Timer>, channel: Channel, count = 1) {
|
||||
export async function addRobotsToTeam(comTeam: MemComBtlTeam, roleId: string, roleCe: number, roleLv: number, teamMap: Map<string, MemComBtlTeam>, teamDisTimer: Map<string, NodeJS.Timer>, count = 1) {
|
||||
const { teamCode, roleStatus } = comTeam;
|
||||
let hasCap = roleStatus.findIndex(cur => cur.isCap) != -1;
|
||||
const { robotStArr, robotIdArr } = getRandComBtlRobots(roleCe, comTeam.ceLimit, roleLv, count);
|
||||
@@ -621,8 +613,8 @@ export async function addRobotsToTeam(comTeam: MemComBtlTeam, roleId: string, ro
|
||||
addRoleStToTeam(comTeam, st);
|
||||
await ComBattleTeamModel.addRole(teamCode, st);
|
||||
}
|
||||
channel.pushMessage('onTeamJoin', resResult(STATUS.SUCCESS, { teamInfo: comTeam }));
|
||||
setDismissTimer(comTeam, teamMap, roleId, teamDisTimer, channel);
|
||||
sendMessageToTeam(teamCode, PUSH_ROUTE.TEAM_JOIN, { teamInfo: comTeam })
|
||||
setDismissTimer(comTeam, teamMap, roleId, teamDisTimer);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -632,9 +624,8 @@ export async function addRobotsToTeam(comTeam: MemComBtlTeam, roleId: string, ro
|
||||
* @param {RoleType} roleInfo
|
||||
* @param {Map<string, MemComBtlTeam>} teamMap
|
||||
* @param {Map<string, NodeJS.Timer>} teamDisTimer
|
||||
* @param {Channel} channel
|
||||
*/
|
||||
export async function addRobotsLater(comTeam: MemComBtlTeam, roleInfo: RoleType, teamMap: Map<string, MemComBtlTeam>, teamDisTimer: Map<string, NodeJS.Timer>, channel: Channel) {
|
||||
export async function addRobotsLater(comTeam: MemComBtlTeam, roleInfo: RoleType, teamMap: Map<string, MemComBtlTeam>, teamDisTimer: Map<string, NodeJS.Timer>) {
|
||||
const teamStatus = comTeam;
|
||||
const { teamCode } = teamStatus;
|
||||
const { roleId, lv } = roleInfo;
|
||||
@@ -647,7 +638,7 @@ export async function addRobotsLater(comTeam: MemComBtlTeam, roleInfo: RoleType,
|
||||
setTimeout(async () => {
|
||||
const curTeamStatus = teamMap.get(teamCode);
|
||||
if (validToJoin(curTeamStatus)) {
|
||||
await addRobotsToTeam(curTeamStatus, roleId, topLineupCe, lv, teamMap, teamDisTimer, channel, 1);
|
||||
await addRobotsToTeam(curTeamStatus, roleId, topLineupCe, lv, teamMap, teamDisTimer, 1);
|
||||
}
|
||||
}, joinTime);
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import { gameData } from '../pubUtils/data';
|
||||
import { shouldRefresh } from '../pubUtils/util';
|
||||
import { getActivitiesByType } from './activity/activityService';
|
||||
import { recordGuildFund } from './activity/timeLimitRankService';
|
||||
import { pushGuildInfoUpdate } from './guildService';
|
||||
/**
|
||||
* 获得军团捐献,并检查是否刷新捐献数据
|
||||
* @param code
|
||||
@@ -62,8 +63,7 @@ export async function addFund(code: string, serverId: number, fund: number) {
|
||||
if(fund < 0) return null
|
||||
|
||||
guild = await GuildModel.updateInfo(code, { todayFund, refTodayFund }, { fund });
|
||||
let chatSid = await getGuildChannelSid(code);
|
||||
pinus.app.rpc.chat.guildRemote.updateInfo.toServer(chatSid, code, { fund: guild.fund });
|
||||
await pushGuildInfoUpdate(code, { fund: guild.fund });
|
||||
await recordGuildFund(serverId, guild, fund);
|
||||
|
||||
return guild
|
||||
|
||||
@@ -3,7 +3,7 @@ import { RoleModel } from "../../db/Role";
|
||||
import { GUILDACTIVITY } from "../../pubUtils/dicParam";
|
||||
import { gameData, getGuildAuctionRewards, getCityActivityRewards } from "../../pubUtils/data";
|
||||
import { getCurDay, nowSeconds, getTimeFun } from "../../pubUtils/timeUtil";
|
||||
import { GUILD_ACTIVITY_STATUS, GET_POINT_WAYS, GUILD_ACTIVITY_TYPE, REDIS_KEY, AUCTION_SOURCE, MAIL_TYPE, CITY_STATUS, DEBUG_MAGIC_WORD, GUILD_POINT_WAYS, TASK_TYPE, AUCTION_TIME, CITY_ACTIVITY_DOOR, ABI_TYPE } from "../../consts";
|
||||
import { GUILD_ACTIVITY_STATUS, GET_POINT_WAYS, GUILD_ACTIVITY_TYPE, REDIS_KEY, AUCTION_SOURCE, MAIL_TYPE, CITY_STATUS, DEBUG_MAGIC_WORD, GUILD_POINT_WAYS, TASK_TYPE, AUCTION_TIME, CITY_ACTIVITY_DOOR, ABI_TYPE, PUSH_ROUTE } from "../../consts";
|
||||
import { Record, UserGuildActivityRecModel } from "../../db/UserGuildActivityRec";
|
||||
import { GateMembersRec, CityParam, Member, WoodenHorse } from "../../domain/battleField/guildActivity";
|
||||
import { DicGuildActivity } from "../../pubUtils/dictionary/DicGuildActivity";
|
||||
@@ -27,6 +27,7 @@ import { addActive } from "../guildService";
|
||||
import { ActivePlayer, GuildRecord, ServerRecordModel } from "../../db/ServerRecords";
|
||||
import { Attack } from "../../domain/battleField/pvp";
|
||||
import { getHonourObject } from "../role/rewardService";
|
||||
import { sendMessageToCityWithSuc, sendMessageToGuildWithSuc, sendMessageToServerWithSuc } from "../pushService";
|
||||
|
||||
let gateActivityObj: GateActivityObject;
|
||||
let cityActivityObj: CityActivityObject;
|
||||
@@ -143,14 +144,6 @@ export function getGuildActivityByDic(dicGuildActivity: DicGuildActivity) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 军团活动状态变化推送,包括开始活动和定时结束活动,3种活动都会推送
|
||||
*/
|
||||
export async function sendGuildActivityStatus(serverId: number) {
|
||||
let chatSid = await getWorldChannelSid(serverId);
|
||||
pinus.app.rpc.chat.chatRemote.sendGuildActivityUpdate.toServer(chatSid, serverId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据每回合上报数据判断军功
|
||||
* @param aid
|
||||
@@ -285,11 +278,9 @@ export async function sendAllGuildRanks(aid: number) {
|
||||
let obj = getGateActivityObj();
|
||||
let guilds = obj.getGuilds();
|
||||
for (let [serverId, guildCodes] of guilds) {
|
||||
// TODO 不需要每个军团都排序一次
|
||||
for (let guildCode of guildCodes) {
|
||||
let ranks = await getGateActivityRank(guildCode, serverId);
|
||||
let chatSid = await getGuildChannelSid(guildCode);
|
||||
pinus.app.rpc.chat.guildRemote.pushRank.toServer(chatSid, guildCode, ranks);
|
||||
await sendMessageToGuildWithSuc(guildCode, PUSH_ROUTE.GATE_ACT_RANK, ranks);
|
||||
}
|
||||
}
|
||||
} else if (aid == GUILD_ACTIVITY_TYPE.CITY_ACTIVITY) {
|
||||
@@ -299,8 +290,7 @@ export async function sendAllGuildRanks(aid: number) {
|
||||
for (let { serverId, cityId, guildCodes } of cities) {
|
||||
for (let guildCode of guildCodes) {
|
||||
let ranks = await getCityActivityRank(guildCode, serverId, cityId);
|
||||
let chatSid = await getGuildChannelSid(guildCode);
|
||||
pinus.app.rpc.chat.guildRemote.pushCityActRank.toServer(chatSid, guildCode, ranks);
|
||||
await sendMessageToGuildWithSuc(guildCode, PUSH_ROUTE.CITY_ACT_RANK, ranks);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -310,7 +300,7 @@ export async function sendAllGuildRanks(aid: number) {
|
||||
* 活动结算奖励
|
||||
* @param aid 活动类型
|
||||
*/
|
||||
export async function sendGuildActEndMsg(aid: number) {
|
||||
export async function settleGuildActivityReward(aid: number) {
|
||||
|
||||
if (aid == GUILD_ACTIVITY_TYPE.GATE_ACTIVITY) {
|
||||
let obj = getGateActivityObj();
|
||||
@@ -343,24 +333,18 @@ export async function sendGuildActEndMsg(aid: number) {
|
||||
}
|
||||
|
||||
// 全服发送结束新号
|
||||
export async function sendEndMsgToAll() {
|
||||
export async function sendEndMsgToAllServer() {
|
||||
let serverlist = await getAllServers();
|
||||
for (let serverId of serverlist) {
|
||||
let chatSid = await getWorldChannelSid(serverId);
|
||||
pinus.app.rpc.chat.chatRemote.sendGuildActivityEnd.toServer(chatSid, serverId);
|
||||
await sendMessageToServerWithSuc(serverId, PUSH_ROUTE.GUILD_ACTIVITY_END, {});
|
||||
await sendGuildActivityStatus(serverId);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 单个军团城门血条破了之后给他发奖励
|
||||
* @param guildCode 军团code
|
||||
*/
|
||||
// export async function sendSingleGateActEndMsg(guildCode: string, serverId: number) {
|
||||
// let chatSid = await getGuildChannelSid(guildCode);
|
||||
// pinus.app.rpc.chat.guildRemote.sendGuildActivityEnd.toServer(chatSid, guildCode);
|
||||
// await gateActivitySettleReward(guildCode, serverId);
|
||||
// }
|
||||
export async function sendGuildActivityStatus(serverId: number) {
|
||||
let guildActivities = getAllGuildActivityStatus();
|
||||
await sendMessageToServerWithSuc(serverId, PUSH_ROUTE.GUILD_ACTIVITY_STATUS, { guildActivities });
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@@ -368,11 +352,10 @@ export async function sendEndMsgToAll() {
|
||||
* @param guildCode 军团code
|
||||
*/
|
||||
export async function sendSingleCityActEndMsg(cityId: number, serverId: number) {
|
||||
let chatSid = await getCityChannelSid(cityId);
|
||||
let obj = getCityActivityObj();
|
||||
let guildCodes = obj.getGuildsInCity(serverId, cityId);
|
||||
for (let guildCode of guildCodes) {
|
||||
pinus.app.rpc.chat.guildRemote.sendGuildActivityEnd.toServer(chatSid, guildCode);
|
||||
await sendMessageToGuildWithSuc(guildCode, PUSH_ROUTE.GUILD_ACTIVITY_END, {});
|
||||
}
|
||||
await cityActivitySettleReward(cityId, serverId);
|
||||
}
|
||||
@@ -383,8 +366,7 @@ export async function sendSingleCityActEndMsg(cityId: number, serverId: number)
|
||||
* @param guildCode 军团code
|
||||
*/
|
||||
export async function sendSingleRaceActEndMsg(guildCode: string, woodenHorse: WoodenHorse) {
|
||||
let chatSid = await getGuildChannelSid(guildCode);
|
||||
pinus.app.rpc.chat.guildRemote.sendGuildActivityEnd.toServer(chatSid, guildCode);
|
||||
await sendMessageToGuildWithSuc(guildCode, PUSH_ROUTE.GUILD_ACTIVITY_END, {});
|
||||
await raceActivitySettleReward(guildCode, woodenHorse);
|
||||
}
|
||||
|
||||
@@ -621,6 +603,12 @@ export function getCityStatus(guildCode: string, cityId: number, dic: DicCityAct
|
||||
return status;
|
||||
}
|
||||
|
||||
export async function sendGuildCityDeclare(cityId: number, declareGuildCode: string, declareCount: number) {
|
||||
let msg = { cityId, declareGuildCode, declareCount };
|
||||
await sendMessageToCityWithSuc(cityId, PUSH_ROUTE.GUILD_CITY_DECLARE, msg);
|
||||
await sendMessageToGuildWithSuc(declareGuildCode, PUSH_ROUTE.GUILD_CITY_DECLARE, msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* 每秒计算木牛流马状态并下发
|
||||
* @param serverId 区id
|
||||
@@ -680,10 +668,8 @@ export async function calWoodenHorseAndSend(serverId: number) {
|
||||
let curRank = ranks[rank];
|
||||
let wh = await obj.getWoodenHorse(curRank.code, serverId);
|
||||
let myGuildRank = new SimpleGuildRankWithTimeParam(curRank.rank, curRank.code, curRank.name, wh);
|
||||
|
||||
let chatSid = await getGuildChannelSid(curRank.code);
|
||||
let events = obj.getEvents(curRank.code, wh ? wh.distance : 0);
|
||||
pinus.app.rpc.chat.guildRemote.pushRaceHorseUpdate.toServer(chatSid, curRank.code, woodenHorseList, { guildRank, myGuildRank }, events);
|
||||
await sendMessageToGuildWithSuc(curRank.code, PUSH_ROUTE.GUILD_RACE_UPDATE, { timestamp: Date.now(), woodenHorseList, guildRank, myGuildRank, events });
|
||||
|
||||
map.delete(rank);
|
||||
}
|
||||
@@ -700,8 +686,7 @@ export async function sendRaceStartMsg(serverId: number) {
|
||||
let obj = getRaceActivityObj();
|
||||
obj.startRace(); // 设置开启活动
|
||||
|
||||
let chatSid = await getWorldChannelSid(serverId);
|
||||
pinus.app.rpc.chat.chatRemote.sendRaceActivityStart.toServer(chatSid, serverId);
|
||||
await sendMessageToServerWithSuc(serverId, PUSH_ROUTE.RACE_START, {});
|
||||
await calWoodenHorseAndSend(serverId);
|
||||
}
|
||||
|
||||
@@ -747,15 +732,6 @@ export async function raceActivitySettleReward(guildCode: string, woodenHorse: W
|
||||
obj.deleteFromList(guildCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* 军团练兵场通关层数后全团发送弹窗礼包
|
||||
* @param guildCode 军团code
|
||||
*/
|
||||
export async function sendPopUpActivityData(guildCode: string, serverId: number, data: any[]) {
|
||||
let chatSid = await getGuildChannelSid(guildCode);
|
||||
pinus.app.rpc.chat.guildRemote.sendPopUpActivity.toServer(chatSid, guildCode, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* !! 注意,这条函数会改变内存中的字典表,仅用于测试中使用
|
||||
* 改变字典表中的军团活动开始时间&持续时间
|
||||
|
||||
@@ -6,12 +6,13 @@ import { RewardInter } from "../../pubUtils/interface";
|
||||
import { getRaceEventItems, gameData } from "../../pubUtils/data";
|
||||
import { GuildModel } from "../../db/Guild";
|
||||
import { sendSingleRaceActEndMsg } from "./guildActivityService";
|
||||
import { REDIS_KEY, RACE_EVENT_TYPE, RACE_EVENT_EFFECT_TYPE, RACE_EVENT, STATUS, RACE_ACTIVITY_STATUS } from "../../consts";
|
||||
import { REDIS_KEY, RACE_EVENT_TYPE, RACE_EVENT_EFFECT_TYPE, RACE_EVENT, STATUS, RACE_ACTIVITY_STATUS, PUSH_ROUTE } from "../../consts";
|
||||
import { getGuildChannelSid } from "../chatService";
|
||||
import { pinus } from "pinus";
|
||||
import { getRandEelm, sortArrRandom, resResult, getRandResultByMember } from "../../pubUtils/util";
|
||||
import { Rank } from "../rankService";
|
||||
import { getTimeFun } from "../../pubUtils/timeUtil";
|
||||
import { sendMessageToGuildWithSuc } from "../pushService";
|
||||
|
||||
// 粮草先行
|
||||
export class RaceActivityObject {
|
||||
@@ -101,9 +102,7 @@ export class RaceActivityObject {
|
||||
events.push(event);
|
||||
this.events.set(toGuild, events);
|
||||
}
|
||||
let chatSid = await getGuildChannelSid(toGuild);
|
||||
pinus.app.rpc.chat.guildRemote.sendRaceEvent.toServer(chatSid, toGuild, [event]);
|
||||
|
||||
await sendMessageToGuildWithSuc(toGuild, PUSH_ROUTE.GUILD_RACE_EVENT, { timestamp: Date.now(), events: [event] });
|
||||
return event;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { BossInstanceType, BossInstanceModel } from '../db/BossInstance';
|
||||
import { lockData } from '../services/redLockService';
|
||||
import { findIndex } from 'underscore';
|
||||
import { findIndex, pick } from 'underscore';
|
||||
import { sismemberAsync, smembersAsync, saddAsync, delAsync, getRoleOnlineInfo } from '../services/redisService';
|
||||
import { pinus } from 'pinus';
|
||||
import { STATUS } from '../consts/statusCode';
|
||||
@@ -8,7 +8,7 @@ import { resResult, shouldRefresh } from '../pubUtils/util';
|
||||
import { BattleRecordModel } from '../db/BattleRecord';
|
||||
import { getArmyBossRank, gameData, getAuctionRewardByPoolId } from '../pubUtils/data';
|
||||
import { sendMailToGuildByContent } from '../services/mailService';
|
||||
import { MAIL_TYPE, AUCTION_SOURCE, ABI_TYPE } from '../consts';
|
||||
import { MAIL_TYPE, AUCTION_SOURCE, ABI_TYPE, PUSH_ROUTE } from '../consts';
|
||||
import { GUILD_BOSS_STATUS } from '../consts/constModules/guildConst';
|
||||
import { genAuction } from './auctionService';
|
||||
import { GuildModel, GuildType } from '../db/Guild';
|
||||
@@ -16,6 +16,7 @@ import { UserGuildModel, UserGuildType } from '../db/UserGuild';
|
||||
import { nowSeconds } from '../pubUtils/timeUtil';
|
||||
import { GUILDACTIVITY } from '../pubUtils/dicParam';
|
||||
import { ServerRecordModel } from '../db/ServerRecords';
|
||||
import { sendMessageToGuildWithSuc } from './pushService';
|
||||
|
||||
/**
|
||||
* 获得boss界面
|
||||
@@ -48,6 +49,10 @@ export async function getBossInstanceInfoByData(bossInstance: BossInstanceType,
|
||||
return { status, bossInfo, ...refObj }
|
||||
}
|
||||
|
||||
export async function pushBossStatus(guildCode: string, result: any) {
|
||||
await sendMessageToGuildWithSuc(guildCode, PUSH_ROUTE.GUILD_BOSS_OPEN, pick(result, ['status', 'bossInfo', 'leaderOpenCnt']));
|
||||
}
|
||||
|
||||
async function getRefBossCnt(guild: GuildType, userGuild: UserGuildType) {
|
||||
let guildCnt = await refreshGuildOfBoss(guild);
|
||||
let userGuildCnt = await refreshUserGuildOfBoss(userGuild);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { gameData, getGuildActiveWeekReward, getGuildActiveByIdAndType, getGoodById } from "../pubUtils/data";
|
||||
import { GuildModel, GuildType } from "../db/Guild";
|
||||
import { GuildModel, GuildType, GuildUpdateParam } from "../db/Guild";
|
||||
import { resResult, shouldRefresh } from "../pubUtils/util";
|
||||
import { STATUS, MAIL_TYPE, GUILD_AUTH, GUILD_JOB, REDIS_KEY, CHAT_SERVER, TASK_TYPE, COUNTER } from "../consts";
|
||||
import { STATUS, MAIL_TYPE, GUILD_AUTH, GUILD_JOB, REDIS_KEY, CHAT_SERVER, TASK_TYPE, COUNTER, GUILD_REC_TYPE, PUSH_ROUTE } from "../consts";
|
||||
import { RoleModel, RoleType } from "../db/Role";
|
||||
import { UserGuildModel, UserGuildType } from "../db/UserGuild";
|
||||
import { UserGuildApplyModel } from "../db/UserGuildApply";
|
||||
@@ -20,6 +20,9 @@ import { checkTask } from "./task/taskService";
|
||||
import { CounterModel } from "../db/Counter";
|
||||
import { getAuction } from "./auctionService";
|
||||
import { changeGuildActivity } from "./activity/guildPayService";
|
||||
import { GuildRecModel } from "../db/GuildRec";
|
||||
import { sendMessageToGuildWithSuc, sendMessageToUserWithSuc } from "./pushService";
|
||||
import { delGuildChannel, leaveGuildChannel } from "./chatChannelService";
|
||||
|
||||
export async function getMyGuildInfo(roleId: string, sid: string, userGuild: UserGuildType, guild: GuildType, serverId: number, session: FrontendOrBackendSession) {
|
||||
|
||||
@@ -215,7 +218,7 @@ export async function addActive(roleId: string, serverId: number, id: number, ty
|
||||
await r.setRankWithGuildInfo(guildCode, guild.activeWeekly, guild.activeUpdateTime, guild);
|
||||
let r2 = new Rank(REDIS_KEY.GUILD_LV_RANK, { serverId });
|
||||
await r2.setRankWithGuildInfo2(guildCode, guild.lv, guild.activeWeekly, guild.lvUpdateTime, guild);
|
||||
pinus.app.rpc.chat.guildRemote.updateInfo.toServer(CHAT_SERVER, guildCode, { activeDaily: guild.activeDaily, activeWeekly: guild.activeWeekly });
|
||||
await pushGuildInfoUpdate(guildCode, { activeDaily: guild.activeDaily, activeWeekly: guild.activeWeekly });
|
||||
return { status: 1, guild, userGuild };
|
||||
}
|
||||
|
||||
@@ -364,4 +367,51 @@ export async function getInvitationList(roleId: string, lastApplyCode = '') {
|
||||
return { applyCode: cur.applyCode, ...guild, leader: leader.roleName };
|
||||
});
|
||||
return list;
|
||||
}
|
||||
|
||||
// 添加军团动态
|
||||
export async function addGuildRecord(roleId: string, guildCode: string, type: GUILD_REC_TYPE, params: string[]) {
|
||||
const rec = await GuildRecModel.createGuildRec(roleId, guildCode, type, params);
|
||||
{
|
||||
let { type, params, createTime } = rec;
|
||||
await sendMessageToGuildWithSuc(guildCode, PUSH_ROUTE.GUILD_REC_ADD, { type, params, createTime });
|
||||
}
|
||||
}
|
||||
|
||||
export async function pushGuildInfoUpdate(guildCode: string, info: any) {
|
||||
await sendMessageToGuildWithSuc(guildCode, PUSH_ROUTE.GUILD_INFO_UPDATE, info);
|
||||
}
|
||||
|
||||
// 更换团长推送
|
||||
export async function pushChangeGuildLeader(guildCode: string, managerCnt: number, newLeader: RoleType, oldLeaderId: string) {
|
||||
let { roleId, roleName, frame, head, spine, lv, quitTime } = newLeader;
|
||||
await pushGuildInfoUpdate(guildCode, { managerCnt, leader: { roleId, roleName, frame, head, spine, lv, quitTime } });
|
||||
// 给旧团长推送
|
||||
await sendMessageToUserWithSuc(oldLeaderId, PUSH_ROUTE.DEMOTION, { code: guildCode });
|
||||
// 给新团长推送
|
||||
await sendMessageToUserWithSuc(roleId, PUSH_ROUTE.PROMOTION, { code: guildCode });
|
||||
}
|
||||
|
||||
/**
|
||||
* 推送踢出某个成员
|
||||
* @param guildCode 军团code
|
||||
* @param roleId 踢出玩家roleId
|
||||
* @param guild 军团信息
|
||||
* @param sid 玩家sid
|
||||
*/
|
||||
export async function pushGuildMemberQuit(roleId: string, guildCode: string, guild: GuildType, sid: string) {
|
||||
// 被踢出公会
|
||||
await sendMessageToUserWithSuc(roleId, PUSH_ROUTE.MEMBER_QUIT, { code: guildCode, roleId }, sid);
|
||||
// 更新人数减少
|
||||
await pushGuildInfoUpdate(guildCode, { memberCnt: guild.memberCnt, guildCe: guild.guildCe });
|
||||
leaveGuildChannel(roleId, sid, guildCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* 推送解散军团
|
||||
* @param guildCode 军团code
|
||||
*/
|
||||
export async function pushGuildDismiss(guildCode: string) {
|
||||
await sendMessageToGuildWithSuc(guildCode, PUSH_ROUTE.DISMISS, { code: guildCode });
|
||||
delGuildChannel(guildCode);
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
import { UserGuildModel, UserGuildType } from '../db/UserGuild';
|
||||
import { getArmyTrainJuDian, getGuildTrainGkInfo, getTrainBaseByLv } from '../pubUtils/data';
|
||||
import { nowSeconds, getZeroPoint } from '../pubUtils/timeUtil';
|
||||
import { GUILD_STRUCTURE } from '../consts';
|
||||
import { GUILD_STRUCTURE, PUSH_ROUTE } from '../consts';
|
||||
import { GuildTrainType, GuildTrainModel, TrainInstance } from '../db/GuildTrain';
|
||||
import { GuildModel, GuildType } from '../db/Guild';
|
||||
import { findWhere } from 'underscore';
|
||||
@@ -16,6 +16,7 @@ import { DATA_NAME } from '../consts/dataName';
|
||||
import { sendMailByContent } from './mailService';
|
||||
import { MAIL_TYPE } from '../consts';
|
||||
import { getGuildChannelSid } from './chatChannelService';
|
||||
import { sendMessageToGuildWithSuc } from './pushService';
|
||||
/**
|
||||
* 获得userGuild,并检查,是否需要每日重置购买挑战次数和今日挑战次数,已经检查是否需要每周重置练兵场
|
||||
* @param roleId
|
||||
@@ -193,8 +194,7 @@ export async function resetTrain(code: string, serverId: number) {
|
||||
}
|
||||
});
|
||||
|
||||
let chatSid = await getGuildChannelSid(code);
|
||||
pinus.app.rpc.chat.guildRemote.sendTrainReset.toServer(chatSid, code);
|
||||
await sendMessageToGuildWithSuc(code, PUSH_ROUTE.GUILD_TRAIN_RESET, {});
|
||||
|
||||
await GuildTrainModel.resetGuildTrain(code);//将开启的练兵场锁定
|
||||
await unlockTrain(code, 1);//开启练兵场1级
|
||||
|
||||
@@ -8,7 +8,7 @@ import { gameData } from "../pubUtils/data";
|
||||
import { nowSeconds } from '../pubUtils/timeUtil';
|
||||
import { STATUS } from '../consts/statusCode';
|
||||
import { genCode, resResult } from '../pubUtils/util';
|
||||
import { GM_MAIL_TYPE, ITID, MAIL_STATUS, MAIL_TIME_TYPE, MAIL_TYPE, SEND_NAME, SEND_TITLE } from "../consts";
|
||||
import { GM_MAIL_TYPE, ITID, MAIL_STATUS, MAIL_TIME_TYPE, MAIL_TYPE, PUSH_ROUTE, SEND_NAME, SEND_TITLE } from "../consts";
|
||||
import { MailParam } from '../domain/roleField/mail';
|
||||
import { GMMailType, GMMailModel, GMMailTypeParam } from "../db/GMMail";
|
||||
import { getGuildChannelSid, getWorldChannelSid } from "./chatChannelService";
|
||||
@@ -16,6 +16,7 @@ import { GMMailRecordModel } from "../db/GMMailRecord";
|
||||
import { BAG } from "../pubUtils/dicParam";
|
||||
import { GuildModel, GuildType } from "../db/Guild";
|
||||
import moment = require("moment");
|
||||
import { sendMessageToGuildWithSuc, sendMessageToServerWithSuc } from "./pushService";
|
||||
|
||||
/**
|
||||
* 获取邮件信息
|
||||
@@ -252,16 +253,14 @@ export class SendMailFun {
|
||||
}
|
||||
|
||||
for(let [guildCode, mails] of pushByGuildCode) {
|
||||
let chatSid = await getGuildChannelSid(guildCode);
|
||||
if(!!chatSid && mails.length > 0) {
|
||||
pinus.app.rpc.chat.guildRemote.sendMailToGuild.toServer(chatSid, guildCode, 'onMailsAdd', { mails });
|
||||
if(mails.length > 0) {
|
||||
await sendMessageToGuildWithSuc(guildCode, PUSH_ROUTE.MAILS_ADD, { mails });
|
||||
}
|
||||
}
|
||||
|
||||
for(let [serverId, mails] of pushByServerId) {
|
||||
let chatSid = await getWorldChannelSid(serverId);
|
||||
if(!!chatSid && mails.length > 0) {
|
||||
pinus.app.rpc.chat.chatRemote.sendMail.toServer(chatSid, serverId, 'onMailsAdd', { mails });
|
||||
if( mails.length > 0) {
|
||||
await sendMessageToServerWithSuc(serverId, PUSH_ROUTE.MAILS_ADD, { mails }, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,130 @@
|
||||
import { Channel, pinus } from "pinus";
|
||||
import { CHANNEL_PREFIX, PUSH_BATCH, PUSH_INTERVAL, PUSH_ROUTE, STATUS } from "../consts";
|
||||
import { resResult } from "../pubUtils/util";
|
||||
import { getCityChannelSid, getGuildChannelSid, getWorldChannelSid, groupRoomId } from "./chatService";
|
||||
import { getRoleOnlineInfo } from "./redisService";
|
||||
import { errlogger, infologger } from '../util/logger';
|
||||
|
||||
export async function sendMessageToServerWithSuc(serverId: number, route: string, data: any, isBatch = false) {
|
||||
await sendMessageToServer(serverId, route, resResult(STATUS.SUCCESS, data), isBatch);
|
||||
}
|
||||
|
||||
export async function sendMessageToServer(serverId: number, route: string, data: any, isBatch = false) {
|
||||
let channelSid = await getWorldChannelSid(serverId);
|
||||
let roomId = groupRoomId(CHANNEL_PREFIX.WORLD, serverId);
|
||||
await pinus.app.rpc.chat.chatRemote.pushMessage.toServer(channelSid, roomId, route, data, isBatch);
|
||||
}
|
||||
|
||||
export async function sendMessageToGuildWithSuc(guildCode: string, route: string, data: any) {
|
||||
await sendMessageToGuild(guildCode, route, resResult(STATUS.SUCCESS, data));
|
||||
}
|
||||
|
||||
export async function sendMessageToGuild(guildCode: string, route: string, data: any) {
|
||||
let channelSid = await getGuildChannelSid(guildCode);
|
||||
let roomId = groupRoomId(CHANNEL_PREFIX.GUILD, guildCode);
|
||||
await pinus.app.rpc.chat.chatRemote.pushMessage.toServer(channelSid, roomId, route, data);
|
||||
}
|
||||
|
||||
export async function sendMessageToCityWithSuc(cityId: number, route: string, data: any) {
|
||||
await sendMessageToCity(cityId, route, resResult(STATUS.SUCCESS, data));
|
||||
}
|
||||
|
||||
export async function sendMessageToCity(cityId: number, route: string, data: any) {
|
||||
let channelSid = await getCityChannelSid(cityId);
|
||||
let roomId = groupRoomId(CHANNEL_PREFIX.CITY, cityId);
|
||||
await pinus.app.rpc.chat.chatRemote.pushMessage.toServer(channelSid, roomId, route, data);
|
||||
}
|
||||
|
||||
export async function sendMessageToUserWithSuc(roleId: string, route: string, data: any, sid?: string) {
|
||||
await sendMessageToUser(roleId, route, resResult(STATUS.SUCCESS, data), sid);
|
||||
}
|
||||
|
||||
export async function sendMessageToUser(roleId: string, route: string, data: any, sid?: string) {
|
||||
let uids = [];
|
||||
if (!sid) {
|
||||
let onlineUser = await getRoleOnlineInfo(roleId);
|
||||
sid = onlineUser.sid;
|
||||
}
|
||||
if (!!sid) {
|
||||
uids.push({ uid: roleId, sid });
|
||||
pinus.app.get('channelService').pushMessageByUids(route, data, uids);
|
||||
}
|
||||
}
|
||||
|
||||
export async function sendMessageToUsersWithSuc(route: string, data: any, uids: { uid: string, sid: string }[]) {
|
||||
await sendMessageToUsers(route, resResult(STATUS.SUCCESS, data), uids);
|
||||
}
|
||||
|
||||
// 推送给个人的方法收束于这个函数
|
||||
export async function sendMessageToUsers(route: string, data: any, uids: { uid: string, sid: string }[]) {
|
||||
if(uids.length > 0) {
|
||||
infologger.debug(`pushMessage route: ${route} data: ${data} members: ${uids.map(obj => obj.uid).join()}`);
|
||||
pinus.app.get('channelService').pushMessageByUids(route, data, uids);
|
||||
}
|
||||
}
|
||||
|
||||
export async function sendMessageToTeam(teamCode: string, route: string, data: any) {
|
||||
const channel = pinus.app.get('channelService').getChannel(teamCode);
|
||||
sendMessageToChannel(channel, route, resResult(STATUS.SUCCESS, data));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param user
|
||||
*/
|
||||
export function addUserToTeamChannel(teamCode: string, isCreate: boolean, roleId: string, sid: string) {
|
||||
let channel = pinus.app.get('channelService').getChannel(teamCode, isCreate);
|
||||
addUserToChannel(channel, roleId, sid);
|
||||
return channel
|
||||
}
|
||||
|
||||
export function addUserToChannel(channel: Channel, roleId: string, sid: string) {
|
||||
const users = channel.getMembers();
|
||||
if (users.indexOf(roleId) === -1) {
|
||||
channel.add(roleId, sid);
|
||||
}
|
||||
}
|
||||
|
||||
export function sendMessgeToChannelByBatch(channel: Channel, route: string, data: any) {
|
||||
let members = channel.getMembers();
|
||||
if(members.length > PUSH_BATCH) {
|
||||
let n = Math.ceil(members.length / PUSH_BATCH); // 一共多少批
|
||||
// console.log(n)
|
||||
let i = -1;
|
||||
let interval = setInterval(() => {
|
||||
if (++i < n) {
|
||||
let uidlist = members.slice(i * PUSH_BATCH, (i + 1) * PUSH_BATCH - 1);
|
||||
let uids: { uid: string, sid: string }[] = [];
|
||||
for (let uid of uidlist) {
|
||||
uids.push(channel.getMember(uid));
|
||||
}
|
||||
sendMessageToUsers(route, resResult(STATUS.SUCCESS, data), uids);
|
||||
} else {
|
||||
clearInterval(interval);
|
||||
}
|
||||
}, PUSH_INTERVAL);
|
||||
} else {
|
||||
channel.pushMessage(route, resResult(STATUS.SUCCESS, data));
|
||||
}
|
||||
}
|
||||
|
||||
// 抽下下来pushMessage收束
|
||||
export function sendMessageToChannel(channel: Channel, route: string, data: any) {
|
||||
infologger.debug(`pushMessage route: ${route} data: ${data} members: ${channel.getMembers().join()}`);
|
||||
channel.pushMessage(route, data);
|
||||
}
|
||||
|
||||
export function delTeamChannel(teamCode: string) {
|
||||
let channel = pinus.app.get('channelService').getChannel(teamCode);
|
||||
if(!!channel) channel.destroy();
|
||||
}
|
||||
|
||||
export function removeFromTeamChannel(teamCode: string, roleId: string) {
|
||||
let channel = pinus.app.get('channelService').getChannel(teamCode);
|
||||
if(!channel) return null;
|
||||
|
||||
let users: string[] = channel.getMembers();
|
||||
if (users.indexOf(roleId) !== -1) {
|
||||
channel.removeMember(roleId);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
import { KeyName, KeyNameParam, RankParam, GuildRankParam, RoleRankInfo, GuildLeader, LineupParam, myIdInter, GeneralRankParam, ValueConfig, GuildRankInfo, RoleAndGuildRankInfo } from "../domain/rank";
|
||||
import { getInfoKeyByRedisKey, ROLE_SELECT, GUILD_SELECT, REDIS_KEY, HERO_SELECT, COMPOSE_FIELD_TYPE, KEY_TO_COMPOSE_FIELD, getRedisKeyByRankType, COUNTER, RANK_TYPE } from "../consts";
|
||||
import { getInfoKeyByRedisKey, ROLE_SELECT, GUILD_SELECT, REDIS_KEY, HERO_SELECT, COMPOSE_FIELD_TYPE, KEY_TO_COMPOSE_FIELD, getRedisKeyByRankType, COUNTER, RANK_TYPE, PUSH_ROUTE } from "../consts";
|
||||
import { redisClient, delKeys } from "./redisService";
|
||||
import { RoleType, RoleModel } from "../db/Role";
|
||||
import { GuildType, GuildModel } from "../db/Guild";
|
||||
@@ -15,6 +15,7 @@ import { getRandSingleEelm } from "../pubUtils/util";
|
||||
import { RANK_FIRST_REWARD_STATUS } from '../consts';
|
||||
import { CounterModel } from "../db/Counter";
|
||||
import { ActivityTimeLimitRankModel } from "../db/ActivityTimeLimitRank";
|
||||
import { sendMessageToServerWithSuc } from "./pushService";
|
||||
|
||||
|
||||
/**
|
||||
@@ -925,14 +926,13 @@ export class Rank {
|
||||
}
|
||||
}
|
||||
if(rankFirstRecs.length > 0) {
|
||||
pinus.app.rpc.chat.chatRemote.sendRankTopUpdated.toServer(sid, serverId, rankFirstRecs);
|
||||
await sendMessageToServerWithSuc(serverId, PUSH_ROUTE.RANK_TOP_UPDATE, { ranks: rankFirstRecs }, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 从数据库内获取排行榜存入redis
|
||||
* @param type 排行榜类型
|
||||
|
||||
@@ -65,19 +65,6 @@ export async function getTeraphStrengthenResult(role: RoleType, count: number, d
|
||||
return { times, consumes: check.getConsume(), criAttr }
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param channel
|
||||
* @param user
|
||||
*/
|
||||
export function addUserToChannel(channel: Channel, user: ChannelUser) {
|
||||
const users = channel.getMembers();
|
||||
const { uid, sid } = user;
|
||||
if (users.indexOf(uid) === -1) {
|
||||
channel.add(uid, sid);
|
||||
}
|
||||
}
|
||||
|
||||
export async function getSimpleRoleInfo(roleId: string) {
|
||||
if (!roleId) return null;
|
||||
let role = await RoleModel.findByRoleId(roleId, ROLE_SELECT.SHOW_SIMPLE, true);
|
||||
|
||||
@@ -18,6 +18,7 @@ import _ = require("underscore");
|
||||
import { getGoldObject } from "./role/rewardService";
|
||||
import { SurveyRecModel } from "../db/SurveyRec";
|
||||
import { SurveyModel } from "../db/Survery";
|
||||
import { pushGuildInfoUpdate } from "./guildService";
|
||||
|
||||
// 检查私聊是否合法
|
||||
|
||||
@@ -142,8 +143,7 @@ export async function treatGuildName(content: string) {
|
||||
await GuildModel.updateInfo(params.code, { name: newName, sdkMark: false });
|
||||
// 通知处理
|
||||
await sendMailToGuildByContent(MAIL_TYPE.TREAT_GUILD_INFO, params.code, {}); // 邮件
|
||||
let chatSid = await getGuildChannelSid(params.code);
|
||||
pinus.app.rpc.chat.guildRemote.updateInfo.toServer(chatSid, params.code, { name: newName }); // 军团推送
|
||||
await pushGuildInfoUpdate(params.code, { name: newName });
|
||||
await updateUserInfo(REDIS_KEY.GUILD_INFO, params.code, [{ field: 'name', value: newName }]); // redis缓存信息
|
||||
for(let roleId of guild.members) {
|
||||
await updateUserInfo(REDIS_KEY.USER_INFO, roleId, [{ field: 'guildName', value: newName }]);
|
||||
@@ -155,8 +155,7 @@ export async function treatGuildName(content: string) {
|
||||
await GuildModel.updateInfo(params.code, { notice: ' ', sdkMark: false });
|
||||
// 通知处理
|
||||
await sendMailToGuildByContent(MAIL_TYPE.TREAT_GUILD_INFO, params.code, {}); // 邮件
|
||||
let chatSid = await getGuildChannelSid(params.code);
|
||||
pinus.app.rpc.chat.guildRemote.updateInfo.toServer(chatSid, params.code, { notice: '' }); // 军团推送
|
||||
await pushGuildInfoUpdate(params.code, { notice: '' });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,11 @@
|
||||
import { EPlace, HeroType } from '../db/Hero';
|
||||
import { GuildType } from '../db/Guild';
|
||||
import { CHANNEL_PREFIX, HERO_GROW_MAX, HERO_INITIAL_QUALITY, MSG_SOURCE, MSG_TYPE, ON_GROUP_MSG_ROUTE, STATUS, WAR_TYPE } from '../consts';
|
||||
import { CHANNEL_PREFIX, HERO_GROW_MAX, HERO_INITIAL_QUALITY, MSG_SOURCE, MSG_TYPE, ON_GROUP_MSG_ROUTE, PUSH_ROUTE, STATUS, WAR_TYPE } from '../consts';
|
||||
import { createGroupMsg, pushGroupMsgToRoom } from './chatService';
|
||||
import { pick } from 'lodash';
|
||||
import { isString } from 'underscore';
|
||||
import { pinus } from 'pinus';
|
||||
import { resResult } from '../pubUtils/util';
|
||||
import { BossInstanceType } from '../db/BossInstance';
|
||||
import { getSimpleRoleInfo } from './roleService';
|
||||
import { GroupMessageType } from '../db/GroupMessage';
|
||||
import { gameData } from '../pubUtils/data';
|
||||
|
||||
async function pushNormalHeroInfoBySource(roleId: string, roleName: string, serverId: number | string, source: number, heroInfo: Partial<HeroType>) {
|
||||
const hero = pick(heroInfo, ['hName', 'hid', 'seqId', 'quality', 'star', 'starStage', 'colorStar', 'colorStarStage']);
|
||||
@@ -70,10 +66,7 @@ export async function pushPresent(roleId: string, roleName: string, serverId: nu
|
||||
|
||||
export async function pushComBtlTeamMsg(teamCode: string, roleId: string, roleName: string, type: number, source: number, content: string, targetRoleId: string, targetMsgCode: string) {
|
||||
const msgData = await createGroupMsg(roleId, roleName, CHANNEL_PREFIX.TEAM, teamCode, type, source, content, targetRoleId, targetMsgCode);
|
||||
if (!msgData) return null;
|
||||
const channel = pinus.app.get('channelService').getChannel(teamCode);
|
||||
const roleInfo = await getSimpleRoleInfo(msgData.roleId);
|
||||
channel.pushMessage(ON_GROUP_MSG_ROUTE, resResult(STATUS.SUCCESS, { ...msgData, roleInfo }));
|
||||
await pushGroupMsgToRoom(msgData);
|
||||
return msgData;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,11 +5,11 @@ import { nowSeconds, getTimeFun, getSeconds } from '../pubUtils/timeUtil';
|
||||
import { getTodayGuildActivity, gameData } from '../pubUtils/data';
|
||||
import { pvpSeasonEnd } from './pvpService';
|
||||
import { getAllOnlineRoles, getAllServers, delGuildActivityRank, getServerCreateTime } from './redisService';
|
||||
import { GUILD_ACTIVITY_TYPE, REFRESH_TIME, COUNTER, AUCTION_TIME, GM_MAIL_TYPE, SERVER_TIMER, ACTIVITY_TYPE } from '../consts';
|
||||
import { GUILD_ACTIVITY_TYPE, REFRESH_TIME, COUNTER, AUCTION_TIME, GM_MAIL_TYPE, SERVER_TIMER, ACTIVITY_TYPE, PUSH_ROUTE, STATUS } from '../consts';
|
||||
import { pinus } from 'pinus';
|
||||
import { settleGuildWeekly } from './guildService';
|
||||
import { SendMailFun, } from './mailService';
|
||||
import { sendEndMsgToAll, autoDeclare, sendGuildActivityStatus } from './guildActivity/guildActivityService';
|
||||
import { sendEndMsgToAllServer, autoDeclare, sendGuildActivityStatus } from './guildActivity/guildActivityService';
|
||||
import { sendUngotDividendJob, startGuildAuction, startWorldAuction, stopAuction } from './auctionService';
|
||||
import { DicGuildActivity } from '../pubUtils/dictionary/DicGuildActivity';
|
||||
import { dispatch } from '../pubUtils/dispatcher';
|
||||
@@ -35,6 +35,8 @@ import { TimeLimitRankData } from '../domain/activityField/timeLimitRankField';
|
||||
import { sendRankMail, takeSnapshot } from './activity/timeLimitRankService';
|
||||
import { getActivitiesByType } from './activity/activityService';
|
||||
import { ActivityGroupModel } from '../db/ActivityGroup';
|
||||
import { sendMessageToServer } from './pushService';
|
||||
import { resResult } from '../pubUtils/util';
|
||||
|
||||
const PER_SECOND = 1 * 1000;
|
||||
const PER_DAY = 24 * 60 * 60;
|
||||
@@ -284,7 +286,7 @@ export async function guildActivityStart(dicGuildActivity?: DicGuildActivity) {
|
||||
export async function gateActivityEnd() {
|
||||
|
||||
console.log('*****gateActivityEnd');
|
||||
await sendEndMsgToAll();
|
||||
await sendEndMsgToAllServer();
|
||||
await pinus.app.rpc.guild.guildActivityRemote.guildActivityEnd.broadcast(GUILD_ACTIVITY_TYPE.GATE_ACTIVITY);
|
||||
|
||||
if (guildActSecondsJobId) {
|
||||
@@ -307,7 +309,7 @@ export async function gateActivitySeconds() {
|
||||
// 结束军团活动
|
||||
export async function cityActivityEnd() {
|
||||
console.log('*****cityActivityEnd');
|
||||
await sendEndMsgToAll();
|
||||
await sendEndMsgToAllServer();
|
||||
await pinus.app.rpc.guild.guildActivityRemote.guildActivityEnd.broadcast(GUILD_ACTIVITY_TYPE.CITY_ACTIVITY);
|
||||
|
||||
// 发完之后再做下周自动宣战
|
||||
@@ -335,7 +337,7 @@ export async function cityActivitySeconds() {
|
||||
// 结束军团活动
|
||||
export async function raceActivityEnd() {
|
||||
console.log('*****raceActivityEnd');
|
||||
await sendEndMsgToAll();
|
||||
await sendEndMsgToAllServer();
|
||||
await pinus.app.rpc.guild.guildActivityRemote.guildActivityEnd.broadcast(GUILD_ACTIVITY_TYPE.RACE_ACTIVITY);
|
||||
|
||||
if (guildActSecondsJobId) {
|
||||
@@ -585,10 +587,7 @@ async function startMaintenanceSchedule(batchCode: string) {
|
||||
|
||||
// 向全服发送
|
||||
for(let { id: serverId } of servers) {
|
||||
let chatSid = await getWorldChannelSid(serverId);
|
||||
if(chatSid) {
|
||||
await pinus.app.rpc.chat.chatRemote.sendServerMaintenance.toServer(chatSid, serverId);
|
||||
}
|
||||
await sendMessageToServer(serverId, PUSH_ROUTE.SERVER_MAINTENANCE, resResult(STATUS.SERVER_MAINTENANCE));
|
||||
}
|
||||
|
||||
// 更新connectorRemote里面的维护服务器
|
||||
|
||||
Reference in New Issue
Block a user