Documentation ¶
Overview ¶
Package publist is used to keep public list of player information. The list is synchronized with read write lock. Data comes from the two servers. The data from the server should be a snapshot(copy) and the Read data is a pointer to the current list and that list is never update, but replaced when updated. This give all the players that read the list a reference to the same list (so no modify!!) until the list is updated and any new reads can give differnt list.
Index ¶
Constants ¶
const ( //SMPass the special move pass SMPass = -1 //SMQuit the special move quit SMQuit = -2 //SMNone used to track fails in json or other file serialization //It is not a move. SMNone = -3 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Data ¶
type Data struct { ID int Name string Invite chan<- *Invite `json:"-"` DoneCom chan struct{} `json:"-"` //Used by the player Message chan<- *MesData `json:"-"` Opp int OppName string Watch *WatchChCl `json:"-"` }
Data the public list data a combination of tabel and player information.
type GameData ¶
GameData is the game information in the game map. Every game have two enteries one for every player.
type Invite ¶
type Invite struct { InvitorID int InvitorName string ReceiverID int Rejected bool //TODO MAYBE add reason Response chan<- *InviteResponse `json:"-"` //Common for all invitaion Retract chan struct{} `json:"-"` //Per invite DoneComCh chan struct{} `json:"-"` }
Invite the invite data. The invite can be retracted before the receive channel have stoped listening. This make the standard select unreliable. Use a select with default to check if retracted and the receiver must count on receiving retracted responses.
type InviteResponse ¶
InviteResponse the response to a invitation. GameCh is nil when decline.
type List ¶
type List struct {
// contains filtered or unexported fields
}
List is the structure that maintain the public data.
func (*List) Read ¶
Read get the current public list. The list is a multible used map. So no change.
func (*List) UpdateGames ¶
UpdateGames update the public data with game information. newgames is used directly so it must be a copy.
func (*List) UpdatePlayers ¶
func (list *List) UpdatePlayers(newplayers map[int]*PlayerData)
UpdatePlayers update the public data with player information. newplayers is used directly so it must be a copy.
type MoveView ¶
type MoveView struct { Mover bool Move bat.Move MoveCardix int DeltCardix int //This is the return card from deck moves, zero when not used. *Turn MoveCh chan<- [2]int `json:"-"` }
MoveView the information send from the table to the players. It should contain all information to animate a player move. Its is non symetrics, each player get his own.
type PlayerData ¶
type PlayerData struct { ID int Name string Invite chan<- *Invite DoneCom chan struct{} //Used by all send to player Message chan<- *MesData //never closed BootCh chan struct{} //For server to boot player }
PlayerData the public list player information.
type StartGameChCl ¶
type StartGameChCl struct { Channel chan *StartGameData Close chan struct{} }
StartGameChCl the start game channel.
func NewStartGameChCl ¶
func NewStartGameChCl() (sgc *StartGameChCl)
NewStartGameChCl creates a StartGameChCl.
type StartGameData ¶
StartGameData is the information need to start a game.
type Turn ¶
type Turn struct { MyTurn bool MovesPass bool State int Moves []bat.Move MovesHand map[string][]bat.Move }
Turn a player turn.