Skip to content

Cardsity/game-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cardsity Game Server

Last Commit Docker Image License

Running

Docker

Build docker image

docker build -t cardsity-game-server .

Run docker image

docker run -it -p 9012:9012 --rm --name cardsity-game-server cardsity-game-server

Compile it yourself

To compile this yourself you will need to link websocketpp and cpr. It's recommended to install these through vcpkg.

Note: To get everything running you have to change the card-deck server endpoint in the "addDeck" function found in the Lobby.cpp unless you are running the deck-server on the same network

Making your own client

Content

Connection and basic packet structure

This is a websocket server that runs on port 9012.

Packets are always sent in json format.

For every packet you send you are expected to specify a requestId - which should always be unique.
The vue-client uses the library websocket-as-promised which implements requestId's by default.

All packets you receive will have the requestId you specified in them.

Flow

The first packet you are expected to send is a LoginRequest.
Then you can send a LobbyListRequest.
Then a CreateGameRequest or a JoinGameRequest.

List of packets that can be sent while in a lobby:

Packets

Custom Types - Sent in Response

Connection

int: id
int: lobbyId
string: name
string: color

WhiteCard

string: text
int: ownerId

BlackCard

string: text
int: blanks

Player

Connection: owner
int: points

DeckInfo

string: name

LobbyStatus

arrayOf(Player): players
arrayOf(DeckInfo): decks
BlackCard: blackCard
int: currentRound
string: name
Player: czar
int: id

float: pickLimit
int: maxPlayers
int: maxRounds
int: maxPoints

LobbyInfo

int: id
bool: password
int: maxPlayers
string: name
int: playerCount
string: hostName

Requests

Packet Content Allowed in Lobby Allowed In-Game Allowed as Player Allowed as Czar Only as Host
LoginRequest string: name (^[a-zA-Z_-0-9äüö ]{3,16}$)
string: color [in Hex] (^#[A-F0-9]{6}$)
CreateGameRequest string: name (^[a-zA-Z_-0-9äüö ]{3,16}$)
string: password [empty string if none] (^[a-zA-Z_-0-9äüö]{0,16}$)
float: pickLimit (min: 0.5, max: 5)
int: maxPlayers (min: 3, max: 15)
int: maxRounds (min: 5, max 20)
int: maxPoints (min: 5, max: 25)
arrayOf(string): decks (contains the deckIds as string)
JoinGameRequest int: lobbyId
string: password [empty string if none] (^[a-zA-Z_-0-9äüö]{0,16}$)
LobbyListRequest int: pageNumber
int: pageSize
KickRequest int: playerId
string: message (^.{1,64}$)
✔️ ✔️ ✔️
CardPlayRequest arrayOf(string): cards (Text of the cards you want to play - you have to own them though) ✔️ ✔️
JokerCardRequest string: text (^.{1,64}$) ✔️ ✔️ ✔️
CzarPickRequest int: winnerId - Id of the selected card owner ✔️ ✔️
SendChatMessageRequest string: message (^.{1,64}$) ✔️ ✔️ ✔️ ✔️
LogoutRequest bool: confirmLogout ✔️ ✔️ ✔️ ✔️
LeaveLobbyRequest bool: confirmLeave ✔️ ✔️ ✔️ ✔️
StartGameRequest bool: startGame ✔️ ✔️

Responses

Packet Content Sent In Lobby Sent In-Game Contains requestId Answer to
Status string: message
bool: success
✔️ ✔️ ✔️ On Error: Everything
On Success: KickRequest, CardPlayRequest, JokerCardRequest, CzarPickRequest, SendChatMessageRequest, LeaveLobbyRequest, StartGameRequest
Welcome Connection: you ✔️ Login Request
UnrevealedCard int: unrevealedCardOwnerId ✔️ None
RevealCards arrayOf(WhiteCard): cards ✔️ None
CzarPickNotify int: winnerId ✔️ None
SentChatMessage Connection: sender
string: message
✔️ ✔️ None
HandUpdate arrayOf(WhiteCard): newHand ✔️ None
GameEnd Player: winner
arrayOf(tuple(Connection, BlackCard, arrayOf(WhiteCard))) cardHistory
✔️ None
KickNotify string: kickReason ✔️ ✔️ None
LobbyListResponse arrayOf(LobbyInfo): lobbies
int: totalRows
✔️ LobbyListRequest