game

package
v0.0.0-...-04e1c13 Latest Latest
Warning

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

Go to latest
Published: May 29, 2024 License: BSD-2-Clause Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GAMESTATE_STOPPED = iota
	GAMESTATE_WAITING = iota
	GAMESTATE_RUNNING = iota
	GAMESTATE_CRASHED = iota
	GAMESTATE_INVALID = iota
)
View Source
const (
	EVENT_GAME_WAITING = "GameWaiting"
	EVENT_GAME_RUNNING = "GameRunning"
	EVENT_GAME_CRASHED = "GameCrashed"
	EVENT_PLAYER_WON   = "PlayerWon"
	EVENT_PLAYER_LOST  = "PlayerLost"
)
View Source
const WAIT_TIME_SECS = 5

Variables

View Source
var (
	ErrUserAlreadyJoined = errors.New("user already joined game")
	ErrWrongGameState    = errors.New("action invalid for current game state")
	ErrUserNotWaiting    = errors.New("user not in waiting list")
	ErrUserNotPlaying    = errors.New("user not playing")
	ErrAlreadyCashedOut  = errors.New("player already cashed out")
)

Functions

This section is empty.

Types

type Bank

type Bank interface {
	IncreaseBalance(
		string,
		string,
		decimal.Decimal,
		string,
		uuid.UUID,
	) (decimal.Decimal, error)

	DecreaseBalance(
		string,
		string,
		decimal.Decimal,
		string,
		uuid.UUID,
	) (decimal.Decimal, error)

	GetBalance(string, string) (decimal.Decimal, error)

	GetBalances(wallet string) (map[string]decimal.Decimal, error)
}

type CashOut

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

type CrashedGame

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

func (*CrashedGame) MarshalJSON

func (g *CrashedGame) MarshalJSON() ([]byte, error)

type Game

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

func NewGame

func NewGame(
	io *socket.Server,
	db *sql.DB,
	config *config.CrashConfig,
	logger *logging.Logger,
	bank Bank,
) (*Game, error)

func (*Game) Emit

func (game *Game) Emit(ev string, params ...any)

*

  • Temporary hack until I can figure out why io.Emit()
  • isn't working.

func (*Game) GetConfig

func (game *Game) GetConfig() *config.CrashConfig

func (*Game) HandleCancelBet

func (game *Game) HandleCancelBet(wallet string) error

func (*Game) HandleCashOut

func (game *Game) HandleCashOut(wallet string) error

func (*Game) HandleConnect

func (game *Game) HandleConnect(client *socket.Socket)

func (*Game) HandleDisconnect

func (game *Game) HandleDisconnect(client *socket.Socket)

func (*Game) HandleLogin

func (game *Game) HandleLogin(client *socket.Socket, wallet string)

func (*Game) HandlePlaceBet

func (game *Game) HandlePlaceBet(
	client *socket.Socket,
	wallet string,
	currency string,
	betAmount decimal.Decimal,
	autoCashOut decimal.Decimal,
) error

type Log

type Log = map[string]any

type Observer

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

type Player

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

func (*Player) MarshalJSON

func (p *Player) MarshalJSON() ([]byte, error)

Jump to

Keyboard shortcuts

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