コード例 #1
0
        /// <summary>
        /// Spins wheel
        /// </summary>
        /// <returns>Win roulette combination</returns>
        public virtual Tuple <int, Color> SpinWheel()
        {
            int   number = GenerateNumber();
            Color color;

            if (number == 0)
            {
                color = Color.Green;
            }
            else
            {
                color = GenerateColor();
            }

            RouletteEventArgs rouletteEventArgs = new RouletteEventArgs(number, color);

            OnBet(this, rouletteEventArgs);
            switch (color)
            {
            case Color.Black:
                OnBetOnBlack(this, rouletteEventArgs);
                break;

            case Color.Green:
                OnBetOnZero(this, rouletteEventArgs);
                break;

            case Color.Red:
                OnBetOnRed(this, rouletteEventArgs);
                break;
            }

            return(new Tuple <int, Color>(number, color));
        }
コード例 #2
0
 /// <summary>
 /// Event handler to handle current roulette combination
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 public void Bet(object sender, RouletteEventArgs e)
 {
     if (e.Combination == BetCombination)
     {
         Console.WriteLine($"{Name}: Bet {e.Combination.Number}, {e.Combination.Color} won");
     }
     else
     {
         Console.WriteLine($"{Name}: Bet {BetCombination.Number}, {BetCombination.Color} didn't win");
     }
 }
コード例 #3
0
 /// <summary>
 /// Notify subscribers about win of zero bet
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected virtual void OnBetOnZero(object sender, RouletteEventArgs e)
 {
     BetOnZero?.Invoke(this, e);
 }
コード例 #4
0
 /// <summary>
 /// Event handler to handle win of zero bet
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 public void BetOnZero(object sender, RouletteEventArgs e)
 {
     Console.WriteLine($"{Name}: Bet on zero won");
 }
コード例 #5
0
 /// <summary>
 /// Event handler to handle win of black bet
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 public void BetOnBlack(object sender, RouletteEventArgs e)
 {
     Console.WriteLine($"{Name}: Bet on black won");
 }
コード例 #6
0
 /// <summary>
 /// Event handler to handle win of red bet
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 public void BetOnRed(object sender, RouletteEventArgs e)
 {
     Console.WriteLine($"{Name}: Bet on red won");
 }