gamegrp

package
v0.0.0-...-0653a19 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2022 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package gamegrp provides the handlers for game play.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handlers

type Handlers struct {
	Bet            bet.Core
	Converter      *currency.Converter
	Book           *book.Book
	Log            *zap.SugaredLogger
	WS             websocket.Upgrader
	Evts           *events.Events
	Auth           *auth.Auth
	BankTimeout    time.Duration
	ConnectTimeout time.Duration
	// contains filtered or unexported fields
}

Handlers manages the set of user endpoints.

func (*Handlers) Configuration

func (h *Handlers) Configuration(ctx context.Context, w http.ResponseWriter, r *http.Request) error

Configuration returns the basic configuration the front end needs to use.

func (*Handlers) Connect

func (h *Handlers) Connect(ctx context.Context, w http.ResponseWriter, r *http.Request) error

Connect is used to return a game token for API usage.

func (*Handlers) CreateBet

func (h *Handlers) CreateBet(ctx context.Context, w http.ResponseWriter, r *http.Request) error

CreateBet creates a new bet and returns its content.

func (*Handlers) Events

func (h *Handlers) Events(ctx context.Context, w http.ResponseWriter, r *http.Request) error

Events handles a web socket to provide events to a client.

func (*Handlers) QueryBet

func (h *Handlers) QueryBet(ctx context.Context, w http.ResponseWriter, r *http.Request) error

QueryBet returns a list of bets with paging.

func (*Handlers) QueryBetByID

func (h *Handlers) QueryBetByID(ctx context.Context, w http.ResponseWriter, r *http.Request) error

QueryBetByID returns a bet by its ID.

func (*Handlers) Test

Test will validate things are working.

func (*Handlers) USD2Wei

func (h *Handlers) USD2Wei(ctx context.Context, w http.ResponseWriter, r *http.Request) error

USD2Wei converts the us dollar amount to wei based on the game engine's conversion rate.

func (*Handlers) UpdateBet

func (h *Handlers) UpdateBet(ctx context.Context, w http.ResponseWriter, r *http.Request) error

UpdateBet updates a bet in the system.

type NewBet

type NewBet struct {
	Description      string      `json:"description"`
	Terms            string      `json:"terms"`
	Amount           int         `json:"amount"`
	ModeratorAddress string      `json:"moderatorAddress" validate:"required"`
	Players          []NewPlayer `json:"players" validate:"required"`
	DateExpired      uint        `json:"dateExpired" validate:"required"`
}

NewBet is what we require from clients when adding a Bet.

type NewPlayer

type NewPlayer struct {
	Address string `json:"address"`
	InFavor bool   `json:"inFavor"`
}

NewPlayer represents the connection between a new Bet and an Account that is in a player role.

type Status

type Status struct {
	Status  string `json:"status"`
	Address string `json:"address"`
}

Status represents the game status.

type UpdateBet

type UpdateBet struct {
	Description      *string `json:"description"`
	Terms            *string `json:"terms"`
	Amount           *int    `json:"amount"`
	ModeratorAddress *string `json:"moderatorAddress" validate:"required"`
	DateExpired      *uint   `json:"dateExpired" validate:"required"`
}

UpdateBet is what we require from clients when updating a Bet.

Jump to

Keyboard shortcuts

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