Пример #1
0
        public void Simulate()
        {
            int theLpz1, theLpz2;

            if (Type == eMatchType.eDoubles)
            {
                theLpz1 = (Players[0].CurrentLivePZ + Players[1].CurrentLivePZ) / 2;
                theLpz2 = (Players[2].CurrentLivePZ + Players[3].CurrentLivePZ) / 2;
            }
            else
            {
                theLpz1 = Players[0].CurrentLivePZ;
                theLpz2 = Players[1].CurrentLivePZ;
            }

            theLpz1 += 25; // Home Court Advantage

            double theWinPercentage1 = 1 / (1 + Math.Pow(10, ((double)theLpz2 - (double)theLpz1) / 150));

            do
            {
                double theRandomNumber = mRandomizer.NextDouble();
                if (theRandomNumber <= theWinPercentage1)
                {
                    SetResults.Add(1);
                }
                else
                {
                    SetResults.Add(-1);
                }
            } while(SetsHome < 3 && SetsAway < 3);
        }
        public void Handle(SetResults command)
        {
            if (command.Results == null)
            {
                return;
            }
            var user = _context.Users.FirstOrDefault(x => x.Email == command.Email);

            command.Results.ToList().ForEach(_ =>
                                             _context.Results.Add(new Result(_.IdLesson, _.Errors, _.Ppm, _.Stars, _.Time, user)));
            _context.SaveChanges();
        }
        private void FillSet()
        {
            _set = new List <CompletedMatchSet>();
            if (string.IsNullOrWhiteSpace(SetResults))
            {
                return;
            }

            foreach (var set in SetResults.Split(new[] { ' ', ',' }, StringSplitOptions.RemoveEmptyEntries))
            {
                var s = set.Split(new[] { ':' }, StringSplitOptions.RemoveEmptyEntries);
                if (s.Length == 2)
                {
                    _set.Add(new CompletedMatchSet(int.Parse(s[0]), int.Parse(s[1])));
                }
            }
        }
Пример #4
0
            private SecureString Generate()
            {
                for (int i = 0; i < Length; i++)
                {
                    GenerateNextCharacter(i, SetResults);
                }

                var incompleteTypes = SetResults.Where(r => r.RequirementDelta < 0);

                while (incompleteTypes.Any())
                {
                    var overCompleteType   = GetNextCharTypeResult(SetResults.Where(r => r.RequirementDelta > 0));
                    var charIndexToReplace = overCompleteType.Indicies.ElementAt(RandomProvider.Next(overCompleteType.Indicies.Count()));
                    overCompleteType.RemoveIndex(charIndexToReplace);

                    GenerateNextCharacter(charIndexToReplace, incompleteTypes, true);
                }

                GeneratedPassword.MakeReadOnly();

                return(GeneratedPassword);
            }
Пример #5
0
 public IActionResult SetResults([FromBody] SetResults results)
 {
     _processor.Send(results);
     return(Ok());
 }