models

package
v0.0.0-...-3db5ba0 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2018 License: GPL-3.0 Imports: 16 Imported by: 1

Documentation

Index

Constants

View Source
const GamesSessionKind = "uu"
View Source
const PlayKind = "Play"
View Source
const (
	UserFirebaseKind = "UserFirebase"
)
View Source
const (
	UserKind = "User"
)

Variables

View Source
var ErrNotEnoughTokens = errors.New("not enough tokens")

Functions

func GamesSessionIdFromUserIDs

func GamesSessionIdFromUserIDs(user1, user2 string) string

func UserIDsFromGameSessionID

func UserIDsFromGameSessionID(id string) (user1, user2 string, err error)

Types

type Battle

type Battle struct {
	ID       arena.BattleID
	OldID    arena.BattleID `json:",omitempty"`
	Name     string         `json:",omitempty"`
	Nick     string         `json:",omitempty"`
	Bid      *Bid           `json:",omitempty"`
	Move     string         `json:",omitempty"` // For GreedGame it's empty. For BiddingTTT it's cell, for RPS its either rock|paper|scissors
	LastGame *LastGame      `json:",omitempty"`
}

Holds information about bids made by a user against other user in some tournament BattleID has form of userId@tournamentID User or some other dedicated entity will hold list of battles for a specific user

func (*Battle) IsWithStranger

func (j *Battle) IsWithStranger() bool

func (*Battle) MarshalJSON

func (j *Battle) MarshalJSON() ([]byte, error)

MarshalJSON marshal bytes to json - template

func (*Battle) MarshalJSONBuf

func (j *Battle) MarshalJSONBuf(buf fflib.EncodingBuffer) error

MarshalJSONBuf marshal buff to json - template

func (*Battle) String

func (j *Battle) String() string

func (*Battle) UnmarshalJSON

func (j *Battle) UnmarshalJSON(input []byte) error

UnmarshalJSON umarshall json - template of ffjson

func (*Battle) UnmarshalJSONFFLexer

func (j *Battle) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error

UnmarshalJSONFFLexer fast json unmarshall - template ffjson

type Battles

type Battles []Battle

func (Battles) GetBattleByRivalID

func (battles Battles) GetBattleByRivalID(k arena.BattleID) *Battle

type BattlesHandler

type BattlesHandler struct {
	BattlesJson  string `datastore:",noindex,omitempty"`
	BattlesCount int    `datastore:",noindex,omitempty"`
}

func (*BattlesHandler) GetBattles

func (entity *BattlesHandler) GetBattles() (battles Battles)

func (*BattlesHandler) SetBattles

func (entity *BattlesHandler) SetBattles(battles []Battle)

type Bid

type Bid struct {
	Time  time.Time
	Value int
}

func (*Bid) MarshalJSON

func (j *Bid) MarshalJSON() ([]byte, error)

MarshalJSON marshal bytes to json - template

func (*Bid) MarshalJSONBuf

func (j *Bid) MarshalJSONBuf(buf fflib.EncodingBuffer) error

MarshalJSONBuf marshal buff to json - template

func (*Bid) String

func (j *Bid) String() string

func (*Bid) UnmarshalJSON

func (j *Bid) UnmarshalJSON(input []byte) error

UnmarshalJSON umarshall json - template of ffjson

func (*Bid) UnmarshalJSONFFLexer

func (j *Bid) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error

UnmarshalJSONFFLexer fast json unmarshall - template ffjson

type GamesSession

type GamesSession struct {
	db.StringID
	*GamesSessionEntity
}

func (GamesSession) Entity

func (s GamesSession) Entity() interface{}

func (GamesSession) Kind

func (GamesSession) Kind() string

func (GamesSession) NewEntity

func (GamesSession) NewEntity() interface{}

func (GamesSession) SetEntity

func (s GamesSession) SetEntity(v interface{})

func (GamesSession) UserBalance

func (s GamesSession) UserBalance(userID string) int

type GamesSessionEntity

type GamesSessionEntity struct {
	Created          time.Time `datastore:",noindex,omitempty"`
	LastGameID       string    `datastore:"LgId,noindex,omitempty"`
	LastGameFinished time.Time `datastore:"LgT,noindex,omitempty"`
	GamesPlayed      int       `datastore:",noindex,omitempty"`
	Balance          int       `datastore:",noindex,omitempty"` // Balance for 1st user
}

type LastGame

type LastGame struct {
	ID       string
	Status   string
	UserBid  int
	RivalBid int
	Prize    int
	Time     time.Time `json:"t"`
}

