Documentation
¶
Index ¶
- type NoteMsg
- type Player
- type PlayerType
- type PublicKey
- type Room
- func (r *Room) AddPlayer(s ssh.Session) (*Player, error)
- func (r *Room) Close()
- func (r *Room) FindPlayer(pub PublicKey) *Player
- func (r *Room) Listen()
- func (r *Room) MakePlayer(pt PlayerType, s ssh.Session) *Player
- func (r *Room) ObserversCount() int
- func (r *Room) P1() *Player
- func (r *Room) P2() *Player
- func (r *Room) Position() string
- func (r *Room) SendMsg(m tea.Msg)
- func (r *Room) String() string
- func (r *Room) Write(b []byte) (n int, err error)
- func (r *Room) WriteString(s string) (int, error)
- type Server
- type SharedGame
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type NoteMsg ¶
type NoteMsg string
NoteMsg is a message that is sent to the client when a message is added to the game.
type Player ¶
type Player struct {
// contains filtered or unexported fields
}
Player is a player in a chess game who belongs to a room, has a ssh session and a bubble tea program.
func (*Player) Close ¶
Close closes the the bubble tea program and deletes the player from the room.
type PlayerType ¶
type PlayerType int
PlayerType is the type of a player in a chess game.
func (PlayerType) String ¶
func (pt PlayerType) String() string
String implements the Stringer interface.
type PublicKey ¶
type PublicKey struct {
// contains filtered or unexported fields
}
PublicKey wraps ssh.PublicKey.
type Room ¶
type Room struct {
// contains filtered or unexported fields
}
Room is a game room with a unique id, password, and a list of players.
func (*Room) Close ¶
func (r *Room) Close()
Close closes the room and deletes the room from the server memory.
func (*Room) FindPlayer ¶
FindPlayer returns the player for the given public key.
func (*Room) Listen ¶
func (r *Room) Listen()
Listen listens for messages from players in the room and other events.
func (*Room) MakePlayer ¶
func (r *Room) MakePlayer(pt PlayerType, s ssh.Session) *Player
MakePlayer creates a new player with the given type and session.
func (*Room) ObserversCount ¶
ObserversCount returns the number of observer players in the room.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is a server that manages chess games.
type SharedGame ¶
type SharedGame struct {
// contains filtered or unexported fields
}
SharedGame is a game that is shared between players. It wraps gambit bubble tea model and synchronizes messages among players and server.
func NewSharedGame ¶
func NewSharedGame(p *Player, sync chan tea.Msg, roomTurn *bool, turn, observer bool, pos string) *SharedGame
NewSharedGame creates a new shared game for a player.
func (*SharedGame) SendMsg ¶
func (r *SharedGame) SendMsg(msg tea.Msg)
SendMsg sends a message to the room.