Documentation
¶
Index ¶
Constants ¶
const ( ActionSetWinners = "SetWinners" // ActionSetWinners sets the winner(s) of a game ActionEndTurn = "EndTurn" // ActionEndTurn ends the turn for the given team )
Common actions most game may utilize if desired
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BoardGame ¶
type BoardGame interface {
// Do performs an action on the game
Do(action *BoardGameAction) error
// GetSnapshot retrieves the current game state from 'team' view
// Entering nothing returns a complete snapshot with no data hidden i.e. all hands, resources, etc.
// Entering more than one team will error
GetSnapshot(team ...string) (*BoardGameSnapshot, error)
}
BoardGame is a representation of a board game allowing one to perform actions on the game as well as to retrieve game data
type BoardGameAction ¶
type BoardGameAction struct {
// Team is the team performing the action - required
Team string
// ActionType is the key that determines what action to perform - required
ActionType string
// MoreDetails allows for additional action details to be passed that are unique to the action type
// Additional details are not required for every action so this field can be ignored if desired
MoreDetails interface{} `json:",omitempty"`
}
BoardGameAction represents an action that is performed on the game state
type BoardGameBuilder ¶
type BoardGameBuilder interface {
// Create creates a game with desired options
Create(options *BoardGameOptions) (BoardGame, error)
// Info provides additional details about the game
Info() *BoardGameInfo
// Key gets the game's unique key, typically the name of the game
Key() string
}
BoardGameBuilder builds a game given a set of options
type BoardGameInfo ¶ added in v1.1.3
type BoardGameInfo struct {
// GameKey is the unique key that differentiates this game from others
GameKey string
// MinTeams and MaxTeams represents the min and max teams allowed when creating a new game
MinTeams, MaxTeams int
// MoreInfo allows for additional game specific info
// Additional info is not required for every game so this field can be ignored if desired
MoreInfo interface{} `json:",omitempty"`
}
BoardGameInfo provides additional details about the game
type BoardGameOptions ¶
type BoardGameOptions struct {
// Teams is the list of teams that will be playing the game - required
Teams []string
// MoreOptions allows for additional game options to be passed that are unique to each game
// Additional options are not required for every game so this field can be ignored if desired
MoreOptions interface{} `json:",omitempty"`
}
BoardGameOptions are the options used to create a new game
type BoardGameSnapshot ¶
type BoardGameSnapshot struct {
// Turn is the turn of the current team - required
Turn string
// Teams is a list of all teams playing the game - required
Teams []string
// Winners is a list of teams that have won the game - required
Winners []string
// MoreData allows for additional game data to be returned that is unique to each game
// Typically more data such as boards, decks, etc. are needed for a game but this field can be ignored if desired
MoreData interface{} `json:",omitempty"`
// Targets are typically a list of BoardGameAction that can be performed on the game state
// This can allow players to view all valid actions through a GUI
// This field is left as an interface to allow for different targeting approaches as well
// Optional feature not required to play a game and can be ignored if desired
Targets interface{} `json:",omitempty"`
// Actions is a list of past game actions that have lead to the current game state
// This can allow players to view game logs of past actions
// Optional feature not required to play a game and can be ignored if desired
Actions []*BoardGameAction `json:",omitempty"`
// Message provides players with information about what to do next
// Optional feature not required to play a game and can be ignored if desired
Message string `json:",omitempty"`
}
BoardGameSnapshot represents the current state of the game that will be viewed by a player
type BoardGameWithBGN ¶
type BoardGameWithBGN interface {
BoardGame
// GetBGN returns the game in board game notation
GetBGN() *bgn.Game
}
BoardGameWithBGN provides extra bgn functionality that does not necessarily need to be implemented to play a game
type BoardGameWithBGNBuilder ¶
type BoardGameWithBGNBuilder interface {
BoardGameBuilder
// CreateWithBGN creates a game with desired options
CreateWithBGN(options *BoardGameOptions) (BoardGameWithBGN, error)
// Load loads a game in board game notation into a normal game
Load(bgn *bgn.Game) (BoardGameWithBGN, error)
}
BoardGameWithBGNBuilder builds a game with additional bgn functionality
type EndTurnActionDetails ¶ added in v1.0.5
type EndTurnActionDetails struct {
}
EndTurnActionDetails are the action details for ending a team's turn
func DecodeEndTurnActionDetailsBGN ¶ added in v1.0.5
func DecodeEndTurnActionDetailsBGN(details, teams []string) (*EndTurnActionDetails, error)
type SetWinnersActionDetails ¶
type SetWinnersActionDetails struct {
Winners []string
}
SetWinnersActionDetails sets the current winner(s) of the game with Winners
func DecodeSetWinnersActionDetailsBGN ¶
func DecodeSetWinnersActionDetailsBGN(details, teams []string) (*SetWinnersActionDetails, error)
DecodeSetWinnersActionDetailsBGN converts a bgn.Action Details object into the SetWinnersActionDetails object