Read-only demo.Generated sample data. Changes cannot be saved.

progression_grant_xp

progression_grant_xp POST YAML steps Enabled Public

Calls this month
0
Errors
0
Error rate
No calls yet
Avg response
No calls yet

This month, UTC.

Definition preview

Read-only outline of the saved source. Edit it under the Edit tab.

Input fields

amount
number

Pipeline (5)

  1. amount_ok assert
  2. player read collection progression_profile
  3. total transform {{player.xp|0}} + {{input.amount}}
  4. level transform floor({{total}} / max({{values.progression_config.xp_per_level}}, 1)) + 1
  5. save write collection progression_profile

Response

Status
200
Body
keys: success, xp, level
Full source
sourceVersion: 1
kind: endpoint
id: progression_grant_xp
name: Grant XP
description: Adds XP and recomputes the level on the server as floor(xp / xp_per_level) + 1.
method: POST
enabled: true
input:
  type: object
  properties:
    amount:
      type: number
  required:
  - amount
steps:
- id: amount_ok
  type: assert
  check:
    all:
    - field: input.amount
      op: '>'
      value: 0
    - field: input.amount
      op: <=
      value: '{{values.progression_config.max_grant_per_call}}'
  status: 422
  errorCode: INVALID_AMOUNT
  message: Amount must be positive and within the per-call limit.
- id: player
  type: read
  collection: progression_profile
  key: '{{steamId}}'
- id: total
  type: transform
  expression: '{{player.xp|0}} + {{input.amount}}'
- id: level
  type: transform
  expression: floor({{total}} / max({{values.progression_config.xp_per_level}}, 1)) + 1
- id: save
  type: write
  collection: progression_profile
  key: '{{steamId}}'
  ops:
  - op: set
    path: xp
    value: '{{total}}'
  - op: set
    path: level
    value: '{{level}}'
response:
  status: 200
  body:
    success: true
    xp: '{{total}}'
    level: '{{level}}'
module: progression

New endpoint

Choose an id using letters, numbers, underscore or hyphen. A fresh draft opens with this id; nothing is published until you save.

Confirm