Commit f22115a4 authored by Jesse Bakker's avatar Jesse Bakker

Specify initial protocol

parent c0d7a42d
# Protocol specification
Protocol specification for the programming project of the Software Science module 2019-2020
\ No newline at end of file
Protocol specification for the programming project of the Software Science module 2019-2020
## Program flow
## Messages
### Handshake
_Request_:
- method: 'handshake'
- params: `HandshakeParams`
```java
class HandshakeParams {
String name;
String[] supportedExtensions;
}
```
_Response_:
- result: `HandshakeResult`
```java
class HandshakeResult {
int clientId;
String[] supportedExtensions;
}
```
### Rooms
#### Get rooms
_Request_:
- method: 'getRooms'
_Response_:
- result: `Room[]`
```java
class Room {
int id;
int maxNPlayers;
Player[] playersInRoom;
}
class Player {
int id;
String name;
Optional<char> team;
}
```
#### Join room
_Request_:
- method: 'joinRoom'
- params: 'JoinRoomParams'
```java
class JoinRoomParams {
int roomId;
Optional<char> team;
}
```
_Errors_:
- Room is full: `ERROR_ROOM_full`
- Team is full: `ERROR_TEAM_FULL`
### Game
#### Start game
_Notification_:
- method: 'startGame'
- params: 'StartGameParams'
```java
class StartGameParams {
Player[] players;
}
```
#### Next turn
_Notification_:
- method: 'nextTurn'
- params: 'NextTurnParams'
```java
class NextTurnParams {
int round;
PlayerScore[];
String[][] fields;
}
class PlayerScore {
int playerId;
Optional<char> team;
int score;
}
```
#### Make move
_Request_:
- method 'makeMove'
- params: 'MoveParams'
```java
class MoveParams {
Coordinate lanceHead;
Coordinate lanceTail;
Coordinate newLanceHead;
}
class Coordinate {
int column;
char row;
}
```
_Errors_:
- ERROR_INVALID_LANCE
- ERROR_INVALID_MOVE
#### End game
_Notification_:
- method: 'endGame'
- params: 'EndGameParams'
```java
class EndGameParams {
Optional<int|char> winner;
}
```
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment