api

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2025 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AECnull = iota

	AEC_auth_absent
	AEC_auth_scheme
	AEC_basic_decode
	AEC_basic_nouser
	AEC_basic_deny
	AEC_token_nouser
	AEC_token_malform
	AEC_token_notsign
	AEC_token_badclaims
	AEC_token_expired
	AEC_token_notyet
	AEC_token_issuer
	AEC_token_error

	AEC_nourl

	AEC_nomethod

	AEC_signis_nobind
	AEC_signis_nouid
	AEC_signis_noemail

	AEC_sendcode_nobind
	AEC_sendcode_nouser
	AEC_sendcode_update
	AEC_sendcode_code

	AEC_activate_nobind
	AEC_activate_nouser
	AEC_activate_oldcode
	AEC_activate_badcode
	AEC_activate_update

	AEC_signup_nobind
	AEC_signup_smallsec
	AEC_signup_code
	AEC_signup_sql

	AEC_signin_nobind
	AEC_signin_nosecret
	AEC_signin_smallsec
	AEC_signin_nouser
	AEC_signin_activate
	AEC_signin_oldcode
	AEC_signin_badcode
	AEC_signin_denypass
	AEC_signin_sigtime
	AEC_signin_timeout
	AEC_signin_hs256
	AEC_signin_denyhash

	AEC_game_new_nobind
	AEC_game_new_noclub
	AEC_game_new_nouser
	AEC_game_new_noaccess
	AEC_game_new_noalias
	AEC_game_new_sql

	AEC_game_join_nobind
	AEC_game_join_nouser
	AEC_game_join_noaccess
	AEC_game_join_noscene

	AEC_game_info_nobind
	AEC_game_info_noscene
	AEC_game_info_nouser
	AEC_game_info_noaccess
	AEC_game_info_noprops

	AEC_game_rtpget_nobind
	AEC_game_rtpget_noscene
	AEC_game_rtpget_noinfo
	AEC_game_rtpget_noclub
	AEC_game_rtpget_nouser
	AEC_game_rtpget_noaccess

	AEC_slot_betget_nobind
	AEC_slot_betget_noscene
	AEC_slot_betget_notslot
	AEC_slot_betget_noaccess

	AEC_slot_betset_nobind
	AEC_slot_betset_noscene
	AEC_slot_betset_notslot
	AEC_slot_betset_noaccess
	AEC_slot_betset_badbet

	AEC_slot_selget_nobind
	AEC_slot_selget_noscene
	AEC_slot_selget_notslot
	AEC_slot_selget_noaccess

	AEC_slot_selset_nobind
	AEC_slot_selset_noscene
	AEC_slot_selset_notslot
	AEC_slot_selset_noaccess
	AEC_slot_selset_badsel

	AEC_slot_modeset_nobind
	AEC_slot_modeset_noscene
	AEC_slot_modeset_notslot
	AEC_slot_modeset_noaccess
	AEC_slot_modeset_badmode

	AEC_slot_spin_nobind
	AEC_slot_spin_noscene
	AEC_slot_spin_notslot
	AEC_slot_spin_noclub
	AEC_slot_spin_nouser
	AEC_slot_spin_noaccess
	AEC_slot_spin_badbet
	AEC_slot_spin_badsel
	AEC_slot_spin_noprops
	AEC_slot_spin_nomoney
	AEC_slot_spin_badbank
	AEC_slot_spin_sqlbank

	AEC_slot_doubleup_nobind
	AEC_slot_doubleup_noscene
	AEC_slot_doubleup_notslot
	AEC_slot_doubleup_noclub
	AEC_slot_doubleup_nouser
	AEC_slot_doubleup_noaccess
	AEC_slot_doubleup_noprops
	AEC_slot_doubleup_nogain
	AEC_slot_doubleup_sqlbank

	AEC_slot_collect_nobind
	AEC_slot_collect_noscene
	AEC_slot_collect_notslot
	AEC_slot_collect_noaccess
	AEC_slot_collect_denied

	AEC_keno_betget_nobind
	AEC_keno_betget_noscene
	AEC_keno_betget_notslot
	AEC_keno_betget_noaccess

	AEC_keno_betset_nobind
	AEC_keno_betset_noscene
	AEC_keno_betset_notslot
	AEC_keno_betset_noaccess
	AEC_keno_betset_badbet

	AEC_keno_selget_nobind
	AEC_keno_selget_noscene
	AEC_keno_selget_notslot
	AEC_keno_selget_noaccess

	AEC_keno_selset_nobind
	AEC_keno_selset_noscene
	AEC_keno_selset_notslot
	AEC_keno_selset_noaccess
	AEC_keno_selset_badsel

	AEC_keno_selgetslice_nobind
	AEC_keno_selgetslice_noscene
	AEC_keno_selgetslice_notslot
	AEC_keno_selgetslice_noaccess

	AEC_keno_selsetslice_nobind
	AEC_keno_selsetslice_noscene
	AEC_keno_selsetslice_notslot
	AEC_keno_selsetslice_noaccess
	AEC_keno_selsetslice_badsel

	AEC_keno_spin_nobind
	AEC_keno_spin_noscene
	AEC_keno_spin_notslot
	AEC_keno_spin_noclub
	AEC_keno_spin_nouser
	AEC_keno_spin_noaccess
	AEC_keno_spin_noprops
	AEC_keno_spin_nomoney
	AEC_keno_spin_badbank
	AEC_keno_spin_sqlbank

	AEC_prop_get_nobind
	AEC_prop_get_noclub
	AEC_prop_get_nouser
	AEC_prop_get_noaccess

	AEC_prop_walletget_nobind
	AEC_prop_walletget_noclub
	AEC_prop_walletget_nouser
	AEC_prop_walletget_noaccess

	AEC_prop_walletadd_nobind
	AEC_prop_walletadd_limit
	AEC_prop_walletadd_noclub
	AEC_prop_walletadd_nouser
	AEC_prop_walletadd_noaccess
	AEC_prop_walletadd_noprops
	AEC_prop_walletadd_nomoney
	AEC_prop_walletadd_sql

	AEC_prop_alget_nobind
	AEC_prop_alget_noclub
	AEC_prop_alget_nouser
	AEC_prop_alget_noaccess

	AEC_prop_alset_nobind
	AEC_prop_alset_noclub
	AEC_prop_alset_nouser
	AEC_prop_alset_noaccess
	AEC_prop_alset_noprops
	AEC_prop_alset_nolevel
	AEC_prop_alset_sql

	AEC_prop_rtpget_nobind
	AEC_prop_rtpget_noclub
	AEC_prop_rtpget_nouser
	AEC_prop_rtpget_noaccess

	AEC_prop_rtpset_nobind
	AEC_prop_rtpset_noclub
	AEC_prop_rtpset_nouser
	AEC_prop_rtpset_noaccess
	AEC_prop_rtpset_noprops
	AEC_prop_rtpset_sql

	AEC_user_is_nobind

	AEC_user_rename_nobind
	AEC_user_rename_nouser
	AEC_user_rename_noaccess
	AEC_user_rename_update

	AEC_user_secret_nobind
	AEC_user_secret_smallsec
	AEC_user_secret_nouser
	AEC_user_secret_noaccess
	AEC_user_secret_notequ
	AEC_user_secret_update

	AEC_user_delete_nobind
	AEC_user_delete_nouser
	AEC_user_delete_noaccess
	AEC_user_delete_nosecret
	AEC_user_delete_sqluser
	AEC_user_delete_sqllock
	AEC_user_delete_sqlprops
	AEC_user_delete_sqlgames

	AEC_club_is_nobind

	AEC_club_info_nobind
	AEC_club_info_noclub
	AEC_club_info_noaccess

	AEC_club_rename_nobind
	AEC_club_rename_noclub
	AEC_club_rename_noaccess
	AEC_club_rename_update

	AEC_club_cashin_nobind
	AEC_club_cashin_nosum
	AEC_club_cashin_noclub
	AEC_club_cashin_noaccess
	AEC_club_cashin_bankout
	AEC_club_cashin_fundout
	AEC_club_cashin_lockout
	AEC_club_cashin_sqlbank
	AEC_club_cashin_sqllog
)

