model

package
v0.0.0-...-f4bc3de Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const AdultHand = 5

AdultHand for an adult-mode game, we deal out 5 cards

View Source
const BoardSquares = 60

BoardSquares there are 60 squares around the outside of the board, numbered 0-59

View Source
const MaxPlayers = 4

MaxPlayers a game consists of no more than 4 players

View Source
const MinPlayers = 2

MinPlayers a game consists of at least 2 players

View Source
const Pawns = 4

Pawns there are 4 pawns per player, numbered 0-3

View Source
const SafeSquares = 5

SafeSquares there are 5 safe squares for each color, numbered 0-4

Variables

View Source
var (
	CardTypes     = enum.NewValues[CardType](Card1, Card2, Card3, Card4, Card5, Card7, Card8, Card10, Card11, Card12, CardApologies)
	Card1         = CardType{"1"}
	Card2         = CardType{"2"}
	Card3         = CardType{"3"}
	Card4         = CardType{"4"}
	Card5         = CardType{"5"}
	Card7         = CardType{"7"}
	Card8         = CardType{"8"}
	Card10        = CardType{"10"}
	Card11        = CardType{"11"}
	Card12        = CardType{"12"}
	CardApologies = CardType{"A"}
)
View Source
var (
	GameModes    = enum.NewValues[GameMode](AdultMode, StandardMode)
	StandardMode = GameMode{"StandardMode"}
	AdultMode    = GameMode{"AdultMode"}
)
View Source
var (
	ActionTypes    = enum.NewValues[ActionType](MoveToStart, MoveToPosition)
	MoveToStart    = ActionType{"MoveToStart"}
	MoveToPosition = ActionType{"MoveToPosition"}
)
View Source
var (
	PlayerColors = enum.NewValues[PlayerColor](Red, Yellow, Green, Blue)
	Red          = PlayerColor{"Red"}
	Yellow       = PlayerColor{"Yellow"}
	Blue         = PlayerColor{"Blue"}
	Green        = PlayerColor{"Green"}
)
View Source
var DeckCounts = map[CardType]int{
	Card1:         5,
	Card2:         4,
	Card3:         4,
	Card4:         4,
	Card5:         4,
	Card7:         4,
	Card8:         4,
	Card10:        4,
	Card11:        4,
	Card12:        4,
	CardApologies: 4,
}

DeckCounts defines the number of each type of card is in the deck

View Source
var DeckSize = func(counts map[CardType]int) int {
	total := 0
	for _, v := range counts {
		total += v
	}
	return total
}(DeckCounts)

DeckSize is the total size of the deck

DrawAgain defines whether a given type of card draws again

View Source
var Slides = map[PlayerColor][]Slide{
	Red:    {newSlide(1, 4), newSlide(9, 13)},
	Blue:   {newSlide(16, 19), newSlide(24, 28)},
	Yellow: {newSlide(31, 34), newSlide(39, 43)},
	Green:  {newSlide(46, 49), newSlide(54, 58)},
}

Slides defines the start positions for each color

View Source
var StartCircles = map[PlayerColor]Position{
	Red:    newPositionAtSquare(4),
	Blue:   newPositionAtSquare(19),
	Yellow: newPositionAtSquare(34),
	Green:  newPositionAtSquare(49),
}

StartCircles defines the start circles for each color

View Source
var TurnSquares = map[PlayerColor]Position{
	Red:    newPositionAtSquare(2),
	Blue:   newPositionAtSquare(17),
	Yellow: newPositionAtSquare(32),
	Green:  newPositionAtSquare(47),
}

TurnSquares defines the turn squares for each color, where forward movement turns into the safe zone

Functions

This section is empty.

Types

type Action

type Action interface {
	// Type The type of the action
	Type() ActionType

	// Pawn the pawn that the action operates on
	Pawn() Pawn

	// Position a position that the pawn should move to (optional)
	Position() Position // optional

	// SetPosition Set the position on the action (can be nil)
	SetPosition(position Position)
}

Action is an action that can be taken as part of a move

func NewAction

func NewAction(actionType ActionType, pawn Pawn, position Position) Action

