军团活动:诸侯混战露出的接口

This commit is contained in:
luying
2021-03-22 20:51:59 +08:00
parent a56a6cf2f3
commit ecb4b87abc
14 changed files with 550 additions and 87 deletions

View File

@@ -27,7 +27,9 @@ export class GuildRemote {
private GUILD_REC_ADD = 'onGuildRecAdd';
private GUILD_ACT_RANK = 'onGuildGateRankUpdate'; // 军团活动排行榜
private GUILD_GATE_ACT_HP = 'onGuildGateHpUpdate'; // 军团活动蛮夷入侵排行榜
private GUILD_ACTIVITY_END = 'onGuildActivityEnd';
private GUILD_ACTIVITY_END = 'onGuildActivityEnd'; // 军团活动结束
private GUILD_CITY_DECLARE = 'onGuildCityDeclare'; // 有军团对这个城池进行宣战了
private GUILD_CITY_ACT_HP = 'onGuildCityGateHpUpdate'; // 诸侯入侵城门血条
/**
* 封装军团相关channel名: 'guild'+guildCode
@@ -76,6 +78,31 @@ export class GuildRemote {
return channel
}
/**
* 诸侯混战按城池区分channel
* @param cityId 城池id
* @param create 是否创建channel
*/
private getCityChannel(cityId: number, create: boolean = false) {
let channelName = groupRoomId(CHANNEL_PREFIX.CITY, cityId);
let channel = this.channelService.getChannel(channelName, create);
return channel
}
/**
* 封装向channel发推送
* @param cityId 城池id
* @param path 推送地址
* @param message 推送信息
*/
private pushMessageToCity(cityId: number, path: string, message: any) {
let channel = this.getCityChannel(cityId);
if(!!channel) {
channel.pushMessage(path, resResult(STATUS.SUCCESS, message));
}
return channel
}
/**
* 踢出某个成员
* @param guildCode 军团code
@@ -163,8 +190,8 @@ export class GuildRemote {
* 向军团推送城门血量
* @param guildCode
*/
public pushGateHp(guildCode: string, msg: GuildGateRankParam) {
this.pushMessage(guildCode, this.GUILD_GATE_ACT_HP, msg);
public pushGateHp(guildCode: string, gateHp: number) {
this.pushMessage(guildCode, this.GUILD_GATE_ACT_HP, { gateHp });
}
/**
@@ -183,4 +210,29 @@ export class GuildRemote {
console.log("MSG END")
this.pushMessage(guildCode, this.GUILD_ACTIVITY_END, {});
}
/**
* @description 向城池推送有宣战
* @param cityId 城池
* @param declareGuildCode 宣战的军团code
* @param declareCount 宣战数量
*/
public async sendGuildCityDeclare(cityId: number, declareGuildCode: string, declareCount: number ) {
this.pushMessageToCity(cityId, this.GUILD_CITY_DECLARE, {
cityId,
declareGuildCode,
declareCount
});
}
/**
* @description 推送城池城门血条
* @param guildCode
*/
public async pushCityGateHp(cityId: number, gateHp: number ) {
this.pushMessageToCity(cityId, this.GUILD_CITY_ACT_HP, {
cityId,
gateHp
});
}
}