/// <summary> Show an estimated countdown to a region's next update </summary> public async Task Run() { var regions = await RepoRegionDump.Dump(Shared.UserAgent, Shared.UserTags).Regions(true); var targetIndex = -1; // Get target region from argument if it was provided if (argument != null) { targetIndex = regions.FindIndex(r => r.Name.ToLower() == argument.ToLower()); } // Get target region from user (ask again if given target doesn't exist) while (targetIndex < 0) { UIConsole.Show("\nTarget Region: "); var t = UIConsole.GetInput(); t = ResolveRegionName(t); if (t == "") { return; } targetIndex = regions.FindIndex(r => r.Name.ToLower() == t.ToLower()); if (targetIndex == -1) { UIConsole.Show("Region name not found.\n"); } } timer = new Kronos.Commands.Timer(regions[targetIndex].Name); #pragma warning disable CS4014 timer.Run(Shared.UserAgent, Shared.UserTags, true); #pragma warning restore CS4014 // Show timer header UIConsole.Show("Press [Q] to quit Timer.\n\n"); UIConsole.Show($"{" Time".PadRight(9, ' ')} | {"Trigger".PadRight(7, ' ')} | Variance \n"); UIConsole.Show($"{"".PadRight(10, '-')} {"".PadRight(9, '-')} {"".PadRight(12, '-')}\n"); // Display the timer asynchronously so that it counts down consistently. await ShowUpdateTimer(); // Tell timer to stop, if still running (in case user interrupted) timer.Stop(); UIConsole.Show("\n\n"); }
/// <summary> Generate a sheet with update times and information for all regions </summary> public async Task Run(string userAgent, Dictionary <string, string> userTags, bool interactiveLog = false) { dump = RepoRegionDump.Dump(userAgent, userTags); var regions = await dump.Regions(); if (interactiveLog) { Console.Write("Creating update sheet... "); } await XlsxSheet(regions); if (interactiveLog) { Console.Write("[done].\n"); } }
/// <summary> Show an estimated countdown to a region's next update </summary> public async Task Run(string userAgent, Dictionary <string, string> userTags, bool interactiveLog = false) { dump = RepoRegionDump.Dump(userAgent, userTags); api = RepoApi.Api(userAgent); var regions = await dump.Regions(interactiveLog); var targetIndex = -1; // Get index of target region in list from dump targetIndex = regions.FindIndex(r => string.Equals(r.Name, targetRegion, StringComparison.InvariantCultureIgnoreCase)); if (targetIndex < 0) { throw new Exception("Target region not found"); } target = regions[targetIndex]; // A boolean indicating if the next update is major (true) or minor (false) nextUpdateIsMajor = TimeUtil.UnixLastMajorStart() < TimeUtil.UnixLastMinorStart(); // Length of the last update in seconds var lastUpdateTook = nextUpdateIsMajor ? await dump.MajorTook() : await dump.MinorTook(); // Select the most appropriate triggers for the target, given the length of the last update await Triggers(targetIndex, regions, lastUpdateTook); // For each trigger, an average "seconds-per-nation" value is calculated and appended to this list. As the // update goes faster or slower, these averages will change in between triggers. This can then be used // to determine variance (unpredictability of the update), which the user can use to better determine how // much risk they can take. secondsPerNation = new List <double> { // The first seconds-per-nation value is taken from the previous update nextUpdateIsMajor?await dump.MajorTick() : await dump.MinorTick() }; // Watch the triggers and target to adjust seconds-per-nation and exit when target updates await WatchTriggers(); }
/// <summary> Generate a report of likely military operations during the last (major or minor) update </summary> public async Task Run(string userAgent, Dictionary <string, string> userTags, bool interactiveLog = false) { Console.Write("Compiling operations report... \n"); api = RepoApi.Api(userAgent); regions = await RepoRegionDump.Dump(userAgent, userTags).Regions(); // Start and end of last (major or minor) update var updateStart = StartOfLastUpdate(); var updateEnd = await api.LastUpdateFor(regions.Last().Name); // Get happenings var delegateChangeHappenings = await api.DelegateChangesFrom(updateStart, updateEnd); // Parse each happening to the DelegacyChange DTO var delegacyChanges = DelegacyChanges(delegateChangeHappenings); // Filter out the suspicious changes from among the (supposedly) legitimate changes var ops = await FilterOps(delegacyChanges, updateEnd - 43200, userTags, interactiveLog); if (interactiveLog) { Console.Write("Saving to report... "); } // Generate report ops = ops.OrderBy(o => o.ChangeTimeStamp).ToList(); var report = Report(ops); // Save var date = TimeUtil.DateForPath(); Directory.CreateDirectory(date); await File.WriteAllTextAsync($"{date}/Kronos-Ops_{date}.md", report); if (interactiveLog) { Console.Write("[done].\n"); } }