Exemplo n.º 1
0
        public static bool BetInRoulette(Bet _bet)
        {
            if (Roulettes.Any(roullete => roullete.id == _bet.id_roullete && roullete.isOpen))
            {
                Bets.Add(_bet);
                if (!Clients.Any(client => client.id_client == _bet.id_client))
                {
                    Clients.Add(new Client {
                        id_client = _bet.id_client
                    });
                }

                Clients.Where(client => client.id_client == _bet.id_client)
                .ToList()
                .ForEach(client =>
                {
                    client.balance -= _bet.amount;
                    client.earnings = 0;
                    client.isWinner = false;
                });

                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 2
0
        public MatchBet PlaceMatchBet(Match match, Player player)
        {
            bool anyParameterIsInvalid = !PlaceMatchBetParametersAreValid(match, player);

            if (anyParameterIsInvalid)
            {
                return(null);
            }

            MatchBet newMatchBet      = MatchBet.Create(this, match, player);
            MatchBet existingMatchBet = FindMatchBet(match);

            bool createdNewMatchBetSuccessfully    = newMatchBet != null;
            bool matchBetForThisMatchAlreadyExists = existingMatchBet != null;

            if (createdNewMatchBetSuccessfully)
            {
                if (matchBetForThisMatchAlreadyExists)
                {
                    Bets.Remove(existingMatchBet);
                    existingMatchBet.MarkForDeletion();
                }

                Bets.Add(newMatchBet);
                MarkAsModified();
            }

            return(newMatchBet);
        }
        /// <summary>
        /// Prompts user for input and Adds to the list of Bets
        /// </summary>
        public void MakeManualBets()
        {
            //TODO: Need Validation of Input implemented

            Console.Write("Please pick a number 1-36, 0 or 00:    ");
            Bets.Add(new Number(Console.ReadLine()));

            Console.Write("Please Enter \"Even\" or \"Odd\":   ");
            Bets.Add(new EvenOdd(Console.ReadLine()));

            Console.Write("Please Enter \"Red\" or \"Black\":   ");
            Bets.Add(new RedBlack(Console.ReadLine()));

            Console.Write("Please Enter \"Low\" or \"High\":   ");
            Bets.Add(new LowHigh(Console.ReadLine()));

            Console.Write("Please Enter Dozen Number  1, 2, or 3:   ");
            Bets.Add(new Dozen(Console.ReadLine()));

            Console.Write("Please Enter Column Number  1, 2, or 3:   ");
            Bets.Add(new Column(Console.ReadLine()));

            Console.Write("Please Enter Row Number  1-12:   ");
            Bets.Add(new Street(Console.ReadLine()));

            Console.Write("Please Enter two consecutive rows i.e  1,2:   ");
            Bets.Add(new SixNumber(Console.ReadLine()));

            Console.Write("Please Enter two consecutive number i.e  11,14:   ");
            Bets.Add(new Split(Console.ReadLine()));

            Console.Write("Please Enter four numbers for a corner i.e  1,2,3,4:   ");
            Bets.Add(new Number(Console.ReadLine()));
        }
Exemplo n.º 4
0
 public void Populate(BetShortInfoModel[] items)
 {
     Bets.Clear();
     foreach (var item in items)
     {
         Bets.Add(item);
     }
 }
Exemplo n.º 5
0
        public void Update()
        {
            IEnumerable <BetDisplayModel> bets = facade.GetAll();

            Bets.Clear();
            foreach (BetDisplayModel bet in bets)
            {
                Bets.Add(bet);
            }
        }
 public void SetStrategy(BaseStrategy Strategy)
 {
     if (Strategy is DoormatBot.Strategies.Labouchere)
     {
         this.Strategy = Strategy as DoormatBot.Strategies.Labouchere;
         Bets.Clear();
         if (this.Strategy != null && this.Strategy.BetList != null)
         {
             foreach (decimal x in this.Strategy?.BetList)
             {
                 Bets.Add(new LabBet {
                     Amount = x
                 });
             }
         }
         if (Bets.Count == 0)
         {
             Bets.Add(new LabBet {
                 Amount = 0.00000001m
             });
             Bets.Add(new LabBet {
                 Amount = 0.00000002m
             });
             Bets.Add(new LabBet {
                 Amount = 0.00000003m
             });
             Bets.Add(new LabBet {
                 Amount = 0.00000004m
             });
             Bets.Add(new LabBet {
                 Amount = 0.00000005m
             });
             Bets.Add(new LabBet {
                 Amount = 0.00000006m
             });
             Bets.Add(new LabBet {
                 Amount = 0.00000005m
             });
             Bets.Add(new LabBet {
                 Amount = 0.00000004m
             });
             Bets.Add(new LabBet {
                 Amount = 0.00000003m
             });
             Bets.Add(new LabBet {
                 Amount = 0.00000002m
             });
             Bets.Add(new LabBet {
                 Amount = 0.00000001m
             });
         }
         OnPropertyChanged(nameof(Bets));
         StartControl.DataContext = Strategy;
     }
 }
Exemplo n.º 7
0
        public delegate int EstimateWin(string bet, int winingNumber); // Using delegate to decouple domain logic to external lib and to test better

        public (Guid spinId, bool won, decimal?wonAmount) MakeBat(MakeBet cmd, EstimateWin estimateWin, int winningNumber, long betAmount, string ipAddress)
        {
            if (betAmount > Balance)
            {
                throw new BadRequestException(Constants.NotEnoughBalanceExceptionText);
            }

            var estWin    = estimateWin(cmd.Bet, winningNumber);
            var won       = estWin > 0;
            var wonAmount = won ? estWin : default(int?);
            var spinId    = Guid.NewGuid();

            Balance = won ? Balance - betAmount + estWin : Balance - betAmount;

            if (Bets == null)
            {
                Bets = new List <UserBet>();
            }

            Bets.Add(new UserBet
            {
                UserId        = Id,
                Bet           = cmd.Bet,
                Amount        = betAmount,
                WonAmount     = wonAmount,
                SpinId        = spinId,
                Won           = won,
                WinningNumber = winningNumber,
                IpAddress     = ipAddress,
                DateCreated   = DateTime.Now
            });

            BetMade = true;

            return(spinId, won, wonAmount);
        }
        /// <summary>
        /// Uses the Random class to get random integers and simulate Bets
        /// </summary>
        public void MakeAutoBets()
        {
            Bin bin = new Bin();

            Random rand = new Random();

            //NUMBER AUTO
            int selection = rand.Next(0, 38);

            Bets.Add(new Number(bin.Numbers[selection]));

            //EVEN ODD AUTO
            selection = rand.Next(0, 38);
            if (selection % 2 == 0)
            {
                Bets.Add(new EvenOdd("Even"));
            }
            else
            {
                Bets.Add(new EvenOdd("Odd"));
            }


            //RED BLACK AUTO
            selection = rand.Next(0, 37);
            if (ConsoleColor.Red == bin.NumberColor[selection.ToString()])
            {
                Bets.Add(new RedBlack("Red"));
            }
            else if (ConsoleColor.Black == bin.NumberColor[selection.ToString()])
            {
                Bets.Add(new RedBlack("Black"));
            }
            else
            {
                Bets.Add(new RedBlack("Green"));
            }

            //LOW HIGH AUTO
            selection = rand.Next(0, 36);
            if (selection > 18)
            {
                Bets.Add(new LowHigh("High"));
            }
            else
            {
                Bets.Add(new LowHigh("Low"));
            }

            //DOZEN AUTO
            selection = rand.Next(1, 3);
            Bets.Add(new Dozen(selection.ToString()));

            //COLUMN AUTO
            selection = rand.Next(1, 3);
            Bets.Add(new Column(selection.ToString()));

            //STREET AUTO
            selection = rand.Next(1, 12);
            Bets.Add(new Street(selection.ToString()));

            //SIX NUMBER AUTO
            selection = rand.Next(1, 11);
            Bets.Add(new SixNumber(selection.ToString() + "," + (selection + 1).ToString()));



            //SPLIT AUTO
            while (true)
            {
                selection = rand.Next(1, 36);
                if (selection % 3 != 0)
                {
                    Bets.Add(new Split(selection.ToString() + "," + (selection + 1).ToString()));
                    break;
                }
            }

            //CORNER
            selection = rand.Next(0, 21);
            Bets.Add(new Corner(bin.Corner[selection]));
        }
Exemplo n.º 9
0
 public void AddBet(Bet bet)
 {
     Bets.Add(bet);
 }
Exemplo n.º 10
0
        public AppSettings(IConfiguration configuration)
        {
            if (Enum.TryParse(configuration["Mode"], out Enums.Modes mode))
            {
                Mode = mode;
            }
            else
            {
                throw new Exception("Failed to load mode - must be a 'Bet', 'Watch', or 'Test'");
            }

            if (decimal.TryParse(configuration["Multiplier"], out var multiplier))
            {
                Multiplier = multiplier;
            }
            else
            {
                throw new Exception("Failed to load multiplier - must be a decimal");
            }

            if (int.TryParse(configuration["MaxNumberOfResets"], out var maxNumberOfResets))
            {
                MaxNumberOfResets = maxNumberOfResets;
            }
            else
            {
                throw new Exception("Failed to load max number of resets - must be a int");
            }

            if (int.TryParse(configuration["MaxNumberOfWinners"], out var maxNumberOfWinners))
            {
                MaxNumberOfWinners = maxNumberOfWinners;
            }
            else
            {
                throw new Exception("Failed to load max number of winners - must be a int");
            }

            if (int.TryParse(configuration["MaxNumberOfWinnersInHowManyRecords"], out var maxNumberOfWinnersInHowManyRecords))
            {
                MaxNumberOfWinnersInHowManyRecords = maxNumberOfWinnersInHowManyRecords;
            }
            else
            {
                throw new Exception("Failed to load max number of winners in how many records - must be a int");
            }

            var bets = configuration.GetSection("Bets").GetChildren().ToArray().Select(x => x.Value).ToArray();

            foreach (var sBet in bets)
            {
                if (int.TryParse(sBet, out var bet))
                {
                    Bets.Add(bet);
                }
                else
                {
                    throw new Exception("Failed to load bets - must be a int array");
                }
            }
        }