API error codes. Each error code have unique source code point, so this error code at service reply exactly points to error place.

Variables

View Source
var (
	ErrNoJwtID  = errors.New("jwt-token does not have user id")
	ErrBadJwtID = errors.New("jwt-token id does not refer to registered user")
	ErrNoAuth   = errors.New("authorization is required")
	ErrNoScheme = errors.New("authorization does not have expected scheme")
	ErrNoSecret = errors.New("expected password or SHA256 hash on it and current time as a nonce")
	ErrSmallKey = errors.New("password too small")
	ErrNoCred   = errors.New("user with given credentials does not registered")
	ErrActivate = errors.New("activation required for this account")
	ErrOldCode  = errors.New("verification code expired")
	ErrBadCode  = errors.New("verification code does not pass")
	ErrNotPass  = errors.New("password is incorrect")
	ErrSigTime  = errors.New("signing time can not been recognized (time in RFC3339 expected)")
	ErrSigOut   = errors.New("nonce is expired")
	ErrBadHash  = errors.New("hash cannot be decoded in hexadecimal")
)
View Source
var (
	Err404       = errors.New("page not found")
	Err405       = errors.New("method not allowed")
	ErrNoClub    = errors.New("club with given ID does not found")
	ErrNoUser    = errors.New("user with given ID does not found")
	ErrNoProps   = errors.New("properties for given user and club does not found")
	ErrNoAddSum  = errors.New("no sum to change balance of bank or fund or deposit")
	ErrNoMoney   = errors.New("not enough money on balance")
	ErrNoGain    = errors.New("no money won")
	ErrBankOut   = errors.New("not enough money at bank")
	ErrFundOut   = errors.New("not enough money at jackpot fund")
	ErrLockOut   = errors.New("not enough money at deposit")
	ErrNotSlot   = errors.New("specified GID refers to non-slot game")
	ErrNotKeno   = errors.New("specified GID refers to non-keno game")
	ErrNoAccess  = errors.New("no access rights for this feature")
	ErrNoLevel   = errors.New("admin have no privilege to modify specified access level to user")
	ErrNotConf   = errors.New("password confirmation does not pass")
	ErrZero      = errors.New("given value is zero")
	ErrTooBig    = errors.New("given value exceeds the limit")
	ErrNoAliase  = errors.New("no game alias")
	ErrNotOpened = errors.New("game with given ID is not opened")
	ErrBadBank   = errors.New("can not generate spin with current bank balance")
)
View Source
var (
	SpinBuf util.SqlBuf[Spinlog]
	MultBuf util.SqlBuf[Multlog]
	BankBat = map[uint64]*SqlBank{}
	JoinBuf = SqlStory{}
)

