Пример #1
0
 public static void RetrieveData(GamePatch patch, int startingRow, string captionFinalizer, HashSet <string> announcedRanks, bool retrieveTotalMatchCount = false, bool isFinalizerBeforeStats = false)
 {
     RetrieveData(patch, PlatinumPlus, PlatinumPlusManager, startingRow, captionFinalizer, announcedRanks, retrieveTotalMatchCount, isFinalizerBeforeStats);
     RetrieveData(patch, DiamondPlus, DiamondPlusManager, startingRow, captionFinalizer, announcedRanks, retrieveTotalMatchCount, isFinalizerBeforeStats);
     RetrieveData(patch, MasterPlus, MasterPlusManager, startingRow, captionFinalizer, announcedRanks, retrieveTotalMatchCount, isFinalizerBeforeStats);
     RetrieveData(patch, AllRanks, AllRanksManager, startingRow, captionFinalizer, announcedRanks, retrieveTotalMatchCount, isFinalizerBeforeStats);
     Console.WriteLine("Completed retrieval");
 }
Пример #2
0
        private void GetPatches()
        {
            patches = new SortedSet <GamePatch>();
            foreach (var s in Spreadsheet.Sheets)
            {
                var number = GamePatchNumber.Parse(s.Properties.Title);
                var values = Service.Spreadsheets.Values.Get(Spreadsheet.SpreadsheetId, $"{s.Properties.Title}!A5:A").Execute();

                Console.Write($"\n{number}");

                var patch = new GamePatch(number);
                patches.Add(patch);

                if (values.Values == null)
                {
                    continue;
                }

                var firstDay = DateTime.MaxValue;
                var lastDay  = DateTime.MinValue;
                foreach (var d in values.Values)
                {
                    if (d.Count == 0)
                    {
                        continue;
                    }

                    var day = DateTime.ParseExact(d[0].ToString(), "dd/MM/yyyy", CultureInfo.InvariantCulture);
                    if (day < firstDay)
                    {
                        firstDay = day;
                    }
                    if (day > lastDay)
                    {
                        lastDay = day;
                    }
                }
                patch.FirstPatchDay = firstDay;
                patch.LastPatchDay  = lastDay;
                Console.Write($": {firstDay:dd/MM/yyyy} - {lastDay:dd/MM/yyyy}");
            }
            Console.WriteLine();
        }
Пример #3
0
 public void CreateNewPatch(GamePatch patch, bool isOlderPatch = false)
 {
     patches.Add(patch);
     PatchSheetCreationRequested?.Invoke(Spreadsheet.SpreadsheetId, patch, isOlderPatch);
 }
Пример #4
0
        public static void RetrieveData(GamePatch patch, string rank, SheetManager manager, int r, string captionFinalizer, HashSet <string> announcedRanks, bool retrieveTotalMatchCount = false, bool isFinalizerBeforeStats = false)
        {
            Console.WriteLine($"Getting {GetAppropriateRankName(rank)} Ekko {GetOrderedCaption()} from u.gg");
            try
            {
                var record = DataRetriever.GetStatRecord(patch, rank);
                Console.WriteLine($"Recording the stats in the spreadsheet");

                var spreadsheet = manager.Spreadsheet;

                if (!manager.Patches.Contains(patch))
                {
                    manager.CreateNewPatch(patch, true);
                }

                var values = new List <IList <object> >
                {
                    new List <object> {
                        record.Mid.PickRateString, record.OverallBanRateString, record.Mid.WinRateString, $"=C{r + 2} + D{r}"
                    },
                    new List <object> {
                        record.Jungle.PickRateString, null, record.Jungle.WinRateString, null
                    },
                    new List <object> {
                        $"=C{r} + C{r + 1}", null, $"=(C{r} * E{r} + C{r + 1} * E{r + 1}) / C{r + 2}", null
                    },
                };

                var request = Service.Spreadsheets.Values.Update(new ValueRange {
                    Values = values, MajorDimension = "ROWS"
                }, spreadsheet.SpreadsheetId, $"{patch}!C{r}:F{r + 2}");
                request.ValueInputOption = SpreadsheetsResource.ValuesResource.UpdateRequest.ValueInputOptionEnum.USERENTERED;
                request.Execute();

                if (retrieveTotalMatchCount)
                {
                    var matchesValues = new List <IList <object> >
                    {
                        new List <object> {
                            (int)record.Mid.Matches
                        },
                        new List <object> {
                            (int)record.Jungle.Matches
                        },
                        new List <object> {
                            $"=G{r} + G{r + 1}"
                        },
                    };

                    request = Service.Spreadsheets.Values.Update(new ValueRange {
                        Values = matchesValues, MajorDimension = "ROWS"
                    }, spreadsheet.SpreadsheetId, $"{patch}!G{r}:G{r + 2}");
                    request.ValueInputOption = SpreadsheetsResource.ValuesResource.UpdateRequest.ValueInputOptionEnum.USERENTERED;
                    request.Execute();
                }

                WriteLineWithColor("Successfully retrieved information", ConsoleColor.Green);

                if (announcedRanks.Contains(rank))
                {
                    SendDiscordMessage(record, $"{GetAppropriateRankName(rank)} Ekko {GetOrderedCaption()}", retrieveTotalMatchCount);
                }

                WriteLineWithColor("", ConsoleColor.Gray);
            }
            catch (Exception e)
            {
                WriteLineWithColor($"Failed to retrieve patch {patch} information", ConsoleColor.Red);
                WriteLineWithColor($"Exception: {e.Message}", ConsoleColor.Red);
                WriteLineWithColor("", ConsoleColor.Gray);
            }

            string GetOrderedCaption() => isFinalizerBeforeStats ? $"{captionFinalizer} stats" : $"stats {captionFinalizer}";
        }
Пример #5
0
 private static string GetURL(GamePatch patch, string rank, string role = "jungle") => $"{BaseURL}?rank={rank}&role={role}&patch={patch.ToURLString()}";
Пример #6
0
 private static string GetHTML(GamePatch patch, string rank, string role = "jungle") => GetHTML(GetURL(patch, rank, role));
Пример #7
0
 public static StatRecord GetStatRecord(GamePatch patch, string rank) => new StatRecord(GetRoleStatRecord(patch, rank, Middle), GetRoleStatRecord(patch, rank, Jungle), GetBanRate(patch, rank));
Пример #8
0
 public static float GetBanRate(GamePatch patch, string rank) => GetBanRateFromHTMLCode(GetHTML(patch, rank));
Пример #9
0
 public static RoleStatRecord GetRoleStatRecord(GamePatch patch, string rank, string role) => GetRoleStatRecordFromHTMLCode(GetHTML(patch, rank, role));