奇遇推送优化,不需要每次传app直接使用pinus.app
This commit is contained in:
@@ -15,7 +15,7 @@ Filter.prototype.before = function (routeRecord: RouteRecord, msg: any, session:
|
||||
};
|
||||
|
||||
Filter.prototype.after = function (err: Error, routeRecord: RouteRecord, msg: any, session: FrontendOrBackendSession, resp: any, next: HandlerCallback) {
|
||||
return checkEvent(this.app, session).then(()=>{
|
||||
return checkEvent(session).then(()=>{
|
||||
next(err);
|
||||
}).catch(e => {
|
||||
console.error(e);
|
||||
|
||||
@@ -720,7 +720,7 @@ export class ComBattleHandler {
|
||||
|
||||
await ComBattleTeamModel.updateRewardSt(teamCode, roleId, true);
|
||||
const goods = await handleFixedReward(roleId, roleName, sid, roleSt.fixReward, 1);
|
||||
let actordata = await roleLevelup(roleId, warInfo.kingExp, this.app, session);// 主公升级经验
|
||||
let actordata = await roleLevelup(roleId, warInfo.kingExp, session);// 主公升级经验
|
||||
|
||||
return resResult(STATUS.SUCCESS, { battleGoods: goods, ...actordata, teamInfo: {status, teamCode, roleStatus, bossHpArr} });
|
||||
}
|
||||
|
||||
@@ -118,7 +118,7 @@ export class EventBattleHandler {
|
||||
session.push('eventStatus', () => {});
|
||||
}
|
||||
// 推送消息刷新
|
||||
await checkEvent(this.app, session, true);
|
||||
await checkEvent(session, true);
|
||||
return resResult(STATUS.SUCCESS, {
|
||||
isSuccess,
|
||||
eventCode: result.eventCode,
|
||||
|
||||
@@ -263,7 +263,7 @@ export class ExpeditionBattleHandler {
|
||||
let warReward = new WarReward(roleId, roleName, sid, battleId, isSuccess);
|
||||
let reward = await warReward.saveReward(1);
|
||||
|
||||
let actordata = await roleLevelup(roleId, isSuccess?warInfo.kingExp:0, this.app, session);// 主公升级经验
|
||||
let actordata = await roleLevelup(roleId, isSuccess?warInfo.kingExp:0, session);// 主公升级经验
|
||||
if(isSuccess) {
|
||||
// 更新下一关状态
|
||||
await ExpeditionWarRecordModel.updateStatus(expeditionCode, expeditionId + 1, EXPEDITION_WAR_RECORD_STATUS.WAITING);
|
||||
|
||||
@@ -189,8 +189,6 @@ export class NormalBattleHandler {
|
||||
return resResult(STATUS.BATTLE_ACTION_POINT_LACK);
|
||||
}
|
||||
|
||||
let channelService = this.app.get('channelService');
|
||||
|
||||
let warReward = new WarReward(roleId, roleName, sid, battleId, isSuccess);
|
||||
|
||||
let dailyNum = {};
|
||||
@@ -205,9 +203,9 @@ export class NormalBattleHandler {
|
||||
dailyNum = Object.assign(dailyNum, checkResult.data)
|
||||
} else if (warInfo.warType == WAR_TYPE.EVENT) {
|
||||
// 记录事件状态
|
||||
await setBattleStatus(this.app, session, roleId, battleId, isSuccess, battleCode);
|
||||
await setBattleStatus(session, roleId, battleId, isSuccess, battleCode);
|
||||
} else if (warInfo.warType == WAR_TYPE.TOWER) {
|
||||
let towerEndResult = await towerBattleEnd(channelService, sid, roleId, serverId, battleCode, battleId, isSuccess, heroes);
|
||||
let towerEndResult = await towerBattleEnd(sid, roleId, serverId, battleCode, battleId, isSuccess, heroes);
|
||||
if(towerEndResult) {
|
||||
if(towerEndResult.status == -1) {
|
||||
return towerEndResult.resResult;
|
||||
@@ -230,7 +228,7 @@ export class NormalBattleHandler {
|
||||
let {warStar} = await RoleModel.findByRoleId(roleId);
|
||||
let condition1 = warStar.find(cur => cur.id == battleId);
|
||||
if(!condition1) {
|
||||
await switchOnFunc(roleId, FUNC_OPT_TYPE.BATTLE_END, battleId, this.app, session);
|
||||
await switchOnFunc(roleId, FUNC_OPT_TYPE.BATTLE_END, battleId, session);
|
||||
warReward.setCondition(0, true);
|
||||
}
|
||||
// 是否首次3星
|
||||
@@ -248,7 +246,7 @@ export class NormalBattleHandler {
|
||||
}, true);
|
||||
let { status } = updateResult;
|
||||
|
||||
let actordata = await roleLevelup(roleId, isSuccess?warInfo.kingExp:0, this.app, session);// 主公升级经验
|
||||
let actordata = await roleLevelup(roleId, isSuccess?warInfo.kingExp:0, session);// 主公升级经验
|
||||
|
||||
// 返回值:
|
||||
// towerStatus: false-本层未通过, true-本层已通过
|
||||
@@ -309,7 +307,7 @@ export class NormalBattleHandler {
|
||||
let warReward = new WarReward(roleId, roleName, sid, battleId, true);
|
||||
let result = await warReward.saveReward(count);
|
||||
|
||||
let actordata = await roleLevelup(roleId, warInfo.kingExp * count, this.app, session)// 主公升级经验
|
||||
let actordata = await roleLevelup(roleId, warInfo.kingExp * count, session)// 主公升级经验
|
||||
|
||||
// 扫荡记录
|
||||
await BattleSweepRecordModel.saveBattleSweepRecordById(roleId, battleId, {
|
||||
|
||||
@@ -68,14 +68,14 @@ export class EntryHandler {
|
||||
session.on('closed', this.onUserLeave.bind(this));
|
||||
|
||||
let channelService = self.app.get('channelService');
|
||||
let channel = channelService.getChannel(`server-${role.serverId}`, true);
|
||||
let channel = channelService.getChannel(role.roleId, true);
|
||||
if (channel.getMembers().indexOf(role.roleId) === -1) {
|
||||
channel.add(role.roleId, self.app.get('serverId'));
|
||||
}
|
||||
|
||||
// put user into channel
|
||||
console.log(JSON.stringify(self.app.rpc.battle))
|
||||
await self.app.rpc.battle.battleRemote.add.route(session)(role.roleId, self.app.get('serverId'), role.serverId, true);
|
||||
// console.log(JSON.stringify(self.app.rpc.battle))
|
||||
// await self.app.rpc.battle.battleRemote.add.route(session)(role.roleId, self.app.get('serverId'), role.serverId, true);
|
||||
// let users = await self.app.rpc.chat.chatRemote.add.route(session)(role.roleId, self.app.get('serverId'), rid, true);
|
||||
let heros = await HeroModel.findByRole(role.roleId);
|
||||
let equips = await EquipModel.findbyRole(role.roleId);
|
||||
@@ -89,7 +89,7 @@ export class EntryHandler {
|
||||
role['apJson'] = apJson;
|
||||
role['ce'] = reduceCe(role.ce);
|
||||
|
||||
await switchOnFunc(role.roleId, FUNC_OPT_TYPE.LEVEL_UP, role.lv, self.app, session);
|
||||
await switchOnFunc(role.roleId, FUNC_OPT_TYPE.LEVEL_UP, role.lv, session);
|
||||
return resResult(STATUS.SUCCESS, { role });
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ export class EntryHandler {
|
||||
let channelService = this.app.get('channelService');
|
||||
let channel = channelService.getChannel(roleId, true);
|
||||
channel.leave(roleId, sid);
|
||||
this.app.rpc.battle.battleRemote.kick.route(session)(roleId, this.app.get('serverId'), serverId);
|
||||
// this.app.rpc.battle.battleRemote.kick.route(session)(roleId, this.app.get('serverId'), serverId);
|
||||
// this.app.rpc.chat.chatRemote.kick.route(session, true)(session.uid, this.app.get('serverId'), session.get('rid'));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user