public static string MxDBuildSaveString(bool inncludeAltEnh, bool forumMode)
    {
        MidsCharacterFileFormat.CompressionData cData = default(MidsCharacterFileFormat.CompressionData);
        string str = MidsCharacterFileFormat.MxDBuildSaveStringShared(ref cData, inncludeAltEnh, true);
        string str2;

        if (string.IsNullOrEmpty(str))
        {
            str2 = string.Empty;
        }
        else
        {
            string str3 = "\n";
            string str4;
            if (forumMode)
            {
                bool flag  = MidsContext.Config.Export.FormatCode[MidsContext.Config.ExportTarget].Notes.IndexOf("HTML", StringComparison.Ordinal) > -1;
                bool flag2 = MidsContext.Config.Export.FormatCode[MidsContext.Config.ExportTarget].Notes.IndexOf("no <br /> tags", StringComparison.OrdinalIgnoreCase) > -1;
                if (flag && !flag2)
                {
                    str  = str.Replace("\n", "<br />");
                    str3 = "<br />";
                }
                str4 = "| Copy & Paste this data into Mids' Hero Designer to view the build |" + str3;
                if (flag)
                {
                    str4 = str4.Replace(" ", "&nbsp;");
                }
                str4 = str4 + "|-------------------------------------------------------------------|" + str3;
            }
            else
            {
                str4 = "|              Do not modify anything below this line!              |" + str3 + "|-------------------------------------------------------------------|" + str3;
            }
            string str5 = ";HEX";
            object obj  = str4;
            str4 = string.Concat(new object[]
            {
                obj,
                "|MxDz;",
                cData.SzUncompressed,
                ";",
                cData.SzCompressed,
                ";",
                cData.SzEncoded,
                str5,
                ";|",
                str3
            });
            str4 = str4 + str + str3;
            str2 = str4 + "|-------------------------------------------------------------------|";
        }
        return(str2);
    }
    public static string MxDBuildSaveHyperlink(bool useBbCode, bool justLink = false)
    {
        MidsCharacterFileFormat.CompressionData cData = default(MidsCharacterFileFormat.CompressionData);
        string str = MidsCharacterFileFormat.MxDBuildSaveStringShared(ref cData, false, false);
        string str2;

        if (string.IsNullOrEmpty(str))
        {
            str2 = string.Empty;
        }
        else
        {
            string str4 = string.Concat(new object[]
            {
                "?uc=",
                cData.SzUncompressed,
                "&c=",
                cData.SzCompressed,
                "&a=",
                cData.SzEncoded,
                "&f=HEX&dc="
            });
            string str3 = "http://www.cohplanner.com/mids/download.php" + str4 + str;
            if (str3.Length > 2048)
            {
                str2 = "";
            }
            else if (justLink)
            {
                str2 = str3;
            }
            else
            {
                if (useBbCode)
                {
                    str3 = "[url=" + str3 + "]Click this DataLink to open the build![/url]";
                }
                else
                {
                    str3 = "<a href=\"" + str3 + "\">Click this DataLink to open the build!</a>";
                }
                str2 = str3;
            }
        }
        return(str2);
    }
Exemplo n.º 3
0
        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();
        }
    static string MxDBuildSaveStringShared(ref MidsCharacterFileFormat.CompressionData cData, bool inncludeAltEnh, bool @break)
    {
        byte[] numArray = new byte[0];
        string str;

        if (!MidsCharacterFileFormat.MxDBuildSaveBuffer(ref numArray, inncludeAltEnh))
        {
            str = string.Empty;
        }
        else
        {
            ASCIIEncoding asciiEncoding = new ASCIIEncoding();
            cData.SzUncompressed = numArray.Length;
            byte[] bytes = Zlib.CompressChunk(ref numArray);
            cData.SzCompressed = bytes.Length;
            bytes           = Zlib.HexEncodeBytes(bytes);
            cData.SzEncoded = bytes.Length;
            str             = (@break ? Zlib.BreakString(asciiEncoding.GetString(bytes), 67, true) : asciiEncoding.GetString(bytes));
        }
        return(str);
    }
Exemplo n.º 5
0
        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;
                }
                }
            }
        }
Exemplo n.º 7
0
        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;
                }
                }
            }
        }
