Documentation ¶
Index ¶
- Constants
- Variables
- func GamesSessionIdFromUserIDs(user1, user2 string) string
- func UserIDsFromGameSessionID(id string) (user1, user2 string, err error)
- type Battle
- func (j *Battle) IsWithStranger() bool
- func (j *Battle) MarshalJSON() ([]byte, error)
- func (j *Battle) MarshalJSONBuf(buf fflib.EncodingBuffer) error
- func (j *Battle) String() string
- func (j *Battle) UnmarshalJSON(input []byte) error
- func (j *Battle) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error
- type Battles
- type BattlesHandler
- type Bid
- type GamesSession
- type GamesSessionEntity
- type LastGame
- type Play
- type PlayEntity
- type TelegramChat
- type TelegramChatEntity
- type User
- type UserEntity
- type UserFirebase
- type UserFirebaseEntity
Constants ¶
const GamesSessionKind = "uu"
const PlayKind = "Play"
const (
UserFirebaseKind = "UserFirebase"
)
const (
UserKind = "User"
)
Variables ¶
var ErrNotEnoughTokens = errors.New("not enough tokens")
Functions ¶
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 (*Battle) MarshalJSON ¶
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) UnmarshalJSON ¶
UnmarshalJSON umarshall json - template of ffjson
func (*Battle) UnmarshalJSONFFLexer ¶
UnmarshalJSONFFLexer fast json unmarshall - template ffjson
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 ¶
func (*Bid) MarshalJSON ¶
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) UnmarshalJSON ¶
UnmarshalJSON umarshall json - template of ffjson
func (*Bid) UnmarshalJSONFFLexer ¶
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 ¶
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 ¶
UnmarshalJSON umarshall json - template of ffjson
func (*LastGame) UnmarshalJSONFFLexer ¶
UnmarshalJSONFFLexer fast json unmarshall - template ffjson
type Play ¶
type Play struct { db.StringID *PlayEntity }
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
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 }
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"` }