47 lines
813 B
Go
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
|
|
}
|