public static GameState MakeBid(GameState gameState, PrivateAuctionRound round, PlayerState biddingPlayerState, PrivateCompany selection, int bid) { if (round.CurrentAuction == null) { // No auction is in progress so start a new auction for the selected private round = round.StartAuction(biddingPlayerState.Player, selection, bid); } else { // Apply the new bid to the current auction var newAuction = round.CurrentAuction.MakeBid(selection, biddingPlayerState.Player, bid); round = round.Update(auction: newAuction, activePlayer: newAuction.GetNextPlayer()); } if (bid == selection.Value) { // Maximum bid was made, auction terminates return CompleteAuction(gameState, round); } return gameState.WithRound(round); }
public static GameState Pass(GameState gameState, PrivateAuctionRound round, Player passingPlayer) { if (round.CurrentAuction != null) { var newAuction = round.CurrentAuction.Pass(passingPlayer); if (newAuction.IsComplete) { return CompleteAuction(gameState, round); } // auction continues round = round.Update(auction: newAuction, activePlayer: newAuction.GetNextPlayer()); return gameState.WithRound(round); } else if (round.ActivePlayer == round.LastToAct) { // Exit the auction round early as everyone passed var priorityDeal = round.Players.GetPlayerAfter(round.LastToAct); var newRound = StockRound.StartOfRound(round.Players, 1, priorityDeal); return new GameState(gameState.Game, newRound, priorityDeal, gameState.PlayerStates, gameState.CompanyStates); } else { // player elects not to put anything up for auction var newRound = round.Update( activePlayer: gameState.Game.Players.GetPlayerAfter(passingPlayer)); return gameState.WithRound(newRound); } }