Skip to content

Feature request: Implement stronger_soldier as a two-step server-tracked daily task #973

Description

@tickBit

What do you want to see in the API?

The task should progress when the reserved player:

  1. Increases the attack value of their own defence soldier through PUT /customCharacter.
  2. Plays a battle afterwards, detected from the existing battle win/loss daily task event flow.

The API should send normal daily task MQTT progress/completion notifications:

  • Step 1 completed:
    /player/{playerId}/daily_task/stronger_soldier/update
  • Task completed after battle:
    /player/{playerId}/daily_task/stronger_soldier/end
  • Clan completion:
    /clan/{clanId}/daily_task/stronger_soldier/end
  • Possible milestone:
    /clan/{clanId}/daily_task/milestone/update

How do you think this should work?

Current code already has the useful pieces:

  • ServerTaskName.STRONGER_SOLDIER = 'stronger_soldier'
  • GET /customCharacter returns the logged-in player’s custom characters.
  • CustomCharacter.player_id identifies the owning player.
  • CustomCharacter.attack is returned as the current total attack value.
  • PUT /customCharacter updates character stats in CustomCharacterController.update.
  • Battle completion already emits ServerTaskName.GO_TO_BATTLE from GameEventsHandler.handleWinBattle and handleLoseBattle.

Suggested backend flow:

flowchart TD
    A[Reserved task: stronger_soldier] --> B[PUT /customCharacter]
    B --> C[Read previous CustomCharacter stats]
    C --> D[Update CustomCharacter]
    D --> E{Is this player's own defence soldier<br/>and did attack increase?}
    E -->|No| F[No stronger_soldier progress]
    E -->|Yes| G[Progress stronger_soldier step 1<br/>amountLeft 2 -> 1]
    G --> H[MQTT TASK_UPDATED]

    H --> I[Player plays battle]
    I --> J[Battle win/loss event]
    J --> K{Reserved stronger_soldier<br/>with step 1 already done?}
    K -->|No| L[No stronger_soldier completion]
    K -->|Yes| M[Complete stronger_soldier<br/>amountLeft 1 -> 0]
    M --> N[Player/clan rewards]
    N --> O[MQTT TASK_COMPLETED + CLAN_TASK_COMPLETED]
Loading

Implementation detail suggestion:

  • In CustomCharacterController.update / CustomCharacterService, compare the character’s previous attack value to the new attack value before/after update.
  • Only progress stronger_soldier if:
    • the logged-in player owns the character,
    • the active reserved daily task is stronger_soldier,
    • the updated character is a defence soldier,
    • attack increased.
  • Set stronger_soldier.amount = 2, so step 1 leaves amountLeft = 1.
  • Do not complete the task during the stat update.
  • On battle win/loss handling, complete stronger_soldier only if it is the player’s active reserved task and amountLeft === 1.
  • Preserve the existing GO_TO_BATTLE behavior for the normal go_to_battle task.

Any additional info?

Note that CustomCharacterService.addValues() adds base stats to stored stat deltas before returning characters. So attack comparison should be done carefully: either compare normalized total values or compare stored deltas consistently.

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