获取箱子列表时,如果箱子是锁定的, 那么根据条件判断, 满足的话, 自动解锁
This commit is contained in:
parent
24efac0604
commit
1ae103eca8
@ -20,9 +20,11 @@ class BoxController extends BaseController {
|
||||
@router('get /api/chest/list')
|
||||
async chestList(req) {
|
||||
const user = req.user
|
||||
const openRecord = await ChestRecord.find({ from: user.address.toLowerCase() })
|
||||
const chestIds = openRecord.map(record => record.chestId)
|
||||
const chestSet = new Set(chestIds)
|
||||
const openRecords = await ChestRecord.find({ from: user.address.toLowerCase() })
|
||||
const chestSet = new Set()
|
||||
openRecords.forEach(record => {
|
||||
chestSet.add(record.chestId)
|
||||
})
|
||||
const chests = await ActivityChest.find({
|
||||
activity: user.activity,
|
||||
user: user.id,
|
||||
@ -30,9 +32,18 @@ class BoxController extends BaseController {
|
||||
}).sort({
|
||||
level: -1,
|
||||
})
|
||||
for (let chest of chests) {
|
||||
// TODO:: 待规则确定后, 将符合条件的锁定的箱子解锁
|
||||
if (chest.status === 0) {
|
||||
if (user.allTaskFinished()) {
|
||||
chest.status = 1
|
||||
await chest.save()
|
||||
}
|
||||
}
|
||||
}
|
||||
const results = chests.map(chest => chest.toJson())
|
||||
for (let result of results) {
|
||||
if (chestSet.has(result.id)) {
|
||||
if (result.stat > 0 && chestSet.has(result.id)) {
|
||||
result.stat = 2
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user