AuthGetters is the list of functions to extract the authorization data from the parts of request. List and order in it can be changed.

View Source
var (
	Cfg = cfg.Cfg
)

All created clubs, by CID.

View Source
var MultCounter uint64 // last multiplier log ID
View Source
var PropMaster []Props

Properties master for new registered user.

Scenes cache, by GID.

View Source
var SpinCounter uint64 // last spin log ID
View Source
var StoryCounter uint64 // last GID

All registered users, by UID.

Functions

func ApiActivate

func ApiActivate(c *gin.Context)

func ApiClubCashin

func ApiClubCashin(c *gin.Context)

Adding or withdrawing coins from club bank, fund and lock balances.

func ApiClubInfo

func ApiClubInfo(c *gin.Context)

Returns current club state.

func ApiClubIs

func ApiClubIs(c *gin.Context)

Returns current club state.

func ApiClubList

func ApiClubList(c *gin.Context)

func ApiClubRename

func ApiClubRename(c *gin.Context)

Rename the club.

func ApiGameInfo

func ApiGameInfo(c *gin.Context)

Returns full info of game scene with given GID, and balance on wallet.

func ApiGameJoin

func ApiGameJoin(c *gin.Context)

Joins to game and creates new instance of game.

func ApiGameList

func ApiGameList(c *gin.Context)