NewAction constructs a new Action

func NewActionFromJSON

func NewActionFromJSON(reader io.Reader) (Action, error)

NewActionFromJSON constructs a new object from JSON in an io.Reader

type ActionType

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

ActionType defines all actions that a character can take

func (ActionType) MarshalText

func (e ActionType) MarshalText() (text []byte, err error)

func (*ActionType) UnmarshalText

func (e *ActionType) UnmarshalText(text []byte) error

func (ActionType) Value

func (e ActionType) Value() string

type Card

type Card interface {
	// Id Unique identifier for this card
	Id() string

	// Type The type of the card
	Type() CardType

	// Copy Return a fully-independent copy of the card.
	Copy() Card
}

Card is a card in a deck or in a player's hand

func NewCard

func NewCard(id string, cardType CardType) Card

NewCard constructs a new Card

func NewCardFromJSON

func NewCardFromJSON(reader io.Reader) (Card, error)

NewCardFromJSON constructs a new object from JSON in an io.Reader

type CardType

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

CardType defines all legal types of cards The "A" card (CardApologies) is like the "Sorry" card in the original game

func (CardType) MarshalText

func (e CardType) MarshalText() (text []byte, err error)

func (*CardType) UnmarshalText

func (e *CardType) UnmarshalText(text []byte) error

func (CardType) Value

func (e CardType) Value() string

type Deck

type Deck interface {
	// Copy Return a fully-independent copy of the deck.
	Copy() Deck

	// Draw a card from the draw pile
	Draw() (Card, error)

	// Discard a card to the discard pile
	Discard(card Card) error
}

Deck The deck of cards associated with a game.

func NewDeck

func NewDeck() Deck

NewDeck constructs a new Deck

func NewDeckFromJSON

func NewDeckFromJSON(reader io.Reader) (Deck, error)

NewDeckFromJSON constructs a new object from JSON in an io.Reader

type Game

type Game interface {
	// PlayerCount Number of players in the game
	PlayerCount() int

	// Players All players in the game
	Players() map[PlayerColor]Player

	// Deck The deck of cards for the game
	Deck() Deck

	// History Game history
	History() []History

	// Copy Return a fully-independent copy of the game.
	Copy() Game

	// Started Whether the game has been started.
	Started() bool

	// Completed Whether the game is completed.
	Completed() bool

	// Winner The winner of the game, if any.
	Winner() *Player

	// Track Tracks an action taken during the game, optionally tracking player and/or card
	Track(action string, player Player, card Card)

	// CreatePlayerView Return a player-specific view of the game, showing only the information a player would have available on their turn.
	CreatePlayerView(color PlayerColor) (PlayerView, error)
}

Game The game, consisting of state for a set of players.

func NewGame

func NewGame(playerCount int, factory timestamp.Factory) (Game, error)

NewGame constructs a new Game, optionally accepting a timestamp factory

func NewGameFromJSON

func NewGameFromJSON(reader io.Reader) (Game, error)

NewGameFromJSON constructs a new object from JSON in an io.Reader

type GameMode

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

GameMode defines legal game modes

func (GameMode) MarshalText

func (e GameMode) MarshalText() (text []byte, err error)

func (*GameMode) UnmarshalText

func (e *GameMode) UnmarshalText(text []byte) error

func (GameMode) Value

func (e GameMode) Value() string

type History

type History interface {
	// Action String describing the action
	Action() string

	// Color Color of the player associated with the action
	Color() *PlayerColor // optional

	// Card Card associated with the action
	Card() *CardType // optional

	// Timestamp Timestamp tied to the action (defaults to current time)
	Timestamp() timestamp.Timestamp

	// Copy Return a fully-independent copy of the history.
	Copy() History
}

History Tracks an action taken during the game.

func NewHistory

func NewHistory(action string, color *PlayerColor, card *CardType, factory timestamp.Factory) History

NewHistory constructs a new History, optionally accepting a timestamp factory

func NewHistoryFromJSON

func NewHistoryFromJSON(reader io.Reader) (History, error)

