Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //This file stores struct types for other use in the program
- package main
- import(
- "github.com/gorilla/websocket"
- )
- // --MESSAGES--
- type DataJSON struct{
- T string `json:"t"`
- Data string `json:"data"`
- }
- type Message struct {
- T int8 `json:"t"`
- Data string `json:"data"`
- }
- // --MATCHING--
- //Stores connections until they are put into a board
- type Match struct {
- ac []*websocket.Conn
- dc []*websocket.Conn
- }
- // --BOARD--
- /*
- Represents one hexagon on a board.
- pos specifies the position of the tile
- sides specifies the other tiles it can connect to
- meta is the metadata for the tile
- root specifies the game board that the tile is a part of
- NOTE: The side values go as follows:
- 0 is the next tile, counting up goes clockwise
- */
- type HexTile struct{
- pos []uint8
- sides []bool
- meta string
- root *GameBoard
- }
- type Attacker struct{
- pos []uint8
- socket *websocket.Conn
- closed bool
- }
- type Defender struct{
- slice uint8
- socket *websocket.Conn
- closed bool
- }
- /*
- Represents a ring of hexagons on the board
- tiles specifies the hexagons
- NOTE: When refering to the board, remember that
- up is relative. UP in this case means up one ring.
- DOWN in this case means down one ring.
- */
- type BoardRing struct{
- tiles []*HexTile
- edge bool
- }
- /*
- Represents the entire game board
- rings specifies the rings
- numa, numd the number of attackers and defenders on the board
- pla, pld the attackers and defenders on the board
- open defines if the board is still in use
- */
- type GameBoard struct{
- rings []*BoardRing
- numa int8
- pla []Attacker
- numd int8
- pld []Defender
- open bool
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement