turnbased

package module
v0.0.0-...-712dc61 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2018 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const BoardKind = "B"
View Source
const LeaveTournamentCommandCode = "leave-tournament"

Variables

View Source
var (
	ErrOldRound     = errors.New("old round")
	ErrUnknownRound = errors.New("unknown round")
)

Functions

func GetBoardID

func GetBoardID(whi bots.WebhookInput, boardID string) (string, error)

func LeaveTournamentAction

func LeaveTournamentAction(whc bots.WebhookContext, prizarenaGameID, prizarenaToken string, database db.Database, board Board) (err error)

func NextRound

func NextRound(board Board)

Types

type Board

type Board struct {
	db.StringID
	*BoardEntity
}

func GetBoardByID

func GetBoardByID(c context.Context, database db.Database, boardID string) (board Board, err error)

func MakeMove

func MakeMove(c context.Context, now time.Time, database db.Database, round int, lang, boardID, userID, userName, move string) (board Board, err error)

func (Board) Entity

func (canvas Board) Entity() interface{}

func (Board) Kind

func (Board) Kind() string

func (Board) NewEntity

func (canvas Board) NewEntity() interface{}

func (*Board) SetEntity

func (canvas *Board) SetEntity(v interface{})

type BoardEntity

type BoardEntity struct {
	BoardEntityBase
	UserTimes     []time.Time                     `datastore:",noindex"`
	UserMoves     slices.CommaSeparatedValuesList `datastore:",noindex,omitempty"`
	UserWinCounts []int                           `datastore:",noindex"`
	DrawsCount    int                             `datastore:",noindex,omitempty"`
}

type BoardEntityBase

type BoardEntityBase struct {
	Created        time.Time
	CreatorUserID  string `datastore:",noindex,omitempty"`
	UserIDs        []string
	UserNames      []string `datastore:",noindex"`
	UserWins       []int    `datastore:",noindex"`
	UsersMin       int      `datastore:",noindex,omitempty"`
	UsersMax       int      `datastore:",noindex,omitempty"`
	Round          int      `datastore:",noindex,omitempty"`
	Lang           string   `datastore:",noindex,omitempty"`
	TournamentID   string   `datastore:",omitempty"`
	TournamentJson string   `datastore:",noindex,omitempty"`
}

func (*BoardEntityBase) AddUser

func (b *BoardEntityBase) AddUser(userID, userName string)

func (BoardEntityBase) GetUserName

func (bb BoardEntityBase) GetUserName(userID string) string

func (BoardEntityBase) IsNewUser

func (bb BoardEntityBase) IsNewUser(userID string) bool

type BoardUsersManagers

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

func (BoardUsersManagers) AddUserToBoard

func (m BoardUsersManagers) AddUserToBoard(
	c context.Context, userID, userName string, boardBase BoardEntityBase,
	getAppUser func() (bots.BotAppUser, error),
) (userName2 string, boardBase2 BoardEntityBase, err error)

type CellAddress

type CellAddress string

CellAddress is coded as "CharDigit" where Char is X and Digit is Y, e.g. A1, B2, C3, etc.

func NewCellAddress

func NewCellAddress(x, y int) CellAddress

func (CellAddress) Index

func (ca CellAddress) Index(boardSize int) int

func (CellAddress) IsXY

func (ca CellAddress) IsXY(x, y int) bool

func (CellAddress) X

func (ca CellAddress) X() int

func (CellAddress) XY

func (ca CellAddress) XY() (x, y int)

func (CellAddress) Y

func (ca CellAddress) Y() int

type PlayEntity

type PlayEntity struct {
	Created      time.Time
	UserIDs      []string
	TournamentID string    `datastore:",omitempty"`
	Strangers    bool      `datastore:",noindex,omitempty"`
	WinnerUserID string    `datastore:",noindex,omitempty"`
	Finished     time.Time `datastore:",omitempty"`
}

type SingleTurnPlay

type SingleTurnPlay struct {
	db.StringID
	*SingleTurnPlayEntity
}

type SingleTurnPlayEntity

type SingleTurnPlayEntity struct {
	PlayEntity
	UserMoves []string
}

type Size

type Size CellAddress

func NewSize

func NewSize(width, height int) Size

func (Size) Count

func (wh Size) Count() (width int)

func (Size) Height

func (wh Size) Height() (height int)

func (Size) Width

func (wh Size) Width() (width int)

func (Size) WidthHeight

func (wh Size) WidthHeight() (width, height int)

type Transcript

type Transcript string

func (Transcript) Cells

func (t Transcript) Cells() (cells []CellAddress)

func (Transcript) Count

func (t Transcript) Count() int

Jump to

Keyboard shortcuts

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