func (*LastGame) MarshalJSON

func (j *LastGame) MarshalJSON() ([]byte, error)

MarshalJSON marshal bytes to json - template

func (*LastGame) MarshalJSONBuf

func (j *LastGame) MarshalJSONBuf(buf fflib.EncodingBuffer) error

MarshalJSONBuf marshal buff to json - template

func (*LastGame) UnmarshalJSON

func (j *LastGame) UnmarshalJSON(input []byte) error

UnmarshalJSON umarshall json - template of ffjson

func (*LastGame) UnmarshalJSONFFLexer

func (j *LastGame) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error

UnmarshalJSONFFLexer fast json unmarshall - template ffjson

type Play

type Play struct {
	db.StringID
	*PlayEntity
}

func (Play) Entity

func (g Play) Entity() interface{}

func (Play) Kind

func (Play) Kind() string

func (Play) NewEntity

func (Play) NewEntity() interface{}

func (*Play) SetEntity

func (g *Play) SetEntity(v interface{})

type PlayEntity

type PlayEntity struct {
	turnbased.PlayEntity
	Bids []int `datastore:",noindex"`
}

func (*PlayEntity) GetBid

func (g *PlayEntity) GetBid(userID string) (bid int)

func (PlayEntity) HasBothBids

func (g PlayEntity) HasBothBids() bool

func (PlayEntity) Prize

func (g PlayEntity) Prize() int

func (*PlayEntity) SetBid

func (g *PlayEntity) SetBid(userID string, bid int) (change int)

type TelegramChat

type TelegramChat struct {
	telegram.TgChatBase
	*TelegramChatEntity
}

func (TelegramChat) Entity

func (tgChat TelegramChat) Entity() interface{}

func (TelegramChat) Kind

func (TelegramChat) Kind() string

func (TelegramChat) NewEntity

func (TelegramChat) NewEntity() interface{}

func (*TelegramChat) SetEntity

func (tgChat *TelegramChat) SetEntity(entity interface{})

type TelegramChatEntity

type TelegramChatEntity struct {
	UserGroupID string `datastore:",index"` // Do index
	telegram.TgChatEntityBase
}

func (*TelegramChatEntity) Load

func (entity *TelegramChatEntity) Load(ps []datastore.Property) error

func (*TelegramChatEntity) Save

func (entity *TelegramChatEntity) Save() (properties []datastore.Property, err error)

type User

type User struct {
	db.StringID
	*UserEntity
}

func (User) Entity

func (u User) Entity() interface{}

func (User) Kind

func (User) Kind() string

func (User) NewEntity

func (User) NewEntity() interface{}

func (User) RecordBid

func (u User) RecordBid(rivalKey arena.BattleID, bid int, now time.Time) (battle Battle, battles []Battle, err error)

func (*User) SetEntity

func (u *User) SetEntity(v interface{})

type UserEntity

type UserEntity struct {
	strongo.AppUserBase
	user.AccountsOfUser

	Name        string `datastore:",noindex,omitempty"`
	Created     time.Time
	AvatarURL   string `datastore:",noindex,omitempty"`
	FirebaseUID string `datastore:",omitempty"`
	Tokens      int
	//
	//
	TournamentIDs []string `datastore:",noindex"`
	BattlesHandler
}

func (*UserEntity) SetBotUserID

func (u *UserEntity) SetBotUserID(platform, botID, botUserID string)

type UserFirebase

type UserFirebase struct {
	db.StringID
	*UserFirebaseEntity
}

func (*UserFirebase) Entity

func (u *UserFirebase) Entity() interface{}

func (UserFirebase) Kind

func (UserFirebase) Kind() string

func (UserFirebase) NewEntity

func (UserFirebase) NewEntity() interface{}

func (*UserFirebase) SetEntity

func (u *UserFirebase) SetEntity(v interface{})

type UserFirebaseEntity

type UserFirebaseEntity struct {
	UserID        string `datastore:",omitempty"`
	Created       time.Time
	DisplayName   string `datastore:",noindex,omitempty"`
	Email         string `datastore:",omitempty"`
	EmailVerified bool   `datastore:",noindex,omitempty"`
	PhotoURL      string `datastore:",noindex,omitempty"`
	PhoneNumber   string `datastore:",noindex,omitempty"`
	ProviderID    string `datastore:",noindex,omitempty"`
	FcmToken      string `datastore:",noindex,omitempty"`
}

Jump to

Keyboard shortcuts

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