聊天:部分系统推送(宝石和藏宝图合成,秘境遗迹首通,天梯指定关)
This commit is contained in:
@@ -4,9 +4,9 @@ import { difference } from 'underscore';
|
|||||||
* @Author: 梁桐川
|
* @Author: 梁桐川
|
||||||
* @Date: 2020-11-30 15:05:48
|
* @Date: 2020-11-30 15:05:48
|
||||||
* @Last Modified by: 梁桐川
|
* @Last Modified by: 梁桐川
|
||||||
* @Last Modified time: 2020-12-03 21:36:00
|
* @Last Modified time: 2021-03-10 20:15:30
|
||||||
*/
|
*/
|
||||||
import { IT_TYPE, CURRENCY_BY_TYPE, CURRENCY_TYPE, COM_TEAM_STATUS, COM_BTL_CONST, CONSUME_TYPE, COM_BTL_QUALITY, MSG_SOURCE } from './../../../consts';
|
import { IT_TYPE, CURRENCY_BY_TYPE, CURRENCY_TYPE, COM_TEAM_STATUS, COM_BTL_CONST, CONSUME_TYPE, COM_BTL_QUALITY, MSG_SOURCE, QUALITY_TYPE } from './../../../consts';
|
||||||
import { getGoodById, getBlueprtComposeByQuality, getBluePrtByQuality, getWarById, getWarIdByBlueprtId } from '../../../pubUtils/gamedata';
|
import { getGoodById, getBlueprtComposeByQuality, getBluePrtByQuality, getWarById, getWarIdByBlueprtId } from '../../../pubUtils/gamedata';
|
||||||
import Role, { RoleModel } from '../../../db/Role';
|
import Role, { RoleModel } from '../../../db/Role';
|
||||||
import { STATUS } from '../../../consts/statusCode';
|
import { STATUS } from '../../../consts/statusCode';
|
||||||
@@ -21,7 +21,7 @@ import { setAp } from '../../../services/actionPointService';
|
|||||||
import { roleLevelup } from '../../../services/normalBattleService';
|
import { roleLevelup } from '../../../services/normalBattleService';
|
||||||
import { addUserToChannel } from '../../../services/roleService';
|
import { addUserToChannel } from '../../../services/roleService';
|
||||||
import { ChannelUser } from '../../../domain/ChannelUser';
|
import { ChannelUser } from '../../../domain/ChannelUser';
|
||||||
import { pushComBtlTeamMsg } from '../../../services/chatService';
|
import { pushComBtlTeamMsg, pushNormalEquipMsg } from '../../../services/chatService';
|
||||||
|
|
||||||
export default function(app: Application) {
|
export default function(app: Application) {
|
||||||
return new ComBattleHandler(app);
|
return new ComBattleHandler(app);
|
||||||
@@ -674,6 +674,7 @@ export class ComBattleHandler {
|
|||||||
const roleId = session.get('roleId');
|
const roleId = session.get('roleId');
|
||||||
const roleName = session.get('roleName');
|
const roleName = session.get('roleName');
|
||||||
const sid = session.get('sid');
|
const sid = session.get('sid');
|
||||||
|
const serverId = session.get('serverId');
|
||||||
|
|
||||||
const { original } = msg;
|
const { original } = msg;
|
||||||
|
|
||||||
@@ -712,6 +713,10 @@ export class ComBattleHandler {
|
|||||||
const target = getRandomByLen(targetList);
|
const target = getRandomByLen(targetList);
|
||||||
const reward = [{id: target, count: 1}];
|
const reward = [{id: target, count: 1}];
|
||||||
const goods = await addItems(roleId, roleName, sid, reward);
|
const goods = await addItems(roleId, roleName, sid, reward);
|
||||||
|
if (dicCompose.targetQuality >= QUALITY_TYPE.ORANGE) {
|
||||||
|
const { name } = getGoodById(target);
|
||||||
|
pushNormalEquipMsg(roleId, roleName, serverId, MSG_SOURCE.ORANGE_BLUEPRT_COMPOSE, target, name);
|
||||||
|
}
|
||||||
|
|
||||||
return resResult(STATUS.SUCCESS, { goods, costGold: 0 });
|
return resResult(STATUS.SUCCESS, { goods, costGold: 0 });
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { BattleRecordModel } from '../../../db/BattleRecord';
|
|||||||
import { BattleSweepRecordModel } from '../../../db/BattleSweepRecord';
|
import { BattleSweepRecordModel } from '../../../db/BattleSweepRecord';
|
||||||
import { getWarById, } from '../../../pubUtils/gamedata';
|
import { getWarById, } from '../../../pubUtils/gamedata';
|
||||||
import { genCode } from '../../../pubUtils/util';
|
import { genCode } from '../../../pubUtils/util';
|
||||||
import { WAR_TYPE, EVENT_STATUS, FUNC_OPT_TYPE } from '../../../consts';
|
import { WAR_TYPE, EVENT_STATUS, FUNC_OPT_TYPE, MSG_SOURCE } from '../../../consts';
|
||||||
import { checkDaily, checkDailyAndIncrease } from '../../../services/dailyBattleService';
|
import { checkDaily, checkDailyAndIncrease } from '../../../services/dailyBattleService';
|
||||||
import { checkTowerWar, towerBattleEnd } from '../../../services/battleService';
|
import { checkTowerWar, towerBattleEnd } from '../../../services/battleService';
|
||||||
import { WarReward } from '../../../services/warRewardService';
|
import { WarReward } from '../../../services/warRewardService';
|
||||||
@@ -11,13 +11,13 @@ import { getAp, setAp } from '../../../services/actionPointService';
|
|||||||
import { setBattleStatus, checkEventBattle } from '../../../services/eventSercive';
|
import { setBattleStatus, checkEventBattle } from '../../../services/eventSercive';
|
||||||
import { STATUS } from '../../../consts/statusCode';
|
import { STATUS } from '../../../consts/statusCode';
|
||||||
import { resResult } from '../../../pubUtils/util';
|
import { resResult } from '../../../pubUtils/util';
|
||||||
import { HeroModel } from '../../../db/Hero';
|
|
||||||
import { RoleModel } from '../../../db/Role';
|
import { RoleModel } from '../../../db/Role';
|
||||||
import { RScriptRecordModel } from '../../../db/RScriptRecord';
|
import { RScriptRecordModel } from '../../../db/RScriptRecord';
|
||||||
import { updateWarStar, checkBattleHeroes, roleLevelup } from '../../../services/normalBattleService';
|
import { updateWarStar, checkBattleHeroes, roleLevelup } from '../../../services/normalBattleService';
|
||||||
import { checkDungeonNum, checkDungeonAndIncrease } from '../../../services/dungeonService';
|
import { checkDungeonNum, checkDungeonAndIncrease } from '../../../services/dungeonService';
|
||||||
import { switchOnFunc } from '../../../services/funcSwitchService';
|
import { switchOnFunc } from '../../../services/funcSwitchService';
|
||||||
import { gameData } from '../../../pubUtils/data';
|
import { gameData } from '../../../pubUtils/data';
|
||||||
|
import { pushMysteryFirstMsg, pushTowerMsg, pushVestigeFirstMsg, shouldPushTowerMsg } from '../../../services/chatService';
|
||||||
|
|
||||||
export default function(app: Application) {
|
export default function(app: Application) {
|
||||||
return new NormalBattleHandler(app);
|
return new NormalBattleHandler(app);
|
||||||
@@ -211,6 +211,7 @@ export class NormalBattleHandler {
|
|||||||
towerStatus = towerEndResult.data.towerStatus;
|
towerStatus = towerEndResult.data.towerStatus;
|
||||||
if(towerEndResult.data.towerReward)
|
if(towerEndResult.data.towerReward)
|
||||||
warReward.setFixReward(towerEndResult.data.towerReward)
|
warReward.setFixReward(towerEndResult.data.towerReward)
|
||||||
|
pushTowerMsg(roleId, roleName, serverId, MSG_SOURCE.TOWER_SUC, towerEndResult.data.newRec.lv);
|
||||||
}
|
}
|
||||||
} else if (warInfo.warType == WAR_TYPE.MYSTERY || warInfo.warType == WAR_TYPE.MYSTERY_ELITE) {
|
} else if (warInfo.warType == WAR_TYPE.MYSTERY || warInfo.warType == WAR_TYPE.MYSTERY_ELITE) {
|
||||||
let checkResult = await checkDungeonAndIncrease(roleId, 1, false);
|
let checkResult = await checkDungeonAndIncrease(roleId, 1, false);
|
||||||
@@ -228,6 +229,8 @@ export class NormalBattleHandler {
|
|||||||
if(!condition1) {
|
if(!condition1) {
|
||||||
await switchOnFunc(roleId, FUNC_OPT_TYPE.BATTLE_END, battleId, session);
|
await switchOnFunc(roleId, FUNC_OPT_TYPE.BATTLE_END, battleId, session);
|
||||||
warReward.setCondition(0, true);
|
warReward.setCondition(0, true);
|
||||||
|
pushMysteryFirstMsg(roleId, roleName, serverId, warInfo.warType, warInfo.war_id);
|
||||||
|
pushVestigeFirstMsg(roleId, roleName, serverId, warInfo.warType, warInfo.war_id);
|
||||||
}
|
}
|
||||||
// 是否首次3星
|
// 是否首次3星
|
||||||
if(star == 3 && (!condition1 || condition1.star != 3)) {
|
if(star == 3 && (!condition1 || condition1.star != 3)) {
|
||||||
|
|||||||
@@ -1,21 +1,20 @@
|
|||||||
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, MSG_SOURCE } from "../../../consts";
|
import { STATUS, EQUIP_STRENGTHEN_TYPE, CURRENCY_BY_TYPE, CURRENCY_TYPE, HERO_SYSTEM_TYPE, CONSUME_TYPE, HERO_GROW_MAX, MSG_SOURCE, JEWEL_PUSH_LV } 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, getRandValueByMinMax, getRandEelm } from "../../../pubUtils/util";
|
||||||
import { addItems, handleCost, decreaseItems } from "../../../services/rewardService";
|
import { addItems, handleCost, decreaseItems } from "../../../services/rewardService";
|
||||||
import { EquipModel, RandSe, EquipType } from "../../../db/Equip";
|
import { EquipModel, EquipType } from "../../../db/Equip";
|
||||||
import { HeroModel, EPlace } from "../../../db/Hero";
|
import { HeroModel, EPlace } from "../../../db/Hero";
|
||||||
import { ItemModel } from "../../../db/Item";
|
|
||||||
import Role from "../../../db/Role";
|
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, getHeroEquipByClassId } from "../../../pubUtils/data";
|
||||||
import { EQUIP } from "../../../pubUtils/dicParam";
|
import { EQUIP } from "../../../pubUtils/dicParam";
|
||||||
import { ITID, SPEICAL_ITEM, RANDOM_SE_COUNT, QUALITY_TYPE } from "../../../consts/constModules/itemConst";
|
import { ITID, SPEICAL_ITEM, 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";
|
import { pushEquipRefineSucMsg, pushNormalEquipMsg } from "../../../services/chatService";
|
||||||
|
|
||||||
export default function (app: Application) {
|
export default function (app: Application) {
|
||||||
return new EquipHandler(app);
|
return new EquipHandler(app);
|
||||||
@@ -584,6 +583,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 goodInfo = getGoodById(jewel);
|
let goodInfo = getGoodById(jewel);
|
||||||
let good = ITID.get(goodInfo.itid);
|
let good = ITID.get(goodInfo.itid);
|
||||||
if (good.type != CONSUME_TYPE.JEWEL)
|
if (good.type != CONSUME_TYPE.JEWEL)
|
||||||
@@ -604,6 +604,9 @@ export class EquipHandler {
|
|||||||
if (!!hasError)
|
if (!!hasError)
|
||||||
return resResult(STATUS.BATTLE_CONSUMES_NOT_ENOUGH);
|
return resResult(STATUS.BATTLE_CONSUMES_NOT_ENOUGH);
|
||||||
await addItems(roleId, roleName, sid, [{ id: jewel, count: count }]);
|
await addItems(roleId, roleName, sid, [{ id: jewel, count: count }]);
|
||||||
|
if (goodInfo.lvLimited >= JEWEL_PUSH_LV) {
|
||||||
|
pushNormalEquipMsg(roleId, roleName, serverId, MSG_SOURCE.JEWEL_COMPOSE, jewel, goodInfo.name);
|
||||||
|
}
|
||||||
return resResult(STATUS.SUCCESS);
|
return resResult(STATUS.SUCCESS);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import { PrivateMessageModel, PrivateMessageParam, PrivateMessageType } from './
|
|||||||
import { GroupMessageParam, GroupMessageType } from '../db/GroupMessage';
|
import { GroupMessageParam, GroupMessageType } from '../db/GroupMessage';
|
||||||
import { genCode, resResult } from '../pubUtils/util';
|
import { genCode, resResult } from '../pubUtils/util';
|
||||||
import { pinus } from 'pinus';
|
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, WAR_TYPE } from '../consts';
|
||||||
import { addRedisChannel, getRoleOnlineInfo, redisChannelServer } from './redisService';
|
import { addRedisChannel, getRoleOnlineInfo, redisChannelServer } from './redisService';
|
||||||
import { crc32 } from 'crc';
|
import { crc32 } from 'crc';
|
||||||
import { EPlace, HeroType } from '../db/Hero';
|
import { EPlace, HeroType } from '../db/Hero';
|
||||||
@@ -325,6 +325,35 @@ export async function pushEquipComposeOrangeMsg(roleId: string, roleName: string
|
|||||||
return msgData;
|
return msgData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function pushTowerMsg(roleId: string, roleName: string, serverId: number, source: number, lv: number) {
|
||||||
|
if (!shouldPushTowerMsg(lv)) return null;
|
||||||
|
const content = JSON.stringify({ lv });
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function pushGKFirstMsg(roleId: string, roleName: string, serverId: number, source: number, warType: number, warId: number) {
|
||||||
|
const content = JSON.stringify({ warType, warId });
|
||||||
|
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 pushMysteryFirstMsg(roleId: string, roleName: string, serverId: number, warType: number, warId: number) {
|
||||||
|
if (warType !== WAR_TYPE.MYSTERY) return null;
|
||||||
|
const result = await pushGKFirstMsg(roleId, roleName, serverId, MSG_SOURCE.MYSTERY_FIRST_SUC, warType, warId);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function pushVestigeFirstMsg(roleId: string, roleName: string, serverId: number, warType: number, warId: number) {
|
||||||
|
if (warType !== WAR_TYPE.VESTIGE) return null;
|
||||||
|
const result = await pushGKFirstMsg(roleId, roleName, serverId, MSG_SOURCE.VESTIGE_FIRST_SUC, warType, warId);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
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) {
|
||||||
@@ -378,3 +407,8 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function shouldPushTowerMsg(lv: number) {
|
||||||
|
// 100 层之后每 50 层触发
|
||||||
|
return lv >= 100 && lv % 50 === 0;
|
||||||
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ export const MSG_CODE_LEN = 8;
|
|||||||
export const RECENT_PRIVATE_CHATS_CNT = 20;
|
export const RECENT_PRIVATE_CHATS_CNT = 20;
|
||||||
export const RECENT_GROUP_MSGS_CNT = 10;
|
export const RECENT_GROUP_MSGS_CNT = 10;
|
||||||
export const MAX_PRIVATE_MSGS = 99;
|
export const MAX_PRIVATE_MSGS = 99;
|
||||||
|
export const JEWEL_PUSH_LV = 7;
|
||||||
|
|
||||||
export const MSG_STATUS = {
|
export const MSG_STATUS = {
|
||||||
NORMAL: 0,
|
NORMAL: 0,
|
||||||
@@ -36,6 +37,11 @@ export const MSG_SOURCE = {
|
|||||||
EQUIP_REFINE_SUC: 10,
|
EQUIP_REFINE_SUC: 10,
|
||||||
EQUIP_COMPOSE_SUIT: 11,
|
EQUIP_COMPOSE_SUIT: 11,
|
||||||
EQUIP_COMPOSE_ORANGE: 12,
|
EQUIP_COMPOSE_ORANGE: 12,
|
||||||
|
JEWEL_COMPOSE: 13,
|
||||||
|
ORANGE_BLUEPRT_COMPOSE: 14,
|
||||||
|
TOWER_SUC: 15,
|
||||||
|
MYSTERY_FIRST_SUC: 16,
|
||||||
|
VESTIGE_FIRST_SUC: 17,
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ON_MSG_ROUTE = 'onMessage';
|
export const ON_MSG_ROUTE = 'onMessage';
|
||||||
|
|||||||
Reference in New Issue
Block a user