static int PerformTestVoyage(TestVoyage opts) { var inputs = opts.TestString.Trim().Split(' '); if ((inputs.Count() < 6) || (inputs.Count() > 7)) { Console.WriteLine($"Expected format is <primary> <secondary> <any skill> <any skill> <any skill> <any skill> [<antimmatter=2500>]"); return(1); } if (int.TryParse(inputs[0], out int primary) && int.TryParse(inputs[1], out int secondary) && int.TryParse(inputs[2], out int skill3) && int.TryParse(inputs[3], out int skill4) && int.TryParse(inputs[4], out int skill5) && int.TryParse(inputs[5], out int skill6)) { int antimatter = 2500; if (inputs.Count() == 7) { int.TryParse(inputs[5], out antimatter); } Console.WriteLine(VoyageCalculator.CalculateVoyage(primary, secondary, skill3, skill4, skill5, skill6, antimatter)); } return(0); }
public void TestVoyageCalculator() { var results = VoyageCalculator.CalculateVoyage(10000, 10000, 3000, 3000, 3000, 3000, 2500); Assert.AreNotEqual(0, results.Count); Assert.IsTrue(results[0].result > 8); }
private async Task HandleMessageVoytime(string searchString, SocketUserMessage message, bool fromImage) { var inputs = searchString.Trim().Split(' '); if ((inputs.Count() < 6) || (inputs.Count() > 7)) { await message.Channel.SendMessageAsync($"Expected format is <primary> <secondary> <any skill> <any skill> <any skill> <any skill> [<antimmatter=2500>]"); } if (int.TryParse(inputs[0], out int primary) && int.TryParse(inputs[1], out int secondary) && int.TryParse(inputs[2], out int skill3) && int.TryParse(inputs[3], out int skill4) && int.TryParse(inputs[4], out int skill5) && int.TryParse(inputs[5], out int skill6)) { int antimatter = 2500; if (inputs.Count() == 7) { int.TryParse(inputs[6], out antimatter); } var extendResults = VoyageCalculator.CalculateVoyage(primary, secondary, skill3, skill4, skill5, skill6, antimatter); string reply; if (fromImage) { reply = $@"Did I get the numbers wrong? I'm still learning, please let @TemporalAgent7 know. Double-check the values, re-run the command with `-d voytime {primary} {secondary} {skill3} {skill4} {skill5} {skill6} {antimatter}` if it needs corrections. *If you're on a laptop / desktop, try the online Voyage tool at {_datacoreURL}voyage for crew recommendations and more.*"; } else { reply = $"*If you're on a laptop / desktop, try the online Voyage tool at {_datacoreURL}voyage for crew recommendations and more.*"; } reply = $@"Estimated voyage length of {TimeFormat(extendResults[0].result)} {extendResults[0].dilChance}% chance to reach the {extendResults[0].lastDil}hr dilemma; refill with {extendResults[1].refillCostResult} dil for a {extendResults[1].dilChance}% chance to reach the {extendResults[1].lastDil}hr dilemma. {reply}"; await message.Channel.SendMessageAsync(reply); } else { await message.Channel.SendMessageAsync($"Expected format is <primary> <secondary> <any skill> <any skill> <any skill> <any skill> [<antimmatter=2500>], with all the parameters being numbers"); } }