Example #1
0
 /// <summary>
 /// The RemoveLastChip method is called to remove the last chip placed on the bet.
 /// </summary>
 public void RemoveLastChip()
 {
     try
     {
         if (Chips.Count > 0)
         {
             Chip chip = Chips[Chips.Count - 1];     // Retrieve the last chip.
             BetAmount = BetAmount - chip.Value;     // Update the bet amount.
             OnBetPlaced?.Invoke(-1 * chip.Value);   // Notify that the last chip as been removed (place a negative bet).
             Chips.RemoveAt(Chips.Count - 1);        // Remove the last chip from the bet.
         }
     }
     catch (Exception ex)
     {
         throw new Exception("Bet.RemoveLastChip(): " + ex.ToString());
     }
 }
Example #2
0
        /// <summary>
        /// The PlaceBet method is called to place a bet for the current selected chip.
        /// </summary>
        public void PlaceBet()
        {
            try
            {
                if (PlaceBets && SelectedChip != ChipType.Undefined)
                {
                    BetAmount = BetAmount + Chip.GetChipValue(SelectedChip);

                    // Create a chip at the bet location.
                    Chip chip = null;
                    switch (Bet.SelectedChip)
                    {
                    case ChipType.One:
                        chip = new One(Chips.Count());
                        break;

                    case ChipType.Five:
                        chip = new Five(Chips.Count());
                        break;

                    case ChipType.TwentyFive:
                        chip = new TwentyFive(Chips.Count());
                        break;

                    case ChipType.OneHundred:
                        chip = new OneHundred(Chips.Count());
                        break;

                    case ChipType.FiveHundred:
                        chip = new FiveHundred(Chips.Count());
                        break;

                    case ChipType.OneThousand:
                        chip = new OneThousand(Chips.Count());
                        break;

                    case ChipType.FiveThousand:
                        chip = new FiveThousand(Chips.Count());
                        break;

                    case ChipType.TwentyFiveThousand:
                        chip = new TwentyFiveThousand(Chips.Count());
                        break;

                    case ChipType.OneHundredThousand:
                        chip = new OneHundredThousand(Chips.Count());
                        break;

                    case ChipType.FiveHundredThousand:
                        chip = new FiveHundredThousand(Chips.Count());
                        break;
                    }

                    if (chip != null)
                    {
                        OnBetPlaced?.Invoke(chip.Value);    // Notify that the bet has been placed.
                        Chips.Add(chip);                    // Add the chip to the bet.
                        CombineChips();                     // Combine the chips.
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Bet.PlaceBet(object parameter): " + ex.ToString());
            }
        }