聊天:推送部分军团消息
This commit is contained in:
@@ -14,6 +14,7 @@ import { checkAuth, addActive } from '../../../services/guildService';
|
||||
import { GuildModel } from '../../../db/Guild';
|
||||
import { getBossByLv } from '../../../pubUtils/data';
|
||||
import { lockData } from '../../../services/redLockService';
|
||||
import { pushGuildBossSucMsg } from '../../../services/chatService';
|
||||
|
||||
export default function (app: Application) {
|
||||
return new GuildHandler(app);
|
||||
@@ -137,6 +138,7 @@ export class GuildHandler {
|
||||
async action (msg: { damage: number, battleCode: string }, session: BackendSession ) {
|
||||
const { battleCode, damage } = msg;
|
||||
const roleId: string = session.get('roleId');
|
||||
const roleName: string = session.get('roleName');
|
||||
const serverId: number = parseInt(session.get('serverId'));
|
||||
let userGuild = await UserGuildModel.getMyGuild(roleId, 'guildCode');
|
||||
if (!userGuild)
|
||||
@@ -153,6 +155,7 @@ export class GuildHandler {
|
||||
if (!flag) {
|
||||
return resResult(STATUS.WRONG_PARMS);
|
||||
}
|
||||
pushGuildBossSucMsg(roleId, roleName, code, bossInstance);
|
||||
return resResult(STATUS.SUCCESS, { bossHp: 0 });
|
||||
} else {
|
||||
pushBossHpMessage(code, serverId, bossInstance.bossHp);
|
||||
|
||||
@@ -21,7 +21,7 @@ import { openGuildRefine } from '../../../services/guildRefineService';
|
||||
import { unlockTrain } from '../../../services/guildTrainService';
|
||||
import { removeBossRank } from '../../../services/guildBossService';
|
||||
import { removeTrainRank } from '../../../services/guildTrainService';
|
||||
import { pushGuildNoticeUpdateMsg } from '../../../services/chatService';
|
||||
import { pushGuildNoticeUpdateMsg, pushGuildUpStructureMsg } from '../../../services/chatService';
|
||||
export default function (app: Application) {
|
||||
return new GuildHandler(app);
|
||||
}
|
||||
@@ -735,6 +735,7 @@ export class GuildHandler {
|
||||
async upStructure(msg: { code: string, id: number }, session: BackendSession) {
|
||||
|
||||
const roleId = session.get('roleId');
|
||||
const roleName = session.get('roleName');
|
||||
const serverId = session.get('serverId');
|
||||
const sid = session.get('sid');
|
||||
const { code, id } = msg;
|
||||
@@ -778,6 +779,9 @@ export class GuildHandler {
|
||||
const rec = await GuildRecModel.createGuildRec(roleId, code, GUILD_REC_TYPE.STRUCTURE_UP, [structureName, resultStructure.lv.toString()]);
|
||||
this.app.rpc.chat.guildRemote.addRec.toServer(CHAT_SERVER,rec);
|
||||
|
||||
// 军团频道聊天消息
|
||||
pushGuildUpStructureMsg(roleId, roleName, result);
|
||||
|
||||
return resResult(STATUS.SUCCESS, result);
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ import { ARMY } from '../../../pubUtils/dicParam';
|
||||
import { addActive } from '../../../services/guildService';
|
||||
import { GuildTrainReportModel } from '../../../db/GuildTrainReport';
|
||||
import { DATA_NAME } from '../../../consts/dataName';
|
||||
import { pushGuildTrainSucMsg } from '../../../services/chatService';
|
||||
|
||||
export default function (app: Application) {
|
||||
return new GuildTrainHandler(app);
|
||||
@@ -238,6 +239,7 @@ export class GuildTrainHandler {
|
||||
//type 1:失败, 2:成功,3:表示系统战报即:被成功压制
|
||||
reports.push({ type: 3, time:nowSeconds(), score: addScore, roleName, trainId, hid, difficulty: battleRecord.record.difficulty });
|
||||
guildTrain = await unlockTrain(code, trainId + 1);
|
||||
pushGuildTrainSucMsg(roleId, roleName, code, hid);
|
||||
}
|
||||
res.releaseCallback();//解锁
|
||||
} else {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { BossInstanceType } from './../db/BossInstance';
|
||||
import { isString } from 'underscore';
|
||||
import { cloneDeep, pick } from 'lodash';
|
||||
import { cloneDeep, isArray, pick } from 'lodash';
|
||||
import { RoleModel } from './../db/Role';
|
||||
import { GroupMessageModel } from './../db/GroupMessage';
|
||||
import { CounterModel } from './../db/Counter';
|
||||
@@ -13,6 +14,7 @@ import { addRedisChannel, getRoleOnlineInfo, redisChannelServer } from './redisS
|
||||
import { crc32 } from 'crc';
|
||||
import { HeroType } from '../db/Hero';
|
||||
import { GuildType } from '../db/Guild';
|
||||
import { GuildTrainType } from '../db/GuildTrain';
|
||||
|
||||
/**
|
||||
* @description 生成私聊房间号
|
||||
@@ -241,3 +243,32 @@ export async function pushGuildNoticeUpdateMsg(roleId: string, roleName: string,
|
||||
await pushGroupMsgToRoom(groupRoomId(CHANNEL_PREFIX.GUILD, code), msgData);
|
||||
return msgData;
|
||||
}
|
||||
|
||||
export async function pushGuildUpStructureMsg(roleId: string, roleName: string, guildInfo: Partial<GuildType>) {
|
||||
const { code, structure } = guildInfo;
|
||||
if (!code || !structure || !isArray(structure)) return null;
|
||||
const guild = pick(guildInfo, ['code', 'structure']);
|
||||
const content = JSON.stringify({ roleId, roleName, guild });
|
||||
const msgData = await createGroupMsg(roleId, roleName, CHANNEL_PREFIX.GUILD, code, MSG_TYPE.TEXT, MSG_SOURCE.GUILD_STRUCTURE_LV_UP, content, null, null);
|
||||
if (!msgData) return null;
|
||||
await pushGroupMsgToRoom(groupRoomId(CHANNEL_PREFIX.GUILD, code), msgData);
|
||||
return msgData;
|
||||
}
|
||||
|
||||
export async function pushGuildTrainSucMsg(roleId: string, roleName: string, guildCode: string, hid: number) {
|
||||
if (!guildCode) return null;
|
||||
const content = JSON.stringify({ hid });
|
||||
const msgData = await createGroupMsg(roleId, roleName, CHANNEL_PREFIX.GUILD, guildCode, MSG_TYPE.TEXT, MSG_SOURCE.GUILD_TRAIN_SUC, content, null, null);
|
||||
if (!msgData) return null;
|
||||
await pushGroupMsgToRoom(groupRoomId(CHANNEL_PREFIX.GUILD, guildCode), msgData);
|
||||
return msgData;
|
||||
}
|
||||
|
||||
export async function pushGuildBossSucMsg(roleId: string, roleName: string, guildCode: string, bossInstance: BossInstanceType) {
|
||||
const boss = pick(bossInstance, ['warId', 'bossLv']);
|
||||
const content = JSON.stringify({ boss });
|
||||
const msgData = await createGroupMsg(roleId, roleName, CHANNEL_PREFIX.GUILD, guildCode, MSG_TYPE.TEXT, MSG_SOURCE.GUILD_BOSS_SUC, content, null, null);
|
||||
if (!msgData) return null;
|
||||
await pushGroupMsgToRoom(groupRoomId(CHANNEL_PREFIX.GUILD, guildCode), msgData);
|
||||
return msgData;
|
||||
}
|
||||
|
||||
@@ -27,6 +27,9 @@ export const MSG_SOURCE = {
|
||||
COMPOSE_ORANGE_HERO: 4,
|
||||
HERO_STAR_MAX: 5,
|
||||
GUILD_NOTICE: 6,
|
||||
GUILD_STRUCTURE_LV_UP: 7,
|
||||
GUILD_TRAIN_SUC: 8,
|
||||
GUILD_BOSS_SUC: 9,
|
||||
}
|
||||
|
||||
export const ON_MSG_ROUTE = 'onMessage';
|
||||
|
||||
Reference in New Issue
Block a user