NewHistoryFromJSON constructs a new object from JSON in an io.Reader

type MockAction

type MockAction struct {
	mock.Mock
}

MockAction is an autogenerated mock type for the Action type

func NewMockAction

func NewMockAction(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockAction

NewMockAction creates a new instance of MockAction. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockAction) Pawn

func (_m *MockAction) Pawn() Pawn

Pawn provides a mock function with given fields:

func (*MockAction) Position

func (_m *MockAction) Position() Position

Position provides a mock function with given fields:

func (*MockAction) SetPosition

func (_m *MockAction) SetPosition(position Position)

SetPosition provides a mock function with given fields: position

func (*MockAction) Type

func (_m *MockAction) Type() ActionType

Type provides a mock function with given fields:

type MockCard

type MockCard struct {
	mock.Mock
}

MockCard is an autogenerated mock type for the Card type

func NewMockCard

func NewMockCard(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockCard

NewMockCard creates a new instance of MockCard. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockCard) Copy

func (_m *MockCard) Copy() Card

Copy provides a mock function with given fields:

func (*MockCard) Id

func (_m *MockCard) Id() string

Id provides a mock function with given fields:

func (*MockCard) Type

func (_m *MockCard) Type() CardType

Type provides a mock function with given fields:

type MockDeck

type MockDeck struct {
	mock.Mock
}

MockDeck is an autogenerated mock type for the Deck type

func NewMockDeck

func NewMockDeck(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockDeck

NewMockDeck creates a new instance of MockDeck. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockDeck) Copy

func (_m *MockDeck) Copy() Deck

Copy provides a mock function with given fields:

func (*MockDeck) Discard

func (_m *MockDeck) Discard(card Card) error

Discard provides a mock function with given fields: card

func (*MockDeck) Draw

func (_m *MockDeck) Draw() (Card, error)

Draw provides a mock function with given fields:

type MockGame

type MockGame struct {
	mock.Mock
}

MockGame is an autogenerated mock type for the Game type

func NewMockGame

func NewMockGame(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockGame

NewMockGame creates a new instance of MockGame. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockGame) Completed

func (_m *MockGame) Completed() bool

Completed provides a mock function with given fields:

func (*MockGame) Copy

func (_m *MockGame) Copy() Game

Copy provides a mock function with given fields:

func (*MockGame) CreatePlayerView

func (_m *MockGame) CreatePlayerView(color PlayerColor) (PlayerView, error)

CreatePlayerView provides a mock function with given fields: color

func (*MockGame) Deck

func (_m *MockGame) Deck() Deck

Deck provides a mock function with given fields:

func (*MockGame) History

func (_m *MockGame) History() []History

History provides a mock function with given fields:

func (*MockGame) PlayerCount

func (_m *MockGame) PlayerCount() int

PlayerCount provides a mock function with given fields:

func (*MockGame) Players

func (_m *MockGame) Players() map[PlayerColor]Player

Players provides a mock function with given fields:

func (*MockGame) Started

func (_m *MockGame) Started() bool

Started provides a mock function with given fields:

func (*MockGame) Track

func (_m *MockGame) Track(action string, player Player, card Card)

Track provides a mock function with given fields: action, player, card

func (*MockGame) Winner

func (_m *MockGame) Winner() *Player

Winner provides a mock function with given fields:

type MockHistory

type MockHistory struct {
	mock.Mock
}

MockHistory is an autogenerated mock type for the History type

func NewMockHistory

func NewMockHistory(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockHistory

NewMockHistory creates a new instance of MockHistory. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockHistory) Action

func (_m *MockHistory) Action() string

Action provides a mock function with given fields:

func (*MockHistory) Card

func (_m *MockHistory) Card() *CardType

Card provides a mock function with given fields:

func (*MockHistory) Color

func (_m *MockHistory) Color() *PlayerColor

Color provides a mock function with given fields:

func (*MockHistory) Copy

func (_m *MockHistory) Copy() History

Copy provides a mock function with given fields:

func (*MockHistory) Timestamp

func (_m *MockHistory) Timestamp() timestamp.Timestamp

