Documentation ¶
Overview ¶
Package acquire manages the flow and status of an acquire game. It acts like a finite state machine (FSM), in which received inputs modify machine state
Index ¶
- Constants
- type Game
- func (g *Game) AreEndConditionsReached() bool
- func (g *Game) Board() interfaces.Board
- func (g *Game) BuyStock(buys map[interfaces.Corporation]int) error
- func (g *Game) ClaimEndGame() *Game
- func (g *Game) Corporations() [7]interfaces.Corporation
- func (g *Game) CurrentPlayer() interfaces.Player
- func (g *Game) FoundCorporation(corp interfaces.Corporation) error
- func (g *Game) GameStateName() string
- func (g *Game) IsCorporationDefunct(corp interfaces.Corporation) bool
- func (g *Game) IsLastRound() bool
- func (g *Game) IsTilePlayable(tl interfaces.Tile) bool
- func (g *Game) PlayTile(tl interfaces.Tile) error
- func (g *Game) Player(playerNumber int) interfaces.Player
- func (g *Game) RemovePlayer(pl interfaces.Player)
- func (g *Game) Round() int
- func (g *Game) SellTrade(sell map[interfaces.Corporation]int, trade map[interfaces.Corporation]int) error
- func (g *Game) TiedCorps() []interfaces.Corporation
- func (g *Game) UntieMerge(acquirer interfaces.Corporation) error
- type Optional
Constants ¶
const ( // Returned when action not allowed at current state ActionNotAllowed = "action_%s_not_allowed_expecting_%s" StockSharesNotBuyable = "stock_shares_not_buyable" NotEnoughStockShares = "not_enough_stock_shares" // Returned when tile temporarily unplayable TileTemporarilyUnplayable = "tile_temporarily_unplayable" // Returned when tile permanently unplayable TilePermanentlyUnplayable = "tile_permanently_unplayable" // Returned when player has not enough cash to buy stock shares NotEnoughCash = "not_enough_cash" TooManyStockSharesToBuy = "too_many_stock_shares_to_buy" // Returned when some corporation names are repeated CorpNamesNotUnique = "corp_names_not_unique" // Returned when corporations classes do not fit rules WrongNumberCorpsClass = "wrong_number_corps_class" // Returned when corporation is already on board and cannot be founded CorporationAlreadyOnBoard = "corporation_already_on_board" // Returned when there must be between 3 and 6 players WrongNumberPlayers = "wrong_number_players" NoCorporationSharesOwned = "no_corporation_shares_owned" NotEnoughCorporationSharesOwned = "not_enough_corporation_shares_owned" // Returned when player does not have tile on hand TileNotOnHand = "tile_not_on_hand" // Returned when corporation is not the acquirer in a merge NotAnAcquirerCorporation = "not_an_acquirer_corporation" // Returned when number of stock shares is not even in a trade TradeAmountNotEven = "trade_amount_not_even" )
Error messages returned by the game
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Game ¶
type Game struct {
// contains filtered or unexported fields
}
Game stores state of game elements and provides methods to control game flow
func (*Game) AreEndConditionsReached ¶
AreEndConditionsReached checks if game end conditions are reached
func (*Game) BuyStock ¶
func (g *Game) BuyStock(buys map[interfaces.Corporation]int) error
BuyStock buys stock from corporations
func (*Game) ClaimEndGame ¶
ClaimEndGame allows the current player to claim end game This can be done at any time. After announcing that the game is over, the player may finish his/her turn.
func (*Game) Corporations ¶
func (g *Game) Corporations() [7]interfaces.Corporation
Corporations returns an array with all seven corporations
func (*Game) CurrentPlayer ¶
func (g *Game) CurrentPlayer() interfaces.Player
CurrentPlayer returns player currently in play
func (*Game) FoundCorporation ¶
func (g *Game) FoundCorporation(corp interfaces.Corporation) error
FoundCorporation founds a new corporation
func (*Game) GameStateName ¶
GameStateName returns game's current state
func (*Game) IsCorporationDefunct ¶
func (g *Game) IsCorporationDefunct(corp interfaces.Corporation) bool
IsCorporationDefunct return true if the passed corporation is in a merge process and will disappear from the board after that merge is complete, false otherwise
func (*Game) IsLastRound ¶
IsLastRound returns if the current round will be the last one or not
func (*Game) IsTilePlayable ¶
func (g *Game) IsTilePlayable(tl interfaces.Tile) bool
IsTilePlayable returns false if the passed tile is either temporary or permanently unplayable, true otherwise
func (*Game) PlayTile ¶
func (g *Game) PlayTile(tl interfaces.Tile) error
PlayTile puts the given tile on board and triggers related actions
func (*Game) Player ¶
func (g *Game) Player(playerNumber int) interfaces.Player
Player returns player with passed number
func (*Game) RemovePlayer ¶
func (g *Game) RemovePlayer(pl interfaces.Player)
RemovePlayer gets the received player and removes him/her from the game because the player has left the game. All player's assets are returned to its respective origin sets. If the removed player was in his/her turn, turn passes to the next player.
func (*Game) SellTrade ¶
func (g *Game) SellTrade(sell map[interfaces.Corporation]int, trade map[interfaces.Corporation]int) error
SellTrade sells and trades stock shares from defunct corporations
func (*Game) TiedCorps ¶
func (g *Game) TiedCorps() []interfaces.Corporation
TiedCorps returns all corporations that are tied in a merge
func (*Game) UntieMerge ¶
func (g *Game) UntieMerge(acquirer interfaces.Corporation) error
UntieMerge resolves a tied merge selecting which corporation will be the acquirer, marking the rest as defunct
type Optional ¶
type Optional struct { Board interfaces.Board Corporations [7]interfaces.Corporation Tileset interfaces.Tileset StateMachine interfaces.StateMachine }
Optional is a struct which stores the fields that are optional when creating a new Game instance with the New() method.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package board holds the struct and related methods that model the game board
|
Package board holds the struct and related methods that model the game board |
Package corporation contains the model Corporation and attahced methods which manages corporations in game
|
Package corporation contains the model Corporation and attahced methods which manages corporations in game |
Package interfaces holds the declaration of all the interfaces used through the Acquire library.
|
Package interfaces holds the declaration of all the interfaces used through the Acquire library. |
Package mocks holds all mock implementations of the interfaces used by the Acquire library
|
Package mocks holds all mock implementations of the interfaces used by the Acquire library |
Package player containst the struct Player and attached methods which manages player status in game.
|
Package player containst the struct Player and attached methods which manages player status in game. |
Package tile contains the struct and related methods which models a tile.
|
Package tile contains the struct and related methods which models a tile. |
Package tileset holds the Tileset struct and related methods
|
Package tileset holds the Tileset struct and related methods |