engine

package
v0.0.0-...-53b8cb7 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package engine provides access to the game engine.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bet

type Bet struct {
	AccountID common.Address `json:"account"`
	Number    int            `json:"number"`
	Suit      int            `json:"suit"`
}

Bet represents the bet response.

type Config

type Config struct {
	Network    string         `json:"network"`
	ChainID    int            `json:"chainId"`
	ContractID common.Address `json:"contractId"`
}

Config represents the configuration of the game engine.

type Cup

type Cup struct {
	AccountID common.Address `json:"account"`
	Dice      []int          `json:"dice"`
	LastBet   Bet            `json:"lastBet"`
	Outs      int            `json:"outs"`
}

Cup represents the cup response.

type Engine

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

Engine provides access to the game engine API.

func New

func New(url string) *Engine

New constructs a client that provides access to the game engine.

func (*Engine) Bet

func (e *Engine) Bet(gameID string, number int, suit rune) (State, error)

Bet submits a bet to the game engine.

func (*Engine) Configuration

func (e *Engine) Configuration() (Config, error)

Configuration returns the configuration of the game engine.

func (*Engine) Connect

func (e *Engine) Connect(keyStorePath string, address common.Address, passPhrase string) (Token, error)

Connect authenticates the use to the game engine.

func (*Engine) Events

func (e *Engine) Events(f func(event string, address common.Address)) (func(), error)

Events establishes a web socket connection to the game engine.

func (*Engine) JoinGame

func (e *Engine) JoinGame(gameID string) (State, error)

JoinGame adds a player to the current game.

func (*Engine) Liar

func (e *Engine) Liar(gameID string) (State, error)

Liar submits a liar call to the game engine.

func (*Engine) NewGame

func (e *Engine) NewGame() (State, error)

NewGame starts a new game on the game engine.

func (*Engine) QueryState

func (e *Engine) QueryState(gameID string) (State, error)

QueryState returns the current state of the specified game.

func (*Engine) Reconcile

func (e *Engine) Reconcile(gameID string) (State, error)

Reconcile submits a reconcile call when the game is over.

func (*Engine) RollDice

func (e *Engine) RollDice(gameID string) (State, error)

RollDice generates the five dice for the player.

func (*Engine) StartGame

func (e *Engine) StartGame(gameID string) (State, error)

StartGame generates the five dice for the player.

func (*Engine) Tables

func (e *Engine) Tables(gameID string) (Tables, error)

Tables returns the current set of tables.

func (*Engine) URL

func (e *Engine) URL() string

URL returns the url of the game engine.

type ErrorResponse

type ErrorResponse struct {
	Error  string            `json:"error"`
	Fields map[string]string `json:"fields,omitempty"`
}

ErrorResponse is the form used for API responses from failures in the API.

type State

type State struct {
	GameID        string           `json:"gameID"`
	Status        string           `json:"status"`
	AnteUSD       float64          `json:"anteUSD"`
	LastOutAcctID common.Address   `json:"lastOut"`
	LastWinAcctID common.Address   `json:"lastWin"`
	CurrentAcctID common.Address   `json:"currentID"`
	Round         int              `json:"round"`
	Cups          []Cup            `json:"cups"`
	CupsOrder     []common.Address `json:"playerOrder"`
	Bets          []Bet            `json:"bets"`
	Balances      []string         `json:"balances"`
}

State represents the game state.

type Tables

type Tables struct {
	GameIDs []string `json:"gameIDs"`
}

Tables represents the current set of tables.

type Token

type Token struct {
	Token   string         `json:"token"`
	Address common.Address `json:"address"`
}

Token contains the user game token and public address of the player.

Jump to

Keyboard shortcuts

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