private void ibExport_ButtonClicked() { MidsContext.Config.ExportScheme = csList.SelectedIndex; MidsContext.Config.ExportTarget = lstCodes.SelectedIndex; MidsContext.Config.DisableExportHex = false; var config = MidsContext.Config; config.I9.DisableExportDataChunk = !chkDataChunk.Checked; config.I9.ExportIOLevels = !chkNoIOLevel.Checked; config.I9.ExportStripSetNames = chkNoSetName.Checked; config.I9.ExportStripEnh = chkNoEnh.Checked; MidsContext.Config.ExportBonusTotals = chkBonusList.Checked; MidsContext.Config.ExportBonusList = chkBreakdown.Checked; MidsContext.Config.ExportChunkOnly = chkChunkOnly.Checked; Exporter = new clsOutput(); var str1 = ""; //this creates the data link var iDataLink = MidsCharacterFileFormat.MxDBuildSaveHyperlink(!Exporter.HTML); if (!chkChunkOnly.Checked) { str1 = Exporter.Build(iDataLink); } var str2 = ExportConfig.FormatCodes.FillCode( MidsContext.Config.Export.FormatCode[MidsContext.Config.ExportTarget].SizeOn, "5"); var sizeOff = MidsContext.Config.Export.FormatCode[MidsContext.Config.ExportTarget].SizeOff; if (!chkChunkOnly.Checked) { str1 += "\r\n\r\n"; } if ((iDataLink == "") | chkAlwaysDataChunk.Checked | chkChunkOnly.Checked && chkDataChunk.Checked | chkAlwaysDataChunk.Checked | chkChunkOnly.Checked) { str1 = str1 + str2 + MidsCharacterFileFormat.MxDBuildSaveString(false, true) + sizeOff; } Clipboard.SetDataObject(str1, true); MessageBox.Show("The build data has been placed on the clipboard and is ready to paste into a forum post. If your forum allows you to disable emoticons/smileys in your post, you should do so.", "Export Done", MessageBoxButtons.OK, MessageBoxIcon.Information); Hide(); }
void ibExport_ButtonClicked() { MidsContext.Config.ExportScheme = this.csList.SelectedIndex; MidsContext.Config.ExportTarget = this.lstCodes.SelectedIndex; MidsContext.Config.ExportHex = true; ConfigData config = MidsContext.Config; config.I9.ExportDataChunk = this.chkDataChunk.Checked; config.I9.ExportIOLevels = !this.chkNoIOLevel.Checked; config.I9.ExportStripSetNames = this.chkNoSetName.Checked; config.I9.ExportStripEnh = this.chkNoEnh.Checked; MidsContext.Config.ExportBonusTotals = this.chkBonusList.Checked; MidsContext.Config.ExportBonusList = this.chkBreakdown.Checked; MidsContext.Config.ExportChunkOnly = this.chkChunkOnly.Checked; this.Exporter = new clsOutput(); string str = ""; string iDataLink = MidsCharacterFileFormat.MxDBuildSaveHyperlink(!this.Exporter.HTML, false); if (!this.chkChunkOnly.Checked) { str = this.Exporter.Build(iDataLink); } string str2 = ExportConfig.FormatCodes.FillCode(MidsContext.Config.Export.FormatCode[MidsContext.Config.ExportTarget].SizeOn, "5"); string sizeOff = MidsContext.Config.Export.FormatCode[MidsContext.Config.ExportTarget].SizeOff; if (!this.chkChunkOnly.Checked) { str += "\r\n\r\n"; } if ((iDataLink == "" | this.chkAlwaysDataChunk.Checked | this.chkChunkOnly.Checked) && (this.chkDataChunk.Checked | this.chkAlwaysDataChunk.Checked | this.chkChunkOnly.Checked)) { str = str + str2 + MidsCharacterFileFormat.MxDBuildSaveString(false, true) + sizeOff; } Clipboard.SetDataObject(str, true); string prompt = "The build data has been placed on the clipboard and is ready to paste into a forum post. If your forum allows you to disable emoticons/smileys in your post, you should do so."; Interaction.MsgBox(prompt, MsgBoxStyle.Information, "Export Done"); base.Hide(); }
internal static void DiscordExport() { //Set vars and shrink the link Statistics displayStats = MidsContext.Character.DisplayStats; var num = MidsContext.Character.Level + 1; if (num > 50) { num = 50; } var discord = ( Server : MidsContext.Config.DSelServer.Replace(" (Default)", ""), User : MidsContext.Config.DNickName, Channel : MidsContext.Config.DChannel); var mrb = ( Level : Conversions.ToString(num), Archetype : MidsContext.Character.Archetype.DisplayName, PriPowerSet : MidsContext.Character.Powersets[0].DisplayName, SecPowerSet : MidsContext.Character.Powersets[1].DisplayName, GlobRecharge : Strings.Format((float)((double)displayStats.BuffHaste(false) - 100.0), "##0" + NumberFormatInfo.CurrentInfo.NumberDecimalSeparator + "#") + "%", EndRecovery : Strings.Format(displayStats.EnduranceRecoveryPercentage(false), "###0") + "% (" + Strings.Format(displayStats.EnduranceRecoveryNumeric, "##0" + NumberFormatInfo.CurrentInfo.NumberDecimalSeparator + "##") + "/s)", //HPRegen: Strings.Format(displayStats.HealthRegenPercent(false), "###0") + "%", //TotalDamageBuff: Strings.Format(displayStats.BuffDamage(false) - 100f, "##0.#") + "%", TotalEndUse : Strings.Format(displayStats.EnduranceUsage, "##0" + NumberFormatInfo.CurrentInfo.NumberDecimalSeparator + "##") + "/s", //TotalToHit: Strings.Format(displayStats.BuffToHit, "##0" + NumberFormatInfo.CurrentInfo.NumberDecimalSeparator + "#") + "%", ToonName : MidsContext.Character.Name, Datalink : MidsCharacterFileFormat.MxDBuildSaveHyperlink(false, true)); var shrunkData = ShrinkTheDatalink(mrb.Datalink); var embedurl = $"[Click Here to Download]({shrunkData})"; byte[] data = Convert.FromBase64String("aHR0cDovL2hvb2tzLm1pZHNyZWJvcm4uY29tOjMwMDAvYXBpP3Rva2VuPVVtUWhUNGtEclMwZ0E1TUY1YUdsaTh6YllDVW1RaFQ0a0RyUzBnQTVNRjVhR2xpOHpiWUM="); string wString = Encoding.UTF8.GetString(data); var httpWebRequest = (HttpWebRequest)WebRequest.Create(wString); httpWebRequest.ContentType = "application/json"; httpWebRequest.Method = "POST"; using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream())) { var json = JsonConvert.SerializeObject(new { guild = discord.Server, channel = discord.Channel, nickname = discord.User, level = mrb.Level, name = mrb.ToonName, archetype = mrb.Archetype, primpowerset = mrb.PriPowerSet, secpowerset = mrb.SecPowerSet, recharge = mrb.GlobRecharge, //dmgbuff = mrb.TotalDamageBuff, //regen = mrb.HPRegen, recov = mrb.EndRecovery, //tohit = mrb.TotalToHit, enduse = mrb.TotalEndUse, embedlink = embedurl }); streamWriter.Write(json); } var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse(); using (var streamReader = new StreamReader(httpResponse.GetResponseStream())) { var result = streamReader.ReadToEnd(); switch (result) { case "Nickname not found in discord": { const string message = "Submission Failed! Check the Discord settings under configuration."; const string title = "Discord Export"; MessageBox.Show(message, title); break; } case "Nickname found": { const string message = "Submission Successful!! Your build should now be posted."; const string title = "Discord Export"; MessageBox.Show(message, title); break; } } } }
internal static async Task DiscordExport() { Statistics displayStats = MidsContext.Character.DisplayStats; var num = MidsContext.Character.Level + 1; if (num > 50) { num = 50; } string[] names = Enum.GetNames(Enums.eDamage.None.GetType()); int num1 = names.Length - 1; for (int dType = 1; dType <= num1; ++dType) { var tmpMatch = new Regex(@"(unique*|toxic|special)", RegexOptions.IgnoreCase | RegexOptions.Multiline); if (tmpMatch.Match(names[dType]).Success) { continue; } string defenseStat = $"{Strings.Format(displayStats.Defense(dType), "##0" + NumberFormatInfo.CurrentInfo.NumberDecimalSeparator + "##")}%"; switch (names[dType]) { case "Smashing": Smashing_Defense = defenseStat; break; case "Lethal": Lethal_Defense = defenseStat; break; case "Fire": Fire_Defense = defenseStat; break; case "Cold": Cold_Defense = defenseStat; break; case "Energy": Energy_Defense = defenseStat; break; case "Negative": Negative_Defense = defenseStat; break; case "Psionic": Psionic_Defense = defenseStat; break; case "Melee": Melee_Defense = defenseStat; break; case "Ranged": Ranged_Defense = defenseStat; break; case "AoE": AOE_Defense = defenseStat; break; } } Resistance_Cap = $"{Strings.Format((float)(MidsContext.Character.Archetype.ResCap * 100.0), "###0")}%"; for (int rType = 1; rType <= num1; ++rType) { var tmpMatch = new Regex(@"(unique*|melee|ranged|aoe|special)", RegexOptions.IgnoreCase | RegexOptions.Multiline); if (tmpMatch.Match(names[rType]).Success) { continue; } var resistanceStat = $"{Strings.Format(displayStats.DamageResistance(rType, true),"##0" + NumberFormatInfo.CurrentInfo.NumberDecimalSeparator + "##")}%"; switch (names[rType]) { case "Smashing": Smashing_Resistance = resistanceStat; break; case "Lethal": Lethal_Resistance = resistanceStat; break; case "Fire": Fire_Resistance = resistanceStat; break; case "Cold": Cold_Resistance = resistanceStat; break; case "Energy": Energy_Resistance = resistanceStat; break; case "Negative": Negative_Resistance = resistanceStat; break; case "Toxic": Toxic_Resistance = resistanceStat; break; case "Psionic": Psionic_Resistance = resistanceStat; break; } } Damage_Buff = Strings.Format(displayStats.BuffDamage(false) - 100f, "##0.#") + "%"; Endurance_Usage = Strings.Format(displayStats.EnduranceUsage, "##0" + NumberFormatInfo.CurrentInfo.NumberDecimalSeparator + "##") + "/s"; Global_Recharge = Strings.Format((float)(displayStats.BuffHaste(false) - 100.0), "##0" + NumberFormatInfo.CurrentInfo.NumberDecimalSeparator + "#") + "%"; Recovery = Strings.Format(displayStats.EnduranceRecoveryPercentage(false), "###0") + "% (" + Strings.Format(displayStats.EnduranceRecoveryNumeric, "##0" + NumberFormatInfo.CurrentInfo.NumberDecimalSeparator + "##") + "/s)"; Regen = Strings.Format(displayStats.HealthRegenPercent(false), "###0") + "%"; ToHit = Strings.Format(displayStats.BuffToHit, "##0" + NumberFormatInfo.CurrentInfo.NumberDecimalSeparator + "#") + "%"; Discord_Server = MidsContext.Config.DSelServer.Replace(" (Default)", ""); Discord_Nickname = MidsContext.Config.DNickName; Discord_Channel = MidsContext.Config.DChannel; Mids_Version = MidsContext.AppAssemblyVersion; Character_Name = MidsContext.Character.Name; Character_Level = Convert.ToString(num); Character_Archetype = MidsContext.Character.Archetype.DisplayName; Character_Primary_Power = MidsContext.Character.Powersets[0].DisplayName; Character_Secondary_Power = MidsContext.Character.Powersets[1].DisplayName; var cDatalink = MidsCharacterFileFormat.MxDBuildSaveHyperlink(false, true); var shrunkData = ShrinkTheDatalink(cDatalink); var embedurl = $"[Click Here to Download]({shrunkData})"; Embed_Link = embedurl; /*foreach (var stat in MidsContext.Config.CheckedStats) * { * var eStat = (Enums.eStats) Enum.Parse(typeof(Enums.eStats), stat, true); * var combEStat = combinedStats[Convert.ToInt32(eStat) - 1]; * * }*/ byte[] data = Convert.FromBase64String("aHR0cDovL2hvb2tzLm1pZHNyZWJvcm4uY29tOjMwMDAvYXBpP3Rva2VuPVVtUWhUNGtEclMwZ0E1TUY1YUdsaTh6YllDVW1RaFQ0a0RyUzBnQTVNRjVhR2xpOHpiWUM="); //byte[] data = Convert.FromBase64String("aHR0cDovL2hvb2tzLm1pZHNyZWJvcm4uY29tOjMwMDEvYXBpP3Rva2VuPVVtUWhUNGtEclMwZ0E1TUY1YUdsaTh6YllDVW1RaFQ0a0RyUzBnQTVNRjVhR2xpOHpiWUM="); string wString = Encoding.UTF8.GetString(data); //Send the data to the API Server and retrieve response var httpWebRequest = (HttpWebRequest)WebRequest.Create(wString); httpWebRequest.ContentType = "application/json"; httpWebRequest.Method = "POST"; using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream())) { var ExportedValues = new Dictionary <string, string>(); ExportedValues.Add(nameof(Mids_Version), Mids_Version); ExportedValues.Add(nameof(Discord_Server), Discord_Server); ExportedValues.Add(nameof(Discord_Channel), Discord_Channel); ExportedValues.Add(nameof(Discord_Nickname), Discord_Nickname); ExportedValues.Add(nameof(Character_Name), Character_Name); ExportedValues.Add(nameof(Character_Level), Character_Level); ExportedValues.Add(nameof(Character_Archetype), Character_Archetype); ExportedValues.Add(nameof(Character_Primary_Power), Character_Primary_Power); ExportedValues.Add(nameof(Character_Secondary_Power), Character_Secondary_Power); ExportedValues.Add(nameof(Embed_Link), Embed_Link); foreach (var stat in MidsContext.Config.CheckedStats) { Clshook val = new Clshook(); ExportedValues.Add(stat, (string)val[stat]); //var eStat = (Enums.eStats)Enum.Parse(typeof(Enums.eStats), stat, true); // MessageBox.Show(eStat.ToString()); //var combEStat = combinedStats[Convert.ToInt32(eStat) - 1]; } var json = JsonConvert.SerializeObject(new { ExportedValues }); streamWriter.Write(json); } var httpResponse = (HttpWebResponse)await httpWebRequest.GetResponseAsync(); using (var streamReader = new StreamReader(httpResponse.GetResponseStream() ?? throw new InvalidOperationException())) { var result = streamReader.ReadToEnd(); switch (result) { case "Nickname not found in discord": { string message = $"Submission Failed: Your discord nickname '{Discord_Nickname}' was not found in the {Discord_Server} discord server."; string title = "Discord Export"; MessageBox.Show(message, title); break; } case "Export Successful": { string message = $"Submission Successful!! Your build should now be posted in {Discord_Channel} on the {Discord_Server} server."; string title = "Discord Export"; MessageBox.Show(message, title); break; } case "Export Failed": { string message = "Submission Failed: Please check your discord export settings and make sure you have the latest version of Mids' Reborn : Hero Designer."; string title = "Discord Export"; MessageBox.Show(message, title); break; } case "Failed to add export to queue": { string message = "Submission Failed: Possible server error, please contact the RebornTeam."; string title = "Discord Export"; MessageBox.Show(message, title); break; } case "RebornBot is not in the discord server": { string message = $"Submission Failed: MidsBot was not found in the {Discord_Server}."; string title = "Discord Export"; MessageBox.Show(message, title); break; } } } }
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); }