/// <summary> /// lets the dealer what the player has bet /// players can bet as many times are they permit and the bet is added /// to their betlist. /// </summary> /// <param name="key"></param> public void PlayerPlaceBet(Guid key, NumberData betType, decimal betAmount) { foreach (Gambler p in PlayerList) { if (p.PlayerID == key) { p.BetList.Add(betType, betAmount); } } updateAllClientBetData(key); }
/// <summary> /// this function processes each kind of bet the user chooses /// and notifies the dealer that the player has placed a bet. /// </summary> /// <param name="t"></param> private void ProcessBet(string t) { NumberData numData = null; if (txtBet.Text == null || txtBet.Text == string.Empty || Convert.ToDecimal(txtBet.Text) == 0) { throw new Exception("Please input a bet amount!"); } switch (t) { case "Number": if (cmboNumber.SelectedIndex == -1) { throw new Exception("Please select a number to bet on!"); } numData = new NumberData(cmboNumber.SelectedIndex, null, null, null); break; case "Color": if (cmboColor.SelectedIndex == -1) { throw new Exception("Please select a color to bet on!"); } numData = new NumberData(null, cmboColor.SelectedValue.ToString(), null, null); break; case "Range": if (cmboRange.SelectedIndex == -1) { throw new Exception("Please select a range to bet on!"); } numData = new NumberData(null, null, cmboRange.SelectedValue.ToString(), null); break; case "OddEven": if (cmboOddEven.SelectedIndex == -1) { throw new Exception("Please select odd or even to bet on!"); } numData = new NumberData(null, null, null, cmboOddEven.SelectedValue.ToString()); break; default: throw new Exception("Something went horribly wrong!"); } try { decimal bet = Convert.ToDecimal(txtBet.Text); if (bet > Convert.ToDecimal(lblMoney.Content)) { throw new Exception("You don't have that much money!"); } dealer.PlayerPlaceBet(myCallbackKey, numData, bet); lblMoney.Content = Convert.ToDecimal(lblMoney.Content) - bet; } catch (Exception ex) { throw new Exception(ex.Message); } }
public CallbackInfo( NumberData winning, List<Gambler> players) { WinningData = winning; PlayerList = players; }