Returns full list of all available games by game type IDs.

func ApiGameNew added in v0.8.0

func ApiGameNew(c *gin.Context)

Creates new instance of game.

func ApiGameRtpGet

func ApiGameRtpGet(c *gin.Context)

Returns master RTP for given GID.

func ApiKenoBetGet

func ApiKenoBetGet(c *gin.Context)

Returns bet value.

func ApiKenoBetSet

func ApiKenoBetSet(c *gin.Context)

Set bet value.

func ApiKenoSelGet

func ApiKenoSelGet(c *gin.Context)

Returns selected numbers bitset.

func ApiKenoSelGetSlice

func ApiKenoSelGetSlice(c *gin.Context)

Returns selected numbers slice.

func ApiKenoSelSet

func ApiKenoSelSet(c *gin.Context)

Set selected numbers bitset.

func ApiKenoSelSetSlice

func ApiKenoSelSetSlice(c *gin.Context)

Set selected numbers slice.

func ApiKenoSpin

func ApiKenoSpin(c *gin.Context)

func ApiMemUsage

func ApiMemUsage(c *gin.Context)

Memory usage footprint.

func ApiPing

func ApiPing(c *gin.Context)

Check service response.

func ApiPropsAlGet

func ApiPropsAlGet(c *gin.Context)

Returns personal access level for pointed user at pointed club.

func ApiPropsAlSet

func ApiPropsAlSet(c *gin.Context)

Set personal access level for given user at given club.

func ApiPropsGet

func ApiPropsGet(c *gin.Context)

Returns all properties for pointed user at pointed club.

func ApiPropsRtpGet

func ApiPropsRtpGet(c *gin.Context)

Returns master RTP for pointed user at pointed club. This RTP if it set have more priority then club RTP.

func ApiPropsRtpSet

func ApiPropsRtpSet(c *gin.Context)

Set personal master RTP for given user at given club.

func ApiPropsWalletAdd

func ApiPropsWalletAdd(c *gin.Context)

Adds some coins to user wallet. Sum can be < 0 to remove some coins.

func ApiPropsWalletGet

func ApiPropsWalletGet(c *gin.Context)

Returns balance at wallet for pointed user at pointed club.

func ApiRefresh

func ApiRefresh(c *gin.Context)

func ApiSendCode

func ApiSendCode(c *gin.Context)

func ApiServInfo

func ApiServInfo(c *gin.Context)

Static service system information.

func ApiSignin

func ApiSignin(c *gin.Context)

func ApiSignis

func ApiSignis(c *gin.Context)

func ApiSignup

func ApiSignup(c *gin.Context)

func ApiSlotBetGet

func ApiSlotBetGet(c *gin.Context)

Returns bet value.

func ApiSlotBetSet

func ApiSlotBetSet(c *gin.Context)

Set bet value.

func ApiSlotCollect

func ApiSlotCollect(c *gin.Context)

func ApiSlotDoubleup

func ApiSlotDoubleup(c *gin.Context)

Double up gamble on last gain.

func ApiSlotModeSet

func ApiSlotModeSet(c *gin.Context)

Change game mode depending on the user's choice.

func ApiSlotSelGet

func ApiSlotSelGet(c *gin.Context)

Returns selected bet lines bitset.

func ApiSlotSelSet

func ApiSlotSelSet(c *gin.Context)

Set selected bet lines bitset.

func ApiSlotSpin

func ApiSlotSpin(c *gin.Context)

Make a spin.

func ApiUserDelete

func ApiUserDelete(c *gin.Context)

Deletes registration, drops user and all linked records from database, and moves all remained coins at wallets to clubs deposits.

func ApiUserIs

func ApiUserIs(c *gin.Context)

func ApiUserRename

func ApiUserRename(c *gin.Context)

Changes 'Name' of given user.

func ApiUserSecret

func ApiUserSecret(c *gin.Context)

func Auth

func Auth(required bool) gin.HandlerFunc

Auth is authorization middleware, sets User object associated with authorization to gin context. `required` parameter tells to continue if authorization is absent.

func GetAdmin

func GetAdmin(c *gin.Context, cid uint64) (*User, AL)

GetAdmin returns User pointer for authorized requests, and access level for it. Or nil pointer for unauthorized requests. It called after Auth(false) middleware.

func GetRTP

func GetRTP(user *User, club *Club) float64

func Handle404

func Handle404(c *gin.Context)

func Handle405

func Handle405(c *gin.Context)

func InitScreen added in v0.8.0

func InitScreen(game any)

Make game screen object.

func MustAdmin

func MustAdmin(c *gin.Context, cid uint64) (*User, AL)

MustAdmin always returns User pointer for authorized requests, and access level for it. It called after Auth(true) middleware.

func Negotiate

func Negotiate(c *gin.Context, code int, data any)

func Ret204

func Ret204(c *gin.Context)

func Ret400

func Ret400(c *gin.Context, code int, err error)

func Ret401

func Ret401(c *gin.Context, code int, err error)

func Ret403

func Ret403(c *gin.Context, code int, err error)

func Ret404

func Ret404(c *gin.Context, code int, err error)

func Ret500

func Ret500(c *gin.Context, code int, err error)

func RetErr

func RetErr(c *gin.Context, status, code int, err error)

func RetOk

func RetOk(c *gin.Context, data any)

func SafeTransaction

func SafeTransaction(engine *xorm.Engine, f func(*Session) error) (err error)

func SetupRouter added in v0.7.0

func SetupRouter(r *gin.Engine)

Types

type AL

type AL uint

Access level.

const (
	ALmem   AL = 1 << iota // user have access to club
	ALgame                 // can change club game settings and users gameplay
	ALuser                 // can change user properties and move user money to/from club deposit
	ALclub                 // can change club bank, fund, deposit
	ALadmin                // can change same access levels to other users
	ALall   = ALgame | ALuser | ALclub | ALadmin
)

type AuthGetter

type AuthGetter func(c *gin.Context) (*User, int, error)

type AuthResp

type AuthResp struct {
	XMLName xml.Name `json:"-" yaml:"-" xml:"ret"`
	UID     uint64   `json:"uid" yaml:"uid" xml:"uid"`
	Email   string   `json:"email" yaml:"email" xml:"email"`
	Access  string   `json:"access" yaml:"access" xml:"access"`
	Refrsh  string   `json:"refrsh" yaml:"refrsh" xml:"refrsh"`
	Expire  string   `json:"expire" yaml:"expire" xml:"expire"`
	Living  string   `json:"living" yaml:"living" xml:"living"`
}

func (*AuthResp) Setup

func (r *AuthResp) Setup(user *User)

type Banklog

type Banklog struct {
	ID      uint64    `xorm:"pk autoincr" json:"id" yaml:"id" xml:"id,attr"`
	CTime   time.Time `xorm:"created 'ctime' notnull default CURRENT_TIMESTAMP" json:"ctime" yaml:"ctime" xml:"ctime"`
	Bank    float64   `xorm:"notnull 'bank'" json:"bank" yaml:"bank" xml:"bank"`
	Fund    float64   `xorm:"notnull 'fund'" json:"fund" yaml:"fund" xml:"fund"`
	Lock    float64   `xorm:"notnull 'lock'" json:"lock" yaml:"lock" xml:"lock"`
	BankSum float64   `xorm:"notnull 'banksum'" json:"banksum" yaml:"banksum" xml:"banksum" form:"banksum"`
	FundSum float64   `xorm:"notnull 'fundsum'" json:"fundsum" yaml:"fundsum" xml:"fundsum" form:"fundsum"`
	LockSum float64   `xorm:"notnull 'locksum'" json:"locksum" yaml:"locksum" xml:"locksum" form:"locksum"`
}

type Claims

type Claims struct {
	jwt.RegisteredClaims
	UID uint64 `json:"uid,omitempty"`
}

Claims of JWT-tokens. Contains additional profile identifier.

func (*Claims) Validate

func (c *Claims) Validate() error

type Club

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

Club means independent bank into which gambles some users.

func MakeClub added in v0.7.0

func MakeClub(cd ClubData) *Club

