Skip to content

Feature request: Daily Task PLAY_WITH_EMOTIONS implementation #948

Description

@tickBit

What do you want to see in the API?

Version 2

Add support for the new server-tracked Daily Task PLAY_WITH_EMOTIONS.

The task should progress when a player sends clan chat messages with different chat feeling values.

Use the existing clan chat Feeling enum:

  • Happy
  • Sad
  • Neutral
  • Love
  • Thinking
  • Wink
  • Angry
  • None

None should be treated as "no feeling" and must not count toward this task.

Add a generic progress field to the Daily Task schema so server-tracked tasks can store partial progress without requiring task-specific schema changes later.

For example:

progress?: {
  steps?: number[];
};

For PLAY_WITH_EMOTIONS, each counted chat feeling should map to one numeric progress step. When all required feeling steps have been collected, the task is completed.

How do you think this should work?

The expected flow is:

  1. A clan has PLAY_WITH_EMOTIONS available as a Daily Task.
  2. A player reserves the task.
  3. The player opens clan chat and sends messages with different Feeling values.
  4. After each successful clan chat message, the server emits a Daily Task event for PLAY_WITH_EMOTIONS.
  5. The Daily Task handler checks whether the player has reserved PLAY_WITH_EMOTIONS.
  6. The submitted chat Feeling is mapped to a numeric progress step.
  7. If the step is missing from task.progress.steps, the step is added and amountLeft is decremented.
  8. If the step already exists, the task does not progress again.
  9. When all required feeling steps have been collected and amountLeft reaches zero, the task is completed through the existing Daily Task completion flow.

Suggested mapping:

const PLAY_WITH_EMOTIONS_STEPS: Record<Feeling, number | null> = {
  [Feeling.HAPPY]: 1,
  [Feeling.SAD]: 2,
  [Feeling.NEUTRAL]: 3,
  [Feeling.LOVE]: 4,
  [Feeling.THINKING]: 5,
  [Feeling.WINK]: 6,
  [Feeling.ANGRY]: 7,
  [Feeling.NONE]: null,
};

Implementation notes:

  • Add an optional generic progress field to the Daily Task schema:
progress?: {
  steps?: number[];
};
  • Give the field a default value of {} for new documents.
  • Existing Daily Task documents without progress must continue to work.
  • Missing progress should be treated as empty progress:
const steps = task.progress?.steps ?? [];
  • When ChatGateway.handleClanMessage() succeeds, emit a Daily Task event for PLAY_WITH_EMOTIONS.
  • Pass the submitted chat Feeling in the Daily Task event payload, for example:
{ feeling?: Feeling }
  • Add optional payload support to EventEmitterService.EmitNewDailyTaskEvent().
  • In DailyTasksService.handleDailyTaskEvent(), route PLAY_WITH_EMOTIONS to a dedicated handler.
  • The handler should:
    • find the current Daily Task reserved by the player
    • continue only if the reserved task is PLAY_WITH_EMOTIONS
    • ignore missing feeling values
    • ignore Feeling.NONE
    • map the feeling to a progress step number
    • ignore the event if the step already exists in progress.steps
    • otherwise add the step number to progress.steps
    • decrement amountLeft by one
    • complete the task through the existing DailyTaskProgressService flow when amountLeft reaches zero
    • avoid sending MQTT notifications when the task did not actually progress

Also make sure task reset clears old progress. The important place is DailyTasksService.deleteTask(), because the current implementation may replace an existing task document with a new random task instead of physically deleting the document. Old progress.steps must not leak into the next task.

Any additional info?

Also register PLAY_WITH_EMOTIONS in the Daily Task generation flow.

The project uses dailyTasksStartupRefresh.service.ts to refresh/create daily tasks on startup, and the available server-tracked tasks are generated through taskGenerator.service.ts.

Make sure PLAY_WITH_EMOTIONS is added to taskGenerator.service.ts, so it can be included when daily tasks are generated or refreshed.

The task configuration should use:

  • task name/type: PLAY_WITH_EMOTIONS
  • amount: 7
  • counted progress steps: all chat Feeling values except Feeling.NONE

Important distinction:

  • Feeling is used by clan chat messages.
  • PlayerEmotion is used by POST /player/emotion.

Although /player/emotion has this validation message:

{
  "message": "Emotion must be one of these: Sorrow, Anger, Joy, Playful, Love, Blank"
}

that endpoint is unrelated to this Daily Task. PLAY_WITH_EMOTIONS should be based on clan chat Feeling values because the task instruction tells the player to open clan chat.

The generic numeric progress.steps field is intentional. It allows future server-tracked daily tasks to store partial progress without adding new task-specific schema fields each time.

Acceptance criteria:

  • PLAY_WITH_EMOTIONS progresses through clan chat messages.
  • A valid chat Feeling other than None maps to a numeric progress step.
  • A new step decrements amountLeft by one.
  • The same step does not decrement amountLeft more than once.
  • None does not progress the task.
  • Missing feeling does not progress the task.
  • Existing Daily Task documents without progress do not break.
  • When a task is reset or regenerated into the same MongoDB document, old progress.steps is cleared.
  • The task completes through the existing Daily Task reward and MQTT notification flow.
  • No custom MQTT publishing is added to ChatGateway.
  • Daily Task MQTT notifications are sent only through the existing Daily Task flow.
  • PLAY_WITH_EMOTIONS is registered in taskGenerator.service.ts.
  • Startup refresh through dailyTasksStartupRefresh.service.ts can generate/create this task.

Suggested tests:

  • a valid new chat feeling adds the matching step and decrements amountLeft by one
  • sending the same feeling again does not decrement amountLeft
  • None does not decrement amountLeft
  • missing feeling does not decrement amountLeft
  • the final missing step completes the task
  • an old Daily Task document without progress behaves like progress: {}
  • resetting or regenerating a task clears old progress.steps

About MQTT

Clan chat should only trigger the Daily Task progress check after a message has been handled successfully. After that, MQTT notifications must go through the existing Daily Task flow.

Use the existing progress handling:
this.progressService.handleProgress(progressResult, session);

That flow already uses DailyTaskNotifier to send the correct MQTT notifications.
Expected notification behavior:

  • when the task progresses but is not completed: DailyTaskNotifier.taskUpdated(...)
  • when the task is completed: DailyTaskNotifier.taskCompleted(...)
  • when clan-level completion needs to be broadcast: DailyTaskNotifier.taskCompletedForClan(...)

Do not send MQTT notifications if the task did not actually progress. For example, no MQTT notification should be sent when:

  • the feeling is missing
  • the feeling is None
  • the same feeling step was already used before

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureNew feature to add

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions