Documentation ¶
Overview ¶
Package moves is a convenience package that implements composable Moves to make it easy to implement common logic. The Base move type is a very simple move that implements the basic stubs necessary for your straightforward moves to have minimal boilerplate. Although it's technically optional, a lot of the magic features throughout the framework depend on some if its base logic, so it's recommended to always embed it anonymously in your move struct (or embed a struct that embeds it).
You interact with and configure various move types by implementing interfaces. Those interfaes are defined in the interfaces subpackage, to make this package's design more clear.
There are many move types defined. Some are designed to be used directly with minimal modification; others are powerful move types that are designed to be sub-classed.
Automatic MoveConfig Generation ¶
Creating MoveConfig's is a necessary part of installing moves on your GameManager, but it's verbose and error-prone. You need to create a lot of extra structs, and then remember to provide the right properties in your config. And to use many of the powerful moves in the moves package, you need to write a lot of boilerplate methods to integrate correctly. Finally, you end up repeating yourself often--which makes it a pain if you change the name of a move.
Take this example:
//boardgame:codegen type MoveDealInitialCards struct { moves.DealComponentsUntilPlayerCountReached } var moveDealInitialCardsConfig = boardgame.MoveConfig { Name: "Deal Initial Cards", Constructor: func() boardgame.Move { return new(MoveDealInitialCards) }, } func (m *MoveDealInitialCards) GameStack(gState boardgame.MutableSubState) boardgame.MutableStack { return gState.(*gameState).DrawStack } func (m *MoveDealInitialCards) PlayerStack(pState boardgame.MutablePlayerState) boardgame.MutableStack { return pState.(*playerState).Hand } func (m *MoveDealInitialCards) TargetCount(state boardgame.ImmutableState) int { return 2 } func (g *gameDelegate) ConfigureMoves() []boardgame.MoveConfig { return moves.Add( &moveDealInitialCardsConfig, ) }
auto.Config (and its panic-y sibling auto.MustConfig) help reduce this signficantly:
func (g *gameDelegate) ConfigureMoves() []boardgame.MoveConfig { auto := moves.NewAutoConfigurer(g) return moves.Add( auto.MustConfig( new(moves.DealComponentsUntilPlayerCountReached), moves.WithGameProperty("DrawStack"), moves.WithPlayerProperty("Hand"), moves.WithTargetCount(2), ) ) }
Basic Usage ¶
AutoConfigurer takes an example struct representing your move, and then a list of 0 to n interfaces.CustomConfigurationOption. These options are given a boardgame.PropertyCollection and then add specific properties to it, and then stash that on the CustomConfiguration property of the returned MoveTypeConfig. Different move methods will then reach into that configuration to alter the behavior of moves of that type.
The moves/with package defines a large collection of CustomConfigurationOption for use with the moves in the moves package.
Moves that are used with AutoConfigurer must satisfy the AutoConfigurableMove interface, which adds one method: DeriveName() string. AutoConfigurer.Config() primarily consists of some set up and then using those return values as fields on the returned MoveConfig. These methods are implemented in moves.Default, which means that any move structs that embed moves.Default (directly or indirectly) can be used with AutoConfigurer.
moves.Default does a fair bit of magic in these methods to implement much of the logic of AutoConfigurer. In general, if you pass a configuration option (via WithMoveName, for example) then that option will be used for that method. moves.Default.DeriveName() also will use reflection to automatically set a struct name like "MoveDealInitialCards" to "Deal Initial Cards". All of the moves in the moves package will also automatically return reasonable names for DeriveName(), so in many cases you can use those structs directly without having to pass WithMoveName().
Other moves in the moves package, like DealCountComponents, will use configuration, like WithGameProperty(), to power their default GameStack() method.
All moves in the moves package are designed to return an error from ValidConfiguration(), which means that if you forgot to pass a required configuration property (e.g. you don't override GameStack and also don't provide WithGameProperty), when you try to create NewGameManager() and all moves' ValidConfiguration() is checked, you'll get an error. This helps catch mis-configurations during boot time.
Refer to the documentation of the various methods in that package for their precise behavior and how to configure them.
Idiomatic Move Definition and Installation ¶
AutoConfigurer is at the core of idiomatic definition and installation of moves, and typically is used for every move you install in your game. The following paragraphs describe the high-level idioms to follow.
Never create your own MoveConfig objects--it's just another global variable that clutters up your code and makes it harder to change. Instead, use AutoConfigurer. There are some rare cases where you do want to refer to the move by name (and not rely on finicky string-based lookup), such as when you want an Agent to propose a speciifc type of move. In those cases use AutoConfigurer to create the move type config, then save the resulting config's Name to a global variable that you use elsewhere, and then pass the created config to moves.Add() (and its cousins)
In general, you should only create a bespoke Move struct in your game if it is not possible to use one of the off-the-shelf moves from the moves package, combined with configuarion options, to do what you want. In practice this means that only if you need to override a method on one of the base moves do you need to create a bespoke struct. This typically allows you to drastically reduce the number of bespoke move structs your game defines, saving thousands of lines of code (each bespoke struct also has hundreds of lines of auto-generated PropertyReader code).
If you do create a bespoke struct, name it like this: "MoveNameOfMyMove", so that moves.Default's default DeriveName() will give it a reasonable name automatically (in this example, "Name Of My Move").
In many cases if you subclass powerful moves like DealCountComponents the default HelpText() value is sufficient (especially if it's a FixUp move that won't ever be seen by players). In other cases, WithHelpText() is often the only config option you will pass to AutoConfigurer.
If your move will be a FixUp move that doesn't sublcass one of the more advanced fix up moves (like RoundRobin or DealCountComponents), embed moves.FixUp into your struct. That will cause IsFixUp to return the right value even without using WithIsFixUp--because WithIsFixUp is easy to forget given that it's often in a different file. In almost all cases if you use WithIsFixUp you should simply embed moves.FixUp instead.
AutoConfigurer.MustConfig is like AutoConfigurer.Config, but instead of returning a MoveConfig and an error, it simply returns a MoveConfig--and panics if it would have returned an error. Since your GameDelegate's ConfigureMoves() is typically called during the boot-up sequence of your game, it is safe to use AutoConfigurer.MustConfig exclusively, which saves many lines of boilerplate error checking.
Configure Move Helpers ¶
Your Game Delegate's ConfigureMoves() []boardgame.MoveConfig is where the action happens for installing moves. In practice you can do whatever you want in there as long as you return a list of MoveConfigs. In practice you often use AutoConfigurer (see section above). If you have a very simple game type you might not need to do anythign special.
If, however, your game type is complicated enough to need the notion of phases, then you'll probably want to use some of the convenience methods for installing moves: Combine, Add, AddForPhase, and AddOrderedForPhase. These methods make sure that enough information is stored for the Legal() methods of those moves to know when the move is legal. Technically they're just convenience wrappers (each describes the straightforward things it's doing), but in practice they're the best way to do it. See the tutorial in the main package for more.
Move Type Hierarchy ¶
The moves in this package are all defined as a hierarchy of structs that anonymously embed higher level structs, overriding, modifying, and extending the behavior of the struct they embed.
You can use many of these moves directly, using the configuration options like WithSourceProperty() to configure which properties they should operate on. Alternatively, you can embed them in your own move struct, overriding or tweaking their behavior, perhaps adding an additional check to their Legal check.
For convenience, here's the type hierarchy, with a brief description of the diff each has on the one above it. See the documentation for each struct for more.
- base.Move - The simplest, unopinonated stub of a move, from the base package.
- Default - Substantial base logic, including base property overriding for with and especially in Legal() around move progressions and phases.
- Done - A simple move that does nothing in its Apply and has no extra Legal() logic, meaning it's primarily a non-fix-up move applied by a player to move out of a move progression.
- CurrentPlayer - Defaults to the GameDelegate.CurrentPlayerIndex, and only lets the move be made if it's on behalf of that player.
- SeatPlayer - A special move that the server package uses to tell the game logic that a new player has been added to the game.
- FixUp - Overrides IsFixUp() to always return true, making the move eligible for base.GameDelegate.ProposeFixUpMove.
- NoOp - A move that does nothing. Useful for specific edge cases of MoveProessionMatching, and also to signal to AddOrderedForPhase that the lack of a StartPhase move was intentional.
- Increment - Increments the provided SourceProperty by Amount. Useful to run automatically at a given spot in a move progression.
- ShuffleStack - Shuffles the stack at SourceProperty. Useful to run automatically at a certain time in a MoveProgression.
- StartPhase - Calls BeforeLeavePhase, then BeforeEnterPhase, then SetCurrentPhase. Generally you have one of these at the end of an AddOrderedForPhase.
- FinishTurn - Checks if State.CurrentPlayer().TurnDone() is true, and if so increments CurrentPlayerIndex to the next player, calling playerState.ResetForTurnEnd() and then ResetForTurnStart.
- WaitForEnoughPlayers - Is illegal until enough players are seated; used to hold up a phase progression to wait for enough players to join
- FixUpMulti - Overrides AllowMultipleInProgression() to true, meaning multiple of the same move are legal to apply in a row according to Deafult.Legal()
- DefaultComponent - Looks at each component in SourceStack() and sees which one's method of Legal() returns nil, selecting that component for you to operate on in your own Apply.
- ActivateInactivePlayer - Activates any players who are not currently active
- CloseEmptySeat - Closes any seats that are still marked as empty, so they won't be filled by the server.
- InactivateEmptySeat - Inactivates any seats that are currently empty, so that the rest of game logic will ignore them.
- ApplyUntil - Legal() returns nil only once ConditionMet() returns nil.
- ApplyUntilCount - Supplies a ConditionMet that returns true when Count() is the same as TargetCount().
- ApplyCountTimes - Supplies a Count() that is the number of times this move has been applied in a row.
- MoveCountComponents - Moves components from SourceStack to DestinationStack until TargetCount have been moved.
- MoveComponentsUntilCountReached - Overrides Count to be how many components are in DestinatinoStack
- MoveComponentsUntilCountLeft - Overrides Count to be how many components are left in SourceStack
- MoveAllComponents - Overrides TargetCount to be 0
- RoundRobin - Applies around and aroudn for each player until PlayerConditionMet returns true for all. You must embed RoundRobinGameStateProperties in your GameState, as all of these moves store state in properties.
- RoundRobinNumRounds - Also checks that no more than NumRounds() around have happened
- DealCountComponents - Moves a component from GameStack to PlayerSTack() one at a time until each player has been dealt TargetCount() components.
- DealComponentsUntilPlayerCountReached - Instead of a fixed number, done when every player has TargetCount or more components in PlayerStack.
- CollectComponentsUntilPlayerCountReached - Flip so that the components move from PlayerStack to GameStack.
- CollectComponentsUntilPlayerCountLeft - Flips it so the TargetCount is when each PlayerStack has that many items or fewer. *CollectAllComponents - Overrides TargetCount to 0, colleting all components.
- CollectComponentsUntilPlayerCountLeft - Flip movement to be from PlayerStack to GameStack, and flip TargetCount to be when all PlayerStack have TargetCount or less.
- DealComponentsUntilGameCountLeft - Instead of a fixed number, done when GameStack's count is TargetCount or less.
- DealAllComponents - Overrides TargetCount to be 0
- CollectComponentsUntilGameCountLeft - Flips move so it's from PlayerStack to GameStack
- CollectCountComponents - Flips so components move from PlayerStacks to GameStack
Move Deal and Collect Component Moves ¶
Generally when moving components from one place to another it makes sense to move one component at a time, so that each component is animated separately. However, this is a pain to implement, because it requires implementing a move that knows how many times to apply itself in a row, which is fincky and error- prone.
There is a collection of 9 moves that all do basically the same thing for moving components, one at a time, from stack to stack. Move-type moves move components between two specific stacks, often both on your GameState. Deal and Collect type moves move components between a stack in GameState and a stack in each Player's PlayerState. Deal-type moves move components from the game stack to the player stack, and Collect-type moves move components from each player to the GameState.
All of these moves define a way to define the source and destination stack. For Move-type moves, you define SourceStack() and DestinationStack(). For Deal and Collect-type moves, you implement GameStack() and PlayerStack().
All moves in this collection implement TargetCount() int, and all of them default to 1. Override this if you want a different number of components checked for in the end condition.
In practice you'll often use WithTargetCount, WithGameProperty, and friends as configuration to AutoConfigurer.Config instead of overriding those yourself. In fact, in many cases configuartion options are powerful enough to allow you to use these moves types on their own directly in your game. See the documentation in the sections above for more examples.
Each of Move, Deal, and Collect have three variants based on the end condition. Note that Move-type moves have only two stacks, but Deal and Collect type moves operate on n pairs of stacks, where n is the number of players in the game. In general for Deal and Collect type moves, the condition is met when all pairs of stacks meet the end condition.
{Move,Deal,Collect}CountComponents simply apply that many moves without regard to the number of components in the source or destination stacks. Move names that end in CountReached operate until the destination stacks all have TargetCount or more items. Move names that end in CountLeft operate until the source stacks all have TargetCount or fewer items in them.
Since a common configuration of these moves is to use {Move,Deal,Collect}ComponentsUntil*Reached with a TargetCount of 0, each also provides a *AllComponents as sugar.
Groups ¶
Groups allow you to specify a specific set of moves that must occur in a given order. You pass them to AddOrderedForPhase. All of the groups are of type MoveProgressionGroup, and this package defines 5: Serial, Parallel, ParallelCount, Repeat, and Optional. They can be nested as often as you'd like to express the semantics of your move progression.
They are defined as functions that return anonymous underlying structs so that when used in configuration you can avoid needing to wrap your children list with []MoveProgressionGroup, saving you typing.
//Example //AddOrderedForPhase accepts move configs from auto.Config, or //groups. moves.AddOrderedForPhase(PhaseNormal, //Top level groups are all joined implicitly into a group.Serial. auto.MustConfig(new(MoveZero)), moves.Serial( auto.MustConfig(new(MoveOne)), moves.Optional( moves.Serial( auto.MustConfig(new(MoveTwo)), auto.MustConfig(new(MoveThree)), ), ), moves.ParallelCount( CountAny(), auto.MustConfig(new(MoveFour)), auto.MustConfig(new(MoveFive)), moves.Repeat( CountAtMost(2), moves.Serial( auto.MustConfig(new(MoveSix)), auto.MustConfig(new(MoveSeven)), ), ), ), ), )
Move names must be unique, but sometimes you want to use the same underlying move at multiple points in a progression. WithMoveNameSuffix is useful for that case.
Seats and Inactive Players ¶
For more on the concepts of seats and inactive players, see the package doc of boardgame/behaviors.
Index ¶
- func Add(moves ...boardgame.MoveConfig) []boardgame.MoveConfig
- func AddForPhase(phase int, moves ...boardgame.MoveConfig) []boardgame.MoveConfig
- func AddOrderedForPhase(phase int, groups ...MoveProgressionGroup) []boardgame.MoveConfig
- func Combine(moves ...[]boardgame.MoveConfig) []boardgame.MoveConfig
- type ActivateInactivePlayer
- func (a *ActivateInactivePlayer) Apply(state boardgame.State) error
- func (a *ActivateInactivePlayer) DefaultsForState(state boardgame.ImmutableState)
- func (a *ActivateInactivePlayer) FallbackHelpText() string
- func (a *ActivateInactivePlayer) FallbackName(m *boardgame.GameManager) string
- func (a *ActivateInactivePlayer) Legal(state boardgame.ImmutableState, proposer boardgame.PlayerIndex) error
- func (a *ActivateInactivePlayer) ReadSetConfigurer() boardgame.PropertyReadSetConfigurer
- func (a *ActivateInactivePlayer) ReadSetter() boardgame.PropertyReadSetter
- func (a *ActivateInactivePlayer) Reader() boardgame.PropertyReader
- func (a *ActivateInactivePlayer) ValidConfiguration(exampleState boardgame.State) error
- type ApplyCountTimes
- func (a *ApplyCountTimes) Count(state boardgame.ImmutableState) int
- func (a *ApplyCountTimes) FallbackHelpText() string
- func (a *ApplyCountTimes) FallbackName(m *boardgame.GameManager) string
- func (a *ApplyCountTimes) ReadSetConfigurer() boardgame.PropertyReadSetConfigurer
- func (a *ApplyCountTimes) ReadSetter() boardgame.PropertyReadSetter
- func (a *ApplyCountTimes) Reader() boardgame.PropertyReader
- type ApplyUntil
- func (a *ApplyUntil) FallbackHelpText() string
- func (a *ApplyUntil) FallbackName(m *boardgame.GameManager) string
- func (a *ApplyUntil) Legal(state boardgame.ImmutableState, proposer boardgame.PlayerIndex) error
- func (a *ApplyUntil) ReadSetConfigurer() boardgame.PropertyReadSetConfigurer
- func (a *ApplyUntil) ReadSetter() boardgame.PropertyReadSetter
- func (a *ApplyUntil) Reader() boardgame.PropertyReader
- func (a *ApplyUntil) ValidConfiguration(exampleState boardgame.State) error
- type ApplyUntilCount
- func (a *ApplyUntilCount) ConditionMet(state boardgame.ImmutableState) error
- func (a *ApplyUntilCount) Count(state boardgame.ImmutableState) int
- func (a *ApplyUntilCount) FallbackHelpText() string
- func (a *ApplyUntilCount) FallbackName(m *boardgame.GameManager) string
- func (a *ApplyUntilCount) ReadSetConfigurer() boardgame.PropertyReadSetConfigurer
- func (a *ApplyUntilCount) ReadSetter() boardgame.PropertyReadSetter
- func (a *ApplyUntilCount) Reader() boardgame.PropertyReader
- func (a *ApplyUntilCount) TargetCount(state boardgame.ImmutableState) int
- func (a *ApplyUntilCount) ValidConfiguration(exampleState boardgame.State) error
- type AutoConfigurableMove
- type AutoConfigurer
- type CloseEmptySeat
- func (c *CloseEmptySeat) Apply(state boardgame.State) error
- func (c *CloseEmptySeat) DefaultsForState(state boardgame.ImmutableState)
- func (c *CloseEmptySeat) FallbackHelpText() string
- func (c *CloseEmptySeat) FallbackName(m *boardgame.GameManager) string
- func (c *CloseEmptySeat) Legal(state boardgame.ImmutableState, proposer boardgame.PlayerIndex) error
- func (c *CloseEmptySeat) ReadSetConfigurer() boardgame.PropertyReadSetConfigurer
- func (c *CloseEmptySeat) ReadSetter() boardgame.PropertyReadSetter
- func (c *CloseEmptySeat) Reader() boardgame.PropertyReader
- func (c *CloseEmptySeat) ValidConfiguration(exampleState boardgame.State) error
- type CollectAllComponents
- func (c *CollectAllComponents) FallbackHelpText() string
- func (c *CollectAllComponents) FallbackName(g *boardgame.GameManager) string
- func (c *CollectAllComponents) ReadSetConfigurer() boardgame.PropertyReadSetConfigurer
- func (c *CollectAllComponents) ReadSetter() boardgame.PropertyReadSetter
- func (c *CollectAllComponents) Reader() boardgame.PropertyReader
- func (c *CollectAllComponents) TargetCount(state boardgame.ImmutableState) int
- type CollectComponentsUntilGameCountReached
- func (d *CollectComponentsUntilGameCountReached) ConditionMet(state boardgame.ImmutableState) error
- func (d *CollectComponentsUntilGameCountReached) FallbackHelpText() string
- func (d *CollectComponentsUntilGameCountReached) FallbackName(m *boardgame.GameManager) string
- func (c *CollectComponentsUntilGameCountReached) ReadSetConfigurer() boardgame.PropertyReadSetConfigurer
- func (c *CollectComponentsUntilGameCountReached) ReadSetter() boardgame.PropertyReadSetter
- func (c *CollectComponentsUntilGameCountReached) Reader() boardgame.PropertyReader
- func (d *CollectComponentsUntilGameCountReached) RoundRobinAction(playerState boardgame.SubState) error
- type CollectComponentsUntilPlayerCountLeft
- func (d *CollectComponentsUntilPlayerCountLeft) FallbackHelpText() string
- func (d *CollectComponentsUntilPlayerCountLeft) FallbackName(m *boardgame.GameManager) string
- func (d *CollectComponentsUntilPlayerCountLeft) PlayerConditionMet(pState boardgame.ImmutableSubState) bool
- func (c *CollectComponentsUntilPlayerCountLeft) ReadSetConfigurer() boardgame.PropertyReadSetConfigurer
- func (c *CollectComponentsUntilPlayerCountLeft) ReadSetter() boardgame.PropertyReadSetter
- func (c *CollectComponentsUntilPlayerCountLeft) Reader() boardgame.PropertyReader
- func (d *CollectComponentsUntilPlayerCountLeft) RoundRobinAction(playerState boardgame.SubState) error
- type CollectCountComponents
- func (d *CollectCountComponents) FallbackHelpText() string
- func (d *CollectCountComponents) FallbackName(m *boardgame.GameManager) string
- func (c *CollectCountComponents) ReadSetConfigurer() boardgame.PropertyReadSetConfigurer
- func (c *CollectCountComponents) ReadSetter() boardgame.PropertyReadSetter
- func (c *CollectCountComponents) Reader() boardgame.PropertyReader
- func (d *CollectCountComponents) RoundRobinAction(playerState boardgame.SubState) error
- type CurrentPlayer
- func (c *CurrentPlayer) DefaultsForState(state boardgame.ImmutableState)
- func (c *CurrentPlayer) FallbackHelpText() string
- func (c *CurrentPlayer) FallbackName(m *boardgame.GameManager) string
- func (c *CurrentPlayer) Legal(state boardgame.ImmutableState, proposer boardgame.PlayerIndex) error
- func (c *CurrentPlayer) ReadSetConfigurer() boardgame.PropertyReadSetConfigurer
- func (c *CurrentPlayer) ReadSetter() boardgame.PropertyReadSetter
- func (c *CurrentPlayer) Reader() boardgame.PropertyReader
- type CustomConfigurationOption
- func WithAmount(amount int) CustomConfigurationOption
- func WithDestinationProperty(stackPropName string) CustomConfigurationOption
- func WithGameProperty(stackPropName string) CustomConfigurationOption
- func WithHelpText(helpText string) CustomConfigurationOption
- func WithIsFixUp(isFixUp bool) CustomConfigurationOption
- func WithLegalMoveProgression(group MoveProgressionGroup) CustomConfigurationOption
- func WithLegalPhases(legalPhases ...int) CustomConfigurationOption
- func WithLegalType(legalType int) CustomConfigurationOption
- func WithMoveName(moveName string) CustomConfigurationOption
- func WithMoveNameSuffix(suffix string) CustomConfigurationOption
- func WithNumRounds(numRounds int) CustomConfigurationOption
- func WithPhaseToStart(phaseToStart int, optionalPhaseEnum enum.Enum) CustomConfigurationOption
- func WithPlayerProperty(stackPropName string) CustomConfigurationOption
- func WithSourceProperty(stackPropName string) CustomConfigurationOption
- func WithTargetCount(targetCount int) CustomConfigurationOption
- type DealAllComponents
- func (d *DealAllComponents) FallbackHelpText() string
- func (d *DealAllComponents) FallbackName(g *boardgame.GameManager) string
- func (d *DealAllComponents) ReadSetConfigurer() boardgame.PropertyReadSetConfigurer
- func (d *DealAllComponents) ReadSetter() boardgame.PropertyReadSetter
- func (d *DealAllComponents) Reader() boardgame.PropertyReader
- func (d *DealAllComponents) TargetCount(state boardgame.ImmutableState) int
- type DealComponentsUntilGameCountLeft
- func (d *DealComponentsUntilGameCountLeft) ConditionMet(state boardgame.ImmutableState) error
- func (d *DealComponentsUntilGameCountLeft) FallbackHelpText() string
- func (d *DealComponentsUntilGameCountLeft) FallbackName(m *boardgame.GameManager) string
- func (d *DealComponentsUntilGameCountLeft) ReadSetConfigurer() boardgame.PropertyReadSetConfigurer
- func (d *DealComponentsUntilGameCountLeft) ReadSetter() boardgame.PropertyReadSetter
- func (d *DealComponentsUntilGameCountLeft) Reader() boardgame.PropertyReader
- type DealComponentsUntilPlayerCountReached
- func (d *DealComponentsUntilPlayerCountReached) ConditionMet(state boardgame.ImmutableState) error
- func (d *DealComponentsUntilPlayerCountReached) FallbackHelpText() string
- func (d *DealComponentsUntilPlayerCountReached) FallbackName(m *boardgame.GameManager) string
- func (d *DealComponentsUntilPlayerCountReached) PlayerConditionMet(pState boardgame.ImmutableSubState) bool
- func (d *DealComponentsUntilPlayerCountReached) ReadSetConfigurer() boardgame.PropertyReadSetConfigurer
- func (d *DealComponentsUntilPlayerCountReached) ReadSetter() boardgame.PropertyReadSetter
- func (d *DealComponentsUntilPlayerCountReached) Reader() boardgame.PropertyReader
- type DealCountComponents
- func (d *DealCountComponents) FallbackHelpText() string
- func (d *DealCountComponents) FallbackName(m *boardgame.GameManager) string
- func (d *DealCountComponents) GameStack(gameState boardgame.SubState) boardgame.Stack
- func (d *DealCountComponents) Legal(state boardgame.ImmutableState, proposer boardgame.PlayerIndex) error
- func (d *DealCountComponents) NumRounds(state boardgame.ImmutableState) int
- func (d *DealCountComponents) PlayerStack(playerState boardgame.SubState) boardgame.Stack
- func (d *DealCountComponents) ReadSetConfigurer() boardgame.PropertyReadSetConfigurer
- func (d *DealCountComponents) ReadSetter() boardgame.PropertyReadSetter
- func (d *DealCountComponents) Reader() boardgame.PropertyReader
- func (d *DealCountComponents) RoundRobinAction(playerState boardgame.SubState) error
- func (d *DealCountComponents) TargetCount(state boardgame.ImmutableState) int
- func (d *DealCountComponents) ValidConfiguration(exampleState boardgame.State) error
- type Default
- func (d *Default) DeriveName(m *boardgame.GameManager) string
- func (d *Default) FallbackHelpText() string
- func (d *Default) FallbackName(m *boardgame.GameManager) string
- func (d *Default) HelpText() string
- func (d *Default) IsFixUp() bool
- func (d *Default) Legal(state boardgame.ImmutableState, proposer boardgame.PlayerIndex) error
- func (d *Default) ReadSetConfigurer() boardgame.PropertyReadSetConfigurer
- func (d *Default) ReadSetter() boardgame.PropertyReadSetter
- func (d *Default) Reader() boardgame.PropertyReader
- func (d *Default) ValidConfiguration(exampleState boardgame.State) error
- type DefaultComponent
- func (d *DefaultComponent) DefaultsForState(state boardgame.ImmutableState)
- func (d *DefaultComponent) FallbackHelpText() string
- func (d *DefaultComponent) FallbackName(m *boardgame.GameManager) string
- func (d *DefaultComponent) Legal(state boardgame.ImmutableState, proposer boardgame.PlayerIndex) error
- func (d *DefaultComponent) LegalType() int
- func (d *DefaultComponent) ReadSetConfigurer() boardgame.PropertyReadSetConfigurer
- func (d *DefaultComponent) ReadSetter() boardgame.PropertyReadSetter
- func (d *DefaultComponent) Reader() boardgame.PropertyReader
- func (d *DefaultComponent) SourceStack(state boardgame.State) boardgame.Stack
- func (d *DefaultComponent) ValidConfiguration(exampleState boardgame.State) error
- type Done
- func (d *Done) Apply(state boardgame.State) error
- func (d *Done) FallbackHelpText() string
- func (d *Done) FallbackName(m *boardgame.GameManager) string
- func (d *Done) ReadSetConfigurer() boardgame.PropertyReadSetConfigurer
- func (d *Done) ReadSetter() boardgame.PropertyReadSetter
- func (d *Done) Reader() boardgame.PropertyReader
- type FinishTurn
- func (f *FinishTurn) Apply(state boardgame.State) error
- func (f *FinishTurn) FallbackHelpText() string
- func (f *FinishTurn) FallbackName(m *boardgame.GameManager) string
- func (f *FinishTurn) Legal(state boardgame.ImmutableState, proposer boardgame.PlayerIndex) error
- func (f *FinishTurn) ReadSetConfigurer() boardgame.PropertyReadSetConfigurer
- func (f *FinishTurn) ReadSetter() boardgame.PropertyReadSetter
- func (f *FinishTurn) Reader() boardgame.PropertyReader
- func (f *FinishTurn) ValidConfiguration(exampleState boardgame.State) error
- type FixUp
- func (f *FixUp) FallbackHelpText() string
- func (f *FixUp) FallbackName(m *boardgame.GameManager) string
- func (f *FixUp) IsFixUp() bool
- func (f *FixUp) ReadSetConfigurer() boardgame.PropertyReadSetConfigurer
- func (f *FixUp) ReadSetter() boardgame.PropertyReadSetter
- func (f *FixUp) Reader() boardgame.PropertyReader
- type FixUpMulti
- type GroupableMoveConfig
- type InactivateEmptySeat
- func (i *InactivateEmptySeat) Apply(state boardgame.State) error
- func (i *InactivateEmptySeat) DefaultsForState(state boardgame.ImmutableState)
- func (i *InactivateEmptySeat) FallbackHelpText() string
- func (i *InactivateEmptySeat) FallbackName(m *boardgame.GameManager) string
- func (i *InactivateEmptySeat) Legal(state boardgame.ImmutableState, proposer boardgame.PlayerIndex) error
- func (i *InactivateEmptySeat) ReadSetConfigurer() boardgame.PropertyReadSetConfigurer
- func (i *InactivateEmptySeat) ReadSetter() boardgame.PropertyReadSetter
- func (i *InactivateEmptySeat) Reader() boardgame.PropertyReader
- func (i *InactivateEmptySeat) ValidConfiguration(exampleState boardgame.State) error
- type Increment
- func (i *Increment) Amount() int
- func (i *Increment) Apply(state boardgame.State) error
- func (i *Increment) FallbackHelpText() string
- func (i *Increment) FallbackName(m *boardgame.GameManager) string
- func (i *Increment) GameProperty() string
- func (i *Increment) PlayerProperty() string
- func (i *Increment) ReadSetConfigurer() boardgame.PropertyReadSetConfigurer
- func (i *Increment) ReadSetter() boardgame.PropertyReadSetter
- func (i *Increment) Reader() boardgame.PropertyReader
- func (i *Increment) ValidConfiguration(exampleState boardgame.State) error
- type MoveAllComponents
- func (m *MoveAllComponents) FallbackHelpText() string
- func (m *MoveAllComponents) FallbackName(g *boardgame.GameManager) string
- func (m *MoveAllComponents) ReadSetConfigurer() boardgame.PropertyReadSetConfigurer
- func (m *MoveAllComponents) ReadSetter() boardgame.PropertyReadSetter
- func (m *MoveAllComponents) Reader() boardgame.PropertyReader
- func (m *MoveAllComponents) TargetCount(state boardgame.ImmutableState) int
- type MoveComponentsUntilCountLeft
- func (m *MoveComponentsUntilCountLeft) Count(state boardgame.ImmutableState) int
- func (m *MoveComponentsUntilCountLeft) FallbackHelpText() string
- func (m *MoveComponentsUntilCountLeft) FallbackName(g *boardgame.GameManager) string
- func (m *MoveComponentsUntilCountLeft) ReadSetConfigurer() boardgame.PropertyReadSetConfigurer
- func (m *MoveComponentsUntilCountLeft) ReadSetter() boardgame.PropertyReadSetter
- func (m *MoveComponentsUntilCountLeft) Reader() boardgame.PropertyReader
- type MoveComponentsUntilCountReached
- func (m *MoveComponentsUntilCountReached) Count(state boardgame.ImmutableState) int
- func (m *MoveComponentsUntilCountReached) FallbackHelpText() string
- func (m *MoveComponentsUntilCountReached) FallbackName(g *boardgame.GameManager) string
- func (m *MoveComponentsUntilCountReached) ReadSetConfigurer() boardgame.PropertyReadSetConfigurer
- func (m *MoveComponentsUntilCountReached) ReadSetter() boardgame.PropertyReadSetter
- func (m *MoveComponentsUntilCountReached) Reader() boardgame.PropertyReader
- type MoveCountComponents
- func (m *MoveCountComponents) Apply(state boardgame.State) error
- func (m *MoveCountComponents) DestinationStack(state boardgame.State) boardgame.Stack
- func (m *MoveCountComponents) FallbackHelpText() string
- func (m *MoveCountComponents) FallbackName(g *boardgame.GameManager) string
- func (m *MoveCountComponents) Legal(state boardgame.ImmutableState, proposer boardgame.PlayerIndex) error
- func (m *MoveCountComponents) ReadSetConfigurer() boardgame.PropertyReadSetConfigurer
- func (m *MoveCountComponents) ReadSetter() boardgame.PropertyReadSetter
- func (m *MoveCountComponents) Reader() boardgame.PropertyReader
- func (m *MoveCountComponents) SourceStack(state boardgame.State) boardgame.Stack
- func (m *MoveCountComponents) ValidConfiguration(exampleState boardgame.State) error
- type MoveGroupHistoryItem
- type MoveProgressionGroup
- func DefaultRoundSetup(auto *AutoConfigurer) MoveProgressionGroup
- func Optional(group MoveProgressionGroup) MoveProgressionGroup
- func Parallel(children ...MoveProgressionGroup) MoveProgressionGroup
- func ParallelCount(count ValidCounter, children ...MoveProgressionGroup) MoveProgressionGroup
- func Repeat(count ValidCounter, group MoveProgressionGroup) MoveProgressionGroup
- func Serial(children ...MoveProgressionGroup) MoveProgressionGroup
- type NoOp
- func (n *NoOp) Apply(state boardgame.State) error
- func (n *NoOp) FallbackHelpText() string
- func (n *NoOp) FallbackName(m *boardgame.GameManager) string
- func (n *NoOp) ReadSetConfigurer() boardgame.PropertyReadSetConfigurer
- func (n *NoOp) ReadSetter() boardgame.PropertyReadSetter
- func (n *NoOp) Reader() boardgame.PropertyReader
- type RoundRobin
- func (r *RoundRobin) Apply(state boardgame.State) error
- func (r *RoundRobin) ConditionMet(state boardgame.ImmutableState) error
- func (r *RoundRobin) FallbackHelpText() string
- func (r *RoundRobin) FallbackName(m *boardgame.GameManager) string
- func (r *RoundRobin) Legal(state boardgame.ImmutableState, proposer boardgame.PlayerIndex) error
- func (r *RoundRobin) PlayerConditionMet(playerState boardgame.ImmutableSubState) bool
- func (r *RoundRobin) ReadSetConfigurer() boardgame.PropertyReadSetConfigurer
- func (r *RoundRobin) ReadSetter() boardgame.PropertyReadSetter
- func (r *RoundRobin) Reader() boardgame.PropertyReader
- func (r *RoundRobin) RoundRobinStarterPlayer(state boardgame.ImmutableState) boardgame.PlayerIndex
- func (r *RoundRobin) ValidConfiguration(exampleState boardgame.State) error
- type RoundRobinNumRounds
- func (r *RoundRobinNumRounds) ConditionMet(state boardgame.ImmutableState) error
- func (r *RoundRobinNumRounds) FallbackHelpText() string
- func (r *RoundRobinNumRounds) FallbackName(m *boardgame.GameManager) string
- func (r *RoundRobinNumRounds) NumRounds(state boardgame.ImmutableState) int
- func (r *RoundRobinNumRounds) ReadSetConfigurer() boardgame.PropertyReadSetConfigurer
- func (r *RoundRobinNumRounds) ReadSetter() boardgame.PropertyReadSetter
- func (r *RoundRobinNumRounds) Reader() boardgame.PropertyReader
- func (r *RoundRobinNumRounds) ValidConfiguration(exampleState boardgame.State) error
- type SeatPlayer
- func (s *SeatPlayer) Apply(state boardgame.State) error
- func (s *SeatPlayer) DefaultsForState(state boardgame.ImmutableState)
- func (s *SeatPlayer) FallbackHelpText() string
- func (s *SeatPlayer) FallbackName(m *boardgame.GameManager) string
- func (s *SeatPlayer) IsSeatPlayerMove() bool
- func (s *SeatPlayer) Legal(state boardgame.ImmutableState, proposer boardgame.PlayerIndex) error
- func (s *SeatPlayer) ReadSetConfigurer() boardgame.PropertyReadSetConfigurer
- func (s *SeatPlayer) ReadSetter() boardgame.PropertyReadSetter
- func (s *SeatPlayer) Reader() boardgame.PropertyReader
- func (s *SeatPlayer) ValidConfiguration(exampleState boardgame.State) error
- type ShuffleStack
- func (s *ShuffleStack) Apply(state boardgame.State) error
- func (s *ShuffleStack) FallbackHelpText() string
- func (s *ShuffleStack) FallbackName(m *boardgame.GameManager) string
- func (s *ShuffleStack) ReadSetConfigurer() boardgame.PropertyReadSetConfigurer
- func (s *ShuffleStack) ReadSetter() boardgame.PropertyReadSetter
- func (s *ShuffleStack) Reader() boardgame.PropertyReader
- func (s *ShuffleStack) SourceStack(state boardgame.State) boardgame.Stack
- func (s *ShuffleStack) ValidConfiguration(exampleState boardgame.State) error
- type StartPhase
- func (s *StartPhase) Apply(state boardgame.State) error
- func (s *StartPhase) FallbackHelpText() string
- func (s *StartPhase) FallbackName(m *boardgame.GameManager) string
- func (s *StartPhase) PhaseToStart(currentPhase int) int
- func (s *StartPhase) ReadSetConfigurer() boardgame.PropertyReadSetConfigurer
- func (s *StartPhase) ReadSetter() boardgame.PropertyReadSetter
- func (s *StartPhase) Reader() boardgame.PropertyReader
- func (s *StartPhase) ValidConfiguration(exampleState boardgame.State) error
- type ValidCounter
- type WaitForEnoughPlayers
- func (w *WaitForEnoughPlayers) Apply(state boardgame.State) error
- func (w *WaitForEnoughPlayers) FallbackHelpText() string
- func (w *WaitForEnoughPlayers) FallbackName(m *boardgame.GameManager) string
- func (w *WaitForEnoughPlayers) Legal(state boardgame.ImmutableState, proposer boardgame.PlayerIndex) error
- func (w *WaitForEnoughPlayers) ReadSetConfigurer() boardgame.PropertyReadSetConfigurer
- func (w *WaitForEnoughPlayers) ReadSetter() boardgame.PropertyReadSetter
- func (w *WaitForEnoughPlayers) Reader() boardgame.PropertyReader
- func (w *WaitForEnoughPlayers) TargetCount(state boardgame.ImmutableState) int
- func (w *WaitForEnoughPlayers) ValidConfiguration(exampleState boardgame.State) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Add ¶
func Add(moves ...boardgame.MoveConfig) []boardgame.MoveConfig
Add is designed to be used inside of Combine for moves that can apply in any phase in any order. It is a parallel of AddForPhase and AddOrderedForPhase. It doesn't actually do any processing, and is effectively equivalent to wrapping your config bundles in []boardgame.MoveConfig{}. However, it makes the intent of your move installers clearer.
func AddForPhase ¶
func AddForPhase(phase int, moves ...boardgame.MoveConfig) []boardgame.MoveConfig
AddForPhase is designed to be used within Combine. It calls WithLegalPhases() on the config for each config passed in, so that those moves will only be Legal() in that phase. It's a convenience to make it less error-prone and more clear what the intent is for phase-locked moves.
func AddOrderedForPhase ¶
func AddOrderedForPhase(phase int, groups ...MoveProgressionGroup) []boardgame.MoveConfig
AddOrderedForPhase is designed to be used within Combine. It calls WithLegalPhases() and also WithLegalMoveProgression() on the config for each config passed in, which means that the moves' Legal() will only be Legal in that phase, in that point in the move progression. It's a convenience to make it less error-prone and more clear what the intent is for phase-locked, ordered moves. All moveTypes passed must be legal auto-configurable moves. You may pass configs generated from AutoConfigurer.Config(), or any of the MoveProgressionGroup types defined in this package. All of the top level groups passed will be treated implicitly like a single Serial group. All moves contained within the provided groups will be registered. If your PhaseEnum is a Tree, then phase must be a leaf enum value, or the moves will fail to pass the ValidConfiguration check. This will also sanity check that the last Move enumerated is a StartPhase move, which is almost always what you want, and omission is likely an error. Check out the package doc for an example of using groups in this function.
func Combine ¶
func Combine(moves ...[]boardgame.MoveConfig) []boardgame.MoveConfig
Combine takes a series of lists of moveTypeConfigs and flattens them into a single list, appropriate for being retunrned from delegate.ConfigureMoves(). It doesn't do anything special, but instead exists entirely as a convenience to make writing your ConfigureMoves easier.
Types ¶
type ActivateInactivePlayer ¶
type ActivateInactivePlayer struct { FixUpMulti TargetPlayerIndex boardgame.PlayerIndex }
ActivateInactivePlayer is a fixup move that is designed to be used to activate any players who are currently inactive, running repeatedly until all of them are activated. Typically you explicitly mark this move as legal whenever you want players to be able to actually "join" the logic of a game. Designed to be used with behaviors.PlayerInactive. If that behavior is used, then when a new player is "seated" once a game starts, by default they'll be marked as Inactive. That means that the game will act as though they don't exist until they're explicitly marked as active. Typically if a player is seated in the middle of a round, they won't actually be included in play until the round is over. If you use that behavior, you should explicitly include this move as legal whenever you want players to be reactivated. Typically you would have it either ALWAYS be legal (which means, as soon as a player is seated they should be actively included in play), or have a specific phase when this move activates, for example at the end of the SetUpForNextRound phase in your game. Designed to be used on its own directly. For more on inactive players, see the package doc of boardgame/behaviors.
func (*ActivateInactivePlayer) Apply ¶
func (a *ActivateInactivePlayer) Apply(state boardgame.State) error
Apply sets the TargetPlayerIndex to be active via SetPlayerActive.
func (*ActivateInactivePlayer) DefaultsForState ¶
func (a *ActivateInactivePlayer) DefaultsForState(state boardgame.ImmutableState)
DefaultsForState sets TargetPlayerIndex to the next player who is currently marked as inactive, according to interfaces.PlayerInactiver.
func (*ActivateInactivePlayer) FallbackHelpText ¶
func (a *ActivateInactivePlayer) FallbackHelpText() string
FallbackHelpText returns "Activates any players who are not currently active."
func (*ActivateInactivePlayer) FallbackName ¶
func (a *ActivateInactivePlayer) FallbackName(m *boardgame.GameManager) string
FallbackName returns "Activate Inactive Players"
func (*ActivateInactivePlayer) Legal ¶
func (a *ActivateInactivePlayer) Legal(state boardgame.ImmutableState, proposer boardgame.PlayerIndex) error
Legal verifies that TargetPlayerIndex is set to a player whose InActive returns true.
func (*ActivateInactivePlayer) ReadSetConfigurer ¶
func (a *ActivateInactivePlayer) ReadSetConfigurer() boardgame.PropertyReadSetConfigurer
ReadSetConfigurer returns an autp-generated boardgame.PropertyReadSetConfigurer for ActivateInactivePlayer
func (*ActivateInactivePlayer) ReadSetter ¶
func (a *ActivateInactivePlayer) ReadSetter() boardgame.PropertyReadSetter
ReadSetter returns an autp-generated boardgame.PropertyReadSetter for ActivateInactivePlayer
func (*ActivateInactivePlayer) Reader ¶
func (a *ActivateInactivePlayer) Reader() boardgame.PropertyReader
Reader returns an autp-generated boardgame.PropertyReader for ActivateInactivePlayer
func (*ActivateInactivePlayer) ValidConfiguration ¶
func (a *ActivateInactivePlayer) ValidConfiguration(exampleState boardgame.State) error
ValidConfiguration checks that player states implement interfaces.PlayerInactiver
type ApplyCountTimes ¶
type ApplyCountTimes struct {
ApplyUntilCount
}
ApplyCountTimes subclasses ApplyUntilCount. It applies the move until TargetCount() number of this move have been applied in a row within the current phase. Override TargetCount() to return the number of moves you actually want to apply. You'll need to provide your own Apply() method.
func (*ApplyCountTimes) Count ¶
func (a *ApplyCountTimes) Count(state boardgame.ImmutableState) int
Count returns the number of times this move has been applied in a row in the immediate past in the current phase.
func (*ApplyCountTimes) FallbackHelpText ¶
func (a *ApplyCountTimes) FallbackHelpText() string
FallbackHelpText returns "Applies the move INT times in a row.", where INT is the target count.
func (*ApplyCountTimes) FallbackName ¶
func (a *ApplyCountTimes) FallbackName(m *boardgame.GameManager) string
FallbackName returns "Apply INT Times", where INT is the target count.
func (*ApplyCountTimes) ReadSetConfigurer ¶
func (a *ApplyCountTimes) ReadSetConfigurer() boardgame.PropertyReadSetConfigurer
ReadSetConfigurer returns an autp-generated boardgame.PropertyReadSetConfigurer for ApplyCountTimes
func (*ApplyCountTimes) ReadSetter ¶
func (a *ApplyCountTimes) ReadSetter() boardgame.PropertyReadSetter
ReadSetter returns an autp-generated boardgame.PropertyReadSetter for ApplyCountTimes
func (*ApplyCountTimes) Reader ¶
func (a *ApplyCountTimes) Reader() boardgame.PropertyReader
Reader returns an autp-generated boardgame.PropertyReader for ApplyCountTimes
type ApplyUntil ¶
type ApplyUntil struct {
FixUpMulti
}
ApplyUntil is a simple move that is legal to apply in succession until its ConditionMet returns nil. You need to implement interfaces.ConditionMetter by implementing a ConditionMet method.
func (*ApplyUntil) FallbackHelpText ¶
func (a *ApplyUntil) FallbackHelpText() string
FallbackHelpText simply returns "Applies the move until a condition is met."
func (*ApplyUntil) FallbackName ¶
func (a *ApplyUntil) FallbackName(m *boardgame.GameManager) string
FallbackName simply returns "Apply Until"
func (*ApplyUntil) Legal ¶
func (a *ApplyUntil) Legal(state boardgame.ImmutableState, proposer boardgame.PlayerIndex) error
Legal returns an error until ConditionMet returns nil.
func (*ApplyUntil) ReadSetConfigurer ¶
func (a *ApplyUntil) ReadSetConfigurer() boardgame.PropertyReadSetConfigurer
ReadSetConfigurer returns an autp-generated boardgame.PropertyReadSetConfigurer for ApplyUntil
func (*ApplyUntil) ReadSetter ¶
func (a *ApplyUntil) ReadSetter() boardgame.PropertyReadSetter
ReadSetter returns an autp-generated boardgame.PropertyReadSetter for ApplyUntil
func (*ApplyUntil) Reader ¶
func (a *ApplyUntil) Reader() boardgame.PropertyReader
Reader returns an autp-generated boardgame.PropertyReader for ApplyUntil
func (*ApplyUntil) ValidConfiguration ¶
func (a *ApplyUntil) ValidConfiguration(exampleState boardgame.State) error
ValidConfiguration verifies the Move this is embedded in implements interfaces.ConditionMetter.
type ApplyUntilCount ¶
type ApplyUntilCount struct {
ApplyUntil
}
ApplyUntilCount is a subclass of ApplyUntil that is legal until Count() is equal to TargetCount(). (This presumes that each time the move is applied it gets the TargetCount one closer to Count and never overshoots). At the minimum you'll want to provide your own Count() and Apply() methods, or use the moves that subclass from this, like MoveComponentsUntilCountReached.
func (*ApplyUntilCount) ConditionMet ¶
func (a *ApplyUntilCount) ConditionMet(state boardgame.ImmutableState) error
ConditionMet returns nil once Count() is equal to TargetCount(). Note this presumes that repeated applciations of this move move Count one closer to TargetCount, and that it never overshoots, otherwise this could never terminate. In general you override Count() and TargetCount() to customize behavior instead of overriding this.
func (*ApplyUntilCount) Count ¶
func (a *ApplyUntilCount) Count(state boardgame.ImmutableState) int
Count is consulted in ConditionMet to see what the current count is. Simply returns 1 by default. You almost certainly want to override this.
func (*ApplyUntilCount) FallbackHelpText ¶
func (a *ApplyUntilCount) FallbackHelpText() string
FallbackHelpText returns "Applies the move until a target count of INT is met.", where INT is the target count.
func (*ApplyUntilCount) FallbackName ¶
func (a *ApplyUntilCount) FallbackName(m *boardgame.GameManager) string
FallbackName returns "Apply Until Count of INT", where INT is the target count.
func (*ApplyUntilCount) ReadSetConfigurer ¶
func (a *ApplyUntilCount) ReadSetConfigurer() boardgame.PropertyReadSetConfigurer
ReadSetConfigurer returns an autp-generated boardgame.PropertyReadSetConfigurer for ApplyUntilCount
func (*ApplyUntilCount) ReadSetter ¶
func (a *ApplyUntilCount) ReadSetter() boardgame.PropertyReadSetter
ReadSetter returns an autp-generated boardgame.PropertyReadSetter for ApplyUntilCount
func (*ApplyUntilCount) Reader ¶
func (a *ApplyUntilCount) Reader() boardgame.PropertyReader
Reader returns an autp-generated boardgame.PropertyReader for ApplyUntilCount
func (*ApplyUntilCount) TargetCount ¶
func (a *ApplyUntilCount) TargetCount(state boardgame.ImmutableState) int
TargetCount should return the count that you want to target. Will return the configuration option passed via WithTargetCount in DefaultConfig, or 1 if that wasn't provided.
func (*ApplyUntilCount) ValidConfiguration ¶
func (a *ApplyUntilCount) ValidConfiguration(exampleState boardgame.State) error
ValidConfiguration verifes the top level move implements Count() and interfaces.TargetCounter, and that TargetCount doesn't return below 0.
type AutoConfigurableMove ¶
type AutoConfigurableMove interface { //DefaultConfigMoves all must implement all Move methods. boardgame.Move //DeriveName() will be called to generate the name. This might be an //expensive method, so it will only be called during installation. DeriveName(manager *boardgame.GameManager) string }
AutoConfigurableMove is the interface that moves passed to AutoConfigurer.Config must implement. These methods are interrogated to set the move name, helptext,isFixUp, and legalPhases to good values. moves.Default defines powerful stubs for these, so any moves that embed moves.Default (or embed a move that embeds moves.Default, etc) satisfy this interface.
type AutoConfigurer ¶
type AutoConfigurer struct {
// contains filtered or unexported fields
}
AutoConfigurer is an object that makes it easy to configure moves. Get a new one with NewAutoConfigurer. See the package doc for much more on how to use it.
func NewAutoConfigurer ¶
func NewAutoConfigurer(g boardgame.GameDelegate) *AutoConfigurer
NewAutoConfigurer returns a new AutoConfigurer ready for use.
func (*AutoConfigurer) Config ¶
func (a *AutoConfigurer) Config(exampleStruct AutoConfigurableMove, options ...CustomConfigurationOption) (GroupableMoveConfig, error)
Config is a powerful default MoveConfig generator. In many cases you'll implement moves that are very thin embeddings of moves in this package. Generating a MoveConfig for each is a pain. This method auto- generates the MoveConfig based on an example zero type of your move to install. Moves need a few extra methods that are consulted to generate the move name, helptext, and isFixUp; anything based on moves.Default automatically satisfies the necessary interface. See the package doc for an example of use. Instead of returning a boardgame.MoveConfig, it returns a GroupableMoveConfig equivalent to what you'd get from NewGroupableMoveConfig, which satisfies boardgame.MoveConfig but also adds enough methods to be useable as input to AddOrderedForPhase.
func (*AutoConfigurer) MustConfig ¶
func (a *AutoConfigurer) MustConfig(exampleStruct AutoConfigurableMove, options ...CustomConfigurationOption) GroupableMoveConfig
MustConfig is a wrapper around Config that if it errors will panic. Only suitable for being used during setup.
type CloseEmptySeat ¶
type CloseEmptySeat struct { FixUpMulti TargetPlayerIndex boardgame.PlayerIndex }
CloseEmptySeat is a move that will go through and repeatedly apply itself to close any seat that is not filled. Typically you put this at the end of a SetUp phase, once all of the players are there who you care to wait for, and want to tell the game to not try to seat any more people in them. For more on the notion of empty seats, see the package doc of boardgames/behaviors.
func (*CloseEmptySeat) Apply ¶
func (c *CloseEmptySeat) Apply(state boardgame.State) error
Apply sets the TargetPlayerIndex to be closed via interfaces.Seater
func (*CloseEmptySeat) DefaultsForState ¶
func (c *CloseEmptySeat) DefaultsForState(state boardgame.ImmutableState)
DefaultsForState sets TargetPlayerIndex to the next player who is currently marked as empty, according to interfaces.Seater.
func (*CloseEmptySeat) FallbackHelpText ¶
func (c *CloseEmptySeat) FallbackHelpText() string
FallbackHelpText returns "Marks any empty seats as being not open for more people to be seated."
func (*CloseEmptySeat) FallbackName ¶
func (c *CloseEmptySeat) FallbackName(m *boardgame.GameManager) string
FallbackName returns "Close Empty Seat"
func (*CloseEmptySeat) Legal ¶
func (c *CloseEmptySeat) Legal(state boardgame.ImmutableState, proposer boardgame.PlayerIndex) error
Legal verifies that TargetPlayerIndex is set to a player that is currently empty and not currently closed.
func (*CloseEmptySeat) ReadSetConfigurer ¶
func (c *CloseEmptySeat) ReadSetConfigurer() boardgame.PropertyReadSetConfigurer
ReadSetConfigurer returns an autp-generated boardgame.PropertyReadSetConfigurer for CloseEmptySeat
func (*CloseEmptySeat) ReadSetter ¶
func (c *CloseEmptySeat) ReadSetter() boardgame.PropertyReadSetter
ReadSetter returns an autp-generated boardgame.PropertyReadSetter for CloseEmptySeat
func (*CloseEmptySeat) Reader ¶
func (c *CloseEmptySeat) Reader() boardgame.PropertyReader
Reader returns an autp-generated boardgame.PropertyReader for CloseEmptySeat
func (*CloseEmptySeat) ValidConfiguration ¶
func (c *CloseEmptySeat) ValidConfiguration(exampleState boardgame.State) error
ValidConfiguration checks that player states implement interfaces.Seater
type CollectAllComponents ¶
type CollectAllComponents struct {
CollectComponentsUntilPlayerCountLeft
}
CollectAllComponents is simply a CollectComponentsUntilPlayerCountLeft that overrides TargetCount() to return 0. A simple convenience since that combination is common.
func (*CollectAllComponents) FallbackHelpText ¶
func (c *CollectAllComponents) FallbackHelpText() string
FallbackHelpText returns "Collects all components from PLAYERSTACKNAME in each PlayerState to GAMESTACKNAME in GameState"
func (*CollectAllComponents) FallbackName ¶
func (c *CollectAllComponents) FallbackName(g *boardgame.GameManager) string
FallbackName returns "Collect All Components From PLAYERSTACKNAME In Each PlayerState To GAMESTACKNAME In GameState"
func (*CollectAllComponents) ReadSetConfigurer ¶
func (c *CollectAllComponents) ReadSetConfigurer() boardgame.PropertyReadSetConfigurer
ReadSetConfigurer returns an autp-generated boardgame.PropertyReadSetConfigurer for CollectAllComponents
func (*CollectAllComponents) ReadSetter ¶
func (c *CollectAllComponents) ReadSetter() boardgame.PropertyReadSetter
ReadSetter returns an autp-generated boardgame.PropertyReadSetter for CollectAllComponents
func (*CollectAllComponents) Reader ¶
func (c *CollectAllComponents) Reader() boardgame.PropertyReader
Reader returns an autp-generated boardgame.PropertyReader for CollectAllComponents
func (*CollectAllComponents) TargetCount ¶
func (c *CollectAllComponents) TargetCount(state boardgame.ImmutableState) int
TargetCount returns 0, no matter what was passed with WithTargetCount. This is the primary behavior of this move, compared to CollectComponentsUntilPlayerCountLeft.
type CollectComponentsUntilGameCountReached ¶
type CollectComponentsUntilGameCountReached struct {
DealComponentsUntilGameCountLeft
}
CollectComponentsUntilGameCountReached goes around and collects components from each player until GameStack() NumComponents() is TargetCount or greater. It's the same as DealComponentsUntilGameCountLeft, just with the action reversed and the size check flipped.
func (*CollectComponentsUntilGameCountReached) ConditionMet ¶
func (d *CollectComponentsUntilGameCountReached) ConditionMet(state boardgame.ImmutableState) error
ConditionMet returns nil if GameStack's NumComponents is TargetCount or greater, and otherwise defaults to RoundRobin's ConditionMet.
func (*CollectComponentsUntilGameCountReached) FallbackHelpText ¶
func (d *CollectComponentsUntilGameCountReached) FallbackHelpText() string
FallbackHelpText returns a string based on the names of the player stack name, game stack name, and target count.
func (*CollectComponentsUntilGameCountReached) FallbackName ¶
func (d *CollectComponentsUntilGameCountReached) FallbackName(m *boardgame.GameManager) string
FallbackName returns a string based on the names of the player stack name, game stack name, and target count.
func (*CollectComponentsUntilGameCountReached) ReadSetConfigurer ¶
func (c *CollectComponentsUntilGameCountReached) ReadSetConfigurer() boardgame.PropertyReadSetConfigurer
ReadSetConfigurer returns an autp-generated boardgame.PropertyReadSetConfigurer for CollectComponentsUntilGameCountReached
func (*CollectComponentsUntilGameCountReached) ReadSetter ¶
func (c *CollectComponentsUntilGameCountReached) ReadSetter() boardgame.PropertyReadSetter
ReadSetter returns an autp-generated boardgame.PropertyReadSetter for CollectComponentsUntilGameCountReached
func (*CollectComponentsUntilGameCountReached) Reader ¶
func (c *CollectComponentsUntilGameCountReached) Reader() boardgame.PropertyReader
Reader returns an autp-generated boardgame.PropertyReader for CollectComponentsUntilGameCountReached
func (*CollectComponentsUntilGameCountReached) RoundRobinAction ¶
func (d *CollectComponentsUntilGameCountReached) RoundRobinAction(playerState boardgame.SubState) error
RoundRobinAction moves a component from the PlayerStack to the GameStack, as configured by the PlayerStacker and GameStacker interfaces.
type CollectComponentsUntilPlayerCountLeft ¶
type CollectComponentsUntilPlayerCountLeft struct {
DealComponentsUntilPlayerCountReached
}
CollectComponentsUntilPlayerCountLeft goes around and collects components from each player until each player has TargetCount() or fewer components in their PlayerStack(). It's the same as DealComponentsUntilPlayerCountReached, just with the action reversed and the size check flipped.
func (*CollectComponentsUntilPlayerCountLeft) FallbackHelpText ¶
func (d *CollectComponentsUntilPlayerCountLeft) FallbackHelpText() string
FallbackHelpText returns a string based on the names of the player stack name, game stack name, and target count.
func (*CollectComponentsUntilPlayerCountLeft) FallbackName ¶
func (d *CollectComponentsUntilPlayerCountLeft) FallbackName(m *boardgame.GameManager) string
FallbackName returns a string based on the names of the player stack name, game stack name, and target count.
func (*CollectComponentsUntilPlayerCountLeft) PlayerConditionMet ¶
func (d *CollectComponentsUntilPlayerCountLeft) PlayerConditionMet(pState boardgame.ImmutableSubState) bool
PlayerConditionMet is true if the NumComponents in the given player's PlayerStack() is TargetCount or less.
func (*CollectComponentsUntilPlayerCountLeft) ReadSetConfigurer ¶
func (c *CollectComponentsUntilPlayerCountLeft) ReadSetConfigurer() boardgame.PropertyReadSetConfigurer
ReadSetConfigurer returns an autp-generated boardgame.PropertyReadSetConfigurer for CollectComponentsUntilPlayerCountLeft
func (*CollectComponentsUntilPlayerCountLeft) ReadSetter ¶
func (c *CollectComponentsUntilPlayerCountLeft) ReadSetter() boardgame.PropertyReadSetter
ReadSetter returns an autp-generated boardgame.PropertyReadSetter for CollectComponentsUntilPlayerCountLeft
func (*CollectComponentsUntilPlayerCountLeft) Reader ¶
func (c *CollectComponentsUntilPlayerCountLeft) Reader() boardgame.PropertyReader
Reader returns an autp-generated boardgame.PropertyReader for CollectComponentsUntilPlayerCountLeft
func (*CollectComponentsUntilPlayerCountLeft) RoundRobinAction ¶
func (d *CollectComponentsUntilPlayerCountLeft) RoundRobinAction(playerState boardgame.SubState) error
RoundRobinAction moves a component from the PlayerStack to the GameStack, as configured by the PlayerStacker and GameStacker interfaces.
type CollectCountComponents ¶
type CollectCountComponents struct {
DealCountComponents
}
CollectCountComponents is a type of RoundRobin move that collects components from each PlayerState's PlayerStack() to gameState's GameStack(). By default it goes around once and collects a component from each. If you want a different number of rounds, override TargetCount(). It subclasses DealCountComponents, but simply reverses the action to make.
boardgame:codegen
func (*CollectCountComponents) FallbackHelpText ¶
func (d *CollectCountComponents) FallbackHelpText() string
FallbackHelpText returns a string based on the names of the player stack name, game stack name, and target count.
func (*CollectCountComponents) FallbackName ¶
func (d *CollectCountComponents) FallbackName(m *boardgame.GameManager) string
FallbackName returns a string based on the names of the player stack name, game stack name, and target count.
func (*CollectCountComponents) ReadSetConfigurer ¶
func (c *CollectCountComponents) ReadSetConfigurer() boardgame.PropertyReadSetConfigurer
ReadSetConfigurer returns an autp-generated boardgame.PropertyReadSetConfigurer for CollectCountComponents
func (*CollectCountComponents) ReadSetter ¶
func (c *CollectCountComponents) ReadSetter() boardgame.PropertyReadSetter
ReadSetter returns an autp-generated boardgame.PropertyReadSetter for CollectCountComponents
func (*CollectCountComponents) Reader ¶
func (c *CollectCountComponents) Reader() boardgame.PropertyReader
Reader returns an autp-generated boardgame.PropertyReader for CollectCountComponents
func (*CollectCountComponents) RoundRobinAction ¶
func (d *CollectCountComponents) RoundRobinAction(playerState boardgame.SubState) error
RoundRobinAction moves a component from the PlayerStack to the GameStack, as configured by the PlayerStacker and GameStacker interfaces.
type CurrentPlayer ¶
type CurrentPlayer struct { Default TargetPlayerIndex boardgame.PlayerIndex }
CurrentPlayer is a convenience embeddable move that represents a move made by the CurrentPlayer.
The target player is encoded as TargetPlayerIndex. This is checked to make sure it is equivalent to the delegate's CurrentPlayerIndex, as well as to the proposer. This means that your Delegate should return a reasonable result from CurrentPlayerIndex. If your game has different rounds where no one may move, return boardgame.ObserverPlayerIndex. If there are rounds where anyone may move, return boardgame.AdminPlayerIndex.
Typically you'd implement your own Legal method that calls CurrentPlayer.Legal() first, then do your own specific checking after that, too.
boardgame:codegen
func (*CurrentPlayer) DefaultsForState ¶
func (c *CurrentPlayer) DefaultsForState(state boardgame.ImmutableState)
DefaultsForState will set the TargetPlayerIndex to be the CurrentPlayerIndex.
func (*CurrentPlayer) FallbackHelpText ¶
func (c *CurrentPlayer) FallbackHelpText() string
FallbackHelpText returns "A move by the current player."
func (*CurrentPlayer) FallbackName ¶
func (c *CurrentPlayer) FallbackName(m *boardgame.GameManager) string
FallbackName returns "Current Player Move"
func (*CurrentPlayer) Legal ¶
func (c *CurrentPlayer) Legal(state boardgame.ImmutableState, proposer boardgame.PlayerIndex) error
Legal will return an error if the TargetPlayerIndex is not the CurrentPlayerIndex, if the TargetPlayerIndex is not equivalent to the proposer, or if the TargetPlayerIndex is not one of the players.
func (*CurrentPlayer) ReadSetConfigurer ¶
func (c *CurrentPlayer) ReadSetConfigurer() boardgame.PropertyReadSetConfigurer
ReadSetConfigurer returns an autp-generated boardgame.PropertyReadSetConfigurer for CurrentPlayer
func (*CurrentPlayer) ReadSetter ¶
func (c *CurrentPlayer) ReadSetter() boardgame.PropertyReadSetter
ReadSetter returns an autp-generated boardgame.PropertyReadSetter for CurrentPlayer
func (*CurrentPlayer) Reader ¶
func (c *CurrentPlayer) Reader() boardgame.PropertyReader
Reader returns an autp-generated boardgame.PropertyReader for CurrentPlayer
type CustomConfigurationOption ¶
type CustomConfigurationOption func(boardgame.PropertyCollection)
CustomConfigurationOption is a function that takes a PropertyCollection and modifies a key on it. This package defines a number of functions that return funcs that satisfy this interface and can be used in auto.Config to pass in configuration to the base moves without requiring verbose embedding and method overriding. All of those functions in this package start with "With".
func WithAmount ¶
func WithAmount(amount int) CustomConfigurationOption
WithAmount returns a function configuration option suitable for being passed to auto.Config.
func WithDestinationProperty ¶
func WithDestinationProperty(stackPropName string) CustomConfigurationOption
WithDestinationProperty returns a function configuration option suitable for being passed to auto.Config. The stackPropName is assumed to be on the GameState object. If it isn't, you'll need to embed the move and override DestinationStack yourself.
func WithGameProperty ¶
func WithGameProperty(stackPropName string) CustomConfigurationOption
WithGameProperty returns a function configuration option suitable for being passed to auto.Config. Often used to configure what a move's GameStack() will return, but other moves use it for non-stack properties.
func WithHelpText ¶
func WithHelpText(helpText string) CustomConfigurationOption
WithHelpText returns a function configuration option suitable for being passed to auto.Config. moves.Default uses this, if provided, to power MoveTypeHelpText, which means that auto.Config will use this text whenever it is passed. See the documentation for moves.Default.MoveTypeHelpText for more information.
func WithIsFixUp ¶
func WithIsFixUp(isFixUp bool) CustomConfigurationOption
WithIsFixUp returns a function configuration option suitable for being passed to auto.Config. moves.Default uses this, if provided, to power MoveTypeIsFixUp, which means that auto.Config will use this if it is passed. See the documentation for moves.Default.IsFixUp for more information. All moves in this package will return reasonable values for IsFixUp on their own, so it is much more rare to use this than other config options in this package. In general, instead of using this option you should simply embed FixUp (or a move that itself embedds IsFixUp), so you don't have to remember to pass WithIsFixUp, which is easy to forget.
func WithLegalMoveProgression ¶
func WithLegalMoveProgression(group MoveProgressionGroup) CustomConfigurationOption
WithLegalMoveProgression returns a function configuration option suitable for being passed to auto.Config. moves.Default's Legal() will use this for this move type to determine if the move is legal in the order it's being applied. Typically you don't use this directly, and instead use moves.AddOrderedForPhase to use this implicitly.
func WithLegalPhases ¶
func WithLegalPhases(legalPhases ...int) CustomConfigurationOption
WithLegalPhases returns a function configuration option suitable for being passed to auto.Config. legalPhases will extend whatever has already been passed before. move.Base will use the result of this to determine if a given move is legal in the current phase. Typically you don't use this directly, and instead use moves.AddForPhase to use this implicitly.
func WithLegalType ¶
func WithLegalType(legalType int) CustomConfigurationOption
WithLegalType returns a function configuration option suitable for being passed to auto.Config. The legalType will be bassed to the components' Legal() method. Idiomatically this should be a value from an enum that is related to the legalType for that type of component. However, if you only have one DefaultComponent move for that type of component, it's fine to just skip this to use 0 instead.
func WithMoveName ¶
func WithMoveName(moveName string) CustomConfigurationOption
WithMoveName returns a function configuration option suitable for being passed to auto.Config. moves.Default uses this, if provided, to power MoveTypeName, which means that auto.Config will use this name whenever it is passed. If you're passing a move struct that not's from this package, the auto-generated move name is likely sufficient and you don't need this. See the documentation for moves.Default.MoveTypeName for more information.
func WithMoveNameSuffix ¶
func WithMoveNameSuffix(suffix string) CustomConfigurationOption
WithMoveNameSuffix returns a function configuration option suitable for being passed to auto.Config. The suffix, if provided, will be appended to whatever the Move's name would have been (see the behavior for DeriveName on move.Default). This is useful because every move must have a unique name, but sometimes you have the same underlying move struct who is legal in different points in different progressions. This makes it easy to provide a suffix for subsequent uses of the same move to ensure the names are all unique.
func WithNumRounds ¶
func WithNumRounds(numRounds int) CustomConfigurationOption
WithNumRounds returns a function configuration option suitable for being passed to auto.Config.
func WithPhaseToStart ¶
func WithPhaseToStart(phaseToStart int, optionalPhaseEnum enum.Enum) CustomConfigurationOption
WithPhaseToStart returns a function configuration option suitable for being passed to auto.Config. PhaseEnum should be the enum that is used for phases, and phaseToStart is the value within that phase to start. The phaseEnum is optional; if not provided, the name of the move and help text will just use the int value of the phase instead.
func WithPlayerProperty ¶
func WithPlayerProperty(stackPropName string) CustomConfigurationOption
WithPlayerProperty returns a function configuration option suitable for being passed to auto.Config. Often used to configure what a move's PlayerStack() will return, but other moves use it for non-stack properties.
func WithSourceProperty ¶
func WithSourceProperty(stackPropName string) CustomConfigurationOption
WithSourceProperty returns a function configuration option suitable for being passed to auto.Config. The stackPropName is assumed to be on the GameState object. If it isn't, you'll need to embed the move and override SourceStack yourself.
func WithTargetCount ¶
func WithTargetCount(targetCount int) CustomConfigurationOption
WithTargetCount returns a function configuration option suitable for being passed to auto.Config.
type DealAllComponents ¶
type DealAllComponents struct {
DealComponentsUntilGameCountLeft
}
DealAllComponents is simply a DealComponentsUntilGameCountLeft that overrides TargetCount() to return 0. A simple convenience since that combination is common.
func (*DealAllComponents) FallbackHelpText ¶
func (d *DealAllComponents) FallbackHelpText() string
FallbackHelpText returns "Deals all components from GAMESTACKNAME in GameState to PLAYERSTACKNAME in cach PlayerState"
func (*DealAllComponents) FallbackName ¶
func (d *DealAllComponents) FallbackName(g *boardgame.GameManager) string
FallbackName returns "Deal All Components From GAMESTACKNAME In GameState To PlAYERSTACKNAME in Each PlayerState"
func (*DealAllComponents) ReadSetConfigurer ¶
func (d *DealAllComponents) ReadSetConfigurer() boardgame.PropertyReadSetConfigurer
ReadSetConfigurer returns an autp-generated boardgame.PropertyReadSetConfigurer for DealAllComponents
func (*DealAllComponents) ReadSetter ¶
func (d *DealAllComponents) ReadSetter() boardgame.PropertyReadSetter
ReadSetter returns an autp-generated boardgame.PropertyReadSetter for DealAllComponents
func (*DealAllComponents) Reader ¶
func (d *DealAllComponents) Reader() boardgame.PropertyReader
Reader returns an autp-generated boardgame.PropertyReader for DealAllComponents
func (*DealAllComponents) TargetCount ¶
func (d *DealAllComponents) TargetCount(state boardgame.ImmutableState) int
TargetCount returns 0, no matter what was passed with WithTargetCount. This is the primary behavior of this move, compared to DealComponentsUntilGameCountLeft.
type DealComponentsUntilGameCountLeft ¶
type DealComponentsUntilGameCountLeft struct {
DealCountComponents
}
DealComponentsUntilGameCountLeft goes around and deals components to each player until the GameStack() has TargetCount() or fewer components left.
func (*DealComponentsUntilGameCountLeft) ConditionMet ¶
func (d *DealComponentsUntilGameCountLeft) ConditionMet(state boardgame.ImmutableState) error
ConditionMet returns nil if GameStack's NumComponents is TargetCount or less, and otherwise defaults to RoundRobin's ConditionMet.
func (*DealComponentsUntilGameCountLeft) FallbackHelpText ¶
func (d *DealComponentsUntilGameCountLeft) FallbackHelpText() string
FallbackHelpText returns a string based on the names of the player stack name, game stack name, and target count.
func (*DealComponentsUntilGameCountLeft) FallbackName ¶
func (d *DealComponentsUntilGameCountLeft) FallbackName(m *boardgame.GameManager) string
FallbackName returns a string based on the names of the player stack name, game stack name, and target count.
func (*DealComponentsUntilGameCountLeft) ReadSetConfigurer ¶
func (d *DealComponentsUntilGameCountLeft) ReadSetConfigurer() boardgame.PropertyReadSetConfigurer
ReadSetConfigurer returns an autp-generated boardgame.PropertyReadSetConfigurer for DealComponentsUntilGameCountLeft
func (*DealComponentsUntilGameCountLeft) ReadSetter ¶
func (d *DealComponentsUntilGameCountLeft) ReadSetter() boardgame.PropertyReadSetter
ReadSetter returns an autp-generated boardgame.PropertyReadSetter for DealComponentsUntilGameCountLeft
func (*DealComponentsUntilGameCountLeft) Reader ¶
func (d *DealComponentsUntilGameCountLeft) Reader() boardgame.PropertyReader
Reader returns an autp-generated boardgame.PropertyReader for DealComponentsUntilGameCountLeft
type DealComponentsUntilPlayerCountReached ¶
type DealComponentsUntilPlayerCountReached struct {
DealCountComponents
}
DealComponentsUntilPlayerCountReached goes around and deals components to each player until each player has TargetCount() or greater components in their PlayerStack().
func (*DealComponentsUntilPlayerCountReached) ConditionMet ¶
func (d *DealComponentsUntilPlayerCountReached) ConditionMet(state boardgame.ImmutableState) error
ConditionMet simply returns the RoundRobin.ConditionMet (throwing out the RoundCount alternate of ConditionMet we get via sub-classing), since our PlayerConditionMet handles the end condtion.
func (*DealComponentsUntilPlayerCountReached) FallbackHelpText ¶
func (d *DealComponentsUntilPlayerCountReached) FallbackHelpText() string
FallbackHelpText returns a string based on the names of the player stack name, game stack name, and target count.
func (*DealComponentsUntilPlayerCountReached) FallbackName ¶
func (d *DealComponentsUntilPlayerCountReached) FallbackName(m *boardgame.GameManager) string
FallbackName returns a string based on the names of the player stack name, game stack name, and target count.
func (*DealComponentsUntilPlayerCountReached) PlayerConditionMet ¶
func (d *DealComponentsUntilPlayerCountReached) PlayerConditionMet(pState boardgame.ImmutableSubState) bool
PlayerConditionMet is true if the NumComponents in the given player's PlayerStack() is TargetCount or greater.
func (*DealComponentsUntilPlayerCountReached) ReadSetConfigurer ¶
func (d *DealComponentsUntilPlayerCountReached) ReadSetConfigurer() boardgame.PropertyReadSetConfigurer
ReadSetConfigurer returns an autp-generated boardgame.PropertyReadSetConfigurer for DealComponentsUntilPlayerCountReached
func (*DealComponentsUntilPlayerCountReached) ReadSetter ¶
func (d *DealComponentsUntilPlayerCountReached) ReadSetter() boardgame.PropertyReadSetter
ReadSetter returns an autp-generated boardgame.PropertyReadSetter for DealComponentsUntilPlayerCountReached
func (*DealComponentsUntilPlayerCountReached) Reader ¶
func (d *DealComponentsUntilPlayerCountReached) Reader() boardgame.PropertyReader
Reader returns an autp-generated boardgame.PropertyReader for DealComponentsUntilPlayerCountReached
type DealCountComponents ¶
type DealCountComponents struct {
RoundRobinNumRounds
}
DealCountComponents is a type of RoundRobin move that deals components from gameState's GameStack() to each PlayerState's PlayerStack(). It goes around TargetCount() times. TargetCount() defaults to 1; override if you want to deal out a different number of components. In practice it is more common to use this move (and its subclasses) directly, and pass configuration for GameStack, PlayerStack, and TargetCount via WithGameProperty, WithPlayerProperty, and WithTargetCount into auto.Config.
boardgame:codegen
func (*DealCountComponents) FallbackHelpText ¶
func (d *DealCountComponents) FallbackHelpText() string
FallbackHelpText returns a string based on the names of the player stack name, game stack name, and target count.
func (*DealCountComponents) FallbackName ¶
func (d *DealCountComponents) FallbackName(m *boardgame.GameManager) string
FallbackName returns a string based on the names of the player stack name, game stack name, and target count.
func (*DealCountComponents) GameStack ¶
func (d *DealCountComponents) GameStack(gameState boardgame.SubState) boardgame.Stack
GameStack by default just returns the property on GameState with the name passed to auto.Config by WithGameProperty. If that is not sufficient, override this in your embedding struct.
func (*DealCountComponents) Legal ¶
func (d *DealCountComponents) Legal(state boardgame.ImmutableState, proposer boardgame.PlayerIndex) error
Legal checks to make sure that there's at least count components to deal to the next player.
func (*DealCountComponents) NumRounds ¶
func (d *DealCountComponents) NumRounds(state boardgame.ImmutableState) int
NumRounds simply returns TargetCount. NumRounds is what RoundRobinNumRounds expects, but TargetCount() is the terminology used for all of the similar Deal/Collect/MoveComponents methods.
func (*DealCountComponents) PlayerStack ¶
func (d *DealCountComponents) PlayerStack(playerState boardgame.SubState) boardgame.Stack
PlayerStack by default just returns the property on GameState with the name passed to auto.Config by WithPlayerProperty. If that is not sufficient, override this in your embedding struct.
func (*DealCountComponents) ReadSetConfigurer ¶
func (d *DealCountComponents) ReadSetConfigurer() boardgame.PropertyReadSetConfigurer
ReadSetConfigurer returns an autp-generated boardgame.PropertyReadSetConfigurer for DealCountComponents
func (*DealCountComponents) ReadSetter ¶
func (d *DealCountComponents) ReadSetter() boardgame.PropertyReadSetter
ReadSetter returns an autp-generated boardgame.PropertyReadSetter for DealCountComponents
func (*DealCountComponents) Reader ¶
func (d *DealCountComponents) Reader() boardgame.PropertyReader
Reader returns an autp-generated boardgame.PropertyReader for DealCountComponents
func (*DealCountComponents) RoundRobinAction ¶
func (d *DealCountComponents) RoundRobinAction(playerState boardgame.SubState) error
RoundRobinAction moves a component from the GameStack to the PlayerStack, as configured by the PlayerStacker and GameStacker interfaces.
func (*DealCountComponents) TargetCount ¶
func (d *DealCountComponents) TargetCount(state boardgame.ImmutableState) int
TargetCount should return the count that you want to target. Will return the configuration option passed via WithTargetCount in auto.Config, or 1 if that wasn't provided.
func (*DealCountComponents) ValidConfiguration ¶
func (d *DealCountComponents) ValidConfiguration(exampleState boardgame.State) error
ValidConfiguration checks that the top level move implements interfaces.PlayerStacker and interfaces.GameStacker, and that both return a non-nil stack. It also verifies the top level move implements interfacdes.TargetCounter.
type Default ¶
Default is an optional, convenience struct designed to be embedded anonymously in your own Moves. It builds on base.Move to add to a layer of default Legal logic and configuraability.. Apply is not covered, because every Move should implement their own, and if this implemented them it would obscure errors where for example your Apply() was incorrectly named and thus not used.
Default's Legal() method does basic checking for whehter the move is legal in this phase, so your own Legal() method should always call Default.Legal() (or the Legal method of whichever struct you embedded that in turn calls Default.Legal()) at the top of its own method.
Default contains a fair bit of logic for generating the values that auto.Config will use for the move configuration; see MoveType* methods on Default for more information.
It is extremely rare to not use moves.Default either directly, or implicitly within another sub-class in your move.
boardgame:codegen
func (*Default) DeriveName ¶
func (d *Default) DeriveName(m *boardgame.GameManager) string
DeriveName is used by auto.Config to generate the name for the move. This implementation is where the majority of MoveName magic logic comes from. First, it will use the configuration passed to auto.Config via WithMoveName, if provided. Next, it checks the name of the topLevelStruct via reflection. If the struct does not come from the moves package, it will create a name like `MoveMyMove` --> `My Move`. Finally, if it's a struct from this package, it will fall back on whatever the FallbackName() method returns. Subclasses generally should not override this. If WithMoveNameSuffix() was used, it will then add " - " + suffix to the end of the move name.
func (*Default) FallbackHelpText ¶
FallbackHelpText is the help text that will be used by HelpText if nothing was passed via WithHelpText to auto.Config. By default it returns "A default move that does nothing on its own"
func (*Default) FallbackName ¶
func (d *Default) FallbackName(m *boardgame.GameManager) string
FallbackName is the name that is returned if other higher-priority methods in MoveTypeName fail. For moves.Default returns "Base Move".
func (*Default) HelpText ¶
HelpText will return the value passed via the WithHelpText config option, if it was passed. Otherwise it will fall back on the move's HelpTextFallback method.
func (*Default) IsFixUp ¶
IsFixUp will return the value passed with WithFixUp, falling back on returning false.
func (*Default) Legal ¶
func (d *Default) Legal(state boardgame.ImmutableState, proposer boardgame.PlayerIndex) error
Legal checks whether the game's CurrentPhase (as determined by the delegate) is one of the LegalPhases for this moveType. If the delegate's PhaseEnum is a TreeEnum, it will also pass this test if delegate.CurrentPhase() value's ancestors match the legal move type. A zero-length LegalPhases is interpreted as the move being legal in all phases. The string for the current phase will be based on the enum value of the PhaseEnum named by delegate.PhaseEnumName(), if it exists. Next, it checks to see if the give move is at a legal point in the move progression for this phase, if it exists. Each move in the move progression must show up 1 or more times. (Moves that don't define a progression group are ignored, since they may show up at any time in the phase.) The method checks to see if we were to make this move, would the moves since the last phase change match the pattern? If your move can be made legally multiple times in a row in a given move progression, implement interfaces.AllowMultipleInProgression() and return true.
func (*Default) ReadSetConfigurer ¶
func (d *Default) ReadSetConfigurer() boardgame.PropertyReadSetConfigurer
ReadSetConfigurer returns an autp-generated boardgame.PropertyReadSetConfigurer for Default
func (*Default) ReadSetter ¶
func (d *Default) ReadSetter() boardgame.PropertyReadSetter
ReadSetter returns an autp-generated boardgame.PropertyReadSetter for Default
func (*Default) Reader ¶
func (d *Default) Reader() boardgame.PropertyReader
Reader returns an autp-generated boardgame.PropertyReader for Default
type DefaultComponent ¶
type DefaultComponent struct { FixUpMulti ComponentIndex int }
DefaultComponent is a fix up move type that iterates through SourceStac(), and for any non-nil component it encounters that implements interface.LegalComponent, calls Legal(). The first index that returns nil for that method will set ComponentIndex to that index and return. You must provide your own Apply(). This move is convenient for fix up moves that have to be done on given components when something becomes true. For example, it's useful in checkers to automatically crown tokens that make it to the other side of the board.
func (*DefaultComponent) DefaultsForState ¶
func (d *DefaultComponent) DefaultsForState(state boardgame.ImmutableState)
DefaultsForState iterates through SourceStack() components one by one from start to finish. If the component is non-nil and implments interfaces.LegalComponent, calls Legal. If that returns nil, it sets the ComponentIndex property to that index and returns.
func (*DefaultComponent) FallbackHelpText ¶
func (d *DefaultComponent) FallbackHelpText() string
FallbackHelpText returns a string based on the stackName passed to WithSourceProperty, and the LegalType.
func (*DefaultComponent) FallbackName ¶
func (d *DefaultComponent) FallbackName(m *boardgame.GameManager) string
FallbackName returns a string based on the stackName passed to WithSourceProperty, and the LegalType.
func (*DefaultComponent) Legal ¶
func (d *DefaultComponent) Legal(state boardgame.ImmutableState, proposer boardgame.PlayerIndex) error
Legal checks that the component specified by the ComponentIndex index within SourceStack implements interfaces.LegalComponent and then returns its return value. Otherwise, it errors.
func (*DefaultComponent) LegalType ¶
func (d *DefaultComponent) LegalType() int
LegalType returns the value that will be passed to the Component's Legal() legalType argument. It will return the value passed to auto.Config with WithLegalType(), or 0 if none was provided. If that behavior isn't sufficient, you may override this method.
func (*DefaultComponent) ReadSetConfigurer ¶
func (d *DefaultComponent) ReadSetConfigurer() boardgame.PropertyReadSetConfigurer
ReadSetConfigurer returns an autp-generated boardgame.PropertyReadSetConfigurer for DefaultComponent
func (*DefaultComponent) ReadSetter ¶
func (d *DefaultComponent) ReadSetter() boardgame.PropertyReadSetter
ReadSetter returns an autp-generated boardgame.PropertyReadSetter for DefaultComponent
func (*DefaultComponent) Reader ¶
func (d *DefaultComponent) Reader() boardgame.PropertyReader
Reader returns an autp-generated boardgame.PropertyReader for DefaultComponent
func (*DefaultComponent) SourceStack ¶
func (d *DefaultComponent) SourceStack(state boardgame.State) boardgame.Stack
SourceStack returns the stack set in configuration by WithSourceProperty on the GameState, or nil. If that is not sufficient for your needs you should override SourceStack yourself.
func (*DefaultComponent) ValidConfiguration ¶
func (d *DefaultComponent) ValidConfiguration(exampleState boardgame.State) error
ValidConfiguration verifies that there's a SourceStack that returns non-nil, and a valid LegalType, and at least one component in the deck implements interfaces.LegalComponent.
type Done ¶
type Done struct {
Default
}
Done is a simple move that does nothing and whose Legal is equivalent to moves.Default.Legal(), meaning it is legal purely if the phase matches and it's the right time in the progression.
It's a non-fix-up equivalent to NoOp. It's used primarily when a player could decide to make multiple moves, or end early, and has opted to end early.
boardgame:codegen
func (*Done) FallbackHelpText ¶
FallbackHelpText returns "The player has signaled that they are done applying moves in this group and are ready to move on."
func (*Done) FallbackName ¶
func (d *Done) FallbackName(m *boardgame.GameManager) string
FallbackName returns "Done"
func (*Done) ReadSetConfigurer ¶
func (d *Done) ReadSetConfigurer() boardgame.PropertyReadSetConfigurer
ReadSetConfigurer returns an autp-generated boardgame.PropertyReadSetConfigurer for Done
func (*Done) ReadSetter ¶
func (d *Done) ReadSetter() boardgame.PropertyReadSetter
ReadSetter returns an autp-generated boardgame.PropertyReadSetter for Done
func (*Done) Reader ¶
func (d *Done) Reader() boardgame.PropertyReader
Reader returns an autp-generated boardgame.PropertyReader for Done
type FinishTurn ¶
type FinishTurn struct {
FixUp
}
FinishTurn is designed to be used as a FixUp move that advances the CurrentPlayer to the next player when the current player's turn is done. Your game's playerStates should implement the PlayerTurnFinisher interface, and your gameState should implement CurrentPlayerSetter (which you can implement easily by using behaviors.CurrentPlayerBehavior). In practice because most of the logic is contained on your game and playerStates, you can often use this move directly in your game, with no configuration override or embedding, like so:
auto.MustConfig( new(moves.FinishTurn), )
boardgame:codegen
func (*FinishTurn) Apply ¶
func (f *FinishTurn) Apply(state boardgame.State) error
Apply resets the current player via ResetForTurnEnd, then advances to the next player (using game.SetCurrentPlayer), then calls ResetForTurnStart on the new player.
func (*FinishTurn) FallbackHelpText ¶
func (f *FinishTurn) FallbackHelpText() string
FallbackHelpText returns "Advances to the next player when the current player's turn is done."
func (*FinishTurn) FallbackName ¶
func (f *FinishTurn) FallbackName(m *boardgame.GameManager) string
FallbackName returns "Finish Turn". In many cases you only have one FinishTurn move in a game, so this name does not need to be overriden.
func (*FinishTurn) Legal ¶
func (f *FinishTurn) Legal(state boardgame.ImmutableState, proposer boardgame.PlayerIndex) error
Legal checks if the game's CurrentPlayer's TurnDone() returns true.
func (*FinishTurn) ReadSetConfigurer ¶
func (f *FinishTurn) ReadSetConfigurer() boardgame.PropertyReadSetConfigurer
ReadSetConfigurer returns an autp-generated boardgame.PropertyReadSetConfigurer for FinishTurn
func (*FinishTurn) ReadSetter ¶
func (f *FinishTurn) ReadSetter() boardgame.PropertyReadSetter
ReadSetter returns an autp-generated boardgame.PropertyReadSetter for FinishTurn
func (*FinishTurn) Reader ¶
func (f *FinishTurn) Reader() boardgame.PropertyReader
Reader returns an autp-generated boardgame.PropertyReader for FinishTurn
func (*FinishTurn) ValidConfiguration ¶
func (f *FinishTurn) ValidConfiguration(exampleState boardgame.State) error
ValidConfiguration verfies that GameState implements interfaces.CurrentPlayerSetter and the PlayerState implements PlayerTurnFinisher.
type FixUp ¶
type FixUp struct {
Default
}
FixUp is a simple move type that just wraps moves.Default. Its primary effect is to have the default IsFixUp for auto.Config to default to true. When you have a custom fix up move, it's best to embed this, because otherwise it's easy to forget to pass moves.WithIsFixUp to auto.Config.
func (*FixUp) FallbackHelpText ¶
FallbackHelpText returns "A move that is applied automatically to fix up the state after a player makes a move."
func (*FixUp) FallbackName ¶
func (f *FixUp) FallbackName(m *boardgame.GameManager) string
FallbackName returns FixUp Move"
func (*FixUp) IsFixUp ¶
IsFixUp will return the value passed with WithFixUp, falling back on returning true. The returning of true is the primary result of embedding this move type.
func (*FixUp) ReadSetConfigurer ¶
func (f *FixUp) ReadSetConfigurer() boardgame.PropertyReadSetConfigurer
ReadSetConfigurer returns an autp-generated boardgame.PropertyReadSetConfigurer for FixUp
func (*FixUp) ReadSetter ¶
func (f *FixUp) ReadSetter() boardgame.PropertyReadSetter
ReadSetter returns an autp-generated boardgame.PropertyReadSetter for FixUp
func (*FixUp) Reader ¶
func (f *FixUp) Reader() boardgame.PropertyReader
Reader returns an autp-generated boardgame.PropertyReader for FixUp
type FixUpMulti ¶
type FixUpMulti struct {
FixUp
}
FixUpMulti is a simple move type that just wraps move.FixUp. Its primary effect is to have AllowMultipleInProgression() return true, which means that the logic for ordered move progressions within a phase will allow multiple in a row, until its Legal returns an error.
func (*FixUpMulti) AllowMultipleInProgression ¶
func (f *FixUpMulti) AllowMultipleInProgression() bool
AllowMultipleInProgression returns true because the move is applied until ConditionMet returns nil.
func (*FixUpMulti) ReadSetConfigurer ¶
func (f *FixUpMulti) ReadSetConfigurer() boardgame.PropertyReadSetConfigurer
ReadSetConfigurer returns an autp-generated boardgame.PropertyReadSetConfigurer for FixUpMulti
func (*FixUpMulti) ReadSetter ¶
func (f *FixUpMulti) ReadSetter() boardgame.PropertyReadSetter
ReadSetter returns an autp-generated boardgame.PropertyReadSetter for FixUpMulti
func (*FixUpMulti) Reader ¶
func (f *FixUpMulti) Reader() boardgame.PropertyReader
Reader returns an autp-generated boardgame.PropertyReader for FixUpMulti
type GroupableMoveConfig ¶
type GroupableMoveConfig interface { boardgame.MoveConfig MoveProgressionGroup }
GroupableMoveConfig is a type of MoveConfig that also has enough methods for it to be used as a MoveProgressionGroup in AddOrderedForPhase. AutoConfigurer.Configure() returns these so that they can be nested directly in any of the objects in the moves/groups package.
func NewGroupableMoveConfig ¶
func NewGroupableMoveConfig(config boardgame.MoveConfig) GroupableMoveConfig
NewGroupableMoveConfig takes a generic boardgame.MoveConfig and makes it satisfy the GroupableMoveConfig interface, so it can be used as a child in the objects in moves/groups. The config returned will simply return a list with a single item of itself for MoveConfigs. For Satisfied, it will consume a move that shares its own name, and, if it implements AllowMultipleInProgression() and returns true from that, it will consume as many of those moves in a row as exist from the front of the tape. AutoConfigurer.Config() returns objects that have been run through this automatically, but it's a public function in case you want to decorate a move config you generated manually and not from AutoConfigurer.Config().
type InactivateEmptySeat ¶
type InactivateEmptySeat struct { FixUpMulti TargetPlayerIndex boardgame.PlayerIndex }
InactivateEmptySeat is a move that will go through and repeatedly apply itself to mark as closed any seat that is not filled. Typically you put this at the end of a SetUp phase, once all of the players are there who you care to wait for, and want to signal to your own game logic to not block on them being seated, and act like those seats aren't even there. For more on the notion of seats and inactive players, see the package doc of boardagme/behaviors.
func (*InactivateEmptySeat) Apply ¶
func (i *InactivateEmptySeat) Apply(state boardgame.State) error
Apply sets the TargetPlayerIndex to be inactive via interfaces.PlayerInactiver.
func (*InactivateEmptySeat) DefaultsForState ¶
func (i *InactivateEmptySeat) DefaultsForState(state boardgame.ImmutableState)
DefaultsForState sets TargetPlayerIndex to the next player who is currently marked as inactive and also empty, according to interfaces.Seater and interfaces.PlayerInactiver.
func (*InactivateEmptySeat) FallbackHelpText ¶
func (i *InactivateEmptySeat) FallbackHelpText() string
FallbackHelpText returns "Marks any empty seats as being inactive, so other game logic will skip them"
func (*InactivateEmptySeat) FallbackName ¶
func (i *InactivateEmptySeat) FallbackName(m *boardgame.GameManager) string
FallbackName returns "Inactivate Empty Seat"
func (*InactivateEmptySeat) Legal ¶
func (i *InactivateEmptySeat) Legal(state boardgame.ImmutableState, proposer boardgame.PlayerIndex) error
Legal verifies that TargetPlayerIndex is set to a player that is currently empty and not currently inactive. If the game is running in a context where moves.SeatPlayer will never be called, then it will not activate for any seat (because it would activate for ALL seats).
func (*InactivateEmptySeat) ReadSetConfigurer ¶
func (i *InactivateEmptySeat) ReadSetConfigurer() boardgame.PropertyReadSetConfigurer
ReadSetConfigurer returns an autp-generated boardgame.PropertyReadSetConfigurer for InactivateEmptySeat
func (*InactivateEmptySeat) ReadSetter ¶
func (i *InactivateEmptySeat) ReadSetter() boardgame.PropertyReadSetter
ReadSetter returns an autp-generated boardgame.PropertyReadSetter for InactivateEmptySeat
func (*InactivateEmptySeat) Reader ¶
func (i *InactivateEmptySeat) Reader() boardgame.PropertyReader
Reader returns an autp-generated boardgame.PropertyReader for InactivateEmptySeat
func (*InactivateEmptySeat) ValidConfiguration ¶
func (i *InactivateEmptySeat) ValidConfiguration(exampleState boardgame.State) error
ValidConfiguration checks that player states implement interfaces.Seater and interfaces.PlayerInactiver.
type Increment ¶
type Increment struct {
FixUp
}
Increment is a simple move that modifies the specified int property by adding Amount() to it. It's often useful to run in a move progression, for example to increment a round count. Its Legal() is just the Legal for FixUp, so this should only be used within a MoveProgression, unless you provide your own Legal method.
func (*Increment) Amount ¶
Amount returns the amount to increment the given property by. Will use the value passed to WithAmount, or 1 if that wasn't used.
func (*Increment) Apply ¶
Apply will increment the given property by Amount(). If GameProperty returns a valid int property, will increment that. If GameProperty is not provided but PlayerProperty is, will increment that property on the CurrentPlayer. If the CurrentPlayer is not valid, will error.
func (*Increment) FallbackHelpText ¶
FallbackHelpText returns "Increments {Game|Player} Property PROPNAME By Amount"
func (*Increment) FallbackName ¶
func (i *Increment) FallbackName(m *boardgame.GameManager) string
FallbackName returns "Increment {Game|Player} Property PROPNAME By Amount"
func (*Increment) GameProperty ¶
GameProperty returns the name of the GameProperty provided by WithGameProperty, or "" if that wasn't called.
func (*Increment) PlayerProperty ¶
PlayerProperty returns the name of the property on PlayerState provided by WithPlayerProperty, or "" if that wasn't called.
func (*Increment) ReadSetConfigurer ¶
func (i *Increment) ReadSetConfigurer() boardgame.PropertyReadSetConfigurer
ReadSetConfigurer returns an autp-generated boardgame.PropertyReadSetConfigurer for Increment
func (*Increment) ReadSetter ¶
func (i *Increment) ReadSetter() boardgame.PropertyReadSetter
ReadSetter returns an autp-generated boardgame.PropertyReadSetter for Increment
func (*Increment) Reader ¶
func (i *Increment) Reader() boardgame.PropertyReader
Reader returns an autp-generated boardgame.PropertyReader for Increment
type MoveAllComponents ¶
type MoveAllComponents struct {
MoveComponentsUntilCountLeft
}
MoveAllComponents is simply a MoveComponentsUntilCountLeft that overrides TargetCount() to return 0. It's effectively the equivalent of stack.MoveAllTo, just broken into individual moves. A simple convenience since that combination is common.
func (*MoveAllComponents) FallbackHelpText ¶
func (m *MoveAllComponents) FallbackHelpText() string
FallbackHelpText returns "Moves all components from SOURCESTACKNAME to DESTINATIONSTACKNAME"
func (*MoveAllComponents) FallbackName ¶
func (m *MoveAllComponents) FallbackName(g *boardgame.GameManager) string
FallbackName returns "Move All Components From SOURCESTACKNAME To DESTINATIONSTACKNAME"
func (*MoveAllComponents) ReadSetConfigurer ¶
func (m *MoveAllComponents) ReadSetConfigurer() boardgame.PropertyReadSetConfigurer
ReadSetConfigurer returns an autp-generated boardgame.PropertyReadSetConfigurer for MoveAllComponents
func (*MoveAllComponents) ReadSetter ¶
func (m *MoveAllComponents) ReadSetter() boardgame.PropertyReadSetter
ReadSetter returns an autp-generated boardgame.PropertyReadSetter for MoveAllComponents
func (*MoveAllComponents) Reader ¶
func (m *MoveAllComponents) Reader() boardgame.PropertyReader
Reader returns an autp-generated boardgame.PropertyReader for MoveAllComponents
func (*MoveAllComponents) TargetCount ¶
func (m *MoveAllComponents) TargetCount(state boardgame.ImmutableState) int
TargetCount returns 0, no matter what was passed with WithTargetCount. This is the primary behavior of this move, compared to MoveComponentsUntilCountLeft.
type MoveComponentsUntilCountLeft ¶
type MoveComponentsUntilCountLeft struct {
MoveCountComponents
}
MoveComponentsUntilCountLeft is a move that will move components, one at a time, from SourceStack() to DestinationStack() until the source stack is down to having TargetCount components in it. Its primary difference from MoveComponentsUntilCountReached is that its target is based on reducing the size of SourceStack to a target size.
func (*MoveComponentsUntilCountLeft) Count ¶
func (m *MoveComponentsUntilCountLeft) Count(state boardgame.ImmutableState) int
Count returns the number of components in the SourceStack().
func (*MoveComponentsUntilCountLeft) FallbackHelpText ¶
func (m *MoveComponentsUntilCountLeft) FallbackHelpText() string
FallbackHelpText returns a string based on the names of the player stack name, game stack name, and target count.
func (*MoveComponentsUntilCountLeft) FallbackName ¶
func (m *MoveComponentsUntilCountLeft) FallbackName(g *boardgame.GameManager) string
FallbackName returns a string based on the names of the player stack name, game stack name, and target count.
func (*MoveComponentsUntilCountLeft) ReadSetConfigurer ¶
func (m *MoveComponentsUntilCountLeft) ReadSetConfigurer() boardgame.PropertyReadSetConfigurer
ReadSetConfigurer returns an autp-generated boardgame.PropertyReadSetConfigurer for MoveComponentsUntilCountLeft
func (*MoveComponentsUntilCountLeft) ReadSetter ¶
func (m *MoveComponentsUntilCountLeft) ReadSetter() boardgame.PropertyReadSetter
ReadSetter returns an autp-generated boardgame.PropertyReadSetter for MoveComponentsUntilCountLeft
func (*MoveComponentsUntilCountLeft) Reader ¶
func (m *MoveComponentsUntilCountLeft) Reader() boardgame.PropertyReader
Reader returns an autp-generated boardgame.PropertyReader for MoveComponentsUntilCountLeft
type MoveComponentsUntilCountReached ¶
type MoveComponentsUntilCountReached struct {
MoveCountComponents
}
MoveComponentsUntilCountReached is a move that will move components, one at a time, from SourceStack() to DestinationStack() until the target stack is up to having TargetCount components in it. See also MoveComponentsUntilCountLeft for a slightly different end condition.
func (*MoveComponentsUntilCountReached) Count ¶
func (m *MoveComponentsUntilCountReached) Count(state boardgame.ImmutableState) int
Count returns the number of components in DestinationStack().
func (*MoveComponentsUntilCountReached) FallbackHelpText ¶
func (m *MoveComponentsUntilCountReached) FallbackHelpText() string
FallbackHelpText returns a string based on the names of the player stack name, game stack name, and target count.
func (*MoveComponentsUntilCountReached) FallbackName ¶
func (m *MoveComponentsUntilCountReached) FallbackName(g *boardgame.GameManager) string
FallbackName returns a string based on the names of the player stack name, game stack name, and target count.
func (*MoveComponentsUntilCountReached) ReadSetConfigurer ¶
func (m *MoveComponentsUntilCountReached) ReadSetConfigurer() boardgame.PropertyReadSetConfigurer
ReadSetConfigurer returns an autp-generated boardgame.PropertyReadSetConfigurer for MoveComponentsUntilCountReached
func (*MoveComponentsUntilCountReached) ReadSetter ¶
func (m *MoveComponentsUntilCountReached) ReadSetter() boardgame.PropertyReadSetter
ReadSetter returns an autp-generated boardgame.PropertyReadSetter for MoveComponentsUntilCountReached
func (*MoveComponentsUntilCountReached) Reader ¶
func (m *MoveComponentsUntilCountReached) Reader() boardgame.PropertyReader
Reader returns an autp-generated boardgame.PropertyReader for MoveComponentsUntilCountReached
type MoveCountComponents ¶
type MoveCountComponents struct {
ApplyCountTimes
}
MoveCountComponents is a move that will move components, one at a time, from SourceStack() to DestinationStack() until TargetCount() components have been moved. It is like DealComponents or CollectComponnets, except instead of working on a certain stack for each player, it operates on two fixed stacks. Other MoveComponents-style moves derive from this. When using it you must implement interfaces.SourceStacker and interfaces.DestinationStacker to encode which stacks to use. You may also want to override TargetCount() if you want to move more than one component.
In practice it is most common to just use this move (and its subclasses) directly, and pass configuration for SourceStack, DestinationStack, and TargetCount with WithSourceProperty, WithDestinationProperty, and WithTargetCount to auto.Config.
func (*MoveCountComponents) Apply ¶
func (m *MoveCountComponents) Apply(state boardgame.State) error
Apply by default moves one component from SourceStack() to DestinationStack(). You likely do not need to override this method.
func (*MoveCountComponents) DestinationStack ¶
func (m *MoveCountComponents) DestinationStack(state boardgame.State) boardgame.Stack
DestinationStack by default just returns the property on GameState with the name passed to DefaultConfig by WithDestinationProperty. If that is not sufficient, override this in your embedding struct.
func (*MoveCountComponents) FallbackHelpText ¶
func (m *MoveCountComponents) FallbackHelpText() string
FallbackHelpText returns a string based on the names of the player stack name, game stack name, and target count.
func (*MoveCountComponents) FallbackName ¶
func (m *MoveCountComponents) FallbackName(g *boardgame.GameManager) string
FallbackName returns a string based on the names of the player stack name, game stack name, and target count.
func (*MoveCountComponents) Legal ¶
func (m *MoveCountComponents) Legal(state boardgame.ImmutableState, proposer boardgame.PlayerIndex) error
Legal checks that source and destiantion stacks exist, that enough components to move exist.
func (*MoveCountComponents) ReadSetConfigurer ¶
func (m *MoveCountComponents) ReadSetConfigurer() boardgame.PropertyReadSetConfigurer
ReadSetConfigurer returns an autp-generated boardgame.PropertyReadSetConfigurer for MoveCountComponents
func (*MoveCountComponents) ReadSetter ¶
func (m *MoveCountComponents) ReadSetter() boardgame.PropertyReadSetter
ReadSetter returns an autp-generated boardgame.PropertyReadSetter for MoveCountComponents
func (*MoveCountComponents) Reader ¶
func (m *MoveCountComponents) Reader() boardgame.PropertyReader
Reader returns an autp-generated boardgame.PropertyReader for MoveCountComponents
func (*MoveCountComponents) SourceStack ¶
func (m *MoveCountComponents) SourceStack(state boardgame.State) boardgame.Stack
SourceStack by default just returns the property on GameState with the name passed to DefaultConfig by WithSourceProperty. If that is not sufficient, override this in your embedding struct.
func (*MoveCountComponents) ValidConfiguration ¶
func (m *MoveCountComponents) ValidConfiguration(exampleState boardgame.State) error
ValidConfiguration checks to make sure that SourceStack and DestinationStack both exist and return non-nil stacks.
type MoveGroupHistoryItem ¶
type MoveGroupHistoryItem struct { MoveName string Rest *MoveGroupHistoryItem }
MoveGroupHistoryItem is a singly-linked list (referred to in various comments as a "tape") that is passed to MoveProgressionGroup.Satisfied(). It represents a list of all of the moves that have applied so far since game.CurrentPhase() last changed.
type MoveProgressionGroup ¶
type MoveProgressionGroup interface { //MoveConfigs should return the full enumeration of contained MoveConfigs //within this Group, from left to right and top to bottom. This is used by //moves.AddOrderedForPhase to know which MoveConfigs contained within it //to install. MoveConfigs() []boardgame.MoveConfig //Satisfied reads the tape and returns an error if the sequence was not //valid (did not match, for example, or the group was configured in an //invalid way in general). If it returns a nil error, it should also //return the rest of the tape representing the items it did not yet //consume. If passed a nil tape, it should immediately return nil, nil. If //the top-level MoveProgressionGroup consumes the entire tape and doesn't //return an error then the progression is considered valid. Satisfied(tape *MoveGroupHistoryItem) (rest *MoveGroupHistoryItem, err error) }
MoveProgressionGroup is an object that can be used to define a valid move progression. moves.AutoConfigurer().Config() returns objects that fit this interface.
func DefaultRoundSetup ¶
func DefaultRoundSetup(auto *AutoConfigurer) MoveProgressionGroup
DefaultRoundSetup returns a serial move progression appropriate for putting at the beginning of your RoundSetUp phase, if you have a game that uses SeatPlayer. It returns a Optional(ActivateInactivePlayer), WaitForEnoughPlayers, Optional(InactivateEmptySeat). What this does is activate any players who have been seated already but not yet activated, then pause until we have enough players to activate the round, and then mark any unfilled seats as Inactive so the game logic within the actual round doesn't wait for them. This progression is finicky to get right, which is why it's provided as a baked function.
func Optional ¶
func Optional(group MoveProgressionGroup) MoveProgressionGroup
Optional returns a MoveProgressionGroup that matches the provided group either 0 or 1 times. Equivalent to Repeat() with a count of Between(0, 1).
func Parallel ¶
func Parallel(children ...MoveProgressionGroup) MoveProgressionGroup
Parallel is a type of move group that requires all sub-groups to be present, but in any order. It is one of the most basic types of groups. If you want parallel semantics but don't want to require matching all groups, see ParallelCount. The base Parallel is equivalent to ParallelCount with a Count of CountAll().
Its Satisfied goes through each item in turn, seeing if any of them that have not yet been applied can consume items off of the front of the tape without erroring. It continues going through until all are met, or no more un- triggered items can consume more items. If at any point more than one item could match at the given point in the tape, it chooses the match that consumes the most tape.
func ParallelCount ¶
func ParallelCount(count ValidCounter, children ...MoveProgressionGroup) MoveProgressionGroup
ParallelCount is a version of Parallel, but where the target count of number of children to match before being satisfied is given by Count. The length argument to Count will be the number of Groups who are children. See ValidCounter in this package for multiple counters you can pass.
func Repeat ¶
func Repeat(count ValidCounter, group MoveProgressionGroup) MoveProgressionGroup
Repeat returns a MoveProgressionGroup that repeats the provided group the number of times count is looking for, in serial. Assumes that the ValidCounter has a single range of legal count values, where before it they are illegal, during the range they are legal, and after it they are illegal agin, and will read as many times from the tape as it can within that legal range. All ValidCounter methods in this package satisfy this. It is conceptually equivalent to duplicating a given group within a parent Serial count times.
func Serial ¶
func Serial(children ...MoveProgressionGroup) MoveProgressionGroup
Serial returns a type of move group that represents the sub-groups provided from top to bottom, in order. It is one of the most basic types of groups.
Its Satisfied walks through each sub-group in turn. It errors if no tape is read.
type NoOp ¶
type NoOp struct {
FixUp
}
NoOp is a simple FixUp move that has a defined Apply() method that does nothing, and whose Legal() is equivalent to base.Legal(). This move is generally useful for MoveProgressionGroup matching scenarios where a move that AllowMultipleInProgression() would match too many of itself in a row greedily, even though the move was in two adjacent groups. A simple example:
//... moves.AddOrderedForPhase(PhaseNormal, Serial( auto.MustConfig(new(FixUpAllowsMultiple)), ), Serial( auto.MustConfig(new(FixUpAllowsMultiple)), auto.Mustconfig(new(FixUpAnotherMove)), ), ), //...
FixUpAllowsMultiple would match all historical moves in the first Serial group, meaning that the second Serial group could never be matched. moves.NoOp provides a barrier:
//... moves.AddOrderedForPhase(PhaseNormal, Serial( auto.MustConfig(new(FixUpAllowsMultiple)), ), Serial( auto.MustConfig(new(moves.NoOp)), auto.MustConfig(new(FixUpAllowsMultiple)), auto.Mustconfig(new(FixUpAnotherMove)), ), ), //...
FixUpAllowsMultiple will at some point decide itself that it is no longer legal to apply. At that point, the next move in the progression is NoOp, which only uses moves.Default.Legal() and is therefore always legal at its point in the phase. After NoOp applies, the next FixUpAllowsMultiple applies, guaranteeing it begins matching the second group.
NoOp is also used by AddOrderedForPhase to signal that the lack of a StartPhase move was intentional.
Note that because every move config installed must have a different name, if you use multiple moves.NoOp in your game, you will want to override at least one of their names with WithMoveName or WithMoveNameSuffix.
boardgame:codegen
func (*NoOp) FallbackHelpText ¶
FallbackHelpText returns "A move that does nothing and is primarily used in specific move progression situations."
func (*NoOp) FallbackName ¶
func (n *NoOp) FallbackName(m *boardgame.GameManager) string
FallbackName returns "No Op"
func (*NoOp) ReadSetConfigurer ¶
func (n *NoOp) ReadSetConfigurer() boardgame.PropertyReadSetConfigurer
ReadSetConfigurer returns an autp-generated boardgame.PropertyReadSetConfigurer for NoOp
func (*NoOp) ReadSetter ¶
func (n *NoOp) ReadSetter() boardgame.PropertyReadSetter
ReadSetter returns an autp-generated boardgame.PropertyReadSetter for NoOp
func (*NoOp) Reader ¶
func (n *NoOp) Reader() boardgame.PropertyReader
Reader returns an autp-generated boardgame.PropertyReader for NoOp
type RoundRobin ¶
type RoundRobin struct {
ApplyUntil
}
RoundRobin is a type of move that goes around every player one by one and does some action. Other moves in this package embed RoundRobin, and it's more common to use those directly.
Round Robin moves start at a given player and goes around. It will skip players for whom move.PlayerConditionMet() has already returned true. When it finds a player whose end condition is not met, it will apply RoundRobinAction() to them, and then advance to the next player. Every time it makes a circuit around the list of players, it will increment RoundRobinRoundCount. By default, once all players have had their player conditions met (that is, no player is legal to select) the round robin's will be done applying: its ConditionMet will return nil.
Round Robin keeps track of various properties on the gameState by using the RoundRobinProperties interface. Generally it's easiest to simply embed the RoundRobinGameStateProperties struct in your GameState anonymously to implement the interface automatically.
The embeding move should implement interfaces.RoundRobinActioner.
boardgame:codegen
func (*RoundRobin) Apply ¶
func (r *RoundRobin) Apply(state boardgame.State) error
Apply is a complex implementation because it needs to figure out when the round is already over and handle complicated signalling about who the next player is. In general you do not want to override this.
func (*RoundRobin) ConditionMet ¶
func (r *RoundRobin) ConditionMet(state boardgame.ImmutableState) error
ConditionMet goes around and returns nil if all players have had their player condition met, meaning that there are no more legal players to select. Because this condition is almost always an important base no matter the other conditions you are considering (it's not possible to select players who have already had their player condition met), if you override CondtionMet you should also call this implementation.
func (*RoundRobin) FallbackHelpText ¶
func (r *RoundRobin) FallbackHelpText() string
FallbackHelpText returns "A round robin move that continues until every player's condition is met."
func (*RoundRobin) FallbackName ¶
func (r *RoundRobin) FallbackName(m *boardgame.GameManager) string
FallbackName returns "Round Robin"
func (*RoundRobin) Legal ¶
func (r *RoundRobin) Legal(state boardgame.ImmutableState, proposer boardgame.PlayerIndex) error
Legal is a complex implementation because it needs to figure out when to start the round robin. In general you do not want to override this.
func (*RoundRobin) PlayerConditionMet ¶
func (r *RoundRobin) PlayerConditionMet(playerState boardgame.ImmutableSubState) bool
PlayerConditionMet is called for each playerState. When advancing to the next player, round robin will only pick a player whose condition has not yet been met. Once all players have their PlayerconditionMet, then the RoundRobin's ConditionMet will return nil, signaling that the RoundRobin is done. By default this will return false. If you will use RoundRobin directly (as opposed to RoundRobinNumRounds) you will want to override this otherwise it will get in an infinite loop.
func (*RoundRobin) ReadSetConfigurer ¶
func (r *RoundRobin) ReadSetConfigurer() boardgame.PropertyReadSetConfigurer
ReadSetConfigurer returns an autp-generated boardgame.PropertyReadSetConfigurer for RoundRobin
func (*RoundRobin) ReadSetter ¶
func (r *RoundRobin) ReadSetter() boardgame.PropertyReadSetter
ReadSetter returns an autp-generated boardgame.PropertyReadSetter for RoundRobin
func (*RoundRobin) Reader ¶
func (r *RoundRobin) Reader() boardgame.PropertyReader
Reader returns an autp-generated boardgame.PropertyReader for RoundRobin
func (*RoundRobin) RoundRobinStarterPlayer ¶
func (r *RoundRobin) RoundRobinStarterPlayer(state boardgame.ImmutableState) boardgame.PlayerIndex
RoundRobinStarterPlayer by default will return delegate.CurrentPlayer. Override this method if you want a different starter.
func (*RoundRobin) ValidConfiguration ¶
func (r *RoundRobin) ValidConfiguration(exampleState boardgame.State) error
ValidConfiguration verifies that GameState implements interfaces.RoundRobinProperties, and that move implements PlayerConditionMet, as well as RoundRobinActioner.
type RoundRobinNumRounds ¶
type RoundRobinNumRounds struct {
RoundRobin
}
RoundRobinNumRounds is a subclass of RoundRobin whose ConditionMet checks whether RoundRobinRoundCount is greater than or equal to NumRounds(), and if it is ends immediately. NumRounds() defaults to 1; if you want to have multiple rounds, override NumRounds().
func (*RoundRobinNumRounds) ConditionMet ¶
func (r *RoundRobinNumRounds) ConditionMet(state boardgame.ImmutableState) error
ConditionMet will check if the round count has been reached; if it has it will return nil immediately. Otherwise it will fall back on RoundRobin's base ConditionMet, returning nil if no players are left to act upon.
func (*RoundRobinNumRounds) FallbackHelpText ¶
func (r *RoundRobinNumRounds) FallbackHelpText() string
FallbackHelpText returns "A round robin move that makes INT circuits.", where INT is NumRounds().
func (*RoundRobinNumRounds) FallbackName ¶
func (r *RoundRobinNumRounds) FallbackName(m *boardgame.GameManager) string
FallbackName returns "Round Robin INT Rounds", where INT is NumRounds().
func (*RoundRobinNumRounds) NumRounds ¶
func (r *RoundRobinNumRounds) NumRounds(state boardgame.ImmutableState) int
NumRounds should return the RoundRobinRoundCount that we are targeting. As soon as that RoundCount is reached, our ConditionMet will start returning nil, signaling the Round Robin is over. Will return the value passed via WithNumRounds to auto.Config, or 1 by default.
func (*RoundRobinNumRounds) ReadSetConfigurer ¶
func (r *RoundRobinNumRounds) ReadSetConfigurer() boardgame.PropertyReadSetConfigurer
ReadSetConfigurer returns an autp-generated boardgame.PropertyReadSetConfigurer for RoundRobinNumRounds
func (*RoundRobinNumRounds) ReadSetter ¶
func (r *RoundRobinNumRounds) ReadSetter() boardgame.PropertyReadSetter
ReadSetter returns an autp-generated boardgame.PropertyReadSetter for RoundRobinNumRounds
func (*RoundRobinNumRounds) Reader ¶
func (r *RoundRobinNumRounds) Reader() boardgame.PropertyReader
Reader returns an autp-generated boardgame.PropertyReader for RoundRobinNumRounds
func (*RoundRobinNumRounds) ValidConfiguration ¶
func (r *RoundRobinNumRounds) ValidConfiguration(exampleState boardgame.State) error
ValidConfiguration verifies that NumRound exists and does not return a negative value.
type SeatPlayer ¶
type SeatPlayer struct { FixUp TargetPlayerIndex boardgame.PlayerIndex }
SeatPlayer is a game that seats a new player into an open seat in the game. It is a special interface point for the server library to interact with your game logic. The core engine has no notion of whether or not a real user is associated with any given player slot. The server package does distinguish this, keeping track of which player slots need to be filled by real users. But by default your core game logic can't detect which player slots haven't been filled, or when they are filled. SeatPlayer, when used in conjunction with behaviors.Seat, introduces the notion of a Seat to each player slot. Those properties communicate whether the seat is filled with a physical player, and whether it is open to having a player sit in it. SeatPlayer is a special type of move that will be proposed by the server engine when it has a player waiting to be seated. Your core game logic can decide when it should be legal based on which phases it is configured to be legal in. If you do not explicitly configure SeatPlayer (or a move that derives from it) in your game then the server will not alert you when a player has been seated.
You may use this move directly, or embed it in a move of your own that overrides some logic, like for example DefaultsForState to override where the next player is seated.
If you don't want a seat to have players seated in it, even if it's not yet filled, then you can call SetSeatClosed() method on the player state. The move CloseEmptySeats will automatically mark all currently unfilled seats as closed, so no new players will be accepted.
For more on the concept of seats, see the package doc of boardgame/behaviors package.
func (*SeatPlayer) Apply ¶
func (s *SeatPlayer) Apply(state boardgame.State) error
Apply sets the targeted player to be Filled. If the player state also implements interfaces.Inactiver (for example because it implements behaviors.PlayerInactive), then it will also set the player to inactive. This is often the behavior you want; if you're in the middle of a round you typically don't want a new player to be active in the middle of it. But if you do use behaviors.PlayerInactive, remember to implement ActivateInactivePlayer at the beginning of rounds to activate any new seated players.
func (*SeatPlayer) DefaultsForState ¶
func (s *SeatPlayer) DefaultsForState(state boardgame.ImmutableState)
DefaultsForState sets TargetPlayerIndex to the PlayerIndex returned by SeatPlayerSignaler, or if that doesn't return anything, the next player who is neither filled nor closed.
func (*SeatPlayer) FallbackHelpText ¶
func (s *SeatPlayer) FallbackHelpText() string
FallbackHelpText returns "Marks the next available seat as seated, which when done will mean the next player is part of the game"
func (*SeatPlayer) FallbackName ¶
func (s *SeatPlayer) FallbackName(m *boardgame.GameManager) string
FallbackName returns "Seat Player"
func (*SeatPlayer) IsSeatPlayerMove ¶
func (s *SeatPlayer) IsSeatPlayerMove() bool
IsSeatPlayerMove returns true. This is a way for moves to signal to other libraries that it's a SeatPlayer move, even if it isn't literally this move struct but a subclass of it. Implements interfaces.SeatPlayerMover.
func (*SeatPlayer) Legal ¶
func (s *SeatPlayer) Legal(state boardgame.ImmutableState, proposer boardgame.PlayerIndex) error
Legal verifies that TargetPlayerIndex is set to a player who is both not filled and not closed, and that the proposer is the admin, since only server should propose this move.
func (*SeatPlayer) ReadSetConfigurer ¶
func (s *SeatPlayer) ReadSetConfigurer() boardgame.PropertyReadSetConfigurer
ReadSetConfigurer returns an autp-generated boardgame.PropertyReadSetConfigurer for SeatPlayer
func (*SeatPlayer) ReadSetter ¶
func (s *SeatPlayer) ReadSetter() boardgame.PropertyReadSetter
ReadSetter returns an autp-generated boardgame.PropertyReadSetter for SeatPlayer
func (*SeatPlayer) Reader ¶
func (s *SeatPlayer) Reader() boardgame.PropertyReader
Reader returns an autp-generated boardgame.PropertyReader for SeatPlayer
func (*SeatPlayer) ValidConfiguration ¶
func (s *SeatPlayer) ValidConfiguration(exampleState boardgame.State) error
ValidConfiguration checks that player states implement interfaces.Seater
type ShuffleStack ¶
type ShuffleStack struct {
FixUp
}
ShuffleStack is a move, typically used in SetUp phases, that simply shuffles a given stack. The struct you embed this in should implement SourceStacker.
In practice it is common to just use this move directly in your game, and pass the stack via WithSourceProperty to auto.Config.
func (*ShuffleStack) Apply ¶
func (s *ShuffleStack) Apply(state boardgame.State) error
Apply shuffles the stack that the embedding move selects by the return value from SourceStack().
func (*ShuffleStack) FallbackHelpText ¶
func (s *ShuffleStack) FallbackHelpText() string
FallbackHelpText returns "Shuffles the STACK stack" where STACK is the name of the stack set by WithSourceProperty.
func (*ShuffleStack) FallbackName ¶
func (s *ShuffleStack) FallbackName(m *boardgame.GameManager) string
FallbackName returns "Shuffle STACK" where STACK is the name of the stack set by WithSourceProperty.
func (*ShuffleStack) ReadSetConfigurer ¶
func (s *ShuffleStack) ReadSetConfigurer() boardgame.PropertyReadSetConfigurer
ReadSetConfigurer returns an autp-generated boardgame.PropertyReadSetConfigurer for ShuffleStack
func (*ShuffleStack) ReadSetter ¶
func (s *ShuffleStack) ReadSetter() boardgame.PropertyReadSetter
ReadSetter returns an autp-generated boardgame.PropertyReadSetter for ShuffleStack
func (*ShuffleStack) Reader ¶
func (s *ShuffleStack) Reader() boardgame.PropertyReader
Reader returns an autp-generated boardgame.PropertyReader for ShuffleStack
func (*ShuffleStack) SourceStack ¶
func (s *ShuffleStack) SourceStack(state boardgame.State) boardgame.Stack
SourceStack by default just returns the property on GameState with the name passed to DefaultConfig by WithSourceProperty. If that is not sufficient, override this in your embedding struct.
func (*ShuffleStack) ValidConfiguration ¶
func (s *ShuffleStack) ValidConfiguration(exampleState boardgame.State) error
ValidConfiguration verifies that the top level move implements interfaces.SourceStacker and returns non-nil stacks.
type StartPhase ¶
type StartPhase struct {
FixUp
}
StartPhase is a simple move that, when it's its turn in the phase move progression, will set the current phase of the game to the given value. When you use this, you almost always want ot use moves.AutoConfig, and make sure to pass the moves.WithPhaseToStart config object, so that the move has enough information to know which phase to enter.
func (*StartPhase) Apply ¶
func (s *StartPhase) Apply(state boardgame.State) error
Apply call BeforeLeavePhase() (if it exists), then BeforeEnterPhase() (if it exists),then SetCurrentPhase to the phase index returned by PhaseToStart from this move type.
func (*StartPhase) FallbackHelpText ¶
func (s *StartPhase) FallbackHelpText() string
FallbackHelpText returns "Enters phase PHASENAME" where PHASENAME is the string value of the phase to start that was passed via WithPhaseToStart, or the int value if no enum was passed.
func (*StartPhase) FallbackName ¶
func (s *StartPhase) FallbackName(m *boardgame.GameManager) string
FallbackName returns "Start Phase PHASENAME" where PHASENAME is the string value of the phase to start that was passed via WithPhaseToStart, or the int value if no enum was passed.
func (*StartPhase) PhaseToStart ¶
func (s *StartPhase) PhaseToStart(currentPhase int) int
PhaseToStart uses the Phase provided via StartPhaseMoveConfig constructor (or 0 if NewStartPhaseConfig wasn't used). If you want a different behavior, override PhaseToStart in your embedding move.
func (*StartPhase) ReadSetConfigurer ¶
func (s *StartPhase) ReadSetConfigurer() boardgame.PropertyReadSetConfigurer
ReadSetConfigurer returns an autp-generated boardgame.PropertyReadSetConfigurer for StartPhase
func (*StartPhase) ReadSetter ¶
func (s *StartPhase) ReadSetter() boardgame.PropertyReadSetter
ReadSetter returns an autp-generated boardgame.PropertyReadSetter for StartPhase
func (*StartPhase) Reader ¶
func (s *StartPhase) Reader() boardgame.PropertyReader
Reader returns an autp-generated boardgame.PropertyReader for StartPhase
func (*StartPhase) ValidConfiguration ¶
func (s *StartPhase) ValidConfiguration(exampleState boardgame.State) error
ValidConfiguration checks that the embedding move implements PhaseToStart which returns a non-negative value, and that GameState implements interfaces.CurrentPhaseStarter, and that PhaseEnum exists and if it's a TreeEnum, that the phaseToStart is a leaf enum value.
type ValidCounter ¶
ValidCounter is the signature of objects in the moves/count package. It is expected within groups in the move/groups package for items like ParallelCount. currentCount is the value of the counter in question, and length is the context-specific length of the important item, often the number of children in the parrent group. If ValidCounter returns nil, the count is considered valid and complete; if it is not valid it should return a descriptive error. Typically these functions are closures that close over configuration options.
func CountAll ¶
func CountAll() ValidCounter
CountAll will return nil if currentCount is precisely the same length as length. Equivalent to CountBetween(0,-1). Not to be confused with CountInfinite; CountAll expects to see precisely all children matched.
func CountAny ¶
func CountAny() ValidCounter
CountAny will return nil if currentCount is 1, denoting that any item has matched. Equivalent to CountBetween(0,1).
func CountAtLeast ¶
func CountAtLeast(min int) ValidCounter
CountAtLeast will return nil if currentCount is min or greater.
func CountAtMost ¶
func CountAtMost(max int) ValidCounter
CountAtMost will return nil as long as currentCount is less than or equal to max. A max argument of less than 0 will be interpreted to mean precisely the length parameter passed into ValidCounter.
func CountBetween ¶
func CountBetween(min, max int) ValidCounter
CountBetween returns nil as long as the value is greater than or equal to min and less than or equal to max. A max argument of less than 0 will be interpreted to mean precise the length parameter passed into ValidCounter.
func CountExactly ¶
func CountExactly(targetCount int) ValidCounter
CountExactly returns nil if currentCount is precisely equaly to targetCount. Equivalent to CountBetween(targetCount,targetCount).
func CountInfinite ¶
func CountInfinite() ValidCounter
CountInfinite always returns nil; that is, any count is legal. Not to be confused with CountAny, which expects any single item to match, and CountAll which expects all children to match.
type WaitForEnoughPlayers ¶
type WaitForEnoughPlayers struct {
FixUp
}
WaitForEnoughPlayers is a move that is useful to include in your phase progressions where you want to wait until there are enough players to start a round. Typically the logic in your SetUpRound game phase will have an Optional(ActivateInactivePlayers) (if your game includes behaviors.InactivePlayer), then a non-optional call to this move, and then the rest of the logic to set up the round. This move will apply as a no-op as long as GameDelegate.NumSeatedActivePlayers is greater than its TargetCount. By default, TargetCount is your game delegate's MinNumPlayers. This move will auto-apply itself in contexts where SeatPlayer won't ever be called (for example, if you're running your game logic outside of an instance of server)
func (*WaitForEnoughPlayers) Apply ¶
func (w *WaitForEnoughPlayers) Apply(state boardgame.State) error
Apply does nothing. The main purpose of this move is to block a move progression from proceeding when it is not yet legal.
func (*WaitForEnoughPlayers) FallbackHelpText ¶
func (w *WaitForEnoughPlayers) FallbackHelpText() string
FallbackHelpText returns "Waits until at least target count players are active and seated before applying itself"
func (*WaitForEnoughPlayers) FallbackName ¶
func (w *WaitForEnoughPlayers) FallbackName(m *boardgame.GameManager) string
FallbackName returns "Wait For Enough Players"
func (*WaitForEnoughPlayers) Legal ¶
func (w *WaitForEnoughPlayers) Legal(state boardgame.ImmutableState, proposer boardgame.PlayerIndex) error
Legal verifies that the GameDelegate's NumSeatedActivePlayers is at least TargetCount.
func (*WaitForEnoughPlayers) ReadSetConfigurer ¶
func (w *WaitForEnoughPlayers) ReadSetConfigurer() boardgame.PropertyReadSetConfigurer
ReadSetConfigurer returns an autp-generated boardgame.PropertyReadSetConfigurer for WaitForEnoughPlayers
func (*WaitForEnoughPlayers) ReadSetter ¶
func (w *WaitForEnoughPlayers) ReadSetter() boardgame.PropertyReadSetter
ReadSetter returns an autp-generated boardgame.PropertyReadSetter for WaitForEnoughPlayers
func (*WaitForEnoughPlayers) Reader ¶
func (w *WaitForEnoughPlayers) Reader() boardgame.PropertyReader
Reader returns an autp-generated boardgame.PropertyReader for WaitForEnoughPlayers
func (*WaitForEnoughPlayers) TargetCount ¶
func (w *WaitForEnoughPlayers) TargetCount(state boardgame.ImmutableState) int
TargetCount returns the value tha twas provided via WithTargetCount. If none was provided, it returns your game delegate's MinNumPlayers, which is nearly always a reasonable default for the minimum number of players for a round.
func (*WaitForEnoughPlayers) ValidConfiguration ¶
func (w *WaitForEnoughPlayers) ValidConfiguration(exampleState boardgame.State) error
ValidConfiguration checks that player states implement interfaces.Seater and interfaces.PlayerInactiver.
Source Files ¶
- apply_until.go
- auto_config.go
- auto_reader.go
- collect_components.go
- count.go
- current_player.go
- deal_components.go
- default.go
- default_component.go
- doc.go
- finish_turn.go
- fixup.go
- group_parallel.go
- group_repeat.go
- group_serial.go
- groups.go
- inactive_player.go
- increment.go
- installers.go
- move_components.go
- no_op.go
- round_robin.go
- seat_player.go
- shuffle_stack.go
- start_phase.go
- with.go
Directories ¶
Path | Synopsis |
---|---|
Package interfaces is a collection of interfaces that your objects can implement to configure how the moves package's base moves operate.
|
Package interfaces is a collection of interfaces that your objects can implement to configure how the moves package's base moves operate. |