优化:抽象推送方法
This commit is contained in:
@@ -6,7 +6,7 @@ import { difference } from 'underscore';
|
||||
* @Last Modified by: 梁桐川
|
||||
* @Last Modified time: 2021-08-27 17:47:56
|
||||
*/
|
||||
import { IT_TYPE, CURRENCY_BY_TYPE, CURRENCY_TYPE, COM_TEAM_STATUS, COM_BTL_CONST, CONSUME_TYPE, MSG_SOURCE, ROLE_SELECT, TASK_TYPE, KING_EXP_RATIO_TYPE, ITEM_CHANGE_REASON, getChannelType, CHANNEL_PREFIX, DEBUG_MAGIC_WORD } from './../../../consts';
|
||||
import { IT_TYPE, CURRENCY_BY_TYPE, CURRENCY_TYPE, COM_TEAM_STATUS, COM_BTL_CONST, CONSUME_TYPE, MSG_SOURCE, ROLE_SELECT, TASK_TYPE, KING_EXP_RATIO_TYPE, ITEM_CHANGE_REASON, getChannelType, CHANNEL_PREFIX, DEBUG_MAGIC_WORD, PUSH_ROUTE } from './../../../consts';
|
||||
import Role, { RoleModel } from '../../../db/Role';
|
||||
import { STATUS } from '../../../consts/statusCode';
|
||||
import { Application, BackendSession } from 'pinus';
|
||||
@@ -18,8 +18,7 @@ import { checkRoleInQueue, rmRoleFromQueue, setTeamSearchReq } from '../../../se
|
||||
import { getRandBlueprtId, clearComBtlTimer, getFrd, updateRobotHurtByTime, comBtlLvInvalid, clearRobotHurtTimer, setDismissTimer, dismissTeam, handleComBtlProgress, getComBattleFriendAdd, teammateInBlackList, blueprtIdValid, hasEnoughBlueprt, addRoleToTeam, addRoleStToTeam, addValidSearchingRoles, validToJoin, addRobotsToTeam, addRobotsLater, teamIsFullToStart, oneTeamNotInBlack, getAllAssistCnt, checkHasMyTeam } from '../../../services/comBattleService';
|
||||
import { setAp } from '../../../services/actionPointService';
|
||||
import { roleLevelup } from '../../../services/normalBattleService';
|
||||
import { addUserToChannel, getSimpleRoleInfo } from '../../../services/roleService';
|
||||
import { ChannelUser } from '../../../domain/ChannelUser';
|
||||
import { getSimpleRoleInfo } from '../../../services/roleService';
|
||||
import { pushComBtlTeamMsg, pushFriendTeamInviteMsg, pushNormalItemMsg, pushTeamInviteMsg } from '../../../services/chatService';
|
||||
import { EXTERIOR } from '../../../pubUtils/dicParam';
|
||||
import { getZeroPointD, getTimeFunD, getSeconds, nowSeconds } from '../../../pubUtils/timeUtil';
|
||||
@@ -27,6 +26,7 @@ import { FriendParams } from '../../../domain/roleField/friend';
|
||||
import { checkTask, checkTaskInComBattleStart } from '../../../services/task/taskService';
|
||||
import { gameData, getWarByBlueprtId } from '../../../pubUtils/data';
|
||||
import { HeroModel } from '../../../db/Hero';
|
||||
import { addUserToTeamChannel, delTeamChannel, removeFromTeamChannel, sendMessageToTeam } from '../../../services/pushService';
|
||||
|
||||
export default function(app: Application) {
|
||||
return new ComBattleHandler(app);
|
||||
@@ -67,30 +67,26 @@ export class ComBattleHandler {
|
||||
return resResult(STATUS.COM_BATTLE_CREATE_CE_LIMIT)
|
||||
}
|
||||
|
||||
|
||||
let channelService = this.app.get('channelService');
|
||||
let channel = channelService.getChannel(teamCode, true);
|
||||
|
||||
// 创建队伍数据结构
|
||||
let comTeam = new MemComBtlTeam(teamCode, pub, blueprtId, roleId, ceLimit);
|
||||
let comTeam = new MemComBtlTeam(teamCode, pub, blueprtId, roleId, ceLimit, sid);
|
||||
addRoleToTeam(comTeam, roleInfo, true, false);
|
||||
addUserToChannel(channel, new ChannelUser(roleId, sid));
|
||||
addUserToTeamChannel(teamCode, true, roleId, sid);
|
||||
// 将正在匹配的符合要求的玩家加入队伍,并推送入队消息
|
||||
await addValidSearchingRoles(comTeam, channelService);
|
||||
await addValidSearchingRoles(comTeam);
|
||||
|
||||
// 队伍数据持久化
|
||||
const team = await ComBattleTeamModel.createTeam(comTeam);
|
||||
if (!team) {
|
||||
channel.destroy();
|
||||
delTeamChannel(teamCode);
|
||||
return resResult(STATUS.COM_BATTLE_CREATE_ERR);
|
||||
}
|
||||
this.teamMap.set(teamCode, comTeam);
|
||||
|
||||
// 倒计时一定时间给队长匹配机器人
|
||||
if (pub === true) {
|
||||
await addRobotsLater(comTeam, roleInfo, this.teamMap, this.teamDisTimer, channel);
|
||||
await addRobotsLater(comTeam, roleInfo, this.teamMap, this.teamDisTimer);
|
||||
}
|
||||
setDismissTimer(comTeam, this.teamMap, roleId, this.teamDisTimer, channel);
|
||||
setDismissTimer(comTeam, this.teamMap, roleId, this.teamDisTimer);
|
||||
return resResult(STATUS.SUCCESS, { teamCode, roleStatus: comTeam.roleStatus });
|
||||
}
|
||||
|
||||
@@ -133,17 +129,15 @@ export class ComBattleHandler {
|
||||
await rmRoleFromQueue(roleId, sid, lvs);
|
||||
// 创建队伍
|
||||
let blueprtId = getRandBlueprtId(lvs).pop();
|
||||
let comTeam = new MemComBtlTeam(teamCode, false, blueprtId, 'robot', 0)
|
||||
let comTeam = new MemComBtlTeam(teamCode, false, blueprtId, 'robot', 0, '')
|
||||
|
||||
let isFrd = await getFrd(roleId);
|
||||
// 将玩家加入队伍
|
||||
addRoleToTeam(comTeam, roleInfo, false, isFrd);
|
||||
let channelService = thiz.app.get('channelService');
|
||||
let channel = channelService.getChannel(teamCode, true);
|
||||
addUserToChannel(channel, new ChannelUser(roleId, sid));
|
||||
addUserToTeamChannel(teamCode, true, roleId, sid);
|
||||
|
||||
// 创建并添加机器人
|
||||
await addRobotsToTeam(comTeam, roleId, topLineupCe, playerLv, thiz.teamMap, thiz.teamDisTimer, channel, 2);
|
||||
await addRobotsToTeam(comTeam, roleId, topLineupCe, playerLv, thiz.teamMap, thiz.teamDisTimer, 2);
|
||||
|
||||
await ComBattleTeamModel.createTeam(comTeam);
|
||||
thiz.teamMap.set(teamCode, comTeam);
|
||||
@@ -213,12 +207,10 @@ export class ComBattleHandler {
|
||||
addRoleStToTeam(teamStatus, roleStatus);
|
||||
|
||||
// 推送队伍信息给所有玩家
|
||||
let channelService = this.app.get('channelService');
|
||||
let channel = channelService.getChannel(teamCode, false);
|
||||
addUserToChannel(channel, new ChannelUser(roleId, sid));
|
||||
channel.pushMessage('onTeamJoin', resResult(STATUS.SUCCESS, {teamInfo: teamStatus}));
|
||||
addUserToTeamChannel(teamCode, false, roleId, sid);
|
||||
sendMessageToTeam(teamCode, PUSH_ROUTE.TEAM_JOIN, { teamInfo: teamStatus });
|
||||
|
||||
setDismissTimer(teamStatus, this.teamMap, roleId, this.teamDisTimer, channel);
|
||||
setDismissTimer(teamStatus, this.teamMap, roleId, this.teamDisTimer);
|
||||
return resResult(STATUS.SUCCESS, { teamInfo: teamStatus});
|
||||
}
|
||||
|
||||
@@ -291,9 +283,7 @@ export class ComBattleHandler {
|
||||
}
|
||||
});
|
||||
|
||||
let channelService = this.app.get('channelService');
|
||||
let channel = channelService.getChannel(teamCode, false);
|
||||
channel.pushMessage('onTeammateReady', resResult(STATUS.SUCCESS, {teamCode, roleId, heroes}));
|
||||
sendMessageToTeam(teamCode, PUSH_ROUTE.TEAMMATE_READY, {teamCode, roleId, heroes});
|
||||
return resResult(STATUS.SUCCESS);
|
||||
}
|
||||
|
||||
@@ -326,9 +316,7 @@ export class ComBattleHandler {
|
||||
}
|
||||
});
|
||||
|
||||
let channelService = this.app.get('channelService');
|
||||
let channel = channelService.getChannel(teamCode, false);
|
||||
channel.pushMessage('onTeammateReady', resResult(STATUS.SUCCESS, {teamCode, roleId, heroes}));
|
||||
sendMessageToTeam(teamCode, PUSH_ROUTE.TEAMMATE_READY, {teamCode, roleId, heroes});
|
||||
return resResult(STATUS.SUCCESS);
|
||||
}
|
||||
|
||||
@@ -364,15 +352,9 @@ export class ComBattleHandler {
|
||||
teamStatus.blacklist.push(roleIdToRm);
|
||||
}
|
||||
|
||||
// 推送移除消息
|
||||
let channelService = this.app.get('channelService');
|
||||
let channel = channelService.getChannel(teamCode, false);
|
||||
// 先推送离队消息,再将玩家从房间中移除
|
||||
channel.pushMessage('onLeaveTeam', resResult(STATUS.SUCCESS, {teamCode, roleId: roleIdToRm}));
|
||||
let users: string[] = channel.getMembers();
|
||||
if (users.indexOf(roleIdToRm) !== -1) {
|
||||
channel.removeMember(roleIdToRm);
|
||||
}
|
||||
sendMessageToTeam(teamCode, PUSH_ROUTE.LEAVE_TEAM, {teamCode, roleId: roleIdToRm});
|
||||
removeFromTeamChannel(teamCode, roleIdToRm);
|
||||
clearComBtlTimer(teamCode, this.teamDisTimer); // 移除队员停止解散计时
|
||||
let thiz = this;
|
||||
setTimeout(async () => {
|
||||
@@ -386,7 +368,7 @@ export class ComBattleHandler {
|
||||
}
|
||||
if (!roleSt) return;
|
||||
let { topLineupCe, lv } = roleSt;
|
||||
await addRobotsToTeam(curTeamStatus, roleId, topLineupCe, lv, thiz.teamMap, thiz.teamDisTimer, channel, 3 - curTeamStatus.roleIds.length);
|
||||
await addRobotsToTeam(curTeamStatus, roleId, topLineupCe, lv, thiz.teamMap, thiz.teamDisTimer, 3 - curTeamStatus.roleIds.length);
|
||||
}
|
||||
}, COM_BTL_CONST.ASSIST_TIME);
|
||||
return resResult(STATUS.SUCCESS);
|
||||
@@ -404,9 +386,7 @@ export class ComBattleHandler {
|
||||
let { teamCode } = msg;
|
||||
let teamStatus = this.teamMap.get(teamCode);
|
||||
if(!teamStatus) return resResult(STATUS.SUCCESS);
|
||||
let channelService = this.app.get('channelService');
|
||||
let channel = channelService.getChannel(teamCode, false);
|
||||
let result = await dismissTeam(teamStatus, this.teamMap, roleId, this.teamDisTimer, channel);
|
||||
let result = await dismissTeam(teamStatus, this.teamMap, roleId, this.teamDisTimer);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -434,31 +414,26 @@ export class ComBattleHandler {
|
||||
if (!team) return resResult(STATUS.COM_BATTLE_START_ERR);
|
||||
|
||||
clearComBtlTimer(teamCode, this.teamDisTimer); // 战斗开始停止解散计时
|
||||
let channelService = this.app.get('channelService');
|
||||
let channel = channelService.getChannel(teamCode, false);
|
||||
|
||||
await getComBattleFriendAdd(teamStatus.roleStatus);
|
||||
channel.pushMessage('onComBtlStart', resResult(STATUS.SUCCESS, {teamCode, roleStatus: teamStatus.roleStatus}));
|
||||
sendMessageToTeam(teamCode, PUSH_ROUTE.COMBATTLE_START, {teamCode, roleStatus: teamStatus.roleStatus});
|
||||
// 每场倒计时结算
|
||||
let thiz = this;
|
||||
setTimeout(async () => {
|
||||
let teamStatus = thiz.teamMap.get(teamCode);
|
||||
if (teamStatus && teamStatus.status === COM_TEAM_STATUS.FIGHTING) {
|
||||
clearRobotHurtTimer(teamStatus, this.robotHurtTimer);
|
||||
let channelService = thiz.app.get('channelService');
|
||||
let channel = channelService.getChannel(teamCode, false);
|
||||
let team = await ComBattleTeamModel.syncTeamData({teamCode, status: COM_TEAM_STATUS.LOOSE, roleStatus: teamStatus.roleStatus, bossHpArr: teamStatus.bossHpArr}, true);
|
||||
if (!team) return resResult(STATUS.COM_BATTLE_RESULT_ERR);
|
||||
// // 将藏宝图加回去
|
||||
// await addItems(roleId, roleName, sid, [{ id: team.blueprtId, count: 1 }])
|
||||
teamStatus.timeout = true;
|
||||
channel.pushMessage('onTeamComplete', resResult(STATUS.SUCCESS, {teamCode, result: false, timeout: true}));
|
||||
sendMessageToTeam(teamCode, PUSH_ROUTE.TEAM_COMPLETE, {teamCode, result: false, timeout: true});
|
||||
thiz.teamMap.delete(teamCode);
|
||||
}
|
||||
}, COM_BTL_CONST.BTL_TIME_LMT);
|
||||
teamStatus.roleStatus.forEach((st, idx) => {
|
||||
if (st.isRobot === true) {
|
||||
updateRobotHurtByTime(teamStatus, st, COM_BTL_CONST.ROBOT_BASE_TIME_INTERVAL + idx, channel, this.robotHurtTimer, this.teamMap);
|
||||
updateRobotHurtByTime(teamStatus, st, COM_BTL_CONST.ROBOT_BASE_TIME_INTERVAL + idx, this.robotHurtTimer, this.teamMap);
|
||||
}
|
||||
});
|
||||
await checkTaskInComBattleStart(teamStatus.roleStatus, teamStatus.capId, teamStatus.blueprtId);
|
||||
@@ -515,11 +490,9 @@ export class ComBattleHandler {
|
||||
teamStatus.bossCurHp = cal.sub(teamStatus.bossCurHp, totalHurtHp);
|
||||
if (teamStatus.bossCurHp < 0) teamStatus.bossCurHp = 0;
|
||||
// 推送本次行动情况
|
||||
let channelService = this.app.get('channelService');
|
||||
let channel = channelService.getChannel(teamCode, false);
|
||||
const roleStatus = teamStatus.roleStatus.map(st => {return {roleId: st.roleId, totalDmg: st.totalDmg, killed: st.killed}});
|
||||
channel.pushMessage('onTeammateAct', resResult(STATUS.SUCCESS, { teamCode, bossCurHp: teamStatus.bossCurHp, bossHpArr: teamStatus.bossHpArr, roleStatus, actRoleId: roleId, actBossHurts }));
|
||||
const result = await handleComBtlProgress(teamStatus, this.robotHurtTimer, this.teamMap, channel);
|
||||
sendMessageToTeam(teamCode, PUSH_ROUTE.TEAMMATE_ACT, { teamCode, bossCurHp: teamStatus.bossCurHp, bossHpArr: teamStatus.bossHpArr, roleStatus, actRoleId: roleId, actBossHurts });
|
||||
const result = await handleComBtlProgress(teamStatus, this.robotHurtTimer, this.teamMap);
|
||||
if (result && result.code !== 0) return result;
|
||||
return resResult(STATUS.SUCCESS);
|
||||
}
|
||||
@@ -535,19 +508,17 @@ export class ComBattleHandler {
|
||||
let teamStatus = this.teamMap.get(teamCode);
|
||||
if (!teamStatus || !teamStatus.roleIds || teamStatus.roleIds.indexOf(roleId) === -1) return resResult(STATUS.COM_BATTLE_TEAM_INVALID);
|
||||
|
||||
let channelService = this.app.get('channelService');
|
||||
let channel = channelService.getChannel(teamCode, false);
|
||||
if (isSuccess && teamStatus.bossCurHp <= 0) {
|
||||
let team = await ComBattleTeamModel.updateResult(teamCode, roleId, isSuccess);
|
||||
if (!team) return resResult(STATUS.COM_BATTLE_RESULT_ERR);
|
||||
channel.pushMessage('onTeamComplete', resResult(STATUS.SUCCESS, {teamCode, result: isSuccess}));
|
||||
sendMessageToTeam(teamCode, PUSH_ROUTE.TEAM_COMPLETE, {teamCode, result: isSuccess});
|
||||
} else if (!isSuccess) {
|
||||
let team = await ComBattleTeamModel.updateResult(teamCode, roleId, isSuccess);
|
||||
if (!team) return resResult(STATUS.COM_BATTLE_RESULT_ERR);
|
||||
if (team.status === COM_TEAM_STATUS.LOOSE) {
|
||||
channel.pushMessage('onTeamComplete', resResult(STATUS.SUCCESS, {teamCode, result: isSuccess}));
|
||||
sendMessageToTeam(teamCode, PUSH_ROUTE.TEAM_COMPLETE, {teamCode, result: isSuccess});
|
||||
} else {
|
||||
channel.pushMessage('onTeammateAct', resResult(STATUS.SUCCESS, {teamCode, bossCurHp: teamStatus.bossCurHp, roleStatus: {roleId, battleStatus: 2}}));
|
||||
sendMessageToTeam(teamCode, PUSH_ROUTE.TEAMMATE_ACT, {teamCode, bossCurHp: teamStatus.bossCurHp, roleStatus: {roleId, battleStatus: 2}});
|
||||
}
|
||||
}
|
||||
return resResult(STATUS.SUCCESS, { bossCurHp: teamStatus.bossCurHp });
|
||||
@@ -705,10 +676,11 @@ export class ComBattleHandler {
|
||||
let roleId = session.get('roleId');
|
||||
let roleName = session.get('roleName');
|
||||
let serverId = session.get('serverId');
|
||||
let guildCode = session.get('guildCode');
|
||||
const { teamCode } = msg;
|
||||
let teamStatus = this.teamMap.get(teamCode);
|
||||
if(!teamStatus) return resResult(STATUS.WRONG_PARMS);
|
||||
const { msgDataWorld, msgDataGuild } = await pushTeamInviteMsg(roleId, roleName, serverId, teamCode, teamStatus.blueprtId);
|
||||
const { msgDataWorld, msgDataGuild } = await pushTeamInviteMsg(roleId, roleName, serverId, guildCode, teamCode, teamStatus.blueprtId);
|
||||
if (!msgDataWorld || !msgDataGuild) return resResult(STATUS.WRONG_PARMS);
|
||||
return resResult(STATUS.SUCCESS);
|
||||
}
|
||||
|
||||
@@ -20,141 +20,6 @@ export class ComBattleRemote {
|
||||
|
||||
private channelService: ChannelService;
|
||||
|
||||
public async create(uid: string, sid: string, name: string, flag: boolean) {
|
||||
console.log('comBattleRemote create: ', name, flag);
|
||||
let channel = this.channelService.getChannel(name, flag);
|
||||
if (!!channel) {
|
||||
let username = uid.split('*')[0];
|
||||
let param = {
|
||||
user: username
|
||||
};
|
||||
channel.pushMessage('onAdd', resResult(STATUS.SUCCESS, param));
|
||||
|
||||
if (!!channel) {
|
||||
channel.add(uid, sid);
|
||||
}
|
||||
}
|
||||
return this.get(name, flag);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add user into chat channel.
|
||||
*
|
||||
* @param {String} uid unique id for user
|
||||
* @param {String} sid server id
|
||||
* @param {String} name channel name
|
||||
* @param {boolean} flag channel parameter
|
||||
*
|
||||
*/
|
||||
public async add(uid: string, sid: string, name: string, flag: boolean) {
|
||||
console.log('comBattleRemote add: ', name, flag);
|
||||
let channel = this.channelService.getChannel(name, flag);
|
||||
if (!!channel && !this.get(name, false).includes(uid)) {
|
||||
let username = uid.split('*')[0];
|
||||
let param = {
|
||||
user: username
|
||||
};
|
||||
channel.pushMessage('onAdd', resResult(STATUS.SUCCESS, param));
|
||||
|
||||
if (!!channel) {
|
||||
channel.add(uid, sid);
|
||||
}
|
||||
}
|
||||
return this.get(name, flag);
|
||||
}
|
||||
|
||||
public async available(uid: string, sid: string, name: string, flag: boolean) {
|
||||
let channel = this.channelService.getChannel(name, flag);
|
||||
if (!!channel) {
|
||||
const users = this.get(name, false);
|
||||
if (users.includes(uid)) {
|
||||
console.log('不得重复加入');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get user from chat channel.
|
||||
*
|
||||
* @param {Object} opts parameters for request
|
||||
* @param {String} name channel name
|
||||
* @param {boolean} flag channel parameter
|
||||
* @return {Array} users uids in channel
|
||||
*
|
||||
*/
|
||||
private get(name: string, flag: boolean) {
|
||||
let users: string[] = [];
|
||||
let channel = this.channelService.getChannel(name, flag);
|
||||
if (!!channel) {
|
||||
users = channel.getMembers();
|
||||
}
|
||||
for (let i = 0; i < users.length; i++) {
|
||||
users[i] = users[i].split('*')[0];
|
||||
}
|
||||
return users;
|
||||
}
|
||||
|
||||
/**
|
||||
* Kick user out chat channel.
|
||||
*
|
||||
* @param {String} uid unique id for user
|
||||
* @param {String} sid server id
|
||||
* @param {String} name channel name
|
||||
*
|
||||
*/
|
||||
public async kick(uid: string, sid: string, name: string) {
|
||||
let channel = this.channelService.getChannel(name, false);
|
||||
// leave channel
|
||||
if (!!channel) {
|
||||
channel.leave(uid, sid);
|
||||
}
|
||||
let username = uid.split('*')[0];
|
||||
let param = {
|
||||
user: username
|
||||
};
|
||||
channel.pushMessage('onLeave', resResult(STATUS.SUCCESS, param));
|
||||
}
|
||||
|
||||
public async hurt(uid: string, sid: string, name: string, bossHurt: number, actorHurt: [{ actorId: number, actorHurt: number }]) {
|
||||
try {
|
||||
console.log('hurt channel name: ', name);
|
||||
let channelService = this.app.get('channelService');
|
||||
this.bossHp -= bossHurt;
|
||||
let channel = channelService.getChannel(name, false);
|
||||
if (!!channel) {
|
||||
if (this.bossHp < 0) {
|
||||
this.bossHp = 0;
|
||||
}
|
||||
channel.pushMessage('bossHp', resResult(STATUS.SUCCESS, { bossHp: this.bossHp }));
|
||||
}
|
||||
return this.bossHp;
|
||||
} catch(e) {
|
||||
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||
}
|
||||
}
|
||||
|
||||
// public async leaveFromBattle(roleId: string, teamCode: string ) {
|
||||
// try {
|
||||
// let teamMap: Map<string, MemComBtlTeam> = this.app.get('teamMap');
|
||||
// if(teamMap && teamMap.has(teamCode)) {
|
||||
// let myTeam = teamMap.get(teamCode);
|
||||
// for(let roleStatus of myTeam.roleStatus) {
|
||||
// if(roleStatus.roleId == roleId) {
|
||||
// roleStatus.battleStatus = 2; // 自己失败了
|
||||
// }
|
||||
// }
|
||||
// let channelService = this.app.get('channelService');
|
||||
// let channel = channelService.getChannel(teamCode, false);
|
||||
|
||||
// await handleComBtlProgress(myTeam, this.app.get('robotHurtTimer'), teamMap, channel); // 结算
|
||||
// }
|
||||
// } catch(e) {
|
||||
// errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||
// }
|
||||
// }
|
||||
|
||||
public async checkMyTeam(roleId: string ) {
|
||||
try {
|
||||
let teamMap: Map<string, MemComBtlTeam> = this.app.get('teamMap');
|
||||
|
||||
@@ -17,65 +17,6 @@ export class ChatHandler {
|
||||
constructor(private app: Application) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Send messages to users
|
||||
*
|
||||
* @param {Object} msg message from client
|
||||
* @param {Object} session
|
||||
*
|
||||
*/
|
||||
async send(msg: { content: string, target: string }, session: BackendSession) {
|
||||
let rid = session.get('rid');
|
||||
let username = session.uid.split('*')[0];
|
||||
let channelService = this.app.get('channelService');
|
||||
let param = {
|
||||
msg: msg.content,
|
||||
from: username,
|
||||
target: msg.target
|
||||
};
|
||||
let channel = channelService.getChannel(rid, false);
|
||||
|
||||
// the target is all users
|
||||
if (msg.target === '*') {
|
||||
channel.pushMessage('onChat', resResult(STATUS.SUCCESS, param));
|
||||
}
|
||||
// the target is specific user
|
||||
else {
|
||||
let tuid = msg.target + '*' + rid;
|
||||
let tsid = channel.getMember(tuid)['sid'];
|
||||
channelService.pushMessageByUids('onChat', resResult(STATUS.SUCCESS, param), [{
|
||||
uid: tuid,
|
||||
sid: tsid
|
||||
}]);
|
||||
}
|
||||
}
|
||||
|
||||
async send2(msg: { content: string, target: string }, session: BackendSession) {
|
||||
let rid = session.get('rid');
|
||||
let username = session.uid.split('*')[0];
|
||||
let channelService = this.app.get('channelService');
|
||||
let param = {
|
||||
msg: msg.content,
|
||||
from: username,
|
||||
target: msg.target
|
||||
};
|
||||
let channel = channelService.getChannel(rid, false);
|
||||
|
||||
// the target is all users
|
||||
if (msg.target === '*') {
|
||||
channel.pushMessage('onChat', resResult(STATUS.SUCCESS, param));
|
||||
}
|
||||
// the target is specific user
|
||||
else {
|
||||
let tuid = msg.target + '*' + rid;
|
||||
let tsid = channel.getMember(tuid)['sid'];
|
||||
channelService.pushMessageByUids('onChat', resResult(STATUS.SUCCESS, param), [{
|
||||
uid: tuid,
|
||||
sid: tsid
|
||||
}]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 群聊发送接口
|
||||
* @param {{ channel: string, type: number, content: string, targetRoleId: string, targetMsgCode: string }} msg
|
||||
|
||||
@@ -1,20 +1,9 @@
|
||||
import { GroupMessageType } from './../../../db/GroupMessage';
|
||||
import { Application, ChannelService, HandlerService, } from 'pinus';
|
||||
import { resResult } from '../../../pubUtils/util';
|
||||
import { ON_ADD_CHANNEL_ROUTE, ON_GROUP_MSG_ROUTE, ON_LEAVE_CHANNEL_ROUTE, STATUS, CHANNEL_PREFIX } from '../../../consts';
|
||||
import { PrivateMessageType } from '../../../db/PrivateMessage';
|
||||
import { addUserToChannel, getSimpleRoleInfo } from '../../../services/roleService';
|
||||
import { ChannelUser } from '../../../domain/ChannelUser';
|
||||
import { getWorldChannelSid, groupRoomId } from '../../../services/chatService';
|
||||
import { reloadResources } from '../../../pubUtils/data';
|
||||
import { GeneralRankParam } from '../../../domain/rank';
|
||||
import { getAllGuildActivityStatus } from '../../../services/guildActivity/guildActivityService';
|
||||
import { MailParam } from '../../../domain/roleField/mail';
|
||||
import { RankFirstType } from '../../../db/RankFirst';
|
||||
import { LotType } from '../../../db/Lot';
|
||||
import { _checkFilterWords, getTire, taflush } from '../../../services/sdkService';
|
||||
import { _checkFilterWords, taflush } from '../../../services/sdkService';
|
||||
import { getServerMainten, setServerMainten, stopServerMainten } from '../../../services/gmService';
|
||||
import { errlogger } from '../../../util/logger';
|
||||
import { addUserToChannel, sendMessageToChannel, sendMessgeToChannelByBatch } from '../../../services/pushService';
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
@@ -41,10 +30,6 @@ export class ChatRemote {
|
||||
}
|
||||
|
||||
private channelService: ChannelService;
|
||||
private GUILD_ACTIVITY_END = 'onGuildActivityEnd';
|
||||
private RACE_ACTIVITY_START = 'onRaceStart';
|
||||
private RANK_TOP_UPDATE = 'onRankTopUpdated';
|
||||
private GUILD_ACTIVITY_STATUS_UPDATE = 'onGuildActivityStatus'; // 军团活动状态变化
|
||||
|
||||
/**
|
||||
* @description 添加用户到频道
|
||||
@@ -57,7 +42,7 @@ export class ChatRemote {
|
||||
try {
|
||||
let channel = this.channelService.getChannel(channelName, true);
|
||||
if (!channel) return;
|
||||
addUserToChannel(channel, new ChannelUser(roleId, sid));
|
||||
addUserToChannel(channel, roleId, sid);
|
||||
} catch(e) {
|
||||
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||
}
|
||||
@@ -82,80 +67,36 @@ export class ChatRemote {
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 推送群消息到频道
|
||||
* @param {Partial<GroupMessageType>} msg
|
||||
* @memberof ChatRemote
|
||||
* 向频道推送消息
|
||||
* @param roomId 房间号
|
||||
* @param path 推送地址
|
||||
* @param data 推送数据
|
||||
* @returns
|
||||
*/
|
||||
public async sendGroupMsg(roomId: string, msg: Partial<GroupMessageType>) {
|
||||
public async pushMessage(roomId: string, path: string, data: any, isBatch = false) {
|
||||
try {
|
||||
let channel = this.channelService.getChannel(roomId, false);
|
||||
if (!channel) return;
|
||||
const roleInfo = await getSimpleRoleInfo(msg.roleId);
|
||||
channel.pushMessage(ON_GROUP_MSG_ROUTE, resResult(STATUS.SUCCESS, { ...msg, roleInfo }));
|
||||
if(isBatch) { // 分批推送
|
||||
sendMessgeToChannelByBatch(channel, path, data);
|
||||
} else {
|
||||
sendMessageToChannel(channel, path, data);
|
||||
}
|
||||
} catch(e) {
|
||||
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 推送私聊消息
|
||||
* @param {Partial<PrivateMessageType>} msg
|
||||
* @memberof ChatRemote
|
||||
*/
|
||||
public async sendPrivateMsg(msg: Partial<PrivateMessageType>) {
|
||||
public async deleteChannel(roomId: string) {
|
||||
try {
|
||||
|
||||
} catch(e) {
|
||||
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 全服推送活动结束通知
|
||||
* @param serverId
|
||||
*/
|
||||
public async sendGuildActivityEnd(serverId: number) {
|
||||
try {
|
||||
let roomId = groupRoomId(CHANNEL_PREFIX.WORLD, serverId);
|
||||
let channel = this.channelService.getChannel(roomId, false);
|
||||
if (!channel) return;
|
||||
channel.pushMessage(this.GUILD_ACTIVITY_END, resResult(STATUS.SUCCESS, {}));
|
||||
channel.destroy();
|
||||
} catch(e) {
|
||||
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 全服推送竞赛活动开始通知
|
||||
* @param serverId
|
||||
*/
|
||||
public async sendRaceActivityStart(serverId: number) {
|
||||
try {
|
||||
let roomId = groupRoomId(CHANNEL_PREFIX.WORLD, serverId);
|
||||
let channel = this.channelService.getChannel(roomId, false);
|
||||
if (!channel) return;
|
||||
channel.pushMessage(this.RACE_ACTIVITY_START, resResult(STATUS.SUCCESS, {}));
|
||||
} catch(e) {
|
||||
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 全服推送排行榜更新信息
|
||||
* @param serverId
|
||||
*/
|
||||
public async sendRankTopUpdated(serverId: number, ranks: (RankFirstType & {status: number})[]) {
|
||||
try {
|
||||
let roomId = groupRoomId(CHANNEL_PREFIX.WORLD, serverId);
|
||||
let channel = this.channelService.getChannel(roomId, false);
|
||||
if (!channel) return;
|
||||
channel.pushMessage(this.RANK_TOP_UPDATE, resResult(STATUS.SUCCESS, { ranks }));
|
||||
} catch(e) {
|
||||
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 重载json资源
|
||||
*/
|
||||
@@ -167,113 +108,6 @@ export class ChatRemote {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @description 全服推送军团活动状态变化
|
||||
* @param serverId
|
||||
*/
|
||||
public async sendGuildActivityUpdate(serverId: number) {
|
||||
try {
|
||||
let roomId = groupRoomId(CHANNEL_PREFIX.WORLD, serverId);
|
||||
let channel = this.channelService.getChannel(roomId, false);
|
||||
if (!channel) return;
|
||||
let guildActivities = getAllGuildActivityStatus();
|
||||
channel.pushMessage(this.GUILD_ACTIVITY_STATUS_UPDATE, resResult(STATUS.SUCCESS, { guildActivities }));
|
||||
} catch(e) {
|
||||
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 向全服推送邮件
|
||||
* @param serverId 服务器id
|
||||
* @param path 推送地址
|
||||
* @param mails 邮件内容
|
||||
*/
|
||||
public async sendMail(serverId: number, path: string, data: { mails: MailParam[] }) {
|
||||
try {
|
||||
let roomId = groupRoomId(CHANNEL_PREFIX.WORLD, serverId);
|
||||
let channel = this.channelService.getChannel(roomId, false);
|
||||
if (!channel) return;
|
||||
channel.pushMessage(path, resResult(STATUS.SUCCESS, data));
|
||||
} catch(e) {
|
||||
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 全服推送维护
|
||||
* @param serverId
|
||||
*/
|
||||
public async sendServerMaintenance(serverId: number) {
|
||||
try {
|
||||
let roomId = groupRoomId(CHANNEL_PREFIX.WORLD, serverId);
|
||||
let channel = this.channelService.getChannel(roomId, false);
|
||||
if (!channel) return { result: false, serverId };
|
||||
channel.pushMessage('onServerMaintenance', resResult(STATUS.SERVER_MAINTENANCE));
|
||||
return { result: true, serverId };
|
||||
} catch(e) {
|
||||
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public async pushCurrentTime(serverId: number, time: number) {
|
||||
try {
|
||||
let roomId = groupRoomId(CHANNEL_PREFIX.WORLD, serverId);
|
||||
let channel = this.channelService.getChannel(roomId, false);
|
||||
if (!channel) return { result: false, serverId };
|
||||
|
||||
channel.pushMessage('onPushCurrentTime', resResult(STATUS.SUCCESS, { time }));
|
||||
return { result: true, serverId };
|
||||
} catch(e) {
|
||||
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 实时推送军团拍卖出价
|
||||
* @param guildCode
|
||||
*/
|
||||
public async sendGuildAuction(guildCode: string, lot: LotType) {
|
||||
try {
|
||||
let roomId = groupRoomId(CHANNEL_PREFIX.GUILD, guildCode);
|
||||
let channel = this.channelService.getChannel(roomId, false);
|
||||
if(!channel) return false;
|
||||
|
||||
channel.pushMessage('onAuctionOver', resResult(STATUS.SUCCESS, { lot }));
|
||||
return true;
|
||||
} catch(e) {
|
||||
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||
}
|
||||
}
|
||||
|
||||
public async sendWorldAuction(serverId: number, lot: LotType) {
|
||||
try {
|
||||
let roomId = groupRoomId(CHANNEL_PREFIX.WORLD, serverId);
|
||||
let channel = this.channelService.getChannel(roomId, false);
|
||||
if(!channel) return false;
|
||||
|
||||
channel.pushMessage('onAuctionOver', resResult(STATUS.SUCCESS, { lot }));
|
||||
return true;
|
||||
} catch(e) {
|
||||
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||
}
|
||||
}
|
||||
|
||||
public async sendAuctionUpdate(serverId: number, params: { lots: LotType[] }) {
|
||||
try {
|
||||
let roomId = groupRoomId(CHANNEL_PREFIX.WORLD, serverId);
|
||||
let channel = this.channelService.getChannel(roomId, false);
|
||||
if(!channel) return false;
|
||||
|
||||
channel.pushMessage('onAuctionUpdate', resResult(STATUS.SUCCESS, params));
|
||||
return true;
|
||||
} catch(e) {
|
||||
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||
}
|
||||
}
|
||||
|
||||
public async checkFilterWords(word: string) {
|
||||
try {
|
||||
return await _checkFilterWords(word);
|
||||
|
||||
@@ -1,463 +0,0 @@
|
||||
import { Application, ChannelService, HandlerService, } from 'pinus';
|
||||
import { resResult } from '../../../pubUtils/util';
|
||||
import { STATUS, CHANNEL_PREFIX } from '../../../consts';
|
||||
import { GuildType } from '../../../db/Guild';
|
||||
import { RoleType } from '../../../db/Role';
|
||||
import { GuildRecType } from '../../../db/GuildRec';
|
||||
import { leaveGuildChannel, groupRoomId } from '../../../services/chatService';
|
||||
import { GuildRankParams, WoodenHorse, Event } from '../../../domain/battleField/guildActivity';
|
||||
import { MailParam } from '../../../domain/roleField/mail';
|
||||
import { pick } from 'underscore';
|
||||
import { LotType } from '../../../db/Lot';
|
||||
import { DividendType } from '../../../db/Dividend';
|
||||
import { getRoleOnlineInfo } from '../../../services/redisService';
|
||||
import { errlogger } from '../../../util/logger';
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
return new GuildRemote(app);
|
||||
}
|
||||
|
||||
export class GuildRemote {
|
||||
|
||||
constructor(private app: Application) {
|
||||
this.app = app;
|
||||
this.channelService = app.get('channelService');
|
||||
}
|
||||
|
||||
private channelService: ChannelService;
|
||||
private MEMBER_QUIT = 'onMemberQuit';
|
||||
private DISMISS = 'onDismiss';
|
||||
private GUILD_INFO_UPDATE = 'onGuildInfoUpdate';
|
||||
private DEMOTION = 'onDemotion';
|
||||
private PROMOTION = 'onPromotion';
|
||||
private GUILD_REC_ADD = 'onGuildRecAdd';
|
||||
private GUILD_BOSS_OPEN = 'onGuildBossStatus';
|
||||
private GATE_ACT_RANK = 'onGuildGateRankUpdate'; // 军团活动排行榜
|
||||
private CITY_ACT_RANK = 'onGuildCityRankUpdate'; // 军团活动排行榜
|
||||
private GUILD_GATE_ACT_HP = 'onGuildGateHpUpdate'; // 军团活动蛮夷入侵排行榜
|
||||
private GUILD_ACTIVITY_END = 'onGuildActivityEnd'; // 军团活动结束
|
||||
private GUILD_CITY_DECLARE = 'onGuildCityDeclare'; // 有军团对这个城池进行宣战了
|
||||
private GUILD_CITY_ACT_HP = 'onGuildCityGateHpUpdate'; // 诸侯入侵城门血条
|
||||
private GUILD_RACE_UPDATE = 'onRaceHorseUpdate'; /// 更新木牛流马
|
||||
private GUILD_RACE_JOIN = 'onRaceHorseJoin'
|
||||
private GUILD_RACE_EVENT = 'onRaceEventUpdate'; /// 更新木牛流马
|
||||
private GUILD_POP_UP_ACTIVITY = 'onActivityTaskUpdate'; /// 向军团成员发送弹窗礼包
|
||||
private GUILD_TRAIN_RESET = 'onGuildTainReset'; // 试炼场重置
|
||||
private GUILD_BOSS_ENCOURAGE = 'onGuildBossEncourage'; // 鼓舞
|
||||
private AUCTION_UPDATE = 'onAuctionUpdate'; // 拍卖行更新
|
||||
private AUCTION_ADD = 'onAuctionAdd'; // 拍卖行增加
|
||||
private DIVIDEND_UPDATE = 'onDividendsUpdate'; // 拍卖行更新
|
||||
private DIVIDEND_ADD = 'onDividendsAdd';
|
||||
|
||||
/**
|
||||
* 封装,军团相关channel名: 'guild'+guildCode
|
||||
* @param guildCode 军团code
|
||||
* @param create 是否创建channel
|
||||
*/
|
||||
private getChannel(guildCode: string, create: boolean = false) {
|
||||
let channelName = groupRoomId(CHANNEL_PREFIX.GUILD, guildCode);
|
||||
let channel = this.channelService.getChannel(channelName, create);
|
||||
return channel
|
||||
}
|
||||
|
||||
/**
|
||||
* 封装,向单人发推送
|
||||
* @param guildCode 军团code
|
||||
* @param path 推送地址
|
||||
* @param roleId 玩家id
|
||||
* @param message 推送信息
|
||||
* @param sid 玩家服
|
||||
*/
|
||||
private async pushMessageByUids(guildCode: string, path: string, roleId: string, message: { code: string, roleId?: string }, sid?: string) {
|
||||
|
||||
let channel = this.getChannel(guildCode);
|
||||
let uids = [];
|
||||
if (!sid) {
|
||||
let onlineUser = await getRoleOnlineInfo(roleId);
|
||||
sid = onlineUser.sid;
|
||||
}
|
||||
if (sid) {
|
||||
uids.push({ uid: roleId, sid });
|
||||
this.channelService.pushMessageByUids(path, resResult(STATUS.SUCCESS, message), uids);
|
||||
}
|
||||
return channel
|
||||
}
|
||||
|
||||
/**
|
||||
* 封装,向channel发推送
|
||||
* @param guildCode 军团code
|
||||
* @param path 推送地址
|
||||
* @param message 推送信息
|
||||
*/
|
||||
private pushMessage(guildCode: string, path: string, message: any) {
|
||||
let channel = this.getChannel(guildCode);
|
||||
if (!!channel) {
|
||||
channel.pushMessage(path, resResult(STATUS.SUCCESS, message));
|
||||
}
|
||||
return channel
|
||||
}
|
||||
|
||||
/**
|
||||
* 诸侯混战,按城池区分channel
|
||||
* @param cityId 城池id
|
||||
* @param create 是否创建channel
|
||||
*/
|
||||
private getCityChannel(cityId: number, create: boolean = false) {
|
||||
let channelName = groupRoomId(CHANNEL_PREFIX.CITY, cityId);
|
||||
let channel = this.channelService.getChannel(channelName, create);
|
||||
return channel
|
||||
}
|
||||
|
||||
/**
|
||||
* 封装,向channel发推送
|
||||
* @param cityId 城池id
|
||||
* @param path 推送地址
|
||||
* @param message 推送信息
|
||||
*/
|
||||
private pushMessageToCity(cityId: number, path: string, message: any) {
|
||||
let channel = this.getCityChannel(cityId);
|
||||
if (!!channel) {
|
||||
channel.pushMessage(path, resResult(STATUS.SUCCESS, message));
|
||||
}
|
||||
return channel
|
||||
}
|
||||
|
||||
/**
|
||||
* 踢出某个成员
|
||||
* @param guildCode 军团code
|
||||
* @param roleId 踢出玩家roleId
|
||||
* @param guild 军团信息
|
||||
* @param sid 玩家sid
|
||||
*/
|
||||
public memberQuit(guildCode: string, roleId: string, guild: GuildType, sid?: string) {
|
||||
try {
|
||||
// 被踢出公会
|
||||
this.pushMessageByUids(guildCode, this.MEMBER_QUIT, roleId, {
|
||||
code: guildCode,
|
||||
roleId
|
||||
}, sid);
|
||||
// 更新人数减少
|
||||
this.updateInfo(guildCode, { memberCnt: guild.memberCnt, guildCe: guild.guildCe });
|
||||
leaveGuildChannel(roleId, sid, guildCode);
|
||||
} catch(e) {
|
||||
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 解散军团
|
||||
* @param guildCode 军团code
|
||||
*/
|
||||
public dismiss(guildCode: string) {
|
||||
try {
|
||||
let channel = this.pushMessage(guildCode, this.DISMISS, { code: guildCode });
|
||||
if (!!channel) {
|
||||
channel.destroy();
|
||||
}
|
||||
} catch(e) {
|
||||
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新军团信息
|
||||
* @param guildCode 军团code
|
||||
* @param info 军团相关信息
|
||||
*/
|
||||
public updateInfo(guildCode: string, info: any) {
|
||||
try {
|
||||
this.pushMessage(guildCode, this.GUILD_INFO_UPDATE, info);
|
||||
} catch(e) {
|
||||
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 更换团长信息
|
||||
* @param guildCode 军团code
|
||||
* @param managerCnt 管理员人数
|
||||
* @param newLeader 新的团长
|
||||
* @param oldLeaderId 旧团长
|
||||
*/
|
||||
public changeLeader(guildCode: string, managerCnt: number, newLeader: RoleType, oldLeaderId: string) {
|
||||
try{
|
||||
let { roleId, roleName, frame, head, spine, lv, quitTime } = newLeader;
|
||||
this.updateInfo(guildCode, { managerCnt, leader: { roleId, roleName, frame, head, spine, lv, quitTime } });
|
||||
this.demotion(guildCode, oldLeaderId);
|
||||
this.promotion(guildCode, roleId);
|
||||
}catch(e) {
|
||||
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 向旧团长推送降职信息
|
||||
* @param guildCode 军团code
|
||||
* @param roleId 旧团长id
|
||||
*/
|
||||
public demotion(guildCode: string, roleId: string) {
|
||||
try {
|
||||
this.pushMessageByUids(guildCode, this.DEMOTION, roleId, {
|
||||
code: guildCode
|
||||
});
|
||||
} catch(e) {
|
||||
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 向新团长推送升职信息
|
||||
* @param guildCode 军团code
|
||||
* @param roleId 新团长id
|
||||
*/
|
||||
public promotion(guildCode: string, roleId: string) {
|
||||
try {
|
||||
this.pushMessageByUids(guildCode, this.PROMOTION, roleId, {
|
||||
code: guildCode
|
||||
});
|
||||
} catch(e) {
|
||||
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加动态
|
||||
* @param guildRecType 动态
|
||||
*/
|
||||
public addRec(guildRecType: GuildRecType) {
|
||||
try {
|
||||
let { guildCode, type, params, createTime } = guildRecType;
|
||||
this.pushMessage(guildCode, this.GUILD_REC_ADD, { type, params, createTime });
|
||||
} catch(e) {
|
||||
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 向军团推送城门血量
|
||||
* @param guildCode
|
||||
*/
|
||||
public pushGateHp(guildCode: string, gateHp: number) {
|
||||
try {
|
||||
this.pushMessage(guildCode, this.GUILD_GATE_ACT_HP, { gateHp });
|
||||
} catch(e) {
|
||||
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 向军团推送排行榜名次
|
||||
* @param guildCode
|
||||
*/
|
||||
public pushRank(guildCode: string, msg: GuildRankParams) {
|
||||
try {
|
||||
this.pushMessage(guildCode, this.GATE_ACT_RANK, msg);
|
||||
} catch(e) {
|
||||
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 向军团推送排行榜名次
|
||||
* @param guildCode
|
||||
*/
|
||||
public pushCityActRank(guildCode: string, msg: GuildRankParams) {
|
||||
try {
|
||||
this.pushMessage(guildCode, this.CITY_ACT_RANK, msg);
|
||||
} catch(e) {
|
||||
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 向军团推送结束活动
|
||||
* @param guildCode
|
||||
*/
|
||||
public async sendGuildActivityEnd(guildCode: string) {
|
||||
try {
|
||||
console.log("MSG END")
|
||||
this.pushMessage(guildCode, this.GUILD_ACTIVITY_END, {});
|
||||
} catch(e) {
|
||||
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 向城池推送有宣战
|
||||
* @param cityId 城池
|
||||
* @param declareGuildCode 宣战的军团code
|
||||
* @param declareCount 宣战数量
|
||||
*/
|
||||
public async sendGuildCityDeclare(cityId: number, declareGuildCode: string, declareCount: number) {
|
||||
try {
|
||||
this.pushMessageToCity(cityId, this.GUILD_CITY_DECLARE, {
|
||||
cityId,
|
||||
declareGuildCode,
|
||||
declareCount
|
||||
});
|
||||
this.pushMessage(declareGuildCode, this.GUILD_CITY_DECLARE, {
|
||||
cityId,
|
||||
declareGuildCode,
|
||||
declareCount
|
||||
});
|
||||
} catch(e) {
|
||||
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 推送城池城门血条
|
||||
* @param cityId 城池
|
||||
* @param gateHp 血条
|
||||
*/
|
||||
public async pushCityGateHp(cityId: number, gateHp: number, maxHp: number) {
|
||||
try {
|
||||
this.pushMessageToCity(cityId, this.GUILD_CITY_ACT_HP, {
|
||||
cityId,
|
||||
gateHp,
|
||||
maxHp
|
||||
});
|
||||
} catch(e) {
|
||||
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 推送木牛流马状态
|
||||
* @param guildCode 军团
|
||||
* @param woodenHorseList 木马
|
||||
* @param ranks 军团排名和自己所在的排名
|
||||
*/
|
||||
public async pushRaceHorseUpdate(guildCode: string, woodenHorseList: WoodenHorse[], ranks: GuildRankParams, events: Event[]) {
|
||||
try {
|
||||
this.pushMessage(guildCode, this.GUILD_RACE_UPDATE, {
|
||||
timestamp: Date.now(),
|
||||
woodenHorseList,
|
||||
...ranks,
|
||||
events
|
||||
});
|
||||
} catch(e) {
|
||||
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @description 当有人加入这个木牛流马
|
||||
* @param guildCode 军团
|
||||
* @param woodenHorse 木马
|
||||
*/
|
||||
public async pushRaceHorseJoin(guildCode: string, woodenHorse: WoodenHorse) {
|
||||
try {
|
||||
this.pushMessage(guildCode, this.GUILD_RACE_JOIN, {
|
||||
timestamp: Date.now(),
|
||||
woodenHorse
|
||||
});
|
||||
} catch(e) {
|
||||
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 向军团推送事件
|
||||
* @param guildCode
|
||||
*/
|
||||
public async sendRaceEvent(guildCode: string, events: Event[]) {
|
||||
try {
|
||||
this.pushMessage(guildCode, this.GUILD_RACE_EVENT, { timestamp: Date.now(), events });
|
||||
} catch(e) {
|
||||
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 当团长开启演武台时
|
||||
* @param guildCode
|
||||
* @param warId
|
||||
* @param bossHp
|
||||
* @param status
|
||||
*/
|
||||
public async pushBossStatus(guildCode: string, result: any) {
|
||||
try {
|
||||
this.pushMessage(guildCode, this.GUILD_BOSS_OPEN, pick(result, ['status', 'bossInfo', 'leaderOpenCnt']));
|
||||
} catch(e) {
|
||||
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 向军团推送弹窗礼包数据活动
|
||||
* @param guildCode
|
||||
*/
|
||||
public async sendPopUpActivity(guildCode: string, data: any[]) {
|
||||
try {
|
||||
console.log("sendPopUpActivity")
|
||||
this.pushMessage(guildCode, this.GUILD_POP_UP_ACTIVITY, data);
|
||||
} catch(e) {
|
||||
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 军团邮件
|
||||
* @param guildCode 军团code
|
||||
* @param path 推送地址
|
||||
* @param data 军团内容
|
||||
*/
|
||||
public async sendMailToGuild(guildCode: string, path: string, data: { mails: MailParam[] }) {
|
||||
try {
|
||||
this.pushMessage(guildCode, path, data);
|
||||
} catch(e) {
|
||||
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||
}
|
||||
}
|
||||
|
||||
public async sendTrainReset(guildCode: string) {
|
||||
try {
|
||||
this.pushMessage(guildCode, this.GUILD_TRAIN_RESET, {});
|
||||
} catch(e) {
|
||||
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||
}
|
||||
}
|
||||
|
||||
public async pushEncourage(guildCode: string, param: {encourageCnt: number; encourageMax: number; myEncourageCnt: number;}) {
|
||||
try {
|
||||
this.pushMessage(guildCode, this.GUILD_BOSS_ENCOURAGE, param);
|
||||
} catch(e) {
|
||||
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||
}
|
||||
}
|
||||
|
||||
public async pushAuctionUpdate(guildCode: string, param: { lots: LotType[]; dividends: DividendType[] }) {
|
||||
try {
|
||||
if(param.lots) this.pushMessage(guildCode, this.AUCTION_UPDATE, { lots: param.lots });
|
||||
if(param.dividends) this.pushMessage(guildCode, this.DIVIDEND_UPDATE, { dividends: param.dividends });
|
||||
} catch(e) {
|
||||
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||
}
|
||||
}
|
||||
|
||||
public async pushAuctionAdd(guildCode: string, param: { lots: LotType[]; dividends: DividendType[] }) {
|
||||
try {
|
||||
if(param.lots) this.pushMessage(guildCode, this.AUCTION_ADD, { lots: param.lots });
|
||||
if(param.dividends) this.pushMessage(guildCode, this.DIVIDEND_ADD, { dividends: param.dividends });
|
||||
} catch(e) {
|
||||
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 活动推送
|
||||
* @param guildCode 军团code
|
||||
* @param path 推送地址
|
||||
* @param param 内容
|
||||
*/
|
||||
public async pushActivityToGuild(guildCode: string, path: string, param: any) {
|
||||
try {
|
||||
this.pushMessage(guildCode, path, param);
|
||||
} catch(e) {
|
||||
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,6 @@ import { GM_MAIL_STATUS, GM_MAIL_TYPE, MAIL_TIME_TYPE, REF_CIRCLE_MAIL_TIME } fr
|
||||
import { RewardInter } from '../../../pubUtils/interface';
|
||||
import { MarqueeModel } from '../../../db/Marquee';
|
||||
import { ServerlistModel } from '../../../db/Serverlist';
|
||||
import { pushCurrentTime } from '../../../services/chatService';
|
||||
import { checkActivityEditable, checkActivityGroupType, checkActivityGroupTypeWithId } from '../../../services/activity/activityService';
|
||||
import { ActivityModel } from '../../../db/Activity';
|
||||
import { ActivityGroupModel } from '../../../db/ActivityGroup';
|
||||
@@ -23,6 +22,7 @@ import moment = require('moment');
|
||||
import { sendUngotDividend } from '../../../services/auctionService';
|
||||
import { taflush } from '../../../services/sdkService';
|
||||
import { ActivityInRemote } from '../../../domain/activityField/activityField';
|
||||
import { pushCurrentTime } from '../../../services/auctionService';
|
||||
let timer: NodeJS.Timer;
|
||||
export default function (app: Application) {
|
||||
return new GmHandler(app);
|
||||
|
||||
@@ -22,6 +22,7 @@ import { SkinModel } from '../../../db/Skin';
|
||||
import { PvpDefenseModel } from '../../../db/PvpDefense';
|
||||
import { createHeroes } from '../../../services/role/createHero';
|
||||
import { calculateCeWithHero } from '../../../services/playerCeService';
|
||||
import { pushChangeGuildLeader, pushGuildDismiss, pushGuildInfoUpdate } from '../../../services/guildService';
|
||||
|
||||
let timer: NodeJS.Timer;
|
||||
export default function (app: Application) {
|
||||
@@ -163,9 +164,7 @@ export class GmRoleHandler {
|
||||
}
|
||||
}
|
||||
updateParams.structure = structure;
|
||||
let chatSid = await getGuildChannelSid(params.code);
|
||||
console.log('*****', params.code, updateParams)
|
||||
this.app.rpc.chat.guildRemote.updateInfo.toServer(chatSid, params.code, updateParams);
|
||||
await pushGuildInfoUpdate(params.code, updateParams);
|
||||
// 设置玩家名
|
||||
if(updateParams.name != undefined || updateParams.lv != undefined) {
|
||||
let arr = [];
|
||||
@@ -206,10 +205,7 @@ export class GmRoleHandler {
|
||||
await this.app.rpc.connector.connectorRemote.setOtherUserGuildSession.broadcast(members.map(roleId => { return { roleId, userGuild: null } })); // 更新session
|
||||
|
||||
// 删除channel
|
||||
|
||||
let chatSid = await getGuildChannelSid(code);
|
||||
this.app.rpc.chat.guildRemote.dismiss.toServer(chatSid, code);
|
||||
|
||||
await pushGuildDismiss(code);
|
||||
let r = new Rank(REDIS_KEY.GUILD_ACTIVE_RANK, { serverId });
|
||||
await r.removeFromRank({ guildCode: code });
|
||||
let r2 = new Rank(REDIS_KEY.GUILD_LV_RANK, { serverId });
|
||||
@@ -247,9 +243,7 @@ export class GmRoleHandler {
|
||||
guild = await GuildModel.updateInfo(code, { leader: role._id }, { managerCnt: managerCntInc }, 'managerCnt name'); // 如果有转让团长设置leader
|
||||
|
||||
// 添加动态
|
||||
let chatSid = await getGuildChannelSid(code);
|
||||
|
||||
this.app.rpc.chat.guildRemote.changeLeader.toServer(chatSid, code, guild.managerCnt, role, leader.roleId);
|
||||
await pushChangeGuildLeader(code, guild.managerCnt, role, leader.roleId);
|
||||
await sendMailByContent(MAIL_TYPE.GUILD_BE_IMPEACH, leader.roleId, { params: [guild.name] });
|
||||
await sendMailByContent(MAIL_TYPE.GUILD_BE_SET_LEADER, roleId, { params: [guild.name] });
|
||||
|
||||
|
||||
@@ -28,69 +28,5 @@ export class GMRemote {
|
||||
|
||||
private channelService: ChannelService;
|
||||
|
||||
/**
|
||||
* Add user into chat channel.
|
||||
*
|
||||
* @param {String} uid unique id for user
|
||||
* @param {String} sid server id
|
||||
* @param {String} name channel name
|
||||
* @param {boolean} flag channel parameter
|
||||
*
|
||||
*/
|
||||
public async add(uid: string, sid: string, name: string, flag: boolean) {
|
||||
let channel = this.channelService.getChannel(name, flag);
|
||||
let username = uid.split('*')[0];
|
||||
let param = {
|
||||
user: username
|
||||
};
|
||||
channel.pushMessage('onAdd', resResult(STATUS.SUCCESS, param));
|
||||
|
||||
if (!!channel) {
|
||||
channel.add(uid, sid);
|
||||
}
|
||||
|
||||
return this.get(name, flag);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get user from chat channel.
|
||||
*
|
||||
* @param {Object} opts parameters for request
|
||||
* @param {String} name channel name
|
||||
* @param {boolean} flag channel parameter
|
||||
* @return {Array} users uids in channel
|
||||
*
|
||||
*/
|
||||
private get(name: string, flag: boolean) {
|
||||
let users: string[] = [];
|
||||
let channel = this.channelService.getChannel(name, flag);
|
||||
if (!!channel) {
|
||||
users = channel.getMembers();
|
||||
}
|
||||
for (let i = 0; i < users.length; i++) {
|
||||
users[i] = users[i].split('*')[0];
|
||||
}
|
||||
return users;
|
||||
}
|
||||
|
||||
/**
|
||||
* Kick user out chat channel.
|
||||
*
|
||||
* @param {String} uid unique id for user
|
||||
* @param {String} sid server id
|
||||
* @param {String} name channel name
|
||||
*
|
||||
*/
|
||||
public async kick(uid: string, sid: string, name: string) {
|
||||
let channel = this.channelService.getChannel(name, false);
|
||||
// leave channel
|
||||
if (!!channel) {
|
||||
channel.leave(uid, sid);
|
||||
}
|
||||
let username = uid.split('*')[0];
|
||||
let param = {
|
||||
user: username
|
||||
};
|
||||
channel.pushMessage('onLeave', resResult(STATUS.SUCCESS, param));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
import { DividendModel } from './../../../db/Dividend';
|
||||
import { Application, BackendSession, ChannelService, HandlerService, pinus, } from "pinus";
|
||||
import { AUCTION_STAGE, DEBUG_MAGIC_WORD, STATUS, CURRENCY_BY_TYPE, CURRENCY_TYPE, DATA_NAME, LOT_STATUS, CHANNEL_PREFIX, MAIL_TYPE, ITEM_CHANGE_REASON, TA_EVENT, ROLE_RECEIVE_STATUS } from "../../../consts";
|
||||
import { AUCTION_STAGE, DEBUG_MAGIC_WORD, STATUS, CURRENCY_BY_TYPE, CURRENCY_TYPE, DATA_NAME, LOT_STATUS, CHANNEL_PREFIX, MAIL_TYPE, ITEM_CHANGE_REASON, TA_EVENT, ROLE_RECEIVE_STATUS, PUSH_ROUTE } from "../../../consts";
|
||||
import { LotModel } from "../../../db/Lot";
|
||||
import { ItemReward } from "../../../domain/dbGeneral";
|
||||
import { genCode, resResult } from "../../../pubUtils/util";
|
||||
@@ -21,6 +21,7 @@ import { addRoleToGuildAuctionChannel, addRoleToWorldAuctionChannel, channelServ
|
||||
import { RewardInter } from '../../../pubUtils/interface';
|
||||
import { sendMailByContent } from '../../../services/mailService';
|
||||
import { reportTAEvent } from '../../../services/sdkService';
|
||||
import { sendMessageToServerWithSuc } from '../../../services/pushService';
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
@@ -326,9 +327,7 @@ export class AuctionHandler {
|
||||
}
|
||||
|
||||
let serverId = session.get('serverId');
|
||||
let roomId = groupRoomId(CHANNEL_PREFIX.WORLD, serverId);
|
||||
const channelSid = await channelServer(roomId);
|
||||
await pinus.app.rpc.chat.chatRemote.pushCurrentTime.toServer(channelSid, serverId, new Date(time).getTime());
|
||||
await sendMessageToServerWithSuc(serverId, PUSH_ROUTE.PUSH_CURRENT_TIME, { time: new Date(time).getTime() });
|
||||
|
||||
return resResult(STATUS.SUCCESS);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Application, ChannelService, BackendSession, pinus, HandlerService, } from "pinus";
|
||||
import { GUILD_ACTIVITY_TYPE, STATUS, REDIS_KEY, GUILD_POINT_WAYS, CITY_STATUS, TASK_TYPE, ITEM_CHANGE_REASON } from "../../../consts";
|
||||
import { GUILD_ACTIVITY_TYPE, STATUS, REDIS_KEY, GUILD_POINT_WAYS, CITY_STATUS, TASK_TYPE, ITEM_CHANGE_REASON, PUSH_ROUTE } from "../../../consts";
|
||||
import { resResult } from "../../../pubUtils/util";
|
||||
import { getGuildActivityStatus, getCityActivityObj, getCityStatus as pubGetCityStatus, getCities, getCityActivityRank, sendSingleCityActEndMsg, getPreDayActiveData } from "../../../services/guildActivity/guildActivityService";
|
||||
import { getGuildActivityStatus, getCityActivityObj, getCityStatus as pubGetCityStatus, getCities, getCityActivityRank, sendSingleCityActEndMsg, getPreDayActiveData, sendGuildCityDeclare } from "../../../services/guildActivity/guildActivityService";
|
||||
import { GuildActivityCityModel } from "../../../db/GuildActivityCity";
|
||||
import { gameData } from "../../../pubUtils/data";
|
||||
import { UserGuildActivityRecModel } from "../../../db/UserGuildActivityRec";
|
||||
@@ -17,6 +17,7 @@ import { checkTask } from "../../../services/task/taskService";
|
||||
import { guildInter } from "../../../pubUtils/interface";
|
||||
import { dispatch } from "../../../pubUtils/dispatcher";
|
||||
import { ServerRecordModel } from "../../../db/ServerRecords";
|
||||
import { sendMessageToCityWithSuc, sendMessageToGuildWithSuc } from "../../../services/pushService";
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
@@ -124,9 +125,7 @@ export class CityActivityHandler {
|
||||
}
|
||||
|
||||
let rec = await GuildActivityCityModel.declare(serverId, cityId, guildCode);
|
||||
|
||||
let chatSid = await getCityChannelSid(guildCode);
|
||||
pinus.app.rpc.chat.guildRemote.sendGuildCityDeclare.toServer(chatSid, cityId, guildCode, rec.declareCount);
|
||||
await sendGuildCityDeclare(cityId, guildCode, rec.declareCount);
|
||||
|
||||
let obj = getCityActivityObj();
|
||||
obj.pushGuild(guildCode, serverId, cityId);
|
||||
@@ -276,8 +275,8 @@ export class CityActivityHandler {
|
||||
await sendSingleCityActEndMsg(cityId, serverId);
|
||||
}
|
||||
// 推送 城门血量
|
||||
let chatSid = await getCityChannelSid(cityId);
|
||||
pinus.app.rpc.chat.guildRemote.pushCityGateHp.toServer(chatSid, cityId, gateHp, maxHp);
|
||||
await sendMessageToCityWithSuc(cityId, PUSH_ROUTE.GUILD_CITY_ACT_HP, { cityId, gateHp, maxHp });
|
||||
|
||||
await pinus.app.rpc.guild.guildActivityRemote.sendRankToGuilds.broadcast(this.aid);
|
||||
|
||||
return resResult(STATUS.SUCCESS, {
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { Application, BackendSession, pinus, HandlerService, } from 'pinus';
|
||||
import { resResult, genCode, getRandSingleEelm } from '../../../pubUtils/util';
|
||||
import { AUCTION_SOURCE, DEBUG_MAGIC_WORD, ITEM_CHANGE_REASON, MAIL_TYPE, STATUS, TASK_TYPE } from '../../../consts';
|
||||
import { AUCTION_SOURCE, DEBUG_MAGIC_WORD, ITEM_CHANGE_REASON, MAIL_TYPE, PUSH_ROUTE, STATUS, TASK_TYPE } from '../../../consts';
|
||||
import { BossInstanceModel } from '../../../db/BossInstance';
|
||||
import { BattleRecordModel } from '../../../db/BattleRecord';
|
||||
import { nowSeconds, getZeroPoint, getSeconds } from '../../../pubUtils/timeUtil';
|
||||
import { getBossInstanceInfo, checkBossBattleMemberExists, pushBossHpMessage, addBossInstance, refreshUserGuildOfBoss, refreshGuildOfBoss, getBossHp, getBossInstanceInfoByData } from '../../../services/guildBossService';
|
||||
import { getBossInstanceInfo, checkBossBattleMemberExists, pushBossHpMessage, addBossInstance, refreshUserGuildOfBoss, refreshGuildOfBoss, getBossHp, getBossInstanceInfoByData, pushBossStatus } from '../../../services/guildBossService';
|
||||
import { findWhere } from 'underscore'
|
||||
import { GUILD_STRUCTURE, GUILD_BOSS_STATUS, GUILD_POINT_WAYS } from '../../../consts/constModules/guildConst';
|
||||
import { DATA_NAME } from '../../../consts/dataName';
|
||||
@@ -21,7 +21,7 @@ import * as dicParam from '../../../pubUtils/dicParam';
|
||||
import { RoleModel } from '../../../db/Role';
|
||||
import { sendMailToGuildByContent } from '../../../services/mailService';
|
||||
import { genAuction } from '../../../services/auctionService';
|
||||
import { getPreDayActiveData } from '../../../services/guildActivity/guildActivityService';
|
||||
import { sendMessageToGuildWithSuc } from '../../../services/pushService';
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
@@ -87,9 +87,7 @@ export class GuildHandler {
|
||||
res.releaseCallback();
|
||||
|
||||
let result = await getBossInstanceInfoByData(bossInstance, userGuild, guild);
|
||||
let chatSid = await getGuildChannelSid(code);
|
||||
pinus.app.rpc.chat.guildRemote.pushBossStatus.toServer(chatSid, code, result );
|
||||
|
||||
await pushBossStatus(code, result);
|
||||
return resResult(STATUS.SUCCESS, result);
|
||||
}
|
||||
|
||||
@@ -192,9 +190,7 @@ export class GuildHandler {
|
||||
}
|
||||
|
||||
let result = await getBossInstanceInfoByData(bossInstance, userGuild);
|
||||
let chatSid = await getGuildChannelSid(guildCode);
|
||||
pinus.app.rpc.chat.guildRemote.pushBossStatus.toServer(chatSid, guildCode, result );
|
||||
|
||||
await pushBossStatus(guildCode, result);
|
||||
pushGuildBossSucMsg(roleId, roleName, guildCode, bossInstance);
|
||||
|
||||
res.releaseCallback();//解锁
|
||||
@@ -270,8 +266,7 @@ export class GuildHandler {
|
||||
encourageMax: dicBossBase.encourageSum,
|
||||
myEncourageCnt: myEncourageCntResult
|
||||
}
|
||||
let chatSid = await getGuildChannelSid(userGuild.guildCode);
|
||||
pinus.app.rpc.chat.guildRemote.pushEncourage.toServer(chatSid, userGuild.guildCode, result);
|
||||
await sendMessageToGuildWithSuc(userGuild.guildCode, PUSH_ROUTE.GUILD_BOSS_ENCOURAGE, result);
|
||||
return resResult(STATUS.SUCCESS, result);
|
||||
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ import { Application, BackendSession, ChannelService, HandlerService, } from 'pi
|
||||
import { resResult, getRandEelm, shouldRefresh, sortArrRandom } from '../../../pubUtils/util';
|
||||
import { STATUS, GUILD_OPERATE, GUILD_AUTH, GUILD_JOB, GUILD_APPLY_TYPE, GUILD_STRUCTURE, GUILD_REC_TYPE, GUILD_STRUCTURE_NAME, MAIL_TYPE, REDIS_KEY, GUILD_SELECT, USER_GUILD_SELECT, TASK_TYPE, DEBUG_MAGIC_WORD, CHANNEL_PREFIX, MSG_TYPE, MSG_SOURCE, ITEM_CHANGE_REASON, TA_EVENT, GUILD_DISMISS_WAY, GUILD_MASTER_CHANGE_WAY, GUILD_QUIT_WAY } from '../../../consts';
|
||||
import { UserGuildModel, UserGuildType } from '../../../db/UserGuild';
|
||||
import { checkAuth, joinGuild, getGuildWithRefActive, getUserGuildWithRefActive, addActive, settleGuildWeekly, getMyGuildInfo, refreshUserGuild, setUserGuildSession, getInvitationList } from '../../../services/guildService';
|
||||
import { checkAuth, joinGuild, getGuildWithRefActive, getUserGuildWithRefActive, addActive, settleGuildWeekly, getMyGuildInfo, refreshUserGuild, setUserGuildSession, getInvitationList, addGuildRecord, pushChangeGuildLeader, pushGuildMemberQuit, pushGuildDismiss, pushGuildInfoUpdate } from '../../../services/guildService';
|
||||
import { GuildModel, GuildType, GuildUpdateParam } from '../../../db/Guild';
|
||||
import { RoleModel, RoleType } from '../../../db/Role';
|
||||
import { ARMY } from '../../../pubUtils/dicParam';
|
||||
@@ -92,9 +92,7 @@ export class GuildHandler {
|
||||
addRoleToGuildChannel(roleId, sid, guild.code);
|
||||
|
||||
// 添加动态
|
||||
const rec = await GuildRecModel.createGuildRec(roleId, guild.code, GUILD_REC_TYPE.JOIN_GUILD, [roleName]);
|
||||
let chatSid = await getGuildChannelSid(guild.code);
|
||||
this.app.rpc.chat.guildRemote.addRec.toServer(chatSid, rec);
|
||||
await addGuildRecord(roleId, guild.code, GUILD_REC_TYPE.JOIN_GUILD, [roleName]);
|
||||
|
||||
// 返回
|
||||
const result = { ...guild, rank, myInfo: { ...userGuild, isOnline: true } };
|
||||
@@ -150,8 +148,7 @@ export class GuildHandler {
|
||||
if(isAuto != undefined) updateInfo.isAuto = isAuto;
|
||||
if(icon != undefined) updateInfo.icon = icon;
|
||||
const guild = await GuildModel.updateInfo(code, updateInfo, {}, select.join(' '));
|
||||
let chatSid = await getGuildChannelSid(code);
|
||||
this.app.rpc.chat.guildRemote.updateInfo.toServer(chatSid, code, { name, notice, introduce, ceLimit, isAuto });
|
||||
await pushGuildInfoUpdate(code, { name, notice, introduce, ceLimit, isAuto });
|
||||
|
||||
if(name != undefined) {
|
||||
await updateUserInfo(REDIS_KEY.GUILD_INFO, code, [{ field: 'name', value: name }]);
|
||||
@@ -239,19 +236,17 @@ export class GuildHandler {
|
||||
|
||||
// 添加动态
|
||||
if (auth == GUILD_AUTH.MANAGER) {
|
||||
const rec = await GuildRecModel.createGuildRec(roleId, code, GUILD_REC_TYPE.SET_MANAGER, [role.roleName]);
|
||||
this.app.rpc.chat.guildRemote.updateInfo.toServer(chatSid, code, { managerCnt: guild.managerCnt });
|
||||
this.app.rpc.chat.guildRemote.addRec.toServer(chatSid, rec);
|
||||
await pushGuildInfoUpdate(code, { managerCnt: guild.managerCnt });
|
||||
await addGuildRecord(roleId, code, GUILD_REC_TYPE.SET_MANAGER, [role.roleName]);
|
||||
await sendMailByContent(MAIL_TYPE.GUILD_BE_SET_MANAGER, memberRoleId, { sendName: roleName, params: [guild.name] });
|
||||
} else if (auth == GUILD_AUTH.LEADER) {
|
||||
const rec = await GuildRecModel.createGuildRec(roleId, code, GUILD_REC_TYPE.SET_LEADER, [roleName, role.roleName]);
|
||||
this.app.rpc.chat.guildRemote.changeLeader.toServer(chatSid, code, guild.managerCnt, role, roleId);
|
||||
this.app.rpc.chat.guildRemote.addRec.toServer(chatSid, rec);
|
||||
await pushChangeGuildLeader(code, guild.managerCnt, role, roleId);
|
||||
await addGuildRecord(roleId, code, GUILD_REC_TYPE.SET_LEADER, [roleName, role.roleName]);
|
||||
await sendMailByContent(MAIL_TYPE.GUILD_BE_SET_LEADER, memberRoleId, { sendName: roleName, params: [guild.name] });
|
||||
|
||||
reportTAEvent(roleId, TA_EVENT.GUILD_MASTER_CHANGE, { way: GUILD_MASTER_CHANGE_WAY, change_id_after: memberRoleId }, ip);
|
||||
} else {
|
||||
this.app.rpc.chat.guildRemote.updateInfo.toServer(chatSid, code, { managerCnt: guild.managerCnt });
|
||||
await pushGuildInfoUpdate(code, { managerCnt: guild.managerCnt });
|
||||
await sendMailByContent(MAIL_TYPE.GUILD_BE_SET_MEMBER, memberRoleId, { sendName: roleName, params: [guild.name] });
|
||||
}
|
||||
|
||||
@@ -317,12 +312,10 @@ export class GuildHandler {
|
||||
}
|
||||
|
||||
// 添加动态
|
||||
const rec = await GuildRecModel.createGuildRec(roleId, code, GUILD_REC_TYPE.JOIN_GUILD, [roleName]);
|
||||
await addGuildRecord(roleId, code, GUILD_REC_TYPE.JOIN_GUILD, [roleName]);
|
||||
// 更新人数增加
|
||||
let chatSid = await getGuildChannelSid(code);
|
||||
await pushGuildInfoUpdate(code, { memberCnt: joinResult.memberCnt, guildCe: joinResult.guildCe });
|
||||
|
||||
this.app.rpc.chat.guildRemote.updateInfo.toServer(chatSid, code, { memberCnt: joinResult.memberCnt, guildCe: joinResult.guildCe });
|
||||
this.app.rpc.chat.guildRemote.addRec.toServer(chatSid, rec);
|
||||
hasGuild = true;
|
||||
} else { // 不自动加入,插入申请表
|
||||
await UserGuildApplyModel.createUserGuildApply(role, guild, GUILD_APPLY_TYPE.APPLY);
|
||||
@@ -365,13 +358,10 @@ export class GuildHandler {
|
||||
for (let { roleId } of applyList) {
|
||||
const joinResult = await joinGuild(code, guild.name, guild.lv, roleId, serverId, session);
|
||||
if (joinResult.status == -1) continue;
|
||||
let chatSid = await getGuildChannelSid(code);
|
||||
// 更新人数增加
|
||||
this.app.rpc.chat.guildRemote.updateInfo.toServer(chatSid, code, { memberCnt: joinResult.memberCnt, guildCe: joinResult.guildCe });
|
||||
await pushGuildInfoUpdate(code, { memberCnt: joinResult.memberCnt, guildCe: joinResult.guildCe });
|
||||
// 添加动态
|
||||
const rec = await GuildRecModel.createGuildRec(roleId, code, GUILD_REC_TYPE.JOIN_GUILD, [joinResult.roleName]);
|
||||
this.app.rpc.chat.guildRemote.addRec.toServer(chatSid, rec);
|
||||
|
||||
await addGuildRecord(roleId, code, GUILD_REC_TYPE.JOIN_GUILD, [joinResult.roleName]);
|
||||
roleIds.push(roleId);
|
||||
}
|
||||
} else { // 拒绝申请,删除申请
|
||||
@@ -491,12 +481,10 @@ export class GuildHandler {
|
||||
return joinResult.resResult;
|
||||
}
|
||||
|
||||
let chatSid = await getGuildChannelSid(code);
|
||||
// 更新人数增加
|
||||
this.app.rpc.chat.guildRemote.updateInfo.toServer(chatSid, code, { memberCnt: joinResult.memberCnt, guildCe: joinResult.guildCe });
|
||||
await pushGuildInfoUpdate(code, { memberCnt: joinResult.memberCnt, guildCe: joinResult.guildCe });
|
||||
// 添加动态
|
||||
const rec = await GuildRecModel.createGuildRec(roleId, code, GUILD_REC_TYPE.JOIN_GUILD, [joinResult.roleName]);
|
||||
this.app.rpc.chat.guildRemote.addRec.toServer(chatSid, rec);
|
||||
await addGuildRecord(roleId, code, GUILD_REC_TYPE.JOIN_GUILD, [joinResult.roleName]);
|
||||
|
||||
code = guild.code;
|
||||
}
|
||||
@@ -572,11 +560,8 @@ export class GuildHandler {
|
||||
await this.app.rpc.connector.connectorRemote.setOtherUserGuildSession.broadcast(members.map(roleId => { return { roleId, userGuild: null } })); // 更新session
|
||||
|
||||
// 删除channel
|
||||
|
||||
let chatSid = await getGuildChannelSid(code);
|
||||
await guildDismisActivity(code, serverId);
|
||||
this.app.rpc.chat.guildRemote.dismiss.toServer(chatSid, code);
|
||||
|
||||
await pushGuildDismiss(code);
|
||||
let r = new Rank(REDIS_KEY.GUILD_ACTIVE_RANK, { serverId });
|
||||
await r.removeFromRank({ guildCode: code });
|
||||
let r2 = new Rank(REDIS_KEY.GUILD_LV_RANK, { serverId });
|
||||
@@ -613,10 +598,8 @@ export class GuildHandler {
|
||||
await removeBossRank(code, roleId);
|
||||
await removeTrainRank(code, roleId, guild.trainId);
|
||||
// 添加动态
|
||||
const rec = await GuildRecModel.createGuildRec(roleId, code, GUILD_REC_TYPE.QUIT_GUILD, [roleName]);
|
||||
let chatSid = await getGuildChannelSid(code);
|
||||
this.app.rpc.chat.guildRemote.addRec.toServer(chatSid, rec);
|
||||
this.app.rpc.chat.guildRemote.memberQuit.toServer(chatSid, code, roleId, guild, sid);
|
||||
await addGuildRecord(roleId, code, GUILD_REC_TYPE.QUIT_GUILD, [roleName]);
|
||||
await pushGuildMemberQuit(roleId, code, guild, sid);
|
||||
|
||||
setUserGuildSession(session, null);
|
||||
reportTAEvent(roleId, TA_EVENT.GUILD_QUIT, { name: guild.name, way: GUILD_QUIT_WAY.QUIT }, ip);
|
||||
@@ -646,14 +629,11 @@ export class GuildHandler {
|
||||
//删除排名信息
|
||||
await removeBossRank(code, roleId);
|
||||
await removeTrainRank(code, roleId, guild.trainId);
|
||||
let chatSid = await getGuildChannelSid(code);
|
||||
|
||||
const { isOnline, sid } = await getRoleOnlineInfo(memberRoleId);
|
||||
this.app.rpc.chat.guildRemote.memberQuit.toServer(chatSid, code, roleId, guild, sid);
|
||||
await pushGuildMemberQuit(roleId, code, guild, sid);
|
||||
|
||||
// 添加动态
|
||||
const rec = await GuildRecModel.createGuildRec(roleId, code, GUILD_REC_TYPE.QUIT_GUILD, [role.roleName]);
|
||||
this.app.rpc.chat.guildRemote.addRec.toServer(chatSid, rec);
|
||||
await addGuildRecord(roleId, code, GUILD_REC_TYPE.QUIT_GUILD, [role.roleName]);
|
||||
if(isOnline) {
|
||||
await this.app.rpc.connector.connectorRemote.setOtherUserGuildSession.toServer(sid,[{ roleId: memberRoleId, userGuild }]);
|
||||
changeGuildActivity('', serverId, memberRoleId, sid);
|
||||
@@ -717,11 +697,8 @@ export class GuildHandler {
|
||||
const guild = await GuildModel.updateInfo(code, { leader: topUser._id }, { managerCnt: managerCntInc }, 'managerCnt name'); // 如果有转让团长设置leader
|
||||
|
||||
// 添加动态
|
||||
let chatSid = await getGuildChannelSid(code);
|
||||
const rec = await GuildRecModel.createGuildRec(roleId, code, GUILD_REC_TYPE.IMPEACH, [oldRoleName, topUser.roleName]);
|
||||
this.app.rpc.chat.guildRemote.addRec.toServer(chatSid, rec);
|
||||
|
||||
this.app.rpc.chat.guildRemote.changeLeader.toServer(chatSid, code, guild.managerCnt, topUser, leaderRoleId);
|
||||
await addGuildRecord(roleId, code, GUILD_REC_TYPE.IMPEACH, [oldRoleName, topUser.roleName]);
|
||||
await pushChangeGuildLeader(code, guild.managerCnt, topUser, leaderRoleId);
|
||||
await sendMailByContent(MAIL_TYPE.GUILD_BE_IMPEACH, leaderRoleId, { sendName: roleName, params: [guild.name] });
|
||||
await sendMailByContent(MAIL_TYPE.GUILD_BE_SET_LEADER, topUser.roleId, { sendName: roleName, params: [guild.name] });
|
||||
|
||||
@@ -776,14 +753,12 @@ export class GuildHandler {
|
||||
const resultStructure = result.structure.find(cur => cur.id == id);
|
||||
|
||||
// 修改信息
|
||||
let chatSid = await getGuildChannelSid(code);
|
||||
this.app.rpc.chat.guildRemote.updateInfo.toServer(chatSid, code, { ...result });
|
||||
await pushGuildInfoUpdate(code, { ...result });
|
||||
await updateUserInfo(REDIS_KEY.GUILD_INFO, code, [{ field: 'lv', value: result.lv }]);
|
||||
|
||||
// 添加动态
|
||||
const structureName = GUILD_STRUCTURE_NAME.get(id);
|
||||
const rec = await GuildRecModel.createGuildRec(roleId, code, GUILD_REC_TYPE.STRUCTURE_UP, [structureName, resultStructure.lv.toString()]);
|
||||
this.app.rpc.chat.guildRemote.addRec.toServer(chatSid, rec);
|
||||
await addGuildRecord(roleId, code, GUILD_REC_TYPE.STRUCTURE_UP, [structureName, resultStructure.lv.toString()]);
|
||||
|
||||
// 军团频道聊天消息
|
||||
pushGuildUpStructureMsg(roleId, roleName, result, resultStructure);
|
||||
@@ -909,10 +884,7 @@ export class GuildHandler {
|
||||
const { guild, userGuild } = result;
|
||||
|
||||
let { activeDaily, activeWeekly } = guild;
|
||||
let chatSid = await getGuildChannelSid(code);
|
||||
|
||||
this.app.rpc.chat.guildRemote.updateInfo.toServer(chatSid, code, { activeDaily, activeWeekly });
|
||||
|
||||
await pushGuildInfoUpdate(code, { activeDaily, activeWeekly });
|
||||
return resResult(STATUS.SUCCESS, { activeDaily, activeWeekly, myInfo: userGuild });
|
||||
}
|
||||
|
||||
@@ -934,8 +906,7 @@ export class GuildHandler {
|
||||
// return resResult(STATUS.TOKEN_ERR);
|
||||
// }
|
||||
const guild = await GuildModel.updateInfo(code, {}, { fund: count }, 'fund');
|
||||
let chatSid = await getGuildChannelSid(code);
|
||||
this.app.rpc.chat.guildRemote.updateInfo.toServer(chatSid, code, { fund: guild.fund });
|
||||
await pushGuildInfoUpdate(code, { fund: guild.fund });
|
||||
return resResult(STATUS.SUCCESS, { code, fund: guild.fund });
|
||||
}
|
||||
|
||||
@@ -1001,10 +972,8 @@ export class GuildHandler {
|
||||
await removeBossRank(oldCode, roleId);
|
||||
await removeTrainRank(oldCode, roleId, guild.trainId);
|
||||
// 添加动态
|
||||
const rec = await GuildRecModel.createGuildRec(roleId, oldCode, GUILD_REC_TYPE.QUIT_GUILD, [roleName]);
|
||||
let chatSid = await getGuildChannelSid(oldCode);
|
||||
this.app.rpc.chat.guildRemote.addRec.toServer(chatSid, rec);
|
||||
this.app.rpc.chat.guildRemote.memberQuit.toServer(chatSid, oldCode, roleId, guild, sid);
|
||||
await addGuildRecord(roleId, oldCode, GUILD_REC_TYPE.QUIT_GUILD, [roleName]);
|
||||
await pushGuildMemberQuit(roleId, oldCode, guild, sid);
|
||||
|
||||
setUserGuildSession(session, userGuild);
|
||||
}
|
||||
@@ -1015,12 +984,9 @@ export class GuildHandler {
|
||||
}
|
||||
|
||||
// 添加动态
|
||||
const rec = await GuildRecModel.createGuildRec(roleId, code, GUILD_REC_TYPE.JOIN_GUILD, [roleName]);
|
||||
await addGuildRecord(roleId, code, GUILD_REC_TYPE.JOIN_GUILD, [roleName]);
|
||||
// 更新人数增加
|
||||
let chatSid = await getGuildChannelSid(code);
|
||||
|
||||
this.app.rpc.chat.guildRemote.updateInfo.toServer(chatSid, code, { memberCnt: joinResult.memberCnt, guildCe: joinResult.guildCe });
|
||||
this.app.rpc.chat.guildRemote.addRec.toServer(chatSid, rec);
|
||||
await pushGuildInfoUpdate(code, { memberCnt: joinResult.memberCnt, guildCe: joinResult.guildCe });
|
||||
return resResult(STATUS.SUCCESS, { code });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@ import { GuildTrainReportModel } from '../../../db/GuildTrainReport';
|
||||
import { DATA_NAME } from '../../../consts/dataName';
|
||||
import { pushGuildTrainSucMsg } from '../../../services/chatService';
|
||||
import { checkTaskInGuildTrain } from '../../../services/task/taskService';
|
||||
import { sendPopUpActivityData } from '../../../services/guildActivity/guildActivityService';
|
||||
import { guildInter, RewardInter } from '../../../pubUtils/interface';
|
||||
import { getGuildTrainGkInfo } from '../../../pubUtils/data';
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Application, ChannelService, BackendSession, HandlerService, } from "pinus";
|
||||
import { GUILD_ACTIVITY_TYPE, STATUS, GUILD_ACTIVITY_STATUS, GUILD_POINT_WAYS, REDIS_KEY, TASK_TYPE } from "../../../consts";
|
||||
import { GUILD_ACTIVITY_TYPE, STATUS, GUILD_ACTIVITY_STATUS, GUILD_POINT_WAYS, REDIS_KEY, TASK_TYPE, PUSH_ROUTE } from "../../../consts";
|
||||
import { resResult } from "../../../pubUtils/util";
|
||||
import { getGuildActivityStatus, getRaceActivityObj, getRaceActivityRank, getWoodenHorseList, calWoodenHorseAndSend, raceActivitySettleReward } from "../../../services/guildActivity/guildActivityService";
|
||||
import { UserGuildModel } from "../../../db/UserGuild";
|
||||
@@ -11,6 +11,7 @@ import { checkTask } from "../../../services/task/taskService";
|
||||
import { guildInter } from "../../../pubUtils/interface";
|
||||
import { getGuildChannelSid } from "../../../services/chatService";
|
||||
import { ServerRecordModel } from "../../../db/ServerRecords";
|
||||
import { sendMessageToGuildWithSuc } from "../../../services/pushService";
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
@@ -88,8 +89,8 @@ export class RaceActivityHandler {
|
||||
if (!woodenHorse) return resResult(STATUS.GUILD_AUTH_NOT_ENOUGH);
|
||||
|
||||
let events = obj.getEvents(guildCode, woodenHorse.distance);
|
||||
let chatSid = await getGuildChannelSid(guildCode);
|
||||
this.app.rpc.chat.guildRemote.pushRaceHorseJoin.toServer(chatSid, guildCode, woodenHorse);
|
||||
await sendMessageToGuildWithSuc(guildCode, PUSH_ROUTE.GUILD_RACE_JOIN, { timestamp: Date.now(), woodenHorse });
|
||||
|
||||
// 全服活跃统计
|
||||
await ServerRecordModel.addActiveGuild(serverId, guildCode);
|
||||
// 任务
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Application, ChannelService, HandlerService, } from 'pinus';
|
||||
import { sendAllGuildRanks, sendGuildActEndMsg, calWoodenHorseAndSend, sendRaceStartMsg, setDicGuildActivity, setDicAuctionTime } from '../../../services/guildActivity/guildActivityService';
|
||||
import { sendAllGuildRanks, calWoodenHorseAndSend, sendRaceStartMsg, setDicGuildActivity, setDicAuctionTime, settleGuildActivityReward } from '../../../services/guildActivity/guildActivityService';
|
||||
import { gameData } from '../../../pubUtils/data';
|
||||
import { setWeek } from '../../../pubUtils/timeUtil';
|
||||
import { sendUngotDividend } from '../../../services/auctionService';
|
||||
@@ -14,10 +14,8 @@ export class GuildActivityRemote {
|
||||
|
||||
constructor(private app: Application) {
|
||||
this.app = app;
|
||||
this.channelService = app.get('channelService');
|
||||
}
|
||||
|
||||
private channelService: ChannelService;
|
||||
private currentTime: number = Date.now();
|
||||
private setTime: number = Date.now();
|
||||
|
||||
@@ -37,7 +35,7 @@ export class GuildActivityRemote {
|
||||
*/
|
||||
public async guildActivityEnd(aid: number) {
|
||||
try {
|
||||
await sendGuildActEndMsg(aid);
|
||||
await settleGuildActivityReward(aid);
|
||||
} catch(e) {
|
||||
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||
}
|
||||
|
||||
@@ -13,11 +13,8 @@ export class GuildRemote {
|
||||
|
||||
constructor(private app: Application) {
|
||||
this.app = app;
|
||||
this.channelService = app.get('channelService');
|
||||
}
|
||||
|
||||
private channelService: ChannelService;
|
||||
|
||||
/**
|
||||
* 重载json资源
|
||||
*/
|
||||
|
||||
@@ -8,7 +8,6 @@ import { ComBattleRemote } from './battle/remote/comBattleRemote';
|
||||
import { BattleRemote } from './battle/remote/battleRemote';
|
||||
import { ConnectorRemote } from './connector/remote/connectorRemote';
|
||||
import { SystimerRemote } from './systimer/remote/systimerRemote';
|
||||
import { GuildRemote } from './chat/remote/guildRemote';
|
||||
import { GMRemote } from './gm/remote/gmRemote';
|
||||
import { RoleRemote } from './role/remote/roleRemote';
|
||||
import { GuildActivityRemote } from './guild/remote/guildActivityRemote';
|
||||
@@ -26,7 +25,6 @@ declare global {
|
||||
};
|
||||
chat: {
|
||||
chatRemote: RemoterClass<FrontendSession, ChatRemote>;
|
||||
guildRemote: RemoterClass<FrontendSession, GuildRemote>;
|
||||
};
|
||||
connector: {
|
||||
connectorRemote: RemoterClass<FrontendSession, ConnectorRemote>;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
130
game-server/app/services/pushService.ts
Normal file
130
game-server/app/services/pushService.ts
Normal file
@@ -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里面的维护服务器
|
||||
|
||||
@@ -6,7 +6,6 @@ const channelRemote_1 = require("../remote/frontend/channelRemote");
|
||||
const pinus_logger_1 = require("pinus-logger");
|
||||
const path = require("path");
|
||||
let logger = pinus_logger_1.getLogger('pinus', path.basename(__filename));
|
||||
let infoLogger = pinus_logger_1.getLogger('info', path.basename(__filename));
|
||||
/**
|
||||
* constant
|
||||
*/
|
||||
|
||||
@@ -88,3 +88,49 @@ export const ON_ADD_CHANNEL_ROUTE = 'onAddChannel';
|
||||
export const ON_LEAVE_CHANNEL_ROUTE = 'onLeaveChannel';
|
||||
|
||||
export const DEFAULT_MSG_PER_PAGE = 10;
|
||||
|
||||
|
||||
export const PUSH_ROUTE = {
|
||||
PRIVATE_MSG: 'onPrivateMessage',
|
||||
GROUP_MSG: 'onGroupMessage',
|
||||
ADD_CHANNEL: 'onAddChannel',
|
||||
LEAVE_CHANNEL: 'onLeaveChannel',
|
||||
GUILD_ACTIVITY_STATUS: 'onGuildActivityStatus',
|
||||
RANK_TOP_UPDATE: 'onRankTopUpdated',
|
||||
MAILS_ADD: 'onMailsAdd',
|
||||
SERVER_MAINTENANCE: 'onServerMaintenance',
|
||||
PUSH_CURRENT_TIME: 'onPushCurrentTime',
|
||||
AUCTION_OVER: 'onAuctionOver',
|
||||
AUCTION_UPDATE: 'onAuctionUpdate',
|
||||
AUCTION_ADD: 'onAuctionAdd',
|
||||
DIVIDEND_UPDATE: 'onDividendsUpdate',
|
||||
DIVIDEND_ADD: 'onDividendsAdd',
|
||||
MEMBER_QUIT: 'onMemberQuit',
|
||||
DISMISS: 'onDismiss',
|
||||
GUILD_INFO_UPDATE: 'onGuildInfoUpdate',
|
||||
DEMOTION: 'onDemotion',
|
||||
PROMOTION: 'onPromotion',
|
||||
GUILD_REC_ADD: 'onGuildRecAdd',
|
||||
GUILD_BOSS_OPEN: 'onGuildBossStatus',
|
||||
RACE_START: 'onRaceStart',
|
||||
GATE_ACT_RANK: 'onGuildGateRankUpdate', // 军团活动排行榜
|
||||
CITY_ACT_RANK: 'onGuildCityRankUpdate', // 军团活动排行榜
|
||||
GUILD_GATE_ACT_HP: 'onGuildGateHpUpdate', // 军团活动蛮夷入侵排行榜
|
||||
GUILD_ACTIVITY_END: 'onGuildActivityEnd', // 军团活动结束
|
||||
GUILD_CITY_DECLARE: 'onGuildCityDeclare', // 有军团对这个城池进行宣战了
|
||||
GUILD_CITY_ACT_HP: 'onGuildCityGateHpUpdate', // 诸侯入侵城门血条
|
||||
GUILD_RACE_UPDATE: 'onRaceHorseUpdate', /// 更新木牛流马
|
||||
GUILD_RACE_JOIN: 'onRaceHorseJoin',
|
||||
GUILD_RACE_EVENT: 'onRaceEventUpdate', /// 更新木牛流马
|
||||
GUILD_POP_UP_ACTIVITY: 'onActivityTaskUpdate', /// 向军团成员发送弹窗礼包
|
||||
GUILD_TRAIN_RESET: 'onGuildTainReset', // 试炼场重置
|
||||
GUILD_BOSS_ENCOURAGE: 'onGuildBossEncourage', // 鼓舞
|
||||
ACTIVITY_UPDATE: 'onActivityUpdate',
|
||||
TEAM_JOIN: 'onTeamJoin',
|
||||
TEAM_DISMISS: 'onTeamDismiss',
|
||||
TEAMMATE_READY: 'onTeammateReady',
|
||||
LEAVE_TEAM: 'onLeaveTeam',
|
||||
COMBATTLE_START: 'onComBtlStart',
|
||||
TEAM_COMPLETE: 'onTeamComplete',
|
||||
TEAMMATE_ACT: 'onTeammateAct',
|
||||
}
|
||||
@@ -21,8 +21,9 @@ export class MemComBtlTeam extends ComBattleTeam {
|
||||
bossCurHp: number;
|
||||
curRnd: number;
|
||||
bossHp: number;
|
||||
sid: string;
|
||||
|
||||
constructor(teamCode: string, pub: boolean, blueprtId: number, capId: string, ceLimit: number) {
|
||||
constructor(teamCode: string, pub: boolean, blueprtId: number, capId: string, ceLimit: number, sid: string) {
|
||||
super();
|
||||
const { lv } = getDicBlueprtById(blueprtId);
|
||||
this.lv = lv;
|
||||
@@ -40,5 +41,6 @@ export class MemComBtlTeam extends ComBattleTeam {
|
||||
this.bossCurHp = bossHpSum;
|
||||
this.bossHp = bossHpSum;
|
||||
this.blacklist = [];
|
||||
this.sid = sid;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user