军团活动:蛮夷入侵定时任务及推送

This commit is contained in:
luying
2021-03-19 09:35:54 +08:00
parent 2cf3b0ffe0
commit 7e7be94688
11 changed files with 289 additions and 39 deletions
@@ -5,6 +5,7 @@ import { ON_ADD_CHANNEL_ROUTE, ON_GROUP_MSG_ROUTE, ON_LEAVE_CHANNEL_ROUTE, STATU
import { PrivateMessageType } from '../../../db/PrivateMessage';
import { addUserToChannel, getSimpleRoleInfo } from '../../../services/roleService';
import { ChannelUser } from '../../../domain/ChannelUser';
import { getWorldChannelSid } from '../../../services/chatService';
export default function (app: Application) {
return new ChatRemote(app);
@@ -29,6 +30,7 @@ export class ChatRemote {
}
private channelService: ChannelService;
private GUILD_ACTIVITY_END = 'onGuildActivityEnd';
/**
* 加入世界频道(分服).
@@ -163,4 +165,16 @@ export class ChatRemote {
public async sendPrivateMsg(msg: Partial<PrivateMessageType>) {
}
/**
* @description 全服推送活动结束通知
* @param serverId
*/
public async sendGuildActivityEnd(serverId: number) {
let roomId = await getWorldChannelSid(serverId);
let channel = this.channelService.getChannel(roomId, false);
if (!channel) return;
channel.pushMessage(this.GUILD_ACTIVITY_END, resResult(STATUS.SUCCESS, { }));
}
}
@@ -5,6 +5,7 @@ import { GuildType } from '../../../db/Guild';
import { RoleType } from '../../../db/Role';
import { GuildRecType } from '../../../db/GuildRec';
import { leaveGuildChannel, groupRoomId } from '../../../services/chatService';
import { GuildGateRankParam } from '../../../domain/battleField/guildActivity';
export default function (app: Application) {
return new GuildRemote(app);
@@ -161,7 +162,7 @@ export class GuildRemote {
* 向军团推送排行榜名次
* @param guildCode
*/
public pushRank(guildCode: string) {
public pushRank(guildCode: string, msg: GuildGateRankParam) {
this.pushMessage(guildCode, this.GUILD_ACT_RANK, msg);
}
}
@@ -1,5 +1,5 @@
import { Application, BackendSession, ChannelService } from "pinus";
import { setMedianCe, getMedianCe, getGuildActivityStatus, getRecordScore, getGuildActivityObj } from "../../../services/guildActivityService";
import { setMedianCe, getMedianCe, getGuildActivityStatus, getRecordScore, getGuildActivityObj, getGuildActivityRank } from "../../../services/guildActivityService";
import { resResult } from "../../../pubUtils/util";
import { STATUS, GUILD_ACTIVITY_TYPE, GUILD_POINT_WAYS, ENEMIES_TYPE, GET_POINT_WAYS } from "../../../consts";
import { GameModel } from "../../../db/Game";
@@ -45,33 +45,13 @@ export class GateActivityHandler {
let myGuildActivityRec = await UserGuildActivityRecModel.getRecord(roleId, roleName, guildCode, serverId, sourceCode, [], this.aid);
let { challengeCnt } = myGuildActivityRec;
// TODO 处理多余字段
let {ranks: guildRank, myRank: myGuildRank} = await getUnionRank(REDIS_KEY.GUILD_ACTIVITY, serverId, guildCode, 10);
let {ranks: memberRank, myRank: myMemberRank} = await getRank(getGuildKeyName(REDIS_KEY.USER_GUILD_ACTIVITY, guildCode), serverId, roleId);
if(!myGuildRank) {
let guild = await GuildModel.findByCode(guildCode, serverId, 'name');
myGuildRank = {
rank: 0,
code: guildCode,
name: guild.name,
num: 0
}
}
if(!myMemberRank) {
myMemberRank = {
rank: 0,
roleId,
roleName,
num: 0
}
}
let ranks = await getGuildActivityRank(guildCode, serverId, roleId, roleName);
return resResult(STATUS.SUCCESS, {
...statusResult,
challengeCnt: GUILDACTIVITY.GATEACTIVITY_CHALLENGE_TIMES - challengeCnt,
guildRank, myGuildRank,
memberRank, myMemberRank
})
...ranks
});
}
// 开启挑战
@@ -101,7 +81,7 @@ export class GateActivityHandler {
let { code, challengeCnt } = myGuildActivityRec;
// 更新公会参与的玩家
getGuildActivityObj(this.aid).pushMembers(guildCode, roleId);
getGuildActivityObj(this.aid).pushMembers(guildCode, serverId, roleId);
// 返回当前军团总军功
let guildScore = await getRankScore(REDIS_KEY.GUILD_ACTIVITY, serverId, guildCode);
@@ -0,0 +1,30 @@
import { Application, ChannelService } from 'pinus';
import { sendAllGuildRanks, sendGuildActEndMsg } from '../../../services/guildActivityService';
export default function (app: Application) {
return new GuildActivityRemote(app);
}
export class GuildActivityRemote {
constructor(private app: Application) {
this.app = app;
this.channelService = app.get('channelService');
}
private channelService: ChannelService;
/**
* 从systimer服分发到guild各个服,发送排行榜数据
*/
public async sendRankToGuilds() {
await sendAllGuildRanks();
}
/**
* 发送结束活动消息
*/
public async guildActivityEnd() {
await sendGuildActEndMsg();
}
}
@@ -11,6 +11,7 @@ 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/guildActivitRemote';
declare global {
interface UserRpc {
chat: {
@@ -32,6 +33,9 @@ declare global {
},
role: {
roleRemote: RemoterClass<FrontendSession, RoleRemote>;
},
guild: {
guildActivityRemote: RemoterClass<FrontendSession, GuildActivityRemote>;
}
}
}