Exemplo n.º 8
0
        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);
        }
    public static MidsCharacterFileFormat.eLoadReturnCode MxDExtractAndLoad(
        Stream iStream)
    {
        StreamReader streamReader;

        try
        {
            streamReader = new StreamReader(iStream);
            streamReader.BaseStream.Seek(0L, SeekOrigin.Begin);
        }
        catch (Exception ex)
        {
            int num = (int)MessageBox.Show("Unable to read data - " + ex.Message, "ExtractAndLoad Failed");
            return(MidsCharacterFileFormat.eLoadReturnCode.Failure);
        }
        string[] strArray1 = new string[4]
        {
            "ABCD",
            "0",
            "0",
            "0"
        };
        string a = "";

        MidsCharacterFileFormat.eLoadReturnCode eLoadReturnCode;
        try
        {
            string str = streamReader.ReadToEnd().Replace("||", "|\n|");
            streamReader.Close();
            string[] strArray2 = str.Split('\n');
            int      num1      = -1;
            if (strArray2.Length < 1)
            {
                int num2 = (int)MessageBox.Show("Unable to locate data header - Zero-Length Input!", "ExtractAndLoad Failed");
                eLoadReturnCode = MidsCharacterFileFormat.eLoadReturnCode.Failure;
            }
            else
            {
                for (int index = 0; index < strArray2.Length; ++index)
                {
                    int startIndex = strArray2[index].IndexOf(MagicUncompressed, StringComparison.Ordinal);
                    if (startIndex < 0)
                    {
                        startIndex = strArray2[index].IndexOf(MagicCompressed, StringComparison.Ordinal);
                    }
                    if (startIndex < 0)
                    {
                        startIndex = strArray2[index].IndexOf("MHDz", StringComparison.OrdinalIgnoreCase);
                    }
                    if (startIndex > -1)
                    {
                        strArray1 = strArray2[index].Substring(startIndex).Split(';');
                        a         = strArray1.Length > 0 ? strArray1[0] : string.Empty;
                        num1      = index;
                        break;
                    }
                }
                if (num1 < 0)
                {
                    int num2 = (int)MessageBox.Show("Unable to locate data header - Magic Number not found!", "ExtractAndLoad Failed");
                    eLoadReturnCode = MidsCharacterFileFormat.eLoadReturnCode.Failure;
                }
                else if (string.Equals(a, "MHDz", StringComparison.OrdinalIgnoreCase))
                {
                    eLoadReturnCode = MidsCharacterFileFormat.eLoadReturnCode.IsOldFormat;
                }
                else if (num1 + 1 == strArray2.Length)
                {
                    int num2 = (int)MessageBox.Show("Unable to locate data - Nothing beyond header!", "ExtractAndLoad Failed");
                    eLoadReturnCode = MidsCharacterFileFormat.eLoadReturnCode.Failure;
                }
                else
                {
                    string iString = string.Empty;
                    for (int index = num1 + 1; index <= strArray2.Length - 1; ++index)
                    {
                        iString = iString + strArray2[index] + "\n";
                    }
                    int  int32_1 = Convert.ToInt32(strArray1[1]);
                    int  int32_2 = Convert.ToInt32(strArray1[2]);
                    int  int32_3 = Convert.ToInt32(strArray1[3]);
                    bool isHex   = false;
                    if (strArray1.Length > 4)
                    {
                        isHex = string.Equals(strArray1[4], "HEX", StringComparison.OrdinalIgnoreCase);
                    }
                    byte[] iBytes = new ASCIIEncoding().GetBytes(isHex ? Zlib.UnbreakHex(iString) : Zlib.UnbreakString(iString, true));
                    streamReader.Close();
                    if (iBytes.Length < int32_3)
                    {
                        int num2 = (int)MessageBox.Show("Data chunk was incomplete! Check that the entire chunk was copied to the clipboard.", "ExtractAndLoad Failed");
                        eLoadReturnCode = MidsCharacterFileFormat.eLoadReturnCode.Failure;
                    }
                    else
                    {
                        if (iBytes.Length > int32_3)
                        {
                            Array.Resize <byte>(ref iBytes, int32_3);
                        }
                        iBytes = isHex ? Zlib.HexDecodeBytes(iBytes) : Zlib.UUDecodeBytes(iBytes);
                        if (iBytes.Length == 0)
                        {
                            eLoadReturnCode = MidsCharacterFileFormat.eLoadReturnCode.Failure;
                        }
                        else
                        {
                            if (a == MagicCompressed)
                            {
                                Array.Resize <byte>(ref iBytes, int32_2);
                                byte[] tempByteArray = iBytes; // Pine
                                iBytes = Zlib.UncompressChunk(ref tempByteArray, int32_1);
                            }
                            eLoadReturnCode = iBytes.Length != 0 ? (MidsCharacterFileFormat.MxDReadSaveData(ref iBytes, false) ? MidsCharacterFileFormat.eLoadReturnCode.Success : MidsCharacterFileFormat.eLoadReturnCode.Failure) : MidsCharacterFileFormat.eLoadReturnCode.Failure;
                        }
                    }
                }
            }
        }
        catch (Exception ex)
        {
            MessageBox.Show("Unable to read data - " + ex.Message, "ExtractAndLoad Failed");
            streamReader?.Close();
            eLoadReturnCode = MidsCharacterFileFormat.eLoadReturnCode.Failure;
        }
        return(eLoadReturnCode);
    }
    static bool MxDBuildSaveBuffer(ref byte[] buffer, bool includeAltEnh)
    {
        MemoryStream memoryStream;
        BinaryWriter writer;

        try
        {
            memoryStream = new MemoryStream();
            writer       = new BinaryWriter(memoryStream);
        }
        catch (Exception ex)
        {
            MessageBox.Show("Save Failed!\n" + ex.Message);
            return(false);
        }
        writer.Write(MidsCharacterFileFormat.MagicNumber, 0, MidsCharacterFileFormat.MagicNumber.Length);
        writer.Write(1.01f);
        writer.Write(false);
        writer.Write(true);
        writer.Write(MidsContext.Character.Archetype.ClassName);
        writer.Write(MidsContext.Character.Archetype.Origin[MidsContext.Character.Origin]);
        writer.Write((int)MidsContext.Character.Alignment);
        writer.Write(MidsContext.Character.Name);
        writer.Write(MidsContext.Character.Powersets.Length - 1);
        for (int index = 0; index < MidsContext.Character.Powersets.Length; index++)
        {
            writer.Write((MidsContext.Character.Powersets[index] != null) ? MidsContext.Character.Powersets[index].FullName : string.Empty);
        }
        writer.Write(MidsContext.Character.CurrentBuild.LastPower + 1);
        writer.Write(MidsContext.Character.CurrentBuild.Powers.Count - 1);
        for (int index2 = 0; index2 < MidsContext.Character.CurrentBuild.Powers.Count; index2++)
        {
            if (MidsContext.Character.CurrentBuild.Powers[index2].NIDPower < 0)
            {
                writer.Write(-1);
            }
            else
            {
                writer.Write(DatabaseAPI.Database.Power[MidsContext.Character.CurrentBuild.Powers[index2].NIDPower].StaticIndex);
                writer.Write(Convert.ToSByte(MidsContext.Character.CurrentBuild.Powers[index2].Level));
                writer.Write(Convert.ToBoolean(MidsContext.Character.CurrentBuild.Powers[index2].StatInclude));
                writer.Write(MidsContext.Character.CurrentBuild.Powers[index2].VariableValue);
                writer.Write(Convert.ToSByte(MidsContext.Character.CurrentBuild.Powers[index2].SubPowers.Length - 1));
                for (int index3 = 0; index3 < MidsContext.Character.CurrentBuild.Powers[index2].SubPowers.Length; index3++)
                {
                    if (MidsContext.Character.CurrentBuild.Powers[index2].SubPowers[index3].nIDPower > -1)
                    {
                        writer.Write(DatabaseAPI.Database.Power[MidsContext.Character.CurrentBuild.Powers[index2].SubPowers[index3].nIDPower].StaticIndex);
                    }
                    else
                    {
                        writer.Write(-1);
                    }
                    writer.Write(MidsContext.Character.CurrentBuild.Powers[index2].SubPowers[index3].StatInclude);
                }
            }
            writer.Write(Convert.ToSByte(MidsContext.Character.CurrentBuild.Powers[index2].Slots.Length - 1));
            for (int index3 = 0; index3 <= MidsContext.Character.CurrentBuild.Powers[index2].Slots.Length - 1; index3++)
            {
                writer.Write(Convert.ToSByte(MidsContext.Character.CurrentBuild.Powers[index2].Slots[index3].Level));
                MidsCharacterFileFormat.WriteSlotData(ref writer, ref MidsContext.Character.CurrentBuild.Powers[index2].Slots[index3].Enhancement);
                writer.Write(includeAltEnh);
                if (includeAltEnh)
                {
                    MidsCharacterFileFormat.WriteSlotData(ref writer, ref MidsContext.Character.CurrentBuild.Powers[index2].Slots[index3].FlippedEnhancement);
                }
            }
        }
        buffer = memoryStream.ToArray();
        return(true);
    }
    public static MidsCharacterFileFormat.eLoadReturnCode MxDExtractAndLoad(Stream iStream)
    {
        StreamReader streamReader;

        MidsCharacterFileFormat.eLoadReturnCode eLoadReturnCode;
        try
        {
            streamReader = new StreamReader(iStream);
            streamReader.BaseStream.Seek(0L, SeekOrigin.Begin);
        }
        catch (Exception ex)
        {
            MessageBox.Show("Unable to read data - " + ex.Message, "ExtractAndLoad Failed");
            eLoadReturnCode = MidsCharacterFileFormat.eLoadReturnCode.Failure;
            return(eLoadReturnCode);
        }
        string[] strArray = new string[]
        {
            "ABCD",
            "0",
            "0",
            "0"
        };
        string a = "";

        try
        {
            string str = streamReader.ReadToEnd().Replace("||", "|\n|");
            streamReader.Close();
            string[] strArray2 = str.Split(new char[]
            {
                '\n'
            });
            int num = -1;
            if (strArray2.Length < 1)
            {
                MessageBox.Show("Unable to locate data header - Zero-Length Input!", "ExtractAndLoad Failed");
                eLoadReturnCode = MidsCharacterFileFormat.eLoadReturnCode.Failure;
            }
            else
            {
                for (int index = 0; index < strArray2.Length; index++)
                {
                    int startIndex = strArray2[index].IndexOf("MxDu", StringComparison.Ordinal);
                    if (startIndex < 0)
                    {
                        startIndex = strArray2[index].IndexOf("MxDz", StringComparison.Ordinal);
                    }
                    if (startIndex < 0)
                    {
                        startIndex = strArray2[index].IndexOf("MHDz", StringComparison.OrdinalIgnoreCase);
                    }
                    if (startIndex > -1)
                    {
                        strArray = strArray2[index].Substring(startIndex).Split(new char[]
                        {
                            ';'
                        });
                        a   = ((strArray.Length > 0) ? strArray[0] : string.Empty);
                        num = index;
                        break;
                    }
                }
                if (num < 0)
                {
                    MessageBox.Show("Unable to locate data header - Magic Number not found!", "ExtractAndLoad Failed");
                    eLoadReturnCode = MidsCharacterFileFormat.eLoadReturnCode.Failure;
                }
                else if (string.Equals(a, "MHDz", StringComparison.OrdinalIgnoreCase))
                {
                    eLoadReturnCode = MidsCharacterFileFormat.eLoadReturnCode.IsOldFormat;
                }
                else if (num + 1 == strArray2.Length)
                {
                    MessageBox.Show("Unable to locate data - Nothing beyond header!", "ExtractAndLoad Failed");
                    eLoadReturnCode = MidsCharacterFileFormat.eLoadReturnCode.Failure;
                }
                else
                {
                    string iString = string.Empty;
                    for (int index2 = num + 1; index2 <= strArray2.Length - 1; index2++)
                    {
                        iString = iString + strArray2[index2] + "\n";
                    }
                    int  int32_  = Convert.ToInt32(strArray[1]);
                    int  int32_2 = Convert.ToInt32(strArray[2]);
                    int  int32_3 = Convert.ToInt32(strArray[3]);
                    bool flag    = false;
                    if (strArray.Length > 4)
                    {
                        flag = string.Equals(strArray[4], "HEX", StringComparison.OrdinalIgnoreCase);
                    }
                    ASCIIEncoding asciiencoding = new ASCIIEncoding();
                    byte[]        iBytes        = asciiencoding.GetBytes(flag ? Zlib.UnbreakHex(iString) : Zlib.UnbreakString(iString, true));
                    streamReader.Close();
                    if (iBytes.Length < int32_3)
                    {
                        MessageBox.Show("Data chunk was incomplete! Check that the entire chunk was copied to the clipboard.", "ExtractAndLoad Failed");
                        eLoadReturnCode = MidsCharacterFileFormat.eLoadReturnCode.Failure;
                    }
                    else
                    {
                        if (iBytes.Length > int32_3)
                        {
                            Array.Resize <byte>(ref iBytes, int32_3);
                        }
                        iBytes = (flag ? Zlib.HexDecodeBytes(iBytes) : Zlib.UUDecodeBytes(iBytes));
                        if (iBytes.Length == 0)
                        {
                            eLoadReturnCode = MidsCharacterFileFormat.eLoadReturnCode.Failure;
                        }
                        else
                        {
                            if (a == "MxDz")
                            {
                                Array.Resize <byte>(ref iBytes, int32_2);
                                iBytes = Zlib.UncompressChunk(ref iBytes, int32_);
                            }
                            if (iBytes.Length == 0)
                            {
                                eLoadReturnCode = MidsCharacterFileFormat.eLoadReturnCode.Failure;
                            }
                            else if (!MidsCharacterFileFormat.MxDReadSaveData(ref iBytes, false))
                            {
                                eLoadReturnCode = MidsCharacterFileFormat.eLoadReturnCode.Failure;
                            }
                            else
                            {
                                eLoadReturnCode = MidsCharacterFileFormat.eLoadReturnCode.Success;
                            }
                        }
                    }
                }
            }
        }
        catch (Exception ex2)
        {
            MessageBox.Show("Unable to read data - " + ex2.Message, "ExtractAndLoad Failed");
            if (streamReader != null)
            {
                streamReader.Close();
            }
            eLoadReturnCode = MidsCharacterFileFormat.eLoadReturnCode.Failure;
        }
        return(eLoadReturnCode);
    }
    static bool MxDReadSaveData(ref byte[] buffer, bool silent)
    {
        bool flag;

        if (buffer.Length < 1)
        {
            MessageBox.Show("Unable to read data - Empty Buffer.", "ReadSaveData Failed");
            flag = false;
        }
        else
        {
            MemoryStream memoryStream;
            BinaryReader reader;
            bool         flag2;
            try
            {
                memoryStream = new MemoryStream(buffer, false);
                reader       = new BinaryReader(memoryStream);
                reader.BaseStream.Seek(0L, SeekOrigin.Begin);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Unable to read data - " + ex.Message, "ReadSaveData Failed");
                flag2 = false;
                return(flag2);
            }
            try
            {
                int num = 0;
                for (; ;)
                {
                    reader.BaseStream.Seek((long)num, SeekOrigin.Begin);
                    byte[] numArray = reader.ReadBytes(4);
                    if (numArray.Length < 4)
                    {
                        break;
                    }
                    bool flag3 = true;
                    for (int index = 0; index < MidsCharacterFileFormat.MagicNumber.Length; index++)
                    {
                        if (MidsCharacterFileFormat.MagicNumber[index] != numArray[index])
                        {
                            flag3 = false;
                        }
                    }
                    if (!flag3)
                    {
                        num++;
                    }
                    if (flag3)
                    {
                        goto Block_11;
                    }
                }
                if (!silent)
                {
                    MessageBox.Show("Unable to read data - Magic Number not found.", "ReadSaveData Failed");
                }
                reader.Close();
                memoryStream.Close();
                flag2 = false;
                return(flag2);

Block_11:
                float fVersion = reader.ReadSingle();
                if ((double)fVersion > 2.0)
                {
                    MessageBox.Show("File was saved by a newer version of the application. Please obtain the most recent release in order to open this file.", "Unable to Load");
                    reader.Close();
                    memoryStream.Close();
                    flag2 = false;
                }
                else
                {
                    bool qualifiedNames = reader.ReadBoolean();
                    bool flag4          = reader.ReadBoolean();
                    int  nIDClass       = DatabaseAPI.NidFromUidClass(reader.ReadString());
                    if (nIDClass < 0)
                    {
                        if (!silent)
                        {
                            MessageBox.Show("Unable to read data - Invalid Class UID.", "ReadSaveData Failed");
                        }
                        reader.Close();
                        memoryStream.Close();
                        flag2 = false;
                    }
                    else
                    {
                        int iOrigin = DatabaseAPI.NidFromUidOrigin(reader.ReadString(), nIDClass);
                        MidsContext.Character.Reset(DatabaseAPI.Database.Classes[nIDClass], iOrigin);
                        if ((double)fVersion > 1.0)
                        {
                            int num2 = reader.ReadInt32();
                            MidsContext.Character.Alignment = (Enums.Alignment)num2;
                        }
                        MidsContext.Character.Name = reader.ReadString();
                        int num3 = reader.ReadInt32();
                        if (MidsContext.Character.Powersets.Length - 1 != num3)
                        {
                            MidsContext.Character.Powersets = new IPowerset[num3 + 1];
                        }
                        for (int index2 = 0; index2 < MidsContext.Character.Powersets.Length; index2++)
                        {
                            string iName = reader.ReadString();
                            if (string.IsNullOrEmpty(iName))
                            {
                                MidsContext.Character.Powersets[index2] = null;
                            }
                            else
                            {
                                MidsContext.Character.Powersets[index2] = DatabaseAPI.GetPowersetByName(iName);
                            }
                        }
                        MidsContext.Character.CurrentBuild.LastPower = reader.ReadInt32() - 1;
                        int num4 = reader.ReadInt32();
                        try
                        {
                            for (int index3 = 0; index3 <= num4; index3++)
                            {
                                int    index4    = -1;
                                string name2     = string.Empty;
                                int    sidPower2 = -1;
                                if (qualifiedNames)
                                {
                                    name2 = reader.ReadString();
                                    if (!string.IsNullOrEmpty(name2))
                                    {
                                        index4 = DatabaseAPI.NidFromUidPower(name2);
                                    }
                                }
                                else
                                {
                                    sidPower2 = reader.ReadInt32();
                                    index4    = DatabaseAPI.NidFromStaticIndexPower(sidPower2);
                                }
                                bool       flag5 = false;
                                PowerEntry powerEntry;
                                if (index3 < MidsContext.Character.CurrentBuild.Powers.Count)
                                {
                                    powerEntry = MidsContext.Character.CurrentBuild.Powers[index3];
                                }
                                else
                                {
                                    powerEntry = new PowerEntry(-1, null, false);
                                    flag5      = true;
                                }
                                if (sidPower2 > -1 | !string.IsNullOrEmpty(name2))
                                {
                                    powerEntry.Level         = (int)reader.ReadSByte();
                                    powerEntry.StatInclude   = reader.ReadBoolean();
                                    powerEntry.VariableValue = reader.ReadInt32();
                                    if (flag4)
                                    {
                                        powerEntry.SubPowers = new PowerSubEntry[(int)(reader.ReadSByte() + 1)];
                                        for (int index5 = 0; index5 < powerEntry.SubPowers.Length; index5++)
                                        {
                                            powerEntry.SubPowers[index5] = new PowerSubEntry();
                                            if (qualifiedNames)
                                            {
                                                name2 = reader.ReadString();
                                                if (!string.IsNullOrEmpty(name2))
                                                {
                                                    powerEntry.SubPowers[index5].nIDPower = DatabaseAPI.NidFromUidPower(name2);
                                                }
                                            }
                                            else
                                            {
                                                sidPower2 = reader.ReadInt32();
                                                powerEntry.SubPowers[index5].nIDPower = DatabaseAPI.NidFromStaticIndexPower(sidPower2);
                                            }
                                            if (powerEntry.SubPowers[index5].nIDPower > -1)
                                            {
                                                powerEntry.SubPowers[index5].Powerset = DatabaseAPI.Database.Power[powerEntry.SubPowers[index5].nIDPower].PowerSetID;
                                                powerEntry.SubPowers[index5].Power    = DatabaseAPI.Database.Power[powerEntry.SubPowers[index5].nIDPower].PowerSetIndex;
                                            }
                                            powerEntry.SubPowers[index5].StatInclude = reader.ReadBoolean();
                                            if (powerEntry.SubPowers[index5].nIDPower > -1 & powerEntry.SubPowers[index5].StatInclude)
                                            {
                                                PowerEntry powerEntry2 = new PowerEntry(DatabaseAPI.Database.Power[powerEntry.SubPowers[index5].nIDPower])
                                                {
                                                    StatInclude = true
                                                };
                                                MidsContext.Character.CurrentBuild.Powers.Add(powerEntry2);
                                            }
                                        }
                                    }
                                }
                                if (index4 < 0 && index3 < DatabaseAPI.Database.Levels_MainPowers.Length)
                                {
                                    powerEntry.Level = DatabaseAPI.Database.Levels_MainPowers[index3];
                                }
                                powerEntry.Slots = new SlotEntry[(int)(reader.ReadSByte() + 1)];
                                for (int index6 = 0; index6 < powerEntry.Slots.Length; index6++)
                                {
                                    powerEntry.Slots[index6] = new SlotEntry
                                    {
                                        Level              = (int)reader.ReadSByte(),
                                        Enhancement        = new I9Slot(),
                                        FlippedEnhancement = new I9Slot()
                                    };
                                    MidsCharacterFileFormat.ReadSlotData(ref reader, ref powerEntry.Slots[index6].Enhancement, qualifiedNames, fVersion);
                                    if (reader.ReadBoolean())
                                    {
                                        MidsCharacterFileFormat.ReadSlotData(ref reader, ref powerEntry.Slots[index6].FlippedEnhancement, qualifiedNames, fVersion);
                                    }
                                }
                                if (powerEntry.SubPowers.Length > 0)
                                {
                                    index4 = -1;
                                }
                                if (index4 > -1)
                                {
                                    powerEntry.NIDPower    = index4;
                                    powerEntry.NIDPowerset = DatabaseAPI.Database.Power[index4].PowerSetID;
                                    powerEntry.IDXPower    = DatabaseAPI.Database.Power[index4].PowerSetIndex;
                                    if (powerEntry.Level == 0 && powerEntry.Power.FullSetName == "Pool.Fitness")
                                    {
                                        if (powerEntry.NIDPower == 2553)
                                        {
                                            powerEntry.NIDPower = 1521;
                                        }
                                        if (powerEntry.NIDPower == 2554)
                                        {
                                            powerEntry.NIDPower = 1523;
                                        }
                                        if (powerEntry.NIDPower == 2555)
                                        {
                                            powerEntry.NIDPower = 1522;
                                        }
                                        if (powerEntry.NIDPower == 2556)
                                        {
                                            powerEntry.NIDPower = 1524;
                                        }
                                        powerEntry.NIDPowerset = DatabaseAPI.Database.Power[index4].PowerSetID;
                                        powerEntry.IDXPower    = DatabaseAPI.Database.Power[index4].PowerSetIndex;
                                    }
                                    if (index3 < MidsContext.Character.CurrentBuild.Powers.Count)
                                    {
                                        if (!MidsContext.Character.CurrentBuild.Powers[index3].Chosen & (powerEntry.Power.PowerSet.nArchetype > -1 | powerEntry.Power.GroupName == "Pool"))
                                        {
                                            goto IL_91F;
                                        }
                                        flag5 = !MidsContext.Character.CurrentBuild.Powers[index3].Chosen;
                                    }
                                    if (flag5)
                                    {
                                        MidsContext.Character.CurrentBuild.Powers.Add(powerEntry);
                                    }
                                    else if (powerEntry.Power.PowerSet.nArchetype > -1 || powerEntry.Power.GroupName == "Pool")
                                    {
                                        MidsContext.Character.CurrentBuild.Powers[index3] = powerEntry;
                                    }
                                }
                                IL_91F :;
                            }
                        }
                        catch (Exception ex2)
                        {
                            if (!silent)
                            {
                                MessageBox.Show("Error reading some power data, will attempt to build character with known data - " + ex2.Message, "ReadSaveData Failed");
                            }
                            flag2 = false;
                            return(flag2);
                        }
                        MidsContext.Archetype = MidsContext.Character.Archetype;
                        MidsContext.Character.Validate();
                        MidsContext.Character.Lock();
                        flag2 = true;
                    }
                }
            }
            catch (Exception ex3)
            {
                if (!silent)
                {
                    MessageBox.Show("Unable to read data - " + ex3.Message, "ReadSaveData Failed");
                }
                flag2 = false;
            }
            flag = flag2;
        }
        return(flag);
    }