What do you want to see in the API?
(Everything is ready to implement this now)
When a player cancels or relinquishes an active daily task, deduct 10 regular points from that player.
The result must be clamped to zero:
newPoints = Math.max(0, currentPoints - TASK_CONSTS.POINTS.DAILY_TASK.CANCEL_PENALTY);
TASK_CONSTS is located at src/dailyTasks/consts/taskConstants.ts
The existing successful 204 No Content response can remain unchanged.
How do you think this should work?
- Apply the penalty when a player-owned daily task is relinquished through:
PUT /dailyTasks/unreserve
DELETE /dailyTasks/:_id
- Read the penalty from
TASK_CONSTS.POINTS.DAILY_TASK.CANCEL_PENALTY.
- Deduct regular player
points, not battlePoints or clan points.
- Implement a dedicated point-deduction method in
PlayerRewarder. Do not pass a negative value to rewardForPlayerTask, because that method rejects negative rewards.
- Perform the task cancellation and point deduction in the same transaction.
- Use an atomic update that prevents the stored value from falling below zero.
- Deduct points only after confirming that the task exists and belongs to the requesting player.
- Do not deduct points for failed, unauthorized, repeated, or otherwise ineffective cancellation requests.
- Ensure concurrent requests cannot charge the same cancellation more than once.
- Add tests for both endpoints, the zero boundary, invalid ownership, repeated requests, and transaction rollback.
Any additional info?
Relevant implementation locations:
src/dailyTasks/dailyTasks.controller.ts
src/dailyTasks/dailyTasks.service.ts
src/rewarder/playerRewarder/playerRewarder.service.ts
src/dailyTasks/consts/taskConstants.ts
The player schema already defines regular points with a minimum value of zero, but the cancellation logic must also enforce the lower bound atomically rather than relying only on schema validation.
What do you want to see in the API?
(Everything is ready to implement this now)
When a player cancels or relinquishes an active daily task, deduct 10 regular points from that player.
The result must be clamped to zero:
TASK_CONSTSis located atsrc/dailyTasks/consts/taskConstants.tsThe existing successful
204 No Contentresponse can remain unchanged.How do you think this should work?
PUT /dailyTasks/unreserveDELETE /dailyTasks/:_idTASK_CONSTS.POINTS.DAILY_TASK.CANCEL_PENALTY.points, notbattlePointsor clan points.PlayerRewarder. Do not pass a negative value torewardForPlayerTask, because that method rejects negative rewards.Any additional info?
Relevant implementation locations:
src/dailyTasks/dailyTasks.controller.tssrc/dailyTasks/dailyTasks.service.tssrc/rewarder/playerRewarder/playerRewarder.service.tssrc/dailyTasks/consts/taskConstants.tsThe player schema already defines regular
pointswith a minimum value of zero, but the cancellation logic must also enforce the lower bound atomically rather than relying only on schema validation.