寻宝战斗内状态同步接口;
修改寻宝组队bug
This commit is contained in:
@@ -80,6 +80,13 @@ export const STATUS = {
|
||||
COM_BATTLE_CE_LIMIT: { code: 20608, simStr: '战力不足' },
|
||||
COM_BATTLE_JOIN_ERR: { code: 20609, simStr: '加入队伍失败' },
|
||||
COM_BATTLE_NO_VALID_TEAM: { code: 20610, simStr: '没有合适的队伍' },
|
||||
COM_BATTLE_TEAM_INVALID: { code: 20611, simStr: '队伍异常' },
|
||||
COM_BATTLE_UPDATE_HEROES_ERR: { code: 20612, simStr: '更新阵容失败' },
|
||||
COM_BATTLE_CAP_ONLY: { code: 20613, simStr: '只有队长可以操作' },
|
||||
COM_BATTLE_TEAM_NO_READY: { code: 20614, simStr: '队友未准备好' },
|
||||
COM_BATTLE_RESULT_ERR: { code: 20615, simStr: '结算信息更新失败' },
|
||||
COM_BATTLE_NOT_START: { code: 20616, simStr: '寻宝未开始' },
|
||||
COM_BATTLE_ALREADY_START: { code: 20616, simStr: '寻宝已开始' },
|
||||
|
||||
// 秘境 20700 - 20799
|
||||
DUNGEON_REFRESH_TIMES_LACK: { code: 20701, simStr: '购买次数不足' },
|
||||
|
||||
@@ -7,7 +7,7 @@ export class RoleStatus {
|
||||
@prop({ required: true })
|
||||
isCap: boolean;
|
||||
@prop({ required: true, default: 0 })
|
||||
damageNum: number;
|
||||
totalDmg: number;
|
||||
// 战斗状态 0-挑战中 1-挑战成功 2-挑战失败
|
||||
@prop({ required: true, default: 0 })
|
||||
battleStatus: number;
|
||||
@@ -29,6 +29,9 @@ export class RoleStatus {
|
||||
// 前五战力
|
||||
@prop({ required: true, default: 0 })
|
||||
topFiveCe: number;
|
||||
// 是否准备
|
||||
@prop({ required: true, default: false })
|
||||
isReady: boolean;
|
||||
}
|
||||
|
||||
@index({ teamCode: 1 })
|
||||
@@ -51,7 +54,7 @@ export default class ComBattleTeam extends BaseModel {
|
||||
@prop({ required: true })
|
||||
blueprtId: number;
|
||||
|
||||
// 战斗状态 0:未开始,1:已开始,2:胜利,3:失败
|
||||
// 战斗状态 0:未开始,1:已开始,2:胜利,3:失败,4:已领奖
|
||||
@prop({ required: true, default: 0 })
|
||||
status: number;
|
||||
|
||||
@@ -76,6 +79,37 @@ export default class ComBattleTeam extends BaseModel {
|
||||
return team;
|
||||
}
|
||||
|
||||
public static async updateHeroes(teamCode: string, roleId: string, heroes: Array<number>, lean = true) {
|
||||
const team = await ComBattleTeamModel.findOneAndUpdate({ teamCode, 'roleStatus.roleId': roleId}, {$set: {'roleStatus.$.heroes': heroes}}, {new: true}).lean(lean);
|
||||
return team;
|
||||
}
|
||||
|
||||
public static async updateResult(teamCode: string, roleId: string, isSuccess: boolean, lean = true) {
|
||||
let team = await ComBattleTeamModel.findOne({teamCode}).select('status roleStatus');
|
||||
if (isSuccess === true) {
|
||||
team.status = 2;
|
||||
team.roleStatus.forEach(st => {
|
||||
if (st.battleStatus !== 2) {
|
||||
st.battleStatus = 1;
|
||||
}
|
||||
})
|
||||
} else if (isSuccess === false) {
|
||||
let loseCnt = 1;
|
||||
team.roleStatus.forEach(st => {
|
||||
if (st.battleStatus === 2 && st.roleId !== roleId) {
|
||||
loseCnt += 1;
|
||||
} else if (st.roleId === roleId && !st.battleStatus) {
|
||||
st.battleStatus = 2;
|
||||
}
|
||||
});
|
||||
if (loseCnt === team.roleStatus.length) {
|
||||
team.status = 3;
|
||||
}
|
||||
}
|
||||
await team.save();
|
||||
return team;
|
||||
}
|
||||
|
||||
public static async findTeamByCapAndStatus(roleId: string, status: number, lean = true) {
|
||||
const teams = await ComBattleTeamModel.find({capId: roleId, status}).lean(lean);
|
||||
return teams;
|
||||
|
||||
Reference in New Issue
Block a user