-
Notifications
You must be signed in to change notification settings - Fork 1
GameController
Paulina Szulc edited this page Jun 23, 2025
·
1 revision
This page contains documentation for the GameController class, which handles game operations like creation, updates, player management, and retrieval for both users and admins.
Base Path: /api/v1/authorized
Package: dev.goral.rpghandyhelper.game
All endpoints require a valid XSRF token in headers:
headers: {
"X-XSRF-TOKEN": "<csrfToken>"
}
| HTTP Method | Path | Description |
|---|---|---|
| GET | /game/{gameId} |
Retrieve a specific game by its ID |
| GET | /game/allPlayers/{gameId} |
Retrieve all players in a specific game |
| GET | /game/userGames |
Retrieve all active games of the current user |
| POST | /game/create |
Create a new game |
| POST | /game/addUserToGame |
Add a user to a game (GMs only) |
| DELETE | /game/deleteUserFromGame |
Remove a user from a game (GMs only) |
| PUT | /game/updateGame/{gameId} |
Update game metadata |
| PUT | /game/changeStatus/{gameId} |
Change the status of a game |
| PUT | /game/updateGameUserRole/{gameUserId} |
Update a player's role in a game (GMs only) |
| GET | /admin/game/all |
Retrieve all games (admin only) |
- name (String): Game name. Required, max 255 characters.
- description (String): Optional description, max 500 characters.
- rpgSystem.id (Long): ID of the RPG system. Required.
- userId (Long): ID of user to add. Required.
- gameId (Long): ID of the game. Required.
-
role (String): Role to assign (
GAMEMASTER,PLAYER,SPECTATOR). Required.
- userId (Long): ID of user to remove. Required.
- gameId (Long): ID of the game. Required.
- Body:
{ "role": "NEW_ROLE" }whereNEW_ROLEisGAMEMASTER,PLAYER, orSPECTATOR.
- Body:
{ "status": "ACTIVE" | "DELETED" }
- message (String): Operation result.
- error (Integer): HTTP status code.
- timestamp (String): Generation time.
- Additional payload:
-
game,games,gameUsers,userGames, or result maps, depending on endpoint.
-
{
"id": 1,
"name": "title",
"description": "description",
"ownerId": 1,
"rpgSystemId": 1
}{
"id": 1,
"name": "title",
"description": "description",
"ownerId": 1,
"rpgSystemId": 1,
"status": "ACTIVE"
}{
"id": 1,
"rpgSystemId": 1,
"rpgSystemName": "System name",
"name": "Game name",
"description": "description"
}{
"id": 1,
"userId": 1,
"gameId": 1,
"role": "PLAYER"
}Method: GET
Path: /game/{gameId}
-
gameId(Long): ID of the game to retrieve.
{
"message": "Pobrano grę.",
"error": 200,
"timestamp": "...",
"game": { ... }
}-
404 Not Found: Game with given ID does not exist.
Method: GET
Path: /game/allPlayers/{gameId}
-
gameId(Long): ID of the game whose players are to be retrieved.
{
"gameUsers": [ ... ],
"message": "Pobrano listę użytkowników gry.",
"error": 200,
"timestamp": "..."
}-
404 Not Found: Game with given ID does not exist.
Method: GET
Path: /game/userGames
{
"message": "Pobrano listę gier użytkownika.",
"error": 200,
"timestamp": "...",
"games": [ ... ]
}-
401 Unauthorized: User is not authenticated.
Method: POST
Path: /game/create
-
GameDTO: JSON object containing game name and description.
{
"message": "Gra została utworzona.",
"error": 200,
"timestamp": "..."
}-
400 Bad Request: Missing name or invalid data. -
401 Unauthorized: User is not authenticated.
Method: POST
Path: /game/addUserToGame
-
GameUserDTO: JSON object with userId and gameId.
{
"message": "Użytkownik został dodany do gry.",
"error": 200,
"timestamp": "..."
}-
400 Bad Request: User already added or invalid game/user ID. -
403 Forbidden: User is not the Game Master. -
404 Not Found: Game or user does not exist.
Method: DELETE
Path: /game/deleteUserFromGame
-
GameUserDTO: JSON object with userId and gameId.
{
"message": "Użytkownik został usunięty z gry.",
"error": 200,
"timestamp": "..."
}-
400 Bad Request: User is not in the game. -
403 Forbidden: User is not the Game Master. -
404 Not Found: Game or user does not exist.
Method: PUT
Path: /game/updateGame/{gameId}
-
gameId(Long): ID of the game to update.
-
GameDTO: JSON object with updated game data.
{
"message": "Gra została zaktualizowana.",
"error": 200,
"timestamp": "..."
}-
400 Bad Request: Invalid game data. -
403 Forbidden: User is not the Game Master. -
404 Not Found: Game not found.
Method: PUT
Path: /game/changeStatus/{gameId}
-
gameId(Long): ID of the game to change status.
-
String: New status ("ACTIVE", "DELETED").
{
"message": "Status gry został zaktualizowany.",
"error": 200,
"timestamp": "..."
}-
400 Bad Request: Invalid status value. -
403 Forbidden: User is not the Game Master. -
404 Not Found: Game not found.
Method: PUT
Path: /game/updateGameUserRole/{gameUserId}
-
gameUserId(Long): ID of the GameUser entity.
-
String: New role ("GAMEMASTER", "PLAYER", "SPECTATOR").
{
"message": "Rola użytkownika gry została zaktualizowana.",
"error": 200,
"timestamp": "..."
}-
400 Bad Request: Invalid role value. -
403 Forbidden: User is not the Game Master. -
404 Not Found: GameUser not found.
Method: GET
Path: /admin/game/all
{
"games": [ ... ],
"message": "Pobrano wszystkie gry.",
"error": 200,
"timestamp": "..."
}-
403 Forbidden: User is not an admin.
-
Missing XSRF Token: Ensure the
X-XSRF-TOKENheader is included in every request. - Invalid Fields: Double-check the request body for missing or invalid fields.
- Permission Issues: Verify that the user is the owner of the note and the game is accessible.
-
Home
- GameNoteController
- SchedulerController
- UserController
- ForgotPasswordController
- RegisterController
- RpgSystemsController
- GameController
- GameRoomController
- AmmunitionController
- ArmorsController
- ClassesController
- CriticalInjuriesController
- CyberwaresController
- EquipmentsController
- SkillsController
- StatsController
- WeaponsController
- WeaponModsController
- CustomAmmunitionController
- CustomArmorsController
- CustomCriticalInjuriesController
- CustomCyberwaresController
- CustomEquipmentsController
- CustomWeaponModsController
- CustomWeaponsController
- CharacterAmmunitionController
- CharacterArmorController
- CharacterClassesController
- CharacterCriticalInjuriesController
- CharacterCustomAmmunitionController
- CharacterCustomArmorsController
- CharacterCustomCriticalInjuriesController
- CharacterCustomCyberwareController
- CharacterCustomEquipmentController
- CharacterCustomWeaponController
- CharacterCyberwareController
- CharacterEnemiesController
- CharacterEquipmentController
- CharacterFriendsController
- CharacterLifePathController
- CharacterOtherInfoController
- CharacterSkillsController
- CharacterStatsController
- CharacterTragicLoveStoryController
- CharacterWeaponsController
- CharacterWeaponModsController