private async Task HandleMessageGauntlet(string searchString, SocketUserMessage message) { var inputs = searchString.ToLower().Split(','); if ((inputs.Count() < 2) || (inputs.Count() > 3)) { await message.Channel.SendMessageAsync($"The gauntlet command expects 3 traits as input; try something like **-d gauntlet borg,resourceful,interrogator** - check **-d help** for details"); } var results = _botHelper.Gauntlet(inputs); if ((results == null) || (results.Results.Count() == 0) || !string.IsNullOrEmpty(results.ErrorMessage)) { await message.Channel.SendMessageAsync($"Sorry, I couldn't run command 'gauntlet {searchString}' ({results.ErrorMessage}); try something like **-d gauntlet borg,resourceful,interrogator** - check **-d help** for details"); } else { StringBuilder sbReply = new StringBuilder(); sbReply.AppendLine($"**Traits: {string.Join(", ", inputs)} ({results.Results.Count()} total)**"); sbReply.AppendLine("_45% or better 4 and 5 star crew:_"); sbReply.AppendLine(string.Join("\n", results.Results.Take(10).Select(entry => (new string('тнР', entry.Crew.max_rarity) + $" {entry.Crew.name} [{string.Join(", ", entry.MatchingTraits)}] - " + FormatCrewStatsWithEmotes(message, entry.Crew, 0, true))))); await message.Channel.SendMessageAsync(sbReply.ToString()); } }
static int PerformTest(Test opts) { if (opts.TestType == 0) { var voyImage = new VoyImage(System.IO.Path.Combine(System.IO.Directory.GetCurrentDirectory(), "..", "..")); VoyImageResult result; if (opts.TestString.StartsWith("http")) { result = voyImage.SearchUrl(opts.TestString); } else { result = voyImage.SearchImage(opts.TestString); } Console.WriteLine(result); } else if (opts.TestType == 1) { var botHelper = new BotHelper("https://datacore.app/", System.IO.Path.Combine(System.IO.Directory.GetCurrentDirectory(), "..", "..", "data")); botHelper.ParseData(); var result = botHelper.BestCrew(opts.TestString, 0); if (result.Count == 0) { Console.WriteLine("Not found"); } else { Console.WriteLine(result[0].name); } } else if (opts.TestType == 2) { var botHelper = new BotHelper("https://datacore.app/", System.IO.Path.Combine(System.IO.Directory.GetCurrentDirectory(), "..", "..", "data")); botHelper.ParseData(); var result = botHelper.Gauntlet(opts.TestString.Split(' ')); if (!string.IsNullOrEmpty(result.ErrorMessage) || result.Results.Count() == 0) { Console.WriteLine("Not found"); } else { Console.WriteLine(string.Join(", ", result.Results.Select(gresult => $"{gresult.Crew.name} [{string.Join(", ", gresult.MatchingTraits)}]"))); } } return(0); }
public void TestBotHelper() { var botHelper = new BotHelper("https://datacore.netlify.com/", Path.Combine(Directory.GetCurrentDirectory(), "../../../../..")); botHelper.ParseData(); Assert.AreNotEqual(0, botHelper.TotalCrew()); var crewResults = botHelper.SearchCrew("data"); Assert.AreNotEqual(0, crewResults.Count); crewResults = botHelper.SearchCrew("skywalker"); Assert.AreEqual(0, crewResults.Count); var itemResults = botHelper.SearchItem("combadge"); Assert.AreNotEqual(0, itemResults.Count); itemResults = botHelper.SearchItem("lightsaber"); Assert.AreEqual(0, itemResults.Count); var dilemmaResults = botHelper.SearchDilemmas("Champion"); Assert.AreNotEqual(0, dilemmaResults.Count); dilemmaResults = botHelper.SearchDilemmas("Jedi"); Assert.AreEqual(0, dilemmaResults.Count); var crew = botHelper.GetCrew("jedi_master"); Assert.AreEqual(null, crew); crew = botHelper.GetCrew("data_detective_crew"); Assert.AreNotEqual(null, crew); Assert.AreEqual("Detective Data", crew.name); Assert.AreNotEqual(null, crew.base_skills.engineering_skill); Assert.AreEqual(null, crew.base_skills.medicine_skill); Assert.IsTrue(crew.skill_data[0].base_skills.engineering_skill.core < crew.skill_data[1].base_skills.engineering_skill.core); Assert.AreNotEqual(0, crew.totalChronCost); var bestCrewResults = botHelper.BestCrew("base cmd", 0); Assert.AreNotEqual(0, bestCrewResults.Count); bestCrewResults = botHelper.BestCrew("gauntlet cmd", 0); Assert.AreNotEqual(0, bestCrewResults.Count); bestCrewResults = botHelper.BestCrew("gauntlet cmd sci", 0); Assert.AreNotEqual(0, bestCrewResults.Count); bestCrewResults = botHelper.BestCrew("voyage cmd", 0); Assert.AreNotEqual(0, bestCrewResults.Count); bestCrewResults = botHelper.BestCrew("voyage cmd sci", 0); Assert.AreNotEqual(0, bestCrewResults.Count); bestCrewResults = botHelper.BestCrew("bases cmd", 0); Assert.AreEqual(null, bestCrewResults); bestCrewResults = botHelper.BestCrew("voyage cmd sci sec", 0); Assert.AreEqual(null, bestCrewResults); var gauntletCrew = botHelper.Gauntlet(new string[] { "borg", "interrogator", "resourceful" }); Assert.AreNotEqual(0, gauntletCrew.Results.Length); gauntletCrew = botHelper.Gauntlet(new string[] { "jedi", "invalid", "bogus" }); Assert.IsFalse(string.IsNullOrEmpty(gauntletCrew.ErrorMessage)); }