func (*Club) AddBank added in v0.7.0

func (club *Club) AddBank(bank float64)

func (*Club) AddCash added in v0.7.0

func (club *Club) AddCash(bank, fund, deposit float64)

func (*Club) AddDeposit added in v0.7.0

func (club *Club) AddDeposit(deposit float64)

func (*Club) AddFund added in v0.7.0

func (club *Club) AddFund(fund float64)

func (*Club) Bank

func (club *Club) Bank() float64

func (*Club) CID

func (club *Club) CID() uint64

func (*Club) Deposit added in v0.7.0

func (club *Club) Deposit() float64

func (*Club) Fund

func (club *Club) Fund() float64

func (*Club) Get added in v0.7.0

func (club *Club) Get() ClubData

func (*Club) GetCash added in v0.7.0

func (club *Club) GetCash() (bank, fund, deposit float64)

func (*Club) MRTP

func (club *Club) MRTP() float64

func (*Club) Name

func (club *Club) Name() string

func (*Club) Rate

func (club *Club) Rate() float64

func (*Club) SetName added in v0.7.0

func (club *Club) SetName(name string)

type ClubData added in v0.7.0

type ClubData struct {
	CID   uint64    `xorm:"pk autoincr" json:"cid" yaml:"cid" xml:"cid,attr"`                                        // club ID
	CTime time.Time `xorm:"created 'ctime' notnull default CURRENT_TIMESTAMP" json:"ctime" yaml:"ctime" xml:"ctime"` // creation time
	UTime time.Time `xorm:"updated 'utime' notnull default CURRENT_TIMESTAMP" json:"utime" yaml:"utime" xml:"utime"` // update time
	Name  string    `xorm:"notnull" json:"name,omitempty" yaml:"name,omitempty" xml:"name,omitempty"`
	Bank  float64   `xorm:"notnull default 0" json:"bank" yaml:"bank" xml:"bank"`          // users win/lost balance, in coins
	Fund  float64   `xorm:"notnull default 0" json:"fund" yaml:"fund" xml:"fund"`          // jackpot fund, in coins
	Lock  float64   `xorm:"notnull default 0" json:"lock" yaml:"lock" xml:"lock"`          // not changed deposit within games
	Rate  float64   `xorm:"'rate' notnull default 2.5" json:"rate" yaml:"rate" xml:"rate"` // jackpot rate for games with progressive jackpot
	MRTP  float64   `xorm:"'mrtp' notnull default 0" json:"mrtp" yaml:"mrtp" xml:"mrtp"`   // master RTP
}

func (ClubData) TableName added in v0.7.0

func (ClubData) TableName() string

type Multlog

type Multlog struct {
	ID     uint64    `xorm:"pk" json:"id" yaml:"id" xml:"id,attr"`
	CTime  time.Time `xorm:"created 'ctime' notnull default CURRENT_TIMESTAMP" json:"ctime" yaml:"ctime" xml:"ctime"`
	GID    uint64    `xorm:"notnull" json:"gid" yaml:"gid" xml:"gid,attr"`    // game ID
	MRTP   float64   `xorm:"notnull" json:"mrtp" yaml:"mrtp" xml:"mrtp,attr"` // master RTP
	Mult   int       `xorm:"notnull" json:"mult" yaml:"mult" xml:"mult"`      // multiplier
	Risk   float64   `xorm:"notnull" json:"risk" yaml:"risk" xml:"risk"`
	Gain   float64   `xorm:"notnull" json:"gain" yaml:"gain" xml:"gain"`
	Wallet float64   `xorm:"notnull" json:"wallet" yaml:"wallet" xml:"wallet"`
}

type Props

