private static void Export(Toon dataToon) { var msgResult = MessageBox.Show(@"Would you like to enter a description for people to see?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (msgResult == DialogResult.Yes) { InputBoxResult result = InputBox.Show("Enter a description for your build.", "Build Description", "Enter your description here", InputBox.InputBoxIcon.Info, inputBox_Validating); dataToon.Description = result.OK ? result.Text : "None"; dataToon.SubmittedBy = MidsContext.GetCryptedValue("BotUser", "username"); dataToon.SubmittedOn = DateTime.Now.ToShortDateString(); MbLogin(); BuildSubmit(dataToon); } else { dataToon.Description = "None"; dataToon.SubmittedBy = MidsContext.GetCryptedValue("BotUser", "username"); dataToon.SubmittedOn = $"{DateTime.Now.ToShortDateString()} {DateTime.Now.ToShortTimeString()}"; MbLogin(); BuildSubmit(dataToon); } }
private static void BuildSubmit(Toon dataToon) { var client = new RestClient(BOT_API_ENDPOINT); var request = new RestRequest("v2/builds/submit", Method.POST); // request.AddHeader("Content-type", "application/json"); request.AddHeader("access_token", MidsContext.GetCryptedValue("BotUser", "access_token")); request.AddJsonBody(new { MemberId = dataToon.MemberId, MemberName = dataToon.MemberName, Server = dataToon.Server, ServerChannel = dataToon.ServerChannel, AppName = dataToon.AppName, AppVersion = dataToon.AppVersion, Name = dataToon.Name, Level = dataToon.Level, Archetype = dataToon.Archetype, Primary = dataToon.Primary, Secondary = dataToon.Secondary, Stats = dataToon.Stats, DataLink = dataToon.DataLink, Description = dataToon.Description, SubmittedBy = dataToon.SubmittedBy, SubmittedOn = dataToon.SubmittedOn }); var response = client.Execute(request); if (response.Content == "Build submitted successfully") { Form.ActiveForm?.Close(); } else { MessageBox.Show($"Error Code: {response.StatusCode}\r\nResponse: {response.Content}\r\nRecommendation: Please reach out to the RebornTeam to resolve this issue.", @"MidsBot Error Response"); } }
public static void GatherData(Dictionary <string, List <string> > selectedStats, string server, string channel) { var data = new Toon { MemberId = MidsContext.GetCryptedValue("User", "id"), MemberName = MidsContext.GetCryptedValue("User", "username"), Server = server, ServerChannel = channel, AppName = MidsContext.AppName, AppVersion = $"{MidsContext.AppVersion}", Name = MidsContext.Character.Name, Level = ToonLevel(), Archetype = MidsContext.Character.Archetype.DisplayName, Primary = MidsContext.Character.Powersets[0].DisplayName, Secondary = MidsContext.Character.Powersets[1].DisplayName, Stats = new Dictionary <string, string>(), DataLink = $"[Click Here to Download]({ShrinkTheDatalink(MidsCharacterFileFormat.MxDBuildSaveHyperlink(false, true))})" }; var gatherData = new Dictionary <string, Dictionary <string, string> >(); var totalStat = MidsContext.Character.Totals; var displayStat = MidsContext.Character.DisplayStats; var statDictionary = new Dictionary <string, string>(); var damTypes = Enum.GetNames(Enums.eDamage.None.GetType()); #region DefenseStats for (var index = 0; index < totalStat.Def.Length; index++) { var convMath = totalStat.Def[index] * 100f; if (!(convMath > 0)) { continue; } var stat = $"{Convert.ToDecimal(convMath):0.##}%"; statDictionary.Add(damTypes[index], stat); } gatherData.Add("Defense", statDictionary); statDictionary = new Dictionary <string, string>(); #endregion #region ResistanceStats for (var index = 0; index < totalStat.Res.Length; index++) { var convMath = totalStat.Res[index] * 100f; if (!(convMath > 0)) { continue; } var stat = $"{Convert.ToDecimal(convMath):0.##}%"; statDictionary.Add(damTypes[index], stat); } gatherData.Add("Resistance", statDictionary); statDictionary = new Dictionary <string, string>(); #endregion var acc = $"{Convert.ToDecimal(totalStat.BuffAcc * 100f):0.##}%"; statDictionary = new Dictionary <string, string> { { "Accuracy", acc } }; gatherData.Add("Accuracy", statDictionary); var dmg = $"{Convert.ToDecimal(totalStat.BuffDam * 100f):0.##}%"; statDictionary = new Dictionary <string, string> { { "Damage", dmg } }; gatherData.Add("Damage", statDictionary); var endRdx = $"{Convert.ToDecimal(totalStat.BuffEndRdx * 100f):0.##}%"; statDictionary = new Dictionary <string, string> { { "Endurance Reduction", endRdx } }; gatherData.Add("Endurance Reduction", statDictionary); var endMax = $"{Convert.ToDecimal(totalStat.EndMax + 100f):0.##}%"; statDictionary = new Dictionary <string, string> { { "Endurance Maximum", endMax } }; gatherData.Add("Endurance Maximum", statDictionary); var endRec = $"{displayStat.EnduranceRecoveryPercentage(false):###0}% ({Convert.ToDecimal(displayStat.EnduranceRecoveryNumeric):0.##}/s)"; statDictionary = new Dictionary <string, string> { { "Endurance Recovery", endRec } }; gatherData.Add("Endurance Recovery", statDictionary); var endUse = $"{Convert.ToDecimal(displayStat.EnduranceUsage):0.##}/s"; statDictionary = new Dictionary <string, string> { { "Endurance Usage", endUse } }; gatherData.Add("Endurance Usage", statDictionary); var elusive = $"{Convert.ToDecimal(totalStat.Elusivity * 100):0.##}%"; statDictionary = new Dictionary <string, string> { { "Elusivity", elusive } }; gatherData.Add("Elusivity", statDictionary); var toHit = $"{Convert.ToDecimal(totalStat.BuffToHit * 100):0.##}%"; statDictionary = new Dictionary <string, string> { { "ToHit", toHit } }; gatherData.Add("ToHit", statDictionary); var globalRech = $"{Convert.ToDecimal(totalStat.BuffHaste * 100):0.##}%"; statDictionary = new Dictionary <string, string> { { "Haste", globalRech } }; gatherData.Add("Haste", statDictionary); var maxHP = $"{Convert.ToDecimal(displayStat.HealthHitpointsPercentage):0.##}% ({Convert.ToDecimal(displayStat.HealthHitpointsNumeric(false)):0.##}HP)"; statDictionary = new Dictionary <string, string> { { "Hitpoints Maximum", maxHP } }; gatherData.Add("Hitpoints Maximum", statDictionary); var regenHP = $"{Convert.ToDecimal(displayStat.HealthRegenPercent(false)):0.##}% ({Convert.ToDecimal(displayStat.HealthRegenHPPerSec):0.##}/s)"; statDictionary = new Dictionary <string, string> { { "Hitpoints Regeneration", regenHP } }; gatherData.Add("Hitpoints Regeneration", statDictionary); foreach (var kvp in selectedStats) { switch (kvp.Key) { case "Defense": foreach (var stat in gatherData[kvp.Key]) { foreach (var item in kvp.Value) { if (item == stat.Key) { data.Stats.Add($"{stat.Key} {kvp.Key}", stat.Value); } } } break; case "Resistance": foreach (var stat in gatherData[kvp.Key]) { foreach (var item in kvp.Value) { if (item == stat.Key) { data.Stats.Add($"{stat.Key} {kvp.Key}", stat.Value); } } } break; case "Misc": foreach (var item in kvp.Value) { foreach (var stat in gatherData[item]) { if (item == stat.Key) { data.Stats.Add(stat.Key, stat.Value); } } } break; } } Export(data); }