예제 #1
0
        /// <summary>
        /// Default constructor.
        /// </summary>
        public RoulettePlayer() : base()
        {
            // Cash/bets.
            _totalCash = Constants.InitialCashDollars;

            // Chips.
            _selectedChip           = ChipType.Undefined;
            OneChip                 = new One();
            FiveChip                = new Five();
            TwentyFiveChip          = new TwentyFive();
            OneHundredChip          = new OneHundred();
            FiveHundredChip         = new FiveHundred();
            OneThousandChip         = new OneThousand();
            FiveThousandChip        = new FiveThousand();
            TwentyFiveThousandChip  = new TwentyFiveThousand();
            OneHundredThousandChip  = new OneHundredThousand();
            FiveHundredThousandChip = new FiveHundredThousand();

            // Commands.
            ClearBetsCommand = new DelegateCommand(ClearBets).ObservesCanExecute(() => PlaceBets);
        }
예제 #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());
            }
        }