StatsController - xEdziu/RPG-Handy-Helper GitHub Wiki

CpRedStatsController

This page contains documentation for the CpRedStatsController, which manages stats in the Cyberpunk Red RPG system.

Basic Information

Base Path: /api/v1/authorized
Package: dev.goral.rpghandyhelper.rpgSystems.cpRed.manual.stats

Authentication

All requests to this controller require an XSRF token to be included in the headers.
Example:

headers: {
  "X-XSRF-TOKEN": "<csrfToken>"
}

Endpoint Summary

HTTP Method Path Description
GET /rpgSystems/cpRed/cpRed/stats/all Returns basic info about all available stats
GET /rpgSystems/cpRed/stats/{statId} Returns detailed information about a specific stat by ID
GET /admin/rpgSystems/cpRed/stats/all Returns a full list of all stats types with administrative data
POST /admin/rpgSystems/cpRed/stats/add Adds a new stat type to the system
PUT /admin/rpgSystems/cpRed/stats/changeable/{statId} Change indicator
PUT /admin/rpgSystems/cpRed/stats/update/{statId} Update stat data

Field Descriptions

Request Body Fields (statDto)

  • name (String): Name of the stat. Required.
  • tag (String): Unique tag for the stat. Required.
  • changeable (Boolean): Indicates if the stat can be changed. Required.
  • description (String): Description of the stat. Required.

Response Fields

  • message (String): Describes the result of the operation.
  • error (Integer): HTTP status code.
  • timestamp (String): Time the response was generated.
  • stat (Object): A single stat object (if applicable).
  • statList (Array): List of stats (if applicable).

Endpoint Details

Get All stats

Method: GET
Path: /rpgSystems/cpRed/stats/all

Response

{
 "stats": [
{
"name": "Zwinność",
"tag": "ZW",
"description": "Zwinność określa zdolność postaci do wykonywania zwinnych ruchów, unikania ataków i wykonywania skomplikowanych manewrów."
}
],
"message": "Statystyki zostały pobrane.",
"error": 200,
"timestamp": "..."
}

Possible Errors

  • 401 Unauthorized: User is not logged in.

Get stat by ID

Method: GET
Path: /rpgSystems/cpRed/skils/{statId}

Response

{
 "stat": {
"name": "Zwinność",
"tag": "ZW",
"description": "Zwinność określa zdolność postaci do wykonywania zwinnych ruchów, unikania ataków i wykonywania skomplikowanych manewrów."
},
"message": "Statystyka została pobrana.",
"error": 200,
"timestamp": "..."
}

Possible Errors

  • 400 Bad Request: Invalid stat ID.
  • 401 Unauthorized: User is not logged in.
  • 404 Not Found: stat with the specified ID does not exist.

Get All stats with Admin Data

Method: GET
Path: admin/rpgSystems/cpRed/stats/all

Response

{
  "stats": [
    {
      "id": 1,
      "name": "Zwinność",
      "tag": "ZW",
      "changeable": false,
      "description": "Zwinność określa zdolność postaci do wykonywania zwinnych ruchów, unikania ataków i wykonywania skomplikowanych manewrów."
    }
  ],
  "message": "Statystyki zostały pobrane dla administratora.",
  "error": 200,
  "timestamp": "..."
}

Possible Errors

  • 401 Unauthorized: User is not logged in.
  • 403 Forbidden: User is not an admin.

Add New stat

Method: POST
Path: /admin/rpgSystems/cpRed/stat/add

Request

{
  "name": "Inteligencja",
  "tag": "INT",
  "changeable": true,
  "description": "Określa ogólną sprawność rozumowania. Według zasad to nie tylko czysta inteligencja, lecz także spryt, wiedza, spostrzegawczość i zdolność uczenia się"
}

Response

{
  "message": "Statystyka została dodana.",
  "error": 200,
  "timestamp": "..."
}

Possible Errors

  • 400 Bad Request: User not authenticated.
  • 401 Unauthorized: User not logged in.
  • 403 Forbidden: User is not an admin.
  • 404 Not Found: Invalid stat data.

Change Changeable Indicator

Method: PUT
Path: /admin/rpgSystems/cpRed/stats/changeable/{statId}

Response

{
  "message": "Zmienność statystyki została zmieniona.",
  "error": 200,
  "timestamp": "..."
}

Possible Errors

  • 400 Bad Request: Invalid stat ID.
  • 401 Unauthorized: User not logged in.
  • 403 Forbidden: User is not an admin.
  • 404 Not Found: stat with the specified ID does not exist.

Update stat

Method: PUT
Path: /admin/rpgSystems/cpRed/cyberwares/stat/{statId}

Request

{
  "tag": "INT",
  "description": "Inny opis"
}

Response

{
  "message": "Statystyka została zaktualizowana.",
  "error": 200,
  "timestamp": "..."
}

Possible Errors

  • 400 Bad Request: Invalid stat ID or data.
  • 401 Unauthorized: User not logged in.
  • 403 Forbidden: User is not an admin.
  • 404 Not Found: stat with the specified ID does not exist.

Common Troubleshooting Tips

  • Missing XSRF Token: Ensure the X-XSRF-TOKEN header is included in every request.
  • Invalid Fields: Double-check the request body for missing or invalid fields.
  • Permission Issues: Verify that the user has the necessary permissions for the requested operation.
⚠️ **GitHub.com Fallback** ⚠️