寻宝:修复藏宝图占用的逻辑错误
This commit is contained in:
@@ -559,7 +559,7 @@ export async function hasEnoughBlueprt(roleId: string, blueprtId: number) {
|
|||||||
let blueprt = await ItemModel.findbyRoleAndGidAndCount(roleId, blueprtId, 1);
|
let blueprt = await ItemModel.findbyRoleAndGidAndCount(roleId, blueprtId, 1);
|
||||||
if (!blueprt) return false;
|
if (!blueprt) return false;
|
||||||
// 检查是否有已创建未结束的寻宝,预先占用一张藏宝图
|
// 检查是否有已创建未结束的寻宝,预先占用一张藏宝图
|
||||||
let teams = await ComBattleTeamModel.getTeamByCapAndStatus(roleId, COM_TEAM_STATUS.FIGHTING);
|
let teams = await ComBattleTeamModel.getBlueprtInUse(roleId, COM_TEAM_STATUS.FIGHTING, blueprtId);
|
||||||
if (teams && blueprt.count <= teams.length) return false;
|
if (teams && blueprt.count <= teams.length) return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -232,6 +232,11 @@ export default class ComBattleTeam extends BaseModel {
|
|||||||
return teams;
|
return teams;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static async getBlueprtInUse(roleId: string, status: number, blueprtId: number, lean = true) {
|
||||||
|
const teams: ComBattleTeamType[] = await ComBattleTeamModel.find({capId: roleId, status, blueprtId}).lean(lean);
|
||||||
|
return teams;
|
||||||
|
}
|
||||||
|
|
||||||
public static async getTeamByBlueprt(blueprtIds: number[], status: number, pub = true, limit = 50, lean = true) {
|
public static async getTeamByBlueprt(blueprtIds: number[], status: number, pub = true, limit = 50, lean = true) {
|
||||||
const teams: ComBattleTeamType[] = await ComBattleTeamModel.find({blueprtId: {$in: blueprtIds}, status, pub}).limit(limit).lean(lean);
|
const teams: ComBattleTeamType[] = await ComBattleTeamModel.find({blueprtId: {$in: blueprtIds}, status, pub}).limit(limit).lean(lean);
|
||||||
return teams;
|
return teams;
|
||||||
|
|||||||
Reference in New Issue
Block a user