game

package
v0.0.0-...-10d6790 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2021 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EnvelopeKey = "red-envelope"
)
View Source
const (
	UserPrefix string = "user-"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Envelope

type Envelope struct {
	Address   string    `json:"address"`
	Remaining uint64    `json:"remaining"`
	Incoming  uint64    `json:"incoming"`
	Taken     uint64    `json:"taken"`      // amount taken for all rounds (lifetime)
	LastTakes TakesList `json:"last_takes"` // who has taken since the last deposit
	// contains filtered or unexported fields
}

type Game

type Game struct {
	NewStatus chan *Status
	// contains filtered or unexported fields
}

func New

func New(db *database.Database, apiaddr string) (*Game, error)

func (*Game) GetUser

func (game *Game) GetUser(uid UID) User

func (*Game) Take

func (game *Game) Take(uid UID) (uint64, error)

func (*Game) Withdraw

func (game *Game) Withdraw(uid UID)

type Status

type Status struct {
	Address   string
	Remaining uint64
	Incoming  uint64
	LastTakes TakesList // RETURNED BY POINTER FOR OPTIMIZATION, DO NOT MODIFY MAP ITSELF, ONLY READ
}

type TakesList

type TakesList map[UID]uint64

type UID

type UID string

type User

type User struct {
	Taken uint64 `json:"taken"`
	Paid  uint64 `json:"paid"`
	Out   uint64 `json:"outgoing"`
}

func (*User) AvailableReward

func (user *User) AvailableReward() uint64

Jump to

Keyboard shortcuts

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