type Props struct {
	CID    uint64    `xorm:"notnull index(bid)" json:"cid" yaml:"cid" xml:"cid,attr"`                                 // club ID
	UID    uint64    `xorm:"notnull index(bid)" json:"uid" yaml:"uid" xml:"uid,attr"`                                 // user ID
	CTime  time.Time `xorm:"created 'ctime' notnull default CURRENT_TIMESTAMP" json:"ctime" yaml:"ctime" xml:"ctime"` // creation time
	UTime  time.Time `xorm:"updated 'utime' notnull default CURRENT_TIMESTAMP" json:"utime" yaml:"utime" xml:"utime"` // update time
	Wallet float64   `xorm:"notnull default 0" json:"wallet" yaml:"wallet" xml:"wallet"`                              // in coins
	Access AL        `xorm:"notnull default 0" json:"access" yaml:"access" xml:"access"`                              // access level
	MRTP   float64   `xorm:"notnull default 0" json:"mrtp" yaml:"mrtp" xml:"mrtp"`                                    // personal master RTP
}

Props contains properties for user at some club. Any property can be zero by default, or if object does not created at DB.

type Scene

type Scene struct {
	Story `yaml:",inline"`
	SID   uint64 `json:"sid" yaml:"sid" xml:"sid,attr"` // last spin ID
	Game  any    `json:"game" yaml:"game" xml:"game"`
}

Scene represents game with all the connected environment.

func GetScene added in v0.8.0

func GetScene(gid uint64) (scene *Scene, err error)

type Session

type Session = xorm.Session

type Spinlog

type Spinlog struct {
	SID    uint64    `xorm:"pk" json:"sid" yaml:"sid" xml:"sid,attr"`                                                 // spin ID
	CTime  time.Time `xorm:"created 'ctime' notnull default CURRENT_TIMESTAMP" json:"ctime" yaml:"ctime" xml:"ctime"` // creation time
	GID    uint64    `xorm:"notnull" json:"gid" yaml:"gid" xml:"gid,attr"`                                            // game ID
	MRTP   float64   `xorm:"notnull" json:"mrtp" yaml:"mrtp" xml:"mrtp,attr"`                                         // master RTP
	Game   string    `xorm:"notnull" json:"game" yaml:"game" xml:"game"`                                              // game data
	Wins   string    `xorm:"text" json:"wins,omitempty" yaml:"wins,omitempty" xml:"wins,omitempty"`                   // list of wins marshaled to JSON
	Gain   float64   `xorm:"notnull" json:"gain" yaml:"gain" xml:"gain"`                                              // total gain at last spin
	Wallet float64   `xorm:"notnull" json:"wallet" yaml:"wallet" xml:"wallet"`
}

type SqlBank

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

func (*SqlBank) Access

func (sb *SqlBank) Access(engine *xorm.Engine, uid uint64, access AL) (err error)

func (*SqlBank) Add

func (sb *SqlBank) Add(engine *xorm.Engine, uid, aid uint64, wallet, sum float64) (err error)

func (*SqlBank) Flush

func (sb *SqlBank) Flush(engine *xorm.Engine, d time.Duration) (err error)

func (*SqlBank) Init

func (sb *SqlBank) Init(cid uint64, capacity, logsize int)

func (*SqlBank) IsEmpty added in v0.7.0

func (sb *SqlBank) IsEmpty() bool

func (*SqlBank) MRTP

func (sb *SqlBank) MRTP(engine *xorm.Engine, uid uint64, mrtp float64) (err error)

func (*SqlBank) Put

func (sb *SqlBank) Put(engine *xorm.Engine, uid uint64, sum float64) (err error)

type SqlStory

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

func (*SqlStory) Flush

func (ss *SqlStory) Flush(engine *xorm.Engine, d time.Duration) (err error)

func (*SqlStory) Init

func (ss *SqlStory) Init(logsize int)

func (*SqlStory) IsEmpty added in v0.7.0

func (ss *SqlStory) IsEmpty() bool

func (*SqlStory) Join

func (ss *SqlStory) Join(engine *xorm.Engine, s *Story) (err error)

type Story

type Story struct {
	GID   uint64    `xorm:"pk" json:"gid" yaml:"gid" xml:"gid,attr"`                                                 // game ID
	CTime time.Time `xorm:"created 'ctime' notnull default CURRENT_TIMESTAMP" json:"ctime" yaml:"ctime" xml:"ctime"` // creation time
	UTime time.Time `xorm:"updated 'utime' notnull default CURRENT_TIMESTAMP" json:"utime" yaml:"utime" xml:"utime"` // update time
	Alias string    `xorm:"notnull" json:"alias" yaml:"alias" xml:"alias"`                                           // game type identifier
	CID   uint64    `xorm:"notnull" json:"cid" yaml:"cid" xml:"cid,attr"`                                            // club ID
	UID   uint64    `xorm:"notnull" json:"uid" yaml:"uid" xml:"uid,attr"`                                            // user ID
}

