Пример #1
0
        /// <summary>
        /// The CombineChips method is called to clean up the stack of chips.
        /// Collection of smaller value chips are combined into larger value chips.
        /// </summary>
        public void CombineChips()
        {
            Chips.Clear();  // Clear the current stack of chips.

            int quotient  = BetAmount / Chip.GetChipValue(ChipType.FiveHundredThousand);
            int remainder = BetAmount % Chip.GetChipValue(ChipType.FiveHundredThousand);

            if (quotient > 0)
            {
                for (int i = 0; i < quotient; i++)
                {
                    Chips.Add(new FiveHundredThousand(Chips.Count));
                }
            }

            quotient  = remainder / Chip.GetChipValue(ChipType.OneHundredThousand);
            remainder = remainder % Chip.GetChipValue(ChipType.OneHundredThousand);
            if (quotient > 0)
            {
                for (int i = 0; i < quotient; i++)
                {
                    Chips.Add(new OneHundredThousand(Chips.Count));
                }
            }

            quotient  = remainder / Chip.GetChipValue(ChipType.TwentyFiveThousand);
            remainder = remainder % Chip.GetChipValue(ChipType.TwentyFiveThousand);
            if (quotient > 0)
            {
                for (int i = 0; i < quotient; i++)
                {
                    Chips.Add(new TwentyFiveThousand(Chips.Count));
                }
            }

            quotient  = remainder / Chip.GetChipValue(ChipType.FiveThousand);
            remainder = remainder % Chip.GetChipValue(ChipType.FiveThousand);
            if (quotient > 0)
            {
                for (int i = 0; i < quotient; i++)
                {
                    Chips.Add(new FiveThousand(Chips.Count));
                }
            }

            quotient  = remainder / Chip.GetChipValue(ChipType.OneThousand);
            remainder = remainder % Chip.GetChipValue(ChipType.OneThousand);
            if (quotient > 0)
            {
                for (int i = 0; i < quotient; i++)
                {
                    Chips.Add(new OneThousand(Chips.Count));
                }
            }

            quotient  = remainder / Chip.GetChipValue(ChipType.FiveHundred);
            remainder = remainder % Chip.GetChipValue(ChipType.FiveHundred);
            if (quotient > 0)
            {
                for (int i = 0; i < quotient; i++)
                {
                    Chips.Add(new FiveHundred(Chips.Count));
                }
            }

            quotient  = remainder / Chip.GetChipValue(ChipType.OneHundred);
            remainder = remainder % Chip.GetChipValue(ChipType.OneHundred);
            if (quotient > 0)
            {
                for (int i = 0; i < quotient; i++)
                {
                    Chips.Add(new OneHundred(Chips.Count));
                }
            }

            quotient  = remainder / Chip.GetChipValue(ChipType.TwentyFive);
            remainder = remainder % Chip.GetChipValue(ChipType.TwentyFive);
            if (quotient > 0)
            {
                for (int i = 0; i < quotient; i++)
                {
                    Chips.Add(new TwentyFive(Chips.Count));
                }
            }

            quotient  = remainder / Chip.GetChipValue(ChipType.Five);
            remainder = remainder % Chip.GetChipValue(ChipType.Five);
            if (quotient > 0)
            {
                for (int i = 0; i < quotient; i++)
                {
                    Chips.Add(new Five(Chips.Count));
                }
            }

            quotient  = remainder / Chip.GetChipValue(ChipType.One);
            remainder = remainder % Chip.GetChipValue(ChipType.One);
            if (quotient > 0)
            {
                for (int i = 0; i < quotient; i++)
                {
                    Chips.Add(new One(Chips.Count));
                }
            }
        }
Пример #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());
            }
        }