Timestamp provides a mock function with given fields:

type MockMove

type MockMove struct {
	mock.Mock
}

MockMove is an autogenerated mock type for the Move type

func NewMockMove

func NewMockMove(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockMove

NewMockMove creates a new instance of MockMove. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockMove) Actions

func (_m *MockMove) Actions() []Action

Actions provides a mock function with given fields:

func (*MockMove) AddSideEffect

func (_m *MockMove) AddSideEffect(action Action)

AddSideEffect provides a mock function with given fields: action

func (*MockMove) Card

func (_m *MockMove) Card() Card

Card provides a mock function with given fields:

func (*MockMove) MergedActions

func (_m *MockMove) MergedActions() []Action

MergedActions provides a mock function with given fields:

func (*MockMove) SideEffects

func (_m *MockMove) SideEffects() []Action

SideEffects provides a mock function with given fields:

type MockPawn

type MockPawn struct {
	mock.Mock
}

MockPawn is an autogenerated mock type for the Pawn type

func NewMockPawn

func NewMockPawn(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockPawn

NewMockPawn creates a new instance of MockPawn. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockPawn) Color

func (_m *MockPawn) Color() PlayerColor

Color provides a mock function with given fields:

func (*MockPawn) Copy

func (_m *MockPawn) Copy() Pawn

Copy provides a mock function with given fields:

func (*MockPawn) Index

func (_m *MockPawn) Index() int

Index provides a mock function with given fields:

func (*MockPawn) Name

func (_m *MockPawn) Name() string

Name provides a mock function with given fields:

func (*MockPawn) Position

func (_m *MockPawn) Position() Position

Position provides a mock function with given fields:

func (*MockPawn) SetPosition

func (_m *MockPawn) SetPosition(position Position)

SetPosition provides a mock function with given fields: position

type MockPlayer

type MockPlayer struct {
	mock.Mock
}

MockPlayer is an autogenerated mock type for the Player type

func NewMockPlayer

func NewMockPlayer(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockPlayer

NewMockPlayer creates a new instance of MockPlayer. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockPlayer) AllPawnsInHome

func (_m *MockPlayer) AllPawnsInHome() bool

AllPawnsInHome provides a mock function with given fields:

func (*MockPlayer) AppendToHand

func (_m *MockPlayer) AppendToHand(card Card)

AppendToHand provides a mock function with given fields: card

func (*MockPlayer) Color

func (_m *MockPlayer) Color() PlayerColor

Color provides a mock function with given fields:

func (*MockPlayer) Copy

func (_m *MockPlayer) Copy() Player

Copy provides a mock function with given fields:

func (*MockPlayer) FindFirstPawnInStart

func (_m *MockPlayer) FindFirstPawnInStart() *Pawn

FindFirstPawnInStart provides a mock function with given fields:

func (*MockPlayer) Hand

func (_m *MockPlayer) Hand() []Card

Hand provides a mock function with given fields:

func (*MockPlayer) IncrementTurns

func (_m *MockPlayer) IncrementTurns()

IncrementTurns provides a mock function with given fields:

func (*MockPlayer) Pawns

func (_m *MockPlayer) Pawns() []Pawn

Pawns provides a mock function with given fields:

func (*MockPlayer) PublicData

func (_m *MockPlayer) PublicData() Player

PublicData provides a mock function with given fields:

func (*MockPlayer) RemoveFromHand

func (_m *MockPlayer) RemoveFromHand(card Card)

RemoveFromHand provides a mock function with given fields: card

func (*MockPlayer) Turns

func (_m *MockPlayer) Turns() int

Turns provides a mock function with given fields:

type MockPlayerView

type MockPlayerView struct {
	mock.Mock
}

MockPlayerView is an autogenerated mock type for the PlayerView type

func NewMockPlayerView

func NewMockPlayerView(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockPlayerView

NewMockPlayerView creates a new instance of MockPlayerView. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockPlayerView) AllPawns

func (_m *MockPlayerView) AllPawns() []Pawn

AllPawns provides a mock function with given fields:

