CharacterAmmunitionController - xEdziu/RPG-Handy-Helper GitHub Wiki

CpRedCharacterAmmunitionController

This page contains documentation for the CpRedCharacterAmmunitionController class, which handles character ammunition management for Cyberpunk Red.

Basic Information

Base Path: /api/v1/authorized
Package: dev.goral.rpgSystems.cpRed.characters.characterAmmunition

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 /games/cpRed/characters/ammunition/{characterId} Returns detailed information about a specific character ammunition by characterID
POST /games/cpRed/characters/ammunition/create Adds a new connection between ammunition type and character to the system
PUT /games/cpRed/characters/ammunition/update/{characterAmmunitionId} Update character ammunition data
DELETE /games/cpRed/characters/ammunition/delete/{characterAmmunitionId} Delete character ammunition data
GET /admin/games/cpRed/characters/ammunition/all Returns a full list of character ammunition type with administrative data

Field Descriptions

Request Body Fields (CharacterAmmunitionDto)

  • Id (Long): Unique identifier for the character ammunition. Required.
  • CharacterId (Long): Unique identifier for the character. Required.
  • AmmunitionId (Long): Unique identifier for the ammunition type. Required.
  • status (String): Status of the ammunition. Required. Possible values: EQUIPPED, STORED.
  • amount (Integer): Amount of ammunition available for the character. Required.

Response Fields

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

Endpoint Details

Get Ammunition by Character ID

Method: GET
Path: /games/cpRed/characters/ammunition/{characterId}

Response

{
  "message": "Amunicje postaci pobrane pomyślnie",
  "error": 200,
  "timestamp": "...",
  "characterAmmunition": [
    {
      "id": 1,
      "characterId": 2,
      "ammunitionId": 2,
      "status": "EQUIPPED",
      "amount": 100
    }
  ]
}

Possible Errors

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

Add New Character Ammunition

Method: POST
Path: /games/cpRed/characters/ammunition/create

Request

{
  "characterId": "2",
  "ammunitionId": "2",
  "status": "EQUIPPED",
  "amount": 100
}

Response

{
  "message": "Amunicja została dodana do postaci",
  "error": 200,
  "timestamp": "..."
}

Possible Errors

  • 400 Bad Request: User not authenticated.
  • 401 Unauthorized: User not logged in.
  • 404 Not Found: Invalid character ammunition data.

Update Ammunition

Method: PUT
Path: /games/cpRed/characters/ammunition/update/{characterAmmunitionId}

Request

{
  "characterId": "2",
  "ammunitionId": "2",
  "status": "STORED",
  "amount": 50
}

Response

{
  "message": "Amunicja postaci została pomyślnie zmodyfikowana",
  "error": 200,
  "timestamp": "..."
}

Possible Errors

  • 400 Bad Request: Invalid character ammunition ID or data.
  • 401 Unauthorized: User not logged in.
  • 404 Not Found: Character ammunition with the specified ID does not exist.

Delete Character Ammunition

Method: DELETE Path: /games/cpRed/characters/ammunition/delete/{characterAmmunitionId}

Response

{
  "message": "Amunicja postaci została pomyślnie usunięta",
  "error": 200,
  "timestamp": "..."
}

Possible Errors

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

Get All Character Ammunition with Admin Data

Method: GET
Path: /admin/games/cpRed/characters/ammunition/all

Response

{
  "allCharacterAmmunition": [],
  "message": "Wszystkie amunicje postaci pobrane pomyślnie",
  "error": 200,
  "timestamp": "..."
}

Possible Errors

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

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** ⚠️