bug fix: 关注任务获取奖励报错
This commit is contained in:
parent
bb28f444e1
commit
fcffa0260a
@ -32,12 +32,12 @@ export abstract class ITask {
|
|||||||
if (!cfg.score) {
|
if (!cfg.score) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
let claimAmount = task.data.claimAmount || 0
|
let claimAmount = task.data?.claimAmount || 0
|
||||||
let score = cfg.score
|
let score = cfg.score
|
||||||
if (user.boost > 1 && Date.now() < user.boostExpire.getTime()) {
|
if (user.boost > 1 && Date.now() < user.boostExpire.getTime()) {
|
||||||
score = Math.floor(score * user.boost)
|
score = Math.floor(score * user.boost)
|
||||||
}
|
}
|
||||||
let finishAmount = cfg.repeat > 1 ? task.data.finishAmount || 0 : 1
|
let finishAmount = cfg.repeat > 1 ? task.data?.finishAmount || 0 : 1
|
||||||
for (let i = claimAmount; i < Math.min(cfg.repeat, finishAmount); i++) {
|
for (let i = claimAmount; i < Math.min(cfg.repeat, finishAmount); i++) {
|
||||||
await updateRankScore({
|
await updateRankScore({
|
||||||
user: user.id,
|
user: user.id,
|
||||||
@ -52,7 +52,7 @@ export abstract class ITask {
|
|||||||
})
|
})
|
||||||
claimAmount += 1
|
claimAmount += 1
|
||||||
}
|
}
|
||||||
task.data.claimAmount = claimAmount
|
task.data = Object.assign(task.data || {}, { claimAmount })
|
||||||
task.markModified('data')
|
task.markModified('data')
|
||||||
if ((cfg.repeat > 1 && claimAmount >= cfg.repeat) || (cfg.repeat === 1 && claimAmount >= 1)) {
|
if ((cfg.repeat > 1 && claimAmount >= cfg.repeat) || (cfg.repeat === 1 && claimAmount >= 1)) {
|
||||||
task.status = TaskStatusEnum.CLAIMED
|
task.status = TaskStatusEnum.CLAIMED
|
||||||
|
Loading…
x
Reference in New Issue
Block a user