修改保存卡组逻辑, 默认卡组不能修改, 不占slot数

This commit is contained in:
zhl 2021-01-22 15:18:39 +08:00
parent 92b597684b
commit c656acb8fb

View File

@ -68,10 +68,18 @@ export default class CardController extends BaseController {
throw new ZError(103, '卡组已被删除') throw new ZError(103, '卡组已被删除')
} }
if (!record) { if (!record) {
let count = await CardGroup.count({accountid, isdefault: false, deleted: false})
let account = req.user
if (count >= account.slot) {
throw new ZError(105, '英雄可使用的卡槽数量不足')
}
record = new CardGroup() record = new CardGroup()
record.accountid = accountid record.accountid = accountid
record.isdefault = false record.isdefault = false
} }
if (record.isdefault) {
throw new ZError(104, '默认卡组不能修改')
}
if (selected) { if (selected) {
await CardGroup.updateMany({ await CardGroup.updateMany({
accountid, accountid,