public void SetBet(int amount) { if (amount < 0 || amount > ChipsAmount) { Exception e = new IllegalBetException("bet must be greater then zero and less - equal to player chips"); Logger.Log(Severity.Error, e.Message); throw e; } CurrentBet += amount; ChipsAmount -= amount; PreviousRaise = amount; BetInThisRound = true; Logger.Log(Severity.Action, "User: "******" player: " + Name + " set Bets= " + CurrentBet + " current Chips Amount=" + ChipsAmount); }
public Room SetBet(IPlayer p, int bet, bool smallBlind) { var maxCips = 0; foreach (var p1 in Players) { if (p1.CurrentBet > maxCips) { maxCips = p1.CurrentBet; } } if (p == null) { var e = new Exception("Player can't be null"); Logger.Log(Severity.Exception, e.Message); throw e; } if (!Players.Contains(p)) { var e = new Exception("Invalid player"); Logger.Log(Severity.Exception, e.Message); throw e; } if (bet + p.CurrentBet < maxCips) { var e = new Exception("Can not bet lower than the higest bet"); Logger.Log(Severity.Exception, e.Message); throw e; } if (bet < GamePreferences.MinBet && !smallBlind) { var e = new IllegalBetException("Can not bet less than min bet"); Logger.Log(Severity.Error, e.Message); throw e; } if (!smallBlind && GamePreferences.GameType == Gametype.NoLimit && p.BetInThisRound && p.PreviousRaise > bet) // no limit mode { var e = new IllegalBetException("Can not bet less than previous raise in no limit mode"); Logger.Log(Severity.Error, e.Message); throw e; } if (!smallBlind && GamePreferences.GameType == Gametype.Limit) // limit mode { if (GameStatus == GameStatus.PreFlop || GameStatus == GameStatus.Flop) //pre flop & flop { if (bet != GamePreferences.MinBet) { var e = new IllegalBetException("In pre flop/flop in limit mode bet must be equal to " + GamePreferences.MinBet); Logger.Log(Severity.Error, e.Message); throw e; } } if (GameStatus == GameStatus.Turn || GameStatus == GameStatus.River) //turn & river { if (bet != GamePreferences.MinBet * 2) { var e = new IllegalBetException( "In pre turn/river in limit mode bet must be equal to " + GamePreferences.MinBet * 2); Logger.Log(Severity.Error, e.Message); throw e; } } } if (!smallBlind && GamePreferences.GameType == Gametype.PotLimit) // limit pot { var pot = 0; foreach (var p1 in Players) { pot += p1.CurrentBet; } if (bet > pot) { var e = new IllegalBetException("In limit pot mode bet must lower than " + pot); Logger.Log(Severity.Error, e.Message); throw e; } } Pot += bet; p.SetBet(bet); NextPlayer(); return(this); }