寻宝解散队伍
This commit is contained in:
@@ -204,6 +204,27 @@ export class ComBattleHandler {
|
||||
return resResult(STATUS.SUCCESS);
|
||||
}
|
||||
|
||||
async dismiss(msg: {teamCode: string}, session: BackendSession) {
|
||||
let roleId = session.get('roleId');
|
||||
let { teamCode } = msg;
|
||||
let teamStatus = this.teamMap.get(teamCode);
|
||||
if (!teamStatus || !teamStatus.roleIds || teamStatus.roleIds.indexOf(roleId) === -1) return resResult(STATUS.COM_BATTLE_TEAM_INVALID);
|
||||
if (roleId !== teamStatus.capId) return resResult(STATUS.COM_BATTLE_CAP_ONLY);
|
||||
|
||||
let team = await ComBattleTeamModel.removeTeam(teamCode);
|
||||
if (!team) return resResult(STATUS.COM_BATTLE_DISSMISS_ERR);
|
||||
|
||||
let rmSt = this.teamMap.delete(teamCode);
|
||||
if (!rmSt) return resResult(STATUS.COM_BATTLE_DISSMISS_ERR);
|
||||
|
||||
let channelService = this.app.get('channelService');
|
||||
let channel = channelService.getChannel(teamCode, false);
|
||||
channel.pushMessage('onTeamDismiss', {teamCode});
|
||||
channel.destroy();
|
||||
|
||||
return resResult(STATUS.SUCCESS);
|
||||
}
|
||||
|
||||
async startBattle(msg: {teamCode: string}, session: BackendSession) {
|
||||
let roleId = session.get('roleId');
|
||||
let { teamCode } = msg;
|
||||
|
||||
@@ -90,8 +90,9 @@ export const STATUS = {
|
||||
COM_BATTLE_ASSIST_NOT_ENOUGH: { code: 20618, simStr: '助战次数不足' },
|
||||
COM_BATTLE_ASSIST_LV_NOT_ENOUGH: { code: 20619, simStr: '助阵等级不够' },
|
||||
COM_BATTLE_RM_SELF: { code: 20620, simStr: '队长移除自己会解散队伍' },
|
||||
COM_BATTLE_RM_TEAMMATE_ERR: { code: 20620, simStr: '移除队友失败' },
|
||||
COM_BATTLE_CAN_NOT_RM: { code: 20620, simStr: '没有移除成员的权限' },
|
||||
COM_BATTLE_RM_TEAMMATE_ERR: { code: 20621, simStr: '移除队友失败' },
|
||||
COM_BATTLE_CAN_NOT_RM: { code: 20622, simStr: '没有移除成员的权限' },
|
||||
COM_BATTLE_DISSMISS_ERR: { code: 20623, simStr: '解散队伍异常' },
|
||||
|
||||
// 秘境 20700 - 20799
|
||||
DUNGEON_REFRESH_TIMES_LACK: { code: 20701, simStr: '购买次数不足' },
|
||||
|
||||
@@ -75,12 +75,17 @@ export default class ComBattleTeam extends BaseModel {
|
||||
}
|
||||
|
||||
public static async addRole(teamCode: string, roleStatus: RoleStatus, lean = true) {
|
||||
const team = await ComBattleTeamModel.findOneAndUpdate({ teamCode: teamCode }, {$push: {roleIds: roleStatus.roleId, roleStatus}}, {upsert: true, new: true}).lean(lean);
|
||||
const team = await ComBattleTeamModel.findOneAndUpdate({ teamCode }, {$push: {roleIds: roleStatus.roleId, roleStatus}}, {upsert: true, new: true}).lean(lean);
|
||||
return team;
|
||||
}
|
||||
|
||||
public static async removeRole(teamCode: string, roleIdToRm: string, lean = true) {
|
||||
const team = await ComBattleTeamModel.findOneAndUpdate({ teamCode: teamCode }, {$pull: {roleIds: roleIdToRm, roleStatus: {roleId: roleIdToRm}}}, {new: true}).lean(lean);
|
||||
const team = await ComBattleTeamModel.findOneAndUpdate({ teamCode }, {$pull: {roleIds: roleIdToRm, roleStatus: {roleId: roleIdToRm}}}, {new: true}).lean(lean);
|
||||
return team;
|
||||
}
|
||||
|
||||
public static async removeTeam(teamCode: string, lean = true) {
|
||||
const team = await ComBattleTeamModel.findOneAndDelete({ teamCode }).lean(lean);
|
||||
return team;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user