func (*MockPlayerView) Copy

func (_m *MockPlayerView) Copy() PlayerView

Copy provides a mock function with given fields:

func (*MockPlayerView) GetPawn

func (_m *MockPlayerView) GetPawn(prototype Pawn) Pawn

GetPawn provides a mock function with given fields: prototype

func (*MockPlayerView) Opponents

func (_m *MockPlayerView) Opponents() map[PlayerColor]Player

Opponents provides a mock function with given fields:

func (*MockPlayerView) Player

func (_m *MockPlayerView) Player() Player

Player provides a mock function with given fields:

type MockPosition

type MockPosition struct {
	mock.Mock
}

MockPosition is an autogenerated mock type for the Position type

func NewMockPosition

func NewMockPosition(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockPosition

NewMockPosition creates a new instance of MockPosition. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockPosition) Copy

func (_m *MockPosition) Copy() Position

Copy provides a mock function with given fields:

func (*MockPosition) Home

func (_m *MockPosition) Home() bool

Home provides a mock function with given fields:

func (*MockPosition) MoveToHome

func (_m *MockPosition) MoveToHome() error

MoveToHome provides a mock function with given fields:

func (*MockPosition) MoveToPosition

func (_m *MockPosition) MoveToPosition(position Position) error

MoveToPosition provides a mock function with given fields: position

func (*MockPosition) MoveToSafe

func (_m *MockPosition) MoveToSafe(safe int) error

MoveToSafe provides a mock function with given fields: safe

func (*MockPosition) MoveToSquare

func (_m *MockPosition) MoveToSquare(square int) error

MoveToSquare provides a mock function with given fields: square

func (*MockPosition) MoveToStart

func (_m *MockPosition) MoveToStart() error

MoveToStart provides a mock function with given fields:

func (*MockPosition) Safe

func (_m *MockPosition) Safe() *int

Safe provides a mock function with given fields:

func (*MockPosition) Square

func (_m *MockPosition) Square() *int

Square provides a mock function with given fields:

func (*MockPosition) Start

func (_m *MockPosition) Start() bool

Start provides a mock function with given fields:

type MockSlide

type MockSlide struct {
	mock.Mock
}

MockSlide is an autogenerated mock type for the Slide type

func NewMockSlide

func NewMockSlide(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockSlide

NewMockSlide creates a new instance of MockSlide. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockSlide) End

func (_m *MockSlide) End() int

End provides a mock function with given fields:

func (*MockSlide) Start

func (_m *MockSlide) Start() int

Start provides a mock function with given fields:

type Move

type Move interface {
	Card() Card
	Actions() []Action
	SideEffects() []Action
	AddSideEffect(action Action)
	MergedActions() []Action
}

Move is a player's move on the board, which consists of one or more actions

Note that the actions associated with a move include both the immediate actions that the player chose (such as moving a pawn from start or swapping places with a different pawn), but also any side-effects (such as pawns that are bumped back to start because of a slide). As a result, executing a move becomes very easy and no validation is required. All of the work is done up-front.

func NewMove

func NewMove(card Card, actions []Action, sideEffects []Action) Move

NewMove constructs a new move, optionally accepting an identify factory If there are no actions or side effects, you may pass nil, which is equivalent to a newly-allocated empty slice

func NewMoveFromJSON

func NewMoveFromJSON(reader io.Reader) (Move, error)

NewMoveFromJSON constructs a new object from JSON in an io.Reader

type Pawn

type Pawn interface {
	// Color the color of this pawn
	Color() PlayerColor

	// Index Zero-based index of this pawn for a given user
	Index() int

	// Name The full name of this pawn as "colorindex"
	Name() string

	// Position The position of this pawn on the board
	Position() Position

	// SetPosition Set the position of this pawn on the board
	SetPosition(position Position)

	// Copy Return a fully-independent copy of the pawn.
	Copy() Pawn
}

Pawn is a pawn on the board, belonging to a player.

func NewPawn

func NewPawn(color PlayerColor, index int) Pawn

NewPawn constructs a new Pawn

func NewPawnFromJSON

