private List <BallStat>[] BuildStats(int maxBallValue, int ballCount, List <Drawing> drawings, DateTime nextDrawDate, int maxSpecialBallValue) { var ballStatList = new List <BallsStats>(); // calculate ball stats for (int ballNbr = 1; ballNbr <= maxBallValue; ballNbr++) { var positionStats = new BallsStats(); for (int pos = 1; pos <= ballCount; pos++) { var ball = CalcBallPositionStats(ballNbr, pos, drawings, nextDrawDate, false); positionStats.Balls.Add(ball); } if (ballNbr <= maxSpecialBallValue) { var ball = CalcBallPositionStats(ballNbr, ballCount + 1, drawings, nextDrawDate, false); positionStats.Balls.Add(ball); } ballStatList.Add(positionStats); } // calculate drawing stats var bs = new List <List <BallStat> >(); for (int i = 0; i < ballCount; i++) { bs.Add(new List <BallStat>()); } bs.Add(new List <BallStat>()); var ballStatsList = bs.ToArray(); foreach (var stat in ballStatList) { foreach (var b in stat.Balls) { if (b.Position == ballCount + 1) { ballStatsList[b.Position - 1].Add(b); } else { if (b.Id >= b.Position && b.Id <= maxBallValue - (ballCount - b.Position)) { ballStatsList[b.Position - 1].Add(b); } } } } return(ballStatsList); }
private BallStat CalcBallPositionStats(int ballNbr, int position, List <Drawing> allDrawings, DateTime nextPickDate, bool dailyDrawing) { var totalDrawings = allDrawings.Count; var positionStats = new BallsStats(); var snglBallDrawings = allDrawings.Where(d => d.Balls.Any(b => b.Seq == position && b.Id == ballNbr)).ToList(); if (snglBallDrawings.Count == 0) { return new BallStat { Position = position, Id = ballNbr, Score = 99999 } } ; else { return(CalcBallScore(ballNbr, position, snglBallDrawings, totalDrawings, nextPickDate, dailyDrawing)); } }