Documentation ¶
Index ¶
- Constants
- Variables
- func Center(width, height int, p tview.Primitive) tview.Primitive
- func Decode(data []byte, o interface{})
- func Encode(o interface{}) json.RawMessage
- func GameFromFEN(gamefen string) *chess.Game
- func InitLog(dest, prefix string)
- func NewGame() *chess.Game
- type Action
- type Client
- type Clock
- type Command
- type Match
- type MessageConnect
- type MessageGame
- type MessageGameAction
- type MessageGameChat
- type MessageGameCommand
- type MessageGameStatus
- type MessageInterface
- type MessageMatchRemovePlayer
- type MessageMove
- type MessageTransport
- type MessageType
- type Player
- type PlayerRole
- type Server
- type ServerConn
Constants ¶
View Source
const ( ActionDrawOffer Action = "Want Draw" ActionDrawPrompt = "Draw?" ActionDrawAccept = "Accept" ActionDrawReject = "Reject" ActionResignPrompt = "Resign" ActionResignYes = "Yes" ActionResignNo = "No" ActionNewGamePrompt = "New Game?" ActionNewGameOffer = "New Game" ActionNewGameAccept = "Yes!" ActionNewGameReject = "No~" ActionExit = "Exit" ActionWin = "Win" ActionLose = "Lose" ActionDraw = "Draw" ActionTimeOut = "Time Out" )
View Source
const ( CommandLs Command = "ls" CommandCreate = "create" CommandJoin = "join" CommandCallme = "callme" CommandMessage = "message" CommandPractice = "practice" )
View Source
const ( ServerIdleTimeout = 30 * time.Minute ServerPort = ":1998" MessageQueueSize = 20 )
View Source
const (
ConnQueueSize = 10
)
Variables ¶
View Source
var ( ChatTextView *tview.TextView StatusTextView *tview.TextView MenuTextView *tview.TextView HistoryTextView *tview.TextView OpponentTimeTextView *tview.TextView OurTimeTextView *tview.TextView )
View Source
var ( ChesstermBinary string LogPath string SshPort = ":2222" )
Functions ¶
func Center ¶
Center returns a new primitive which shows the provided primitive in its center, given the provided primitive's size.
func Encode ¶
func Encode(o interface{}) json.RawMessage
func GameFromFEN ¶
Types ¶
type Client ¶
type Client struct { Game *chess.Game App *tview.Application Board *tview.Table GameLayout *tview.Grid MenuLayout *tview.Grid OurClock *Clock OpponentClock *Clock Conn net.Conn In chan MessageInterface Out chan MessageInterface Role PlayerRole // contains filtered or unexported fields }
func (*Client) Disconnect ¶
func (cl *Client) Disconnect()
func (*Client) HandleAction ¶
func (*Client) HandleRead ¶
func (cl *Client) HandleRead()
func (*Client) HandleWrite ¶
func (cl *Client) HandleWrite()
func (*Client) UpdateTime ¶
func (cl *Client) UpdateTime()
type Clock ¶
type Match ¶
type Match struct { //Players [2]*Player Players map[int]*Player Game *chess.Game Server Server Turn PlayerRole In chan MessageInterface Out chan MessageInterface Name string PracticeMode bool Engine *uci.Engine PracticeLevel int Duration time.Duration Increment time.Duration Clocks map[int]*Clock }
func (*Match) HandleRead ¶
func (m *Match) HandleRead()
type MessageConnect ¶
type MessageConnect struct { Role PlayerRole Fen string IsTurn bool BlackClock *Clock WhiteClock *Clock }
Initialize connection
func (MessageConnect) Type ¶
func (m MessageConnect) Type() MessageType
type MessageGameAction ¶
func (MessageGameAction) Type ¶
func (m MessageGameAction) Type() MessageType
type MessageGameChat ¶
Chatting purpose
func (MessageGameChat) Type ¶
func (m MessageGameChat) Type() MessageType
type MessageGameCommand ¶
func (MessageGameCommand) Type ¶
func (m MessageGameCommand) Type() MessageType
type MessageGameStatus ¶
type MessageGameStatus struct {
Message string
}
func (MessageGameStatus) Type ¶
func (m MessageGameStatus) Type() MessageType
type MessageInterface ¶
type MessageInterface interface {
Type() MessageType
}
type MessageMatchRemovePlayer ¶
type MessageMatchRemovePlayer struct {
PlayerId int
}
func (MessageMatchRemovePlayer) Type ¶
func (m MessageMatchRemovePlayer) Type() MessageType
type MessageMove ¶
Move from player
func (MessageMove) Type ¶
func (m MessageMove) Type() MessageType
type MessageTransport ¶
type MessageTransport struct { MsgType MessageType Data json.RawMessage PlayerId int }
A generic sturct used to transport between server-client
func (MessageTransport) Type ¶
func (m MessageTransport) Type() MessageType
type MessageType ¶
type MessageType int
const ( TypeMessageGame MessageType = iota TypeMessageMove TypeMessageTransport TypeMessageConnect TypeMessageGameChat TypeMessageGameAction TypeMessageGameStatus TypeMessageMatchRemovePlayer TypeMessageGameCommand )
func (MessageType) String ¶
func (m MessageType) String() string
type Player ¶
type Player struct { Conn net.Conn Role PlayerRole Out chan MessageInterface Id int Name string }
func (*Player) Disconnect ¶
func (p *Player) Disconnect()
func (*Player) HandleRead ¶
func (p *Player) HandleRead(In chan MessageInterface)
func (*Player) HandleWrite ¶
func (p *Player) HandleWrite()
type PlayerRole ¶
type PlayerRole int
const ( White PlayerRole = iota Black Viewer )
func (PlayerRole) String ¶
func (pc PlayerRole) String() string
type Server ¶
type Server struct { *ssh.Server Matches map[string]*Match Clients []net.Conn Engine *uci.Engine In chan MessageInterface Out chan MessageInterface }
func (*Server) CleanIdleMatches ¶
func (s *Server) CleanIdleMatches()
func (*Server) HandleConn ¶
func (s *Server) HandleConn(sconn ServerConn)
func (*Server) IsMatchExisted ¶
func (*Server) NewMatchName ¶
type ServerConn ¶
Source Files ¶
Click to show internal directories.
Click to hide internal directories.