From 1ae103eca89fa90aa7a66ca440317b8dc7dcfde5 Mon Sep 17 00:00:00 2001 From: CounterFire2023 <136581895+CounterFire2023@users.noreply.github.com> Date: Wed, 27 Mar 2024 17:24:01 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E7=AE=B1=E5=AD=90=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E6=97=B6,=E5=A6=82=E6=9E=9C=E7=AE=B1=E5=AD=90?= =?UTF-8?q?=E6=98=AF=E9=94=81=E5=AE=9A=E7=9A=84,=20=E9=82=A3=E4=B9=88?= =?UTF-8?q?=E6=A0=B9=E6=8D=AE=E6=9D=A1=E4=BB=B6=E5=88=A4=E6=96=AD,=20?= =?UTF-8?q?=E6=BB=A1=E8=B6=B3=E7=9A=84=E8=AF=9D,=20=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E8=A7=A3=E9=94=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/chest.controller.ts | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/controllers/chest.controller.ts b/src/controllers/chest.controller.ts index 3ecc530..1b2c5f0 100644 --- a/src/controllers/chest.controller.ts +++ b/src/controllers/chest.controller.ts @@ -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 } }