game

package
v0.0.0-...-5811b38 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Log -
	Log *zap.SugaredLogger
)

Functions

func NewLog

func NewLog()

NewLog -

Types

type CurrentScore

type CurrentScore struct {
	Low     int
	High    int
	Guesses int
}

CurrentScore -

type HTTPGame

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

HTTPGame -

func NewHTTPGame

func NewHTTPGame(id string) *HTTPGame

NewHTTPGame -

func (*HTTPGame) Play

func (gme *HTTPGame) Play(w http.ResponseWriter, r *http.Request, onlinePlayers int)

Play -

type HighLow

type HighLow struct {
	ActualValue int
	State       States
	CurrentScore
}

HighLow -

func NewHighLow

func NewHighLow() *HighLow

NewHighLow - Create new game

func (*HighLow) GetState

func (h *HighLow) GetState() (s States)

GetState -

func (*HighLow) Guess

func (h *HighLow) Guess(guess int) (hit bool, err error)

Guess - execute a guess

type Session

type Session struct {
	ID string
	// contains filtered or unexported fields
}

Session -

func NewSession

func NewSession(id string) *Session

NewSession -

func (*Session) PlayGame

func (s *Session) PlayGame(w http.ResponseWriter, r *http.Request, onlinePlayers int)

PlayGame -

func (*Session) TimeoutIn

func (s *Session) TimeoutIn() time.Duration

TimeoutIn -

type SessionManager

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

SessionManager -

func NewSessionManager

func NewSessionManager() *SessionManager

NewSessionManager -

func (*SessionManager) CleanupSessions

func (m *SessionManager) CleanupSessions()

CleanupSessions - remove sessions

func (*SessionManager) GetOrCreateSession

func (m *SessionManager) GetOrCreateSession(w http.ResponseWriter, r *http.Request) (*Session, error)

GetOrCreateSession - retrieve existing session or create a new one for request

func (*SessionManager) OnlineSessions

func (m *SessionManager) OnlineSessions() *[]*Session

OnlineSessions -

type States

type States int

States -

const (
	// GameInitialized -
	GameInitialized States = iota
	// GameRunning -
	GameRunning
	// GameFinished -
	GameFinished
)

Jump to

Keyboard shortcuts

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