This is the multi-page printable view of this section. Click here to print.

Return to the regular view of this page.

Game Service

Game Service

1 - Commands

Commands

Commands

The game service must manage the commands from the player because it owns the information about the round timer and can send the commands at the right time to the right services.

It owns a list of all robots, to verify, that players don’t sent commands for robots of other players.

The list is created by the information of the robot-create-events, so the service knows all the robots, that are owned by the players.

The commands from the players are stored in the game service and are sent to the other services, that fit the command-type during the execution phase.

The players receives an id, to find the right event, that informs him of the outcome of his command.

How does a command look like?

example command:

{
  "type": "buying",
  "data": {
    "robotId": "d290f1ee-6c54-4b01-90e6-d701748f0851",
    "itemName": "d290f1ee-6c54-4b01-90e6-d701748f0851",
    "itemQuantity": "d290f1ee-6c54-4b01-90e6-d701748f0851",
  },
}

response example

{
  "transactionId": "d290f1ee-6c54-4b01-90e6-d701748f0851"
}

2 - Game Loop

Game Loop

Game Loop

The current phases of the execution part of a round are these(for more information look in the technical views of robot and trading):

1. Trading
2. Moving
3. Repairing
4. Battleing
5. Mining
6. Regenerating

Events

Before a game

Before the start of a game there are these three game service related events.

  • Game Created

  • Player “name” joined the game. (optional, if no player joins then this event is not produced)

  • Excursus: The game world is created through a REST call to the map service. The game world is automatically sized to the created game maximal player and round amount.

POST

http://{defaultHost}/gameworlds

example request payload

{
  "gameworld": {
    "player_amount": 100,
    "round_amount": 1000
  }
}
  • The map service is producing an event for the created game world in the channel gameworld-created

example event payload

{
  "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
  "spacestation_ids": [
    "497f6eca-6276-4993-bfeb-53cbbbba6f08"
  ],
  "status": "active"
}
  • Game started

During a game

In the gameplay there is a loop of repeating events:

  • Round x started (With round x started event automatically begins the command collection phase, where all the players send their commands to the game service)

  • Command Input ended. (after this event the game service is distributing the commands as packages to the other services for every possible command type in the correct phase order. The services execute the commands directly after receiving it. The other services have no awareness about phases.)

  • Round x ended.(After this event a new round will start. Here you can adjust your strategy, after receiving all responses to all actions )

Game ending

The final event is:

  • Game ended (with this event a game ends. No commands can be issued anymore. GameLog service should provide a scoreboard and trophies. When a new game starts, you have to join it again to play.)

Cheat Sheet

Game Timeline

Repository Link Game

3 - OpenAPI

OpenAPI

4 - AsyncAPI

AsyncAPI