Skip to content

Feature request: Deduct points when a daily task is cancelled #996

Description

@tickBit

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

featureNew feature to add

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions