This repository has been archived on 2021-10-15. You can view files and clone it, but cannot push or open issues or pull requests.
2020-coding-projects/uno/server/models.go
2020-05-05 22:35:48 +02:00

47 lines
813 B
Go

package main
import (
"github.com/gorilla/websocket"
)
// DataObject is used for parsing and encoding the communication with WebSocket clients
type DataObject struct {
Type string `json:"type"`
Data map[string]interface{} `json:"data"`
}
// Game is a model for a game instance of UNO which can be joined by users
type Game struct {
ID string
MaxPlayers int
Players []*Player
DirectionClockwise bool
CurrentPlayerIndex int
ChoosingColor bool
DrawingStack Stack
PlayingStack Stack
AvailableCards []Card
}
// Player contains data about a connected player
type Player struct {
ID string
Name string
Connection *websocket.Conn
Game *Game
Hand []*Card
}
type Stack struct {
Cards []*Card
}
type Card struct {
Color string
Value string
}