Documentation
¶
Index ¶
Constants ¶
View Source
const GameEntity = "KaiserGame"
Variables ¶
View Source
var ( ErrNotFound = errors.New("Not found") ErrNotUnique = errors.New("ID is not unique") ErrPlayerPositionFilled = errors.New("Player position is already filled") ErrPlayerAlreadyAdded = errors.New("Player is already added") )
View Source
var ( // ErrCacheMiss means the item was not found in the cache. ErrCacheMiss = errors.New("Not in cache") )
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache interface { // Get gets a value for a key. Returns ErrCacheMiss if not found. Get(ctx context.Context, key string) (string, error) // Set sets a value for a key. Use timeout=0 for "forever". // Of course, since this is a "cache", nothing is guaranted and the item may disappear at any time. Set(ctx context.Context, key, value string, timeout time.Duration) error // Clear clears the cache key. Clear(ctx context.Context, key string) error }
Cache stores key/value pairs inexpensively.
func NewMemcacheCache ¶
func NewMemcacheCache() Cache
NewMemcacheCache creates a cache backed by appengine.memcache.
type Game ¶
type Game struct { Key *datastore.Key PlayerIDs []string // Organizing player is 0-index; clockwise afterwards (e.g., 0 and 2 are partners). Created time.Time Updated time.Time Complete bool Score string `datastore:",noindex"` // The running tally of the game. CurrentDealerPos int `datastore:",noindex"` // The position of the current dealer. CurrentBidding string `datastore:",noindex"` // The bids for the current hand; 0-index is the player clockwise from the CurrentDealerPos (one higher, wrapping at 4). CurrentHands string `datastore:",noindex"` // Cards held by each player, parallel with the PlayerIDs above. CurrentTrick string `datastore:",noindex"` // Cards played for current trick; 0-index is the lead player (i.e., the order the cards were played). LastTrick string `datastore:",noindex"` // Cards played for the previous trick. CurrentTally string `datastore:",noindex"` // The running tally for the current hand. PassedCards string `datastore:",noindex"` // Cards passed for the current trick. Rules Rules }
type GameStore ¶
type GameStore interface { Create(ctx context.Context, id, organizingPlayerID string, rules Rules) (*Game, error) Get(ctx context.Context, id string) (*Game, error) Set(ctx context.Context, id string, g *Game) error AddPlayer(ctx context.Context, id, playerID string, pos int) (*Game, error) GetCurrentGames(ctx context.Context, playerID string, count int) ([]*Game, error) }
func NewDatastoreGameStore ¶
func NewDatastoreGameStore() GameStore
func NewFakeGameStore ¶
NewFakeGameStore creates an in-memory game store, accepting an initial map of id->*Game.
type PlayerStore ¶
type PlayerStore interface { Create(ctx context.Context, id, name string) (*Player, error) Get(ctx context.Context, id string) (*Player, error) GetMulti(ctx context.Context, ids []string) ([]*Player, error) Set(ctx context.Context, id string, p *Player) error }
func NewDatastorePlayerStore ¶
func NewDatastorePlayerStore() PlayerStore
func NewFakePlayerStore ¶
func NewFakePlayerStore(ids ...string) PlayerStore
NewFakePlayerStore creates an in-memory player store.
Click to show internal directories.
Click to hide internal directories.