聊天:系统推送(精炼,合成套装或橙装)
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import { Application, BackendSession } from "pinus";
|
import { Application, BackendSession } from "pinus";
|
||||||
import { STATUS, EQUIP_STRENGTHEN_TYPE, CURRENCY_BY_TYPE, CURRENCY_TYPE, HERO_SYSTEM_TYPE, CONSUME_TYPE, GOOD_TYPE, HERO_GROW_MAX } from "../../../consts";
|
import { STATUS, EQUIP_STRENGTHEN_TYPE, CURRENCY_BY_TYPE, CURRENCY_TYPE, HERO_SYSTEM_TYPE, CONSUME_TYPE, GOOD_TYPE, HERO_GROW_MAX, MSG_SOURCE } from "../../../consts";
|
||||||
import { ItemInter } from "../../../pubUtils/interface";
|
import { ItemInter } from "../../../pubUtils/interface";
|
||||||
|
|
||||||
import { resResult, parseGoodStr, getRandomByLen, deepCopy, mergeSameGoods, getRandValueByMinMax, getRandEelm } from "../../../pubUtils/util";
|
import { resResult, parseGoodStr, getRandomByLen, deepCopy, mergeSameGoods, getRandValueByMinMax, getRandEelm } from "../../../pubUtils/util";
|
||||||
@@ -11,10 +11,11 @@ import Role from "../../../db/Role";
|
|||||||
import { calPlayerCeAndSave } from "../../../services/playerCeService";
|
import { calPlayerCeAndSave } from "../../../services/playerCeService";
|
||||||
import { getHeroJob, getGoodById, gameData, getSuit, getHeroEquipByClassId } from "../../../pubUtils/data";
|
import { getHeroJob, getGoodById, gameData, getSuit, getHeroEquipByClassId } from "../../../pubUtils/data";
|
||||||
import { EQUIP } from "../../../pubUtils/dicParam";
|
import { EQUIP } from "../../../pubUtils/dicParam";
|
||||||
import { ITID, SPEICAL_ITEM, RANDOM_SE_COUNT } from "../../../consts/constModules/itemConst";
|
import { ITID, SPEICAL_ITEM, RANDOM_SE_COUNT, QUALITY_TYPE } from "../../../consts/constModules/itemConst";
|
||||||
import { changeEquip, dressEquip, checkMaterialEnough, takeOffEquipAndCalPlayerCe } from "../../../services/equipService";
|
import { changeEquip, dressEquip, checkMaterialEnough, takeOffEquipAndCalPlayerCe } from "../../../services/equipService";
|
||||||
|
|
||||||
import { indexOf, findIndex } from 'underscore';
|
import { indexOf, findIndex } from 'underscore';
|
||||||
|
import { pushEquipComposeOrangeMsg, pushEquipComposeSuitMsg, pushEquipRefineSucMsg, pushNormalEquipMsg } from "../../../services/chatService";
|
||||||
|
|
||||||
export default function (app: Application) {
|
export default function (app: Application) {
|
||||||
return new EquipHandler(app);
|
return new EquipHandler(app);
|
||||||
@@ -41,6 +42,7 @@ export class EquipHandler {
|
|||||||
let roleId: string = session.get('roleId');
|
let roleId: string = session.get('roleId');
|
||||||
let roleName: string = session.get('roleName');
|
let roleName: string = session.get('roleName');
|
||||||
let sid: string = session.get('sid');
|
let sid: string = session.get('sid');
|
||||||
|
const serverId = session.get('serverId');
|
||||||
// 消耗材料
|
// 消耗材料
|
||||||
// 获得装备
|
// 获得装备
|
||||||
let { gid, originalEquip } = msg;
|
let { gid, originalEquip } = msg;
|
||||||
@@ -76,6 +78,12 @@ export class EquipHandler {
|
|||||||
|
|
||||||
let items = [{ id: gid, count: 1 }];
|
let items = [{ id: gid, count: 1 }];
|
||||||
let goods = await addItems(roleId, roleName, sid, items);
|
let goods = await addItems(roleId, roleName, sid, items);
|
||||||
|
if (targetGood.suitId) {
|
||||||
|
pushNormalEquipMsg(roleId, roleName, serverId, MSG_SOURCE.EQUIP_COMPOSE_SUIT, gid, targetGood.name);
|
||||||
|
}
|
||||||
|
if (targetGood.quality >= QUALITY_TYPE.ORANGE) {
|
||||||
|
pushNormalEquipMsg(roleId, roleName, serverId, MSG_SOURCE.EQUIP_COMPOSE_ORANGE, gid, targetGood.name);
|
||||||
|
}
|
||||||
return resResult(STATUS.SUCCESS, { goods });
|
return resResult(STATUS.SUCCESS, { goods });
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -208,7 +216,8 @@ export class EquipHandler {
|
|||||||
// 装备栏精炼
|
// 装备栏精炼
|
||||||
public async refine(msg: { hid: number, ePlaceId: number, material: { id: number, count: number }[] }, session: BackendSession) {
|
public async refine(msg: { hid: number, ePlaceId: number, material: { id: number, count: number }[] }, session: BackendSession) {
|
||||||
let roleId: string = session.get('roleId');
|
let roleId: string = session.get('roleId');
|
||||||
// let roleName: string = session.get('roleName');
|
let roleName: string = session.get('roleName');
|
||||||
|
let serverId = session.get('serverId');
|
||||||
let sid: string = session.get('sid');
|
let sid: string = session.get('sid');
|
||||||
|
|
||||||
let { hid, ePlaceId, material } = msg;
|
let { hid, ePlaceId, material } = msg;
|
||||||
@@ -267,6 +276,10 @@ export class EquipHandler {
|
|||||||
hid,
|
hid,
|
||||||
ePlace: [curEplace]
|
ePlace: [curEplace]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isSuccess) {
|
||||||
|
pushEquipRefineSucMsg(roleId, roleName, serverId, curEplace);
|
||||||
|
}
|
||||||
return resResult(STATUS.SUCCESS, { isSuccess, curHero });
|
return resResult(STATUS.SUCCESS, { isSuccess, curHero });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import { pinus } from 'pinus';
|
|||||||
import { CHANNEL_PREFIX, MSG_CODE_LEN, MSG_SOURCE, MSG_STATUS, MSG_TYPE, ON_GROUP_MSG_ROUTE, ON_MSG_ROUTE, RICH_TEXT_TABLE, RECENT_PRIVATE_CHATS_CNT, MAX_PRIVATE_MSGS, RECENT_GROUP_MSGS_CNT } from '../consts';
|
import { CHANNEL_PREFIX, MSG_CODE_LEN, MSG_SOURCE, MSG_STATUS, MSG_TYPE, ON_GROUP_MSG_ROUTE, ON_MSG_ROUTE, RICH_TEXT_TABLE, RECENT_PRIVATE_CHATS_CNT, MAX_PRIVATE_MSGS, RECENT_GROUP_MSGS_CNT } from '../consts';
|
||||||
import { addRedisChannel, getRoleOnlineInfo, redisChannelServer } from './redisService';
|
import { addRedisChannel, getRoleOnlineInfo, redisChannelServer } from './redisService';
|
||||||
import { crc32 } from 'crc';
|
import { crc32 } from 'crc';
|
||||||
import { HeroType } from '../db/Hero';
|
import { EPlace, HeroType } from '../db/Hero';
|
||||||
import { GuildType } from '../db/Guild';
|
import { GuildType } from '../db/Guild';
|
||||||
import { ChatInfoModel } from '../db/ChatInfo';
|
import { ChatInfoModel } from '../db/ChatInfo';
|
||||||
|
|
||||||
@@ -268,7 +268,7 @@ export async function pushGuildUpStructureMsg(roleId: string, roleName: string,
|
|||||||
if (!code || !structure || !isArray(structure)) return null;
|
if (!code || !structure || !isArray(structure)) return null;
|
||||||
const guild = pick(guildInfo, ['code', 'structure']);
|
const guild = pick(guildInfo, ['code', 'structure']);
|
||||||
const content = JSON.stringify({ roleId, roleName, guild });
|
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);
|
const msgData = await createGroupMsg(roleId, roleName, CHANNEL_PREFIX.GUILD, code, MSG_TYPE.RICH_TEXT, MSG_SOURCE.GUILD_STRUCTURE_LV_UP, content, null, null);
|
||||||
if (!msgData) return null;
|
if (!msgData) return null;
|
||||||
await pushGroupMsgToRoom(groupRoomId(CHANNEL_PREFIX.GUILD, code), msgData);
|
await pushGroupMsgToRoom(groupRoomId(CHANNEL_PREFIX.GUILD, code), msgData);
|
||||||
return msgData;
|
return msgData;
|
||||||
@@ -277,7 +277,7 @@ export async function pushGuildUpStructureMsg(roleId: string, roleName: string,
|
|||||||
export async function pushGuildTrainSucMsg(roleId: string, roleName: string, guildCode: string, hid: number) {
|
export async function pushGuildTrainSucMsg(roleId: string, roleName: string, guildCode: string, hid: number) {
|
||||||
if (!guildCode) return null;
|
if (!guildCode) return null;
|
||||||
const content = JSON.stringify({ hid });
|
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);
|
const msgData = await createGroupMsg(roleId, roleName, CHANNEL_PREFIX.GUILD, guildCode, MSG_TYPE.RICH_TEXT, MSG_SOURCE.GUILD_TRAIN_SUC, content, null, null);
|
||||||
if (!msgData) return null;
|
if (!msgData) return null;
|
||||||
await pushGroupMsgToRoom(groupRoomId(CHANNEL_PREFIX.GUILD, guildCode), msgData);
|
await pushGroupMsgToRoom(groupRoomId(CHANNEL_PREFIX.GUILD, guildCode), msgData);
|
||||||
return msgData;
|
return msgData;
|
||||||
@@ -286,12 +286,45 @@ export async function pushGuildTrainSucMsg(roleId: string, roleName: string, gui
|
|||||||
export async function pushGuildBossSucMsg(roleId: string, roleName: string, guildCode: string, bossInstance: BossInstanceType) {
|
export async function pushGuildBossSucMsg(roleId: string, roleName: string, guildCode: string, bossInstance: BossInstanceType) {
|
||||||
const boss = pick(bossInstance, ['warId', 'bossLv']);
|
const boss = pick(bossInstance, ['warId', 'bossLv']);
|
||||||
const content = JSON.stringify({ boss });
|
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);
|
const msgData = await createGroupMsg(roleId, roleName, CHANNEL_PREFIX.GUILD, guildCode, MSG_TYPE.RICH_TEXT, MSG_SOURCE.GUILD_BOSS_SUC, content, null, null);
|
||||||
if (!msgData) return null;
|
if (!msgData) return null;
|
||||||
await pushGroupMsgToRoom(groupRoomId(CHANNEL_PREFIX.GUILD, guildCode), msgData);
|
await pushGroupMsgToRoom(groupRoomId(CHANNEL_PREFIX.GUILD, guildCode), msgData);
|
||||||
return msgData;
|
return msgData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function pushEquipRefineSucMsg(roleId: string, roleName: string, serverId: number, eplace: Partial<EPlace>) {
|
||||||
|
const data = pick(eplace, ['id', 'lv', 'refineLv']);
|
||||||
|
const content = JSON.stringify({ eplace: data });
|
||||||
|
const msgData = await createGroupMsg(roleId, roleName, CHANNEL_PREFIX.SYS, `${serverId}`, MSG_TYPE.RICH_TEXT, MSG_SOURCE.EQUIP_REFINE_SUC, content, null, null);
|
||||||
|
if (!msgData) return null;
|
||||||
|
await pushGroupMsgToRoom(groupRoomId(CHANNEL_PREFIX.SYS, serverId), msgData);
|
||||||
|
return msgData;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function pushNormalEquipMsg(roleId: string, roleName: string, serverId: number, source: number, id: number, name: string) {
|
||||||
|
const content = JSON.stringify({ id, name });
|
||||||
|
const msgData = await createGroupMsg(roleId, roleName, CHANNEL_PREFIX.SYS, `${serverId}`, MSG_TYPE.RICH_TEXT, source, content, null, null);
|
||||||
|
if (!msgData) return null;
|
||||||
|
await pushGroupMsgToRoom(groupRoomId(CHANNEL_PREFIX.SYS, serverId), msgData);
|
||||||
|
return msgData;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function pushEquipComposeSuitMsg(roleId: string, roleName: string, serverId: number, id: number, name: string) {
|
||||||
|
const content = JSON.stringify({ id, name });
|
||||||
|
const msgData = await createGroupMsg(roleId, roleName, CHANNEL_PREFIX.SYS, `${serverId}`, MSG_TYPE.RICH_TEXT, MSG_SOURCE.EQUIP_COMPOSE_SUIT, content, null, null);
|
||||||
|
if (!msgData) return null;
|
||||||
|
await pushGroupMsgToRoom(groupRoomId(CHANNEL_PREFIX.SYS, serverId), msgData);
|
||||||
|
return msgData;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function pushEquipComposeOrangeMsg(roleId: string, roleName: string, serverId: number, id: number, name: string) {
|
||||||
|
const content = JSON.stringify({ id, name });
|
||||||
|
const msgData = await createGroupMsg(roleId, roleName, CHANNEL_PREFIX.SYS, `${serverId}`, MSG_TYPE.RICH_TEXT, MSG_SOURCE.EQUIP_COMPOSE_SUIT, content, null, null);
|
||||||
|
if (!msgData) return null;
|
||||||
|
await pushGroupMsgToRoom(groupRoomId(CHANNEL_PREFIX.SYS, serverId), msgData);
|
||||||
|
return msgData;
|
||||||
|
}
|
||||||
|
|
||||||
export async function roleChatInfos(roleId: string, roleName: string) {
|
export async function roleChatInfos(roleId: string, roleName: string) {
|
||||||
let result = await ChatInfoModel.findInfo(roleId);
|
let result = await ChatInfoModel.findInfo(roleId);
|
||||||
if (!result) {
|
if (!result) {
|
||||||
@@ -344,4 +377,4 @@ export async function recentSysMsgs(serverId: number, count?: number) {
|
|||||||
export async function recentGuildMsgs(guildCode: string, count?: number) {
|
export async function recentGuildMsgs(guildCode: string, count?: number) {
|
||||||
const result = await recentGroupMsgs(groupRoomId(CHANNEL_PREFIX.GUILD, guildCode), count);
|
const result = await recentGroupMsgs(groupRoomId(CHANNEL_PREFIX.GUILD, guildCode), count);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,6 +33,9 @@ export const MSG_SOURCE = {
|
|||||||
GUILD_STRUCTURE_LV_UP: 7,
|
GUILD_STRUCTURE_LV_UP: 7,
|
||||||
GUILD_TRAIN_SUC: 8,
|
GUILD_TRAIN_SUC: 8,
|
||||||
GUILD_BOSS_SUC: 9,
|
GUILD_BOSS_SUC: 9,
|
||||||
|
EQUIP_REFINE_SUC: 10,
|
||||||
|
EQUIP_COMPOSE_SUIT: 11,
|
||||||
|
EQUIP_COMPOSE_ORANGE: 12,
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ON_MSG_ROUTE = 'onMessage';
|
export const ON_MSG_ROUTE = 'onMessage';
|
||||||
|
|||||||
Reference in New Issue
Block a user