game

package
v0.0.0-...-494d6a6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 13, 2021 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BoardColor

type BoardColor int
const (
	Red BoardColor = iota
	Green
	None
)

type ChessPiecesColor

type ChessPiecesColor int
const (
	White ChessPiecesColor = iota
	Black
)

func (ChessPiecesColor) String

func (c ChessPiecesColor) String() string

type Game

type Game struct {
	Name   string
	Redraw chan struct{}

	Model *chess.Game
	// contains filtered or unexported fields
}

func NewGame

func NewGame(worldWidth, worldHeight int, name string, logger logger.Logger) *Game

func NewUserCreatedGame

func NewUserCreatedGame(worldWidth, worldHeight int, name string) *Game

func (*Game) AddSession

func (g *Game) AddSession(s *Session)

func (*Game) CheckGameState

func (g *Game) CheckGameState()

func (*Game) RemoveSession

func (g *Game) RemoveSession(s *Session, msg string)

func (*Game) Render

func (g *Game) Render(s *Session)

func (*Game) Run

func (g *Game) Run()

func (*Game) SessionCount

func (g *Game) SessionCount() int

func (*Game) SetBoardColorsSelectingPiece

func (g *Game) SetBoardColorsSelectingPiece(playerPosition Position, chessPiecesColor ChessPiecesColor)

func (*Game) SetPositionColor

func (g *Game) SetPositionColor(playerPosition Position, boardColor BoardColor)

func (*Game) SwitchPlayersIsActive

func (g *Game) SwitchPlayersIsActive()

func (*Game) Update

func (g *Game) Update(delta float64)

Update is the main game logic loop. Delta is the time since the last update in milliseconds.

func (*Game) WorldHeight

func (g *Game) WorldHeight() int

func (*Game) WorldWidth

func (g *Game) WorldWidth() int

type GameManager

type GameManager struct {
	UserCreatedGames map[string]*Game
	Games            map[string]*Game
	HandleChannel    chan ssh.Channel
	// contains filtered or unexported fields
}

func NewGameManager

func NewGameManager(logger logger.Logger) *GameManager

func (*GameManager) GameCount

func (gm *GameManager) GameCount() int

func (*GameManager) HandleNewChannel

func (gm *GameManager) HandleNewChannel(c ssh.Channel, user string)

func (*GameManager) SessionCount

func (gm *GameManager) SessionCount() int

type Hub

type Hub struct {
	Sessions   map[*Session]struct{}
	Redraw     chan struct{}
	Register   chan *Session
	Unregister chan UnregisterMessage
}

func NewHub

func NewHub() Hub

func (*Hub) Run

func (h *Hub) Run(g *Game)

type KeyState

type KeyState int
const (
	KeyUp KeyState = iota
	KeyDown
	KeyLeft
	KeyRight
	KeyAction
	KeyNone
)

type Player

type Player struct {
	Name                  string
	CreatedAt             time.Time
	BoardPosition         *Position
	IsActive              bool
	PlayerColor           ChessPiecesColor
	PlayerState           PlayerState
	SelectedPiecePosition *Position

	TakenPiecesList []string
	// contains filtered or unexported fields
}

func NewPlayer

func NewPlayer(s *Session, worldWidth, worldHeight int, playerName string, logger logger.Logger) *Player

func (*Player) HandleAction

func (p *Player) HandleAction()

func (*Player) HandleDown

func (p *Player) HandleDown()

func (*Player) HandleLeft

func (p *Player) HandleLeft()

func (*Player) HandleRight

func (p *Player) HandleRight()

func (*Player) HandleUp

func (p *Player) HandleUp()

func (*Player) SetIsActive

func (p *Player) SetIsActive(b bool)

func (*Player) Update

func (p *Player) Update(g *Game, delta float64)

type PlayerState

type PlayerState int
const (
	SelectingPiece PlayerState = iota
	PlacingPiece
)

type Position

type Position struct {
	// contains filtered or unexported fields
}

type Session

type Session struct {
	LastAction time.Time
	HighScore  int
	Player     *Player
	// contains filtered or unexported fields
}

func NewSession

func NewSession(c ssh.Channel, worldWidth, worldHeight int, playerName string, logger logger.Logger) *Session

func (*Session) Read

func (s *Session) Read(p []byte) (int, error)

func (*Session) Write

func (s *Session) Write(p []byte) (int, error)

type UnregisterMessage

type UnregisterMessage struct {
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL