寻宝:增加设置情谊助战的接口

This commit is contained in:
liangtongchuan
2021-01-25 20:23:49 +08:00
parent aa41523792
commit 11c5705a5f
3 changed files with 36 additions and 1 deletions

View File

@@ -306,7 +306,9 @@ export class ComBattleHandler {
return resResult(STATUS.COM_BATTLE_CE_LIMIT);
}
isFrd = await getFrd(roleId, quality);
if (!isFrd) {
isFrd = await getFrd(roleId, quality);
}
// 加入队伍
let roleStatus = new RoleStatus(roleId, roleName, false, isFrd, headHid, sHid, topFiveCe, lv);
const team = await ComBattleTeamModel.addRole(teamCode, roleStatus);
@@ -329,6 +331,33 @@ export class ComBattleHandler {
return resResult(STATUS.SUCCESS, { teamInfo: teamStatus});
}
/**
* @description 设置是否情谊助战
* @param {{teamCode: string, isFrd: boolean}} msg 队伍编号情谊助战要设置的值true 为情谊助战
* @param {BackendSession} session
* @returns
* @memberof ComBattleHandler
*/
async setFrdAssistance(msg: {teamCode: string, isFrd: boolean}, session: BackendSession) {
let roleId = session.get('roleId');
let { isFrd, teamCode } = msg;
const isFrdPre = isFrd;
let teamStatus = this.teamMap.get(teamCode);
if (!teamStatus || teamStatus.status !== COM_TEAM_STATUS.DEFAULT) return resResult(STATUS.COM_BATTLE_TEAM_INVALID);
if (teamStatus.capId === roleId) return resResult(STATUS.COM_BATTLE_SET_FRD_ERR);
if (!isFrd) {
isFrd = await getFrd(roleId, teamStatus.quality);
}
if (isFrd !== isFrdPre) {
return resResult(STATUS.COM_BATTLE_ASSIST_NOT_ENOUGH);
}
teamStatus.roleStatus.forEach(async st => {
st.isFrd = isFrd;
await ComBattleTeamModel.updateRoleStFrd(teamCode, roleId, isFrd);
});
return resResult(STATUS.SUCCESS, { teamCode, isFrd });
}
/**
* 获取队伍列表-deprecated
* @param msg

View File

@@ -106,6 +106,7 @@ export const STATUS = {
COM_BATTLE_REWARD_ERR: { code: 20627, simStr: '不能领取奖励' },
COM_BATTLE_REWARDED: { code: 20628, simStr: '奖励已领取' },
COM_BATTLE_HEROES_ERR: { code: 20629, simStr: '阵容异常' },
COM_BATTLE_SET_FRD_ERR: { code: 20630, simStr: '设置情谊助战异常' },
// 共斗藏宝图合成
COM_BLUEPRT_QUALITY_CANNOT_COMPOSE: { code: 20630, simStr: '该品质藏宝图不可合成' },

View File

@@ -144,6 +144,11 @@ export default class ComBattleTeam extends BaseModel {
return team;
}
public static async updateRoleStFrd(teamCode: string, roleId: string, isFrd: boolean, lean = true) {
const team: ComBattleTeamType = await ComBattleTeamModel.findOneAndUpdate({ teamCode, 'roleStatus.roleId': roleId }, { $set: {'roleStatus.$.isFrd': isFrd}}, {new: true}).lean(lean);
return team;
}
public static async removeTeam(teamCode: string, lean = true) {
const team: ComBattleTeamType = await ComBattleTeamModel.findOneAndDelete({ teamCode }).lean(lean);
return team;