public static void ValidateIPOBid(GameState state, GameActionValidator validator, StockRound round, PlayerState actingPlayerState, Location selection, int bid) { var currentAuction = round.CurrentAuction; if (currentAuction != null) { validator.Validate(selection == currentAuction.Selection, $"Bid on '{selection}' is not legal - there is already an auction for '{currentAuction.Selection}' in progress."); validator.Validate(bid > currentAuction.HighBid, $"Bid of '{bid}' is not legal - the current high bid is '{currentAuction.HighBid}'."); } validator.ValidateMultipleOf(5, bid, $"Bid of '{bid}' is not legal - must be a multiple of 5."); validator.Validate(bid <= MaximumIPOBid, $"Bid of '{bid}' is not legal - the maximum IPO bid is $400."); validator.Validate(bid <= actingPlayerState.Money, $"Bid of '{bid}' is not legal - player '{actingPlayerState.Player}' has only {actingPlayerState.Money} cash available."); }
public static GameState MakeIPOBid(GameState gameState, StockRound round, PlayerState biddingPlayerState, Location 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 == MaximumIPOBid) { // Maximum bid was made, auction terminates return CompleteAuction(gameState, round); } return gameState.WithRound(round); }
private static GameState CompleteAuction(GameState gameState, StockRound round) { // Go into a state that requires the player to specify funding throw new NotImplementedException(); }