コード例 #1
0
 public string placed_bets(Gamblers bettor)
 {
     money = bettor;
     if (Amount > 0)
     {
         return($@"{money.PlayerName} places a bet ${Amount} on Racer {Cycle}");
     }
     return($@"{money.PlayerName} neet to place a bet yet");
 }
コード例 #2
0
ファイル: Game.cs プロジェクト: devedse/RaceForm
 public void addGambler(string naam, int cash)
 {
     if (naam != null && cash > Amount)         //Als een naam bestaat en de cash minder dan de (minimale bet) is.
     {
         Gamblers.Add(new Gambler(naam, cash)); //En geef een naam op met hoeveel cash hij/zij heef
     }
     else
     {
         throw new Exception("There is no gambler");
     }
 }
コード例 #3
0
 /// <summary>
 /// Добавляет игрока
 /// </summary>
 /// <param name="_gambler"></param>
 /// <returns></returns>
 public static bool AddGambler(Gambler _gambler)
 {
     try
     {
         Gamblers.Add(_gambler);//добавляем игрока в коллекцию
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
コード例 #4
0
ファイル: Game.cs プロジェクト: devedse/RaceConsoleGame
        public void AddGambler()
        {
            Console.WriteLine("What's your name?");
            var name = Console.ReadLine();

            Console.WriteLine($"\n{name}, how much money do you have?");
            int cash;

            while (!int.TryParse(Console.ReadLine(), out cash))
            {
                Console.WriteLine("\nI was asking about money, not about some weird stuff.");
            }

            Console.WriteLine($"\nYour total cash is {cash}");
            Gamblers.Add(new Gambler(name, cash));
            Console.WriteLine($"{name} is now added to the game");
        }
コード例 #5
0
 /// 赌徒入局
 public void AddGambler(BasicUser gambler, float money, GambleChoose choose)
 {
     Gamblers.Add(new Gambler(gambler.UserID, choose, money, gambler.ChangeMoney));
     gambler.ChangeMoney(-money);
     GamblingMoney += money;
 }
コード例 #6
0
        /// <summary>
        /// Метод устанваливает ставки
        /// </summary>
        /// <param name="col"></param>
        public static void CalculateGame(IEnumerable <Setter> col)
        {
            Bets = new List <Bet>();
            foreach (var item in col)
            {
                var g = Gamblers.Find(s => s.Number == item.Gambler); //Выбираем игрока
                var b = Bugs.Find(s => s.Number == item.Bug);         //ВЫбираем участника

                var row = new Bet(b, g, item.Bet);                    //создаем ставку
                Bets.Add(row);                                        //добавляем ставку
            }

            //Генерируем случайные числа для каждого участника
            foreach (var item in Bugs)
            {
                item.RandomPosition();
            }

            //Определяем побудителей
            //-------------- первое место -----------------
            var Positions = Bugs.OrderByDescending(s => s.Position).Select(s => s.Position).Distinct().ToList();//Отсортировали по убыванию взяли тока уникальные значения
            var bugs      = Bugs.Where(s => s.Position == Positions[0]);

            var res = "";

            if (bugs.Count() > 1)
            {
                res = bugs.Aggregate("В забеге победили участники с номерами ", (current, item) => current + " " + item.Number);
            }
            else
            {
                res = "В забеге победил участник с номером " + bugs.First().Number;
            }
            ResultGames.Add(res + "\n");              //добавили в историю
            var summ       = Bets.Sum(s => s.Amount); //сумма всех ставок
            var first      = (summ / 2) / bugs.Count();
            var totalFirst = (summ / 2);

            if (bugs.Count() > 1)
            {
                res = "1-е место. Выйгрышь составил " + first.ToString("F2") + ". Количество победителей: " + bugs.Count();
            }
            else
            {
                res = "1-е место. Выйгрышь составил " + first.ToString("F2") + ". Количество победителей: 1";
            }
            ResultGames.Add(res + "\n");//добавили в историю

            //------------- второе место -----------------

            bugs = Bugs.Where(s => s.Position == Positions[1]);
            summ = summ - totalFirst;//сумма всех ставок
            var two      = (summ * 0.75) / bugs.Count();
            var totalTwo = (summ * 0.75);

            if (bugs.Count() > 1)
            {
                res = "2-е место. Выйгрышь составил " + two.ToString("F2") + ". Количество победителей: " + bugs.Count();
            }
            else
            {
                res = "2-е место. Выйгрышь составил " + two.ToString("F2") + ". Количество победителей: 1";
            }
            ResultGames.Add(res + "\n");//добавили в историю


            //-----------------третье место--------------
            bugs = Bugs.Where(s => s.Position == Positions[1]);
            summ = summ - (float)totalTwo;//сумма всех ставок
            var free = (summ) / bugs.Count();

            if (bugs.Count() > 1)
            {
                res = "3-е место. Выйгрышь составил " + free.ToString("F2") + ". Количество победителей: " + bugs.Count();
            }
            else
            {
                res = "3-е место. Выйгрышь составил " + free.ToString("F2") + ". Количество победителей: 1";
            }
            ResultGames.Add(res + "\n");//добавили в историю
        }