using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Security.Cryptography; using System.Text; using System.Threading.Tasks; using WindowsFormsCore.Domain; namespace WindowsFormsCore { public class Lotto { private List numberBack; private List numberDraw; #region Constants const decimal l00 = 0M; const decimal l01 = 10.286M; const decimal l02 = 20.572M; const decimal l03 = 30.858M; const decimal l04 = 41.144M; const decimal l05 = 51.430M; const decimal l06 = 61.716M; const decimal l07 = 72.002M; const decimal l08 = 82.288M; const decimal l09 = 92.574M; const decimal l10 = 102.860M; const decimal l11 = 113.146M; const decimal l12 = 123.432M; const decimal l13 = 133.718M; const decimal l14 = 144.004M; const decimal l15 = 154.290M; const decimal l16 = 164.576M; const decimal l17 = 174.862M; const decimal l18 = 185.148M; const decimal l19 = 195.434M; const decimal l20 = 205.720M; const decimal l21 = 216.006M; const decimal l22 = 226.292M; const decimal l23 = 236.578M; const decimal l24 = 246.864M; const decimal l25 = 257.150M; const decimal l26 = 267.436M; const decimal l27 = 277.722M; const decimal l28 = 288.008M; const decimal l29 = 298.294M; const decimal l30 = 308.580M; const decimal l31 = 318.866M; const decimal l32 = 329.152M; const decimal l33 = 339.432M; const decimal l34 = 349.721M; const decimal l35 = 360.000M; #endregion public Lotto(Random rnd) { InitLottoTables(); Rnd = rnd; } private Random Rnd; public string[] RandomRad() { if (numberDraw.Count < numberBack.Count) { InitLottoTables(); } var numberTable = new string[7]; for (int i = 0; i < 7; i++) { numberTable[i] = DrawNewNumber(); } return numberTable; } private string DrawNewNumber() { var number = RndFix(numberDraw.Min(x => x.PrimeNr), numberDraw.Max(x => x.PrimeNr)); var drawn = numberDraw.Find(n => n.PrimeNr == number).ActLottoNr; numberBack.Find(b => b.ChoseNumber == drawn).Valid = false; var remobj = numberDraw.Find(n => n.PrimeNr == number); numberDraw.Remove(remobj); var newNr = 1; for (int x = 0; x < numberDraw.Count; x++) { numberDraw[x].PrimeNr = newNr++; } return drawn.ToString(); } private int RndFix(int min, int max) { return Rnd.Next(min, max); } private void InitLottoTables() { numberBack = GenerateBaseTable(); numberDraw = GenerateDrawTable(); } private List GenerateBaseTable() { var lottos = new List(); for (int i = 0; i < 35; i++) { lottos.Add(new LottoNum { ChoseNumber = i + 1, Valid = true }); } return lottos; } private List GenerateDrawTable() { var lottos = new List(); for (int i = 0; i < 35; i++) { lottos.Add(new Connect { PrimeNr = i + 1, ActLottoNr = i + 1 }); } return lottos; } public int AntiCircularValue( int actValue) { var output = 0; decimal angleValue = GetNumberAngle(actValue); output = GetNumberByAngle(angleValue + 180M); return output; } public int GetNumberByAngle(decimal angle) { var result = 0; decimal lAngle = angle; while (result <= 0 || result == 99) { result = lAngle switch { < l00 => -1, >= l00 and <= l01 => 1, > l01 and <= l02 => 2, > l02 and <= l03 => 3, > l03 and <= l04 => 4, > l04 and <= l05 => 5, > l05 and <= l06 => 6, > l06 and <= l07 => 7, > l07 and <= l08 => 8, > l08 and <= l09 => 9, > l09 and <= l10 => 10, > l10 and <= l11 => 11, > l11 and <= l12 => 12, > l12 and <= l13 => 13, > l13 and <= l14 => 14, > l14 and <= l15 => 15, > l15 and <= l16 => 16, > l16 and <= l17 => 17, > l17 and <= l18 => 18, > l18 and <= l19 => 19, > l19 and <= l20 => 20, > l20 and <= l21 => 21, > l21 and <= l22 => 22, > l22 and <= l23 => 23, > l23 and <= l24 => 24, > l24 and <= l25 => 25, > l25 and <= l26 => 26, > l26 and <= l27 => 27, > l27 and <= l28 => 28, > l28 and <= l29 => 29, > l29 and <= l30 => 30, > l30 and <= l31 => 31, > l31 and <= l32 => 32, > l32 and <= l33 => 33, > l33 and <= l34 => 34, > l34 and <= l35 => 35, _ => 99 }; if (result == -1) lAngle += 360; if (result == 99) lAngle -= 360; }; return result; } public decimal GetNumberAngle(int LtNumber) { decimal res = 0; double nrSect = 360d / 35d; double angle = 2 + (LtNumber - 1) * nrSect; res = (decimal)angle; return res; } } }