func NewPawnFromJSON(reader io.Reader) (Pawn, error)

NewPawnFromJSON constructs a new object from JSON in an io.Reader

type Player

type Player interface {
	// Color the color of this player
	Color() PlayerColor

	// Hand List of cards in the player's hand
	Hand() []Card

	// Pawns List of all pawns belonging to the player
	Pawns() []Pawn

	// Turns number of turns for this player
	Turns() int

	// Copy Return a fully-independent copy of the player.
	Copy() Player

	// PublicData Return a fully-independent copy of the player with only public data visible.
	PublicData() Player

	// AppendToHand appends a card into the player's hand
	AppendToHand(card Card)

	// RemoveFromHand removes a card from the player's hand
	RemoveFromHand(card Card)

	// FindFirstPawnInStart Find the first pawn in the start area, if any.
	FindFirstPawnInStart() *Pawn // optional

	// AllPawnsInHome Whether all of this user's pawns are in home.
	AllPawnsInHome() bool

	// IncrementTurns the number of turns for a player
	IncrementTurns()
}

Player A player, which has a color and a set of pawns.

func NewPlayer

func NewPlayer(color PlayerColor) Player

NewPlayer constructs a new Player

func NewPlayerFromJSON

func NewPlayerFromJSON(reader io.Reader) (Player, error)

NewPlayerFromJSON constructs a new object from JSON in an io.Reader

type PlayerColor

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

PlayerColor defines all legal player colors, enumerated in order of use

func (PlayerColor) MarshalText

func (e PlayerColor) MarshalText() (text []byte, err error)

func (*PlayerColor) UnmarshalText

func (e *PlayerColor) UnmarshalText(text []byte) error

func (PlayerColor) Value

func (e PlayerColor) Value() string

type PlayerView

type PlayerView interface {
	// Player The player associated with the view.
	Player() Player

	// Opponents The player's opponents, with private information stripped
	Opponents() map[PlayerColor]Player

	// Copy Return a fully-independent copy of the player view.
	Copy() PlayerView

	// GetPawn Return the pawn from this view with the same color and index, possibly nil
	GetPawn(prototype Pawn) Pawn

	// AllPawns Return a list of all pawns on the board.
	AllPawns() []Pawn
}

PlayerView A player-specific view of the game, showing only the information a player would have available on their turn.

func NewPlayerView

func NewPlayerView(player Player, opponents map[PlayerColor]Player) PlayerView

NewPlayerView contructs a new PlayerView

func NewPlayerViewFromJSON

func NewPlayerViewFromJSON(reader io.Reader) (PlayerView, error)

NewPlayerViewFromJSON constructs a new object from JSON in an io.Reader

type Position

type Position interface {
	// Start Whether this pawn resides in its start area
	Start() bool

	// Home Whether this pawn resides in its home area
	Home() bool

	// Safe Zero-based index of the square in the safe area where this pawn resides
	Safe() *int // optional

	// Square Zero-based index of the square on the board where this pawn resides
	Square() *int // optional

	// Copy Return a fully-independent copy of the position.
	Copy() Position

	// MoveToPosition Move the pawn to a specific position on the board.
	MoveToPosition(position Position) error

	// MoveToStart Move the pawn back to its start area.
	MoveToStart() error

	// MoveToHome Move the pawn to its home area.
	MoveToHome() error

	// MoveToSafe Move the pawn to a square in its safe area.
	MoveToSafe(safe int) error

	// MoveToSquare Move the pawn to a square on the board.
	MoveToSquare(square int) error
}

Position is the position of a pawn on the board.

func NewPosition

func NewPosition(start bool, home bool, safe *int, square *int) Position

NewPosition constructs a new Position

func NewPositionFromJSON

func NewPositionFromJSON(reader io.Reader) (Position, error)

NewPositionFromJSON constructs a new object from JSON in an io.Reader

type Slide

type Slide interface {
	// Start is the start of the slide
	Start() int

	// End is the end of a the slide
	End() int
}

Slide defines the start and end positions of a slide on the board

Jump to

Keyboard shortcuts

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