public CreateAndWriteManager() { _client = ElasticClientManager.CreateClient(); _writer = new ElasticWriter(); _converter = new ElasticClassConverter(); }
public int Setup(GameSetupInfo setup) { var weekDates = SplitIntoWeeklyDates(setup); foreach (var weekDate in weekDates) { var userHandStats = new List <ElasticUserStat>(); Console.WriteLine(""); Console.WriteLine($"{setup.StartDate.Year} - {weekDate.GetIso8601WeekOfYear()} week started..."); ResetPlayersGamesPlayedCounter(); var maxNumberOfGamesToPlay = _random.Next(5, 500); for (int i = 0; i < maxNumberOfGamesToPlay; i++) { var shouldStopEarly = _random.Next(0, 100) > 95; if (shouldStopEarly) { break; } var game = _gameGenerator.Create(weekDate); ResetPlayersHandsPlayedCounter(); var previousPlayersInHand = new List <User>(); for (int j = 0; j < game.MaxNumberOfHands; j++) { var hand = _handGenerator.Create(game, _users, previousPlayersInHand, j); if (hand == null) { break; } _hands++; previousPlayersInHand = hand.Players; //play hand var playersInHand = hand.Players; for (int k = 0; k < 4; k++) { var round = _betGenerator.CreateRound(playersInHand, k, hand, game); playersInHand = round.Bets.Where(b => b.Value > 0).Select(b => b.Player).ToList(); if (playersInHand.Count == 1) { break; } } var winningTemp = _winningsGenerator.Create(hand, playersInHand); userHandStats.AddRange(ConvertToElasticData(hand, winningTemp)); } } var writer = new ElasticWriter(); Console.WriteLine($"Writing week {weekDate.GetIso8601WeekOfYear()}"); writer.WriteAllData(userHandStats); } return(_hands); }