Story is opened game for user with UID at club with CID. Each instance of game have own GID. Alias - is game type identifier.

type UF

type UF uint

User flag.

const (
	UFactivated UF = 1 << iota // account is activated
	UFsigncode                 // sign-in required code
)

type User

type User struct {
	UID    uint64    `xorm:"pk autoincr" json:"uid" yaml:"uid" xml:"uid,attr"`                                         // user ID
	CTime  time.Time `xorm:"created 'ctime' notnull default CURRENT_TIMESTAMP" json:"ctime" yaml:"ctime" xml:"ctime"`  // creation time
	UTime  time.Time `xorm:"updated 'utime' notnull default CURRENT_TIMESTAMP" json:"utime" yaml:"utime" xml:"utime"`  // update time
	Email  string    `xorm:"notnull unique index" json:"email" yaml:"email" xml:"email"`                               // unique user email
	Secret string    `xorm:"notnull" json:"secret" yaml:"secret" xml:"secret"`                                         // auth password
	Name   string    `xorm:"notnull" json:"name,omitempty" yaml:"name,omitempty" xml:"name,omitempty"`                 // user name
	Code   uint32    `xorm:"notnull default 0" json:"code,omitempty" yaml:"code,omitempty" xml:"code,omitempty"`       // verification code
	Status UF        `xorm:"notnull default 0" json:"status,omitempty" yaml:"status,omitempty" xml:"status,omitempty"` // account status
	GAL    AL        `xorm:"notnull default 0" json:"gal,omitempty" yaml:"gal,omitempty" xml:"gal,omitempty"`          // global access level
	// contains filtered or unexported fields
}

User means registration of somebody. Each user can have splitted wallet with some coins balance in each Club. User can opens several games without any limitation.

func GetBasicAuth

func GetBasicAuth(credentials string) (user *User, code int, err error)

func GetBearerAuth

func GetBearerAuth(tokenstr string) (user *User, code int, err error)

func UserFromCookie

func UserFromCookie(c *gin.Context) (*User, int, error)

func UserFromForm

func UserFromForm(c *gin.Context) (*User, int, error)

func UserFromHeader

func UserFromHeader(c *gin.Context) (*User, int, error)

func UserFromQuery

func UserFromQuery(c *gin.Context) (*User, int, error)

func (*User) GetAL

func (user *User) GetAL(cid uint64) AL

func (*User) GetRTP

func (user *User) GetRTP(cid uint64) float64

func (*User) GetWallet

func (user *User) GetWallet(cid uint64) float64

func (*User) Init

func (user *User) Init()

func (*User) InsertProps

func (user *User) InsertProps(props *Props)

type Walletlog

type Walletlog struct {
	ID     uint64    `xorm:"pk autoincr" json:"id" yaml:"id" xml:"id,attr"`
	CTime  time.Time `xorm:"created 'ctime' notnull default CURRENT_TIMESTAMP" json:"ctime" yaml:"ctime" xml:"ctime"` // creation time
	CID    uint64    `xorm:"notnull index(bid)" json:"cid" yaml:"cid" xml:"cid,attr"`                                 // club ID
	UID    uint64    `xorm:"notnull index(bid)" json:"uid" yaml:"uid" xml:"uid,attr"`                                 // user ID
	AID    uint64    `xorm:"notnull" json:"aid" yaml:"aid" xml:"aid"`                                                 // admin ID
	Wallet float64   `xorm:"notnull" json:"wallet" yaml:"wallet" xml:"wallet"`                                        // new value in coins
	Sum    float64   `xorm:"notnull" json:"sum" yaml:"sum" xml:"sum"`
}

Jump to

Keyboard shortcuts

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