public void Assign(clsUniversalImport.sPowerLine iPL)
            {
                this.Level     = iPL.Level;
                this.Power     = iPL.Power;
                this.Slots     = new clsUniversalImport.sSlot[iPL.Slots.Length - 1 + 1];
                this.HistoryID = iPL.HistoryID;
                int num = this.Slots.Length - 1;

                for (int index = 0; index <= num; index++)
                {
                    this.Slots[index].Assign(iPL.Slots[index]);
                }
            }
        public static bool InterpretForumPost(string iPost)
        {
            Enums.dmModes buildMode = MidsContext.Config.BuildMode;
            MidsContext.Config.BuildMode = Enums.dmModes.Dynamic;
            bool flag3;

            try
            {
                iPost = clsUniversalImport.PowerNameFix(iPost);
                char[] chArray = new char[]
                {
                    '`'
                };
                iPost = iPost.Replace("\r\n", "`");
                iPost = iPost.Replace("\n", "`");
                iPost = iPost.Replace("\r", "`");
                string[] haystack = iPost.Split(chArray);
                int      num      = 0;
                string   dest     = "";
                MidsContext.Character.Reset(null, 0);
                Character character = MidsContext.Character;
                string    name      = character.Name;
                character.Name = name;
                if (clsUniversalImport.FindValue("Name", haystack, ref name) < 0)
                {
                    MidsContext.Character.Name = "Unknown";
                }
                if (clsUniversalImport.SmartFind("Archetype", haystack, ref dest) < 0)
                {
                    int index = -1;
                    int num2  = DatabaseAPI.Database.Classes.Length - 1;
                    for (int index2 = 0; index2 <= num2; index2++)
                    {
                        if (clsUniversalImport.FindString(DatabaseAPI.Database.Classes[index2].DisplayName, haystack) > -1)
                        {
                            index = index2;
                            break;
                        }
                    }
                    if (index <= -1)
                    {
                        throw new Exception("Archetype value not found.");
                    }
                    MidsContext.Character.Archetype = DatabaseAPI.Database.Classes[index];
                }
                else
                {
                    MidsContext.Character.Archetype = DatabaseAPI.GetArchetypeByName(dest);
                }
                int index3 = -1;
                if (clsUniversalImport.FindValue("Primary", haystack, ref dest) > -1)
                {
                    index3 = DatabaseAPI.GetPowersetByName(dest, MidsContext.Character.Archetype.DisplayName).nID;
                }
                if (index3 < 0)
                {
                    index3 = clsUniversalImport.FindPowerSetAdvanced("Primary", Enums.ePowerSetType.Primary, MidsContext.Character.Archetype.Idx, haystack);
                    if (index3 < 0)
                    {
                        throw new Exception("Primary Powerset value not found.");
                    }
                }
                MidsContext.Character.Powersets[0] = DatabaseAPI.Database.Powersets[index3];
                index3 = -1;
                if (clsUniversalImport.FindValue("Secondary", haystack, ref dest) > -1)
                {
                    index3 = DatabaseAPI.GetPowersetByName(dest, MidsContext.Character.Archetype.DisplayName).nID;
                }
                if (index3 < 0)
                {
                    index3 = clsUniversalImport.FindPowerSetAdvanced("Secondary", Enums.ePowerSetType.Secondary, MidsContext.Character.Archetype.Idx, haystack);
                    if (index3 < 0)
                    {
                        throw new Exception("Secondary Powerset value not found.");
                    }
                }
                MidsContext.Character.Powersets[1] = DatabaseAPI.Database.Powersets[index3];
                if (MidsContext.Character.Powersets[0] == null | MidsContext.Character.Powersets[1] == null)
                {
                    throw new Exception("Powerset Name value couldn't be interpreted.");
                }
                int firstPower = clsUniversalImport.FindFirstPower(haystack, MidsContext.Character.Archetype.Idx);
                if (firstPower < 0)
                {
                    throw new Exception("First power entry couldn't be located.");
                }
                clsUniversalImport.sPowerLine[] sPowerLineArray = new clsUniversalImport.sPowerLine[0];
                clsUniversalImport.sPowerLine   iPL             = default(clsUniversalImport.sPowerLine);
                int num3 = haystack.Length - 1;
                for (int index4 = firstPower; index4 <= num3; index4++)
                {
                    iPL.Assign(clsUniversalImport.BreakLine(haystack[index4], MidsContext.Character.Archetype.Idx));
                    if (iPL.Level > 0 & iPL.Power != "")
                    {
                        sPowerLineArray = (clsUniversalImport.sPowerLine[])Utils.CopyArray(sPowerLineArray, new clsUniversalImport.sPowerLine[sPowerLineArray.Length + 1]);
                        sPowerLineArray[sPowerLineArray.Length - 1].Assign(iPL);
                    }
                }
                int num4 = sPowerLineArray.Length - 1;
                for (int index4 = 0; index4 <= num4; index4++)
                {
                    if (sPowerLineArray[index4].Level > num)
                    {
                        num = sPowerLineArray[index4].Level;
                    }
                    int num5 = sPowerLineArray[index4].Slots.Length - 1;
                    for (int index5 = 0; index5 <= num5; index5++)
                    {
                        if (sPowerLineArray[index4].Slots[index5].Level > num)
                        {
                            num = sPowerLineArray[index4].Slots[index5].Level;
                        }
                    }
                }
                MainModule.MidsController.Toon.Locked = true;
                if (sPowerLineArray.Length < 1)
                {
                    return(false);
                }
                int num6 = sPowerLineArray.Length - 1;
                for (int index4 = 0; index4 <= num6; index4++)
                {
                    sPowerLineArray[index4].HistoryID = -1;
                    bool flag2 = false;
                    clsUniversalImport.SetPair power = clsUniversalImport.FindPower(sPowerLineArray[index4].Power, MidsContext.Character.Archetype.Idx);
                    if (power.Powerset > -1 && DatabaseAPI.Database.Powersets[power.Powerset].SetType == Enums.ePowerSetType.Inherent)
                    {
                        flag2 = true;
                    }
                    if (power.Powerset < 0)
                    {
                        flag2 = true;
                    }
                    else if (power.Powerset == MidsContext.Character.Powersets[1].nID & power.Power == 0)
                    {
                        flag2 = true;
                    }
                    if (!flag2)
                    {
                        MainModule.MidsController.Toon.RequestedLevel = sPowerLineArray[index4].Level - 1;
                        MainModule.MidsController.Toon.BuildPower(power.Powerset, power.Power, false);
                        if (DatabaseAPI.Database.Powersets[power.Powerset].SetType == Enums.ePowerSetType.Pool)
                        {
                            int num7 = MainModule.MidsController.Toon.PoolLocked.Length - 2;
                            for (int index6 = 0; index6 <= num7; index6++)
                            {
                                if (MainModule.MidsController.Toon.PoolLocked[index6] & MidsContext.Character.Powersets[3 + index6].nID == power.Powerset)
                                {
                                    break;
                                }
                                if (!MainModule.MidsController.Toon.PoolLocked[index6])
                                {
                                    MidsContext.Character.Powersets[3 + index6].nID   = power.Powerset;
                                    MainModule.MidsController.Toon.PoolLocked[index6] = true;
                                    break;
                                }
                            }
                        }
                        else if (DatabaseAPI.Database.Powersets[power.Powerset].SetType == Enums.ePowerSetType.Ancillary && !MainModule.MidsController.Toon.PoolLocked[MainModule.MidsController.Toon.PoolLocked.Length - 1])
                        {
                            MidsContext.Character.Powersets[7].nID = power.Powerset;
                            MainModule.MidsController.Toon.PoolLocked[MainModule.MidsController.Toon.PoolLocked.Length - 1] = true;
                        }
                    }
                }
                int num8 = sPowerLineArray.Length - 1;
                for (int index4 = 0; index4 <= num8; index4++)
                {
                    sPowerLineArray[index4].HistoryID = MidsContext.Character.CurrentBuild.FindInToonHistory(DatabaseAPI.NidFromUidPower(sPowerLineArray[index4].Power));
                    if (sPowerLineArray[index4].HistoryID == -1 && (index4 > -1 & index4 < MidsContext.Character.CurrentBuild.Powers.Count))
                    {
                        sPowerLineArray[index4].HistoryID = index4;
                    }
                    if (sPowerLineArray[index4].HistoryID > -1 & sPowerLineArray[index4].Slots.Length > 0)
                    {
                        if (sPowerLineArray[index4].Slots.Length > 1)
                        {
                            MidsContext.Character.CurrentBuild.Powers[sPowerLineArray[index4].HistoryID].Slots = new SlotEntry[sPowerLineArray[index4].Slots.Length - 1 + 1];
                        }
                        int num9 = sPowerLineArray[index4].Slots.Length - 1;
                        for (int index5 = 0; index5 <= num9; index5++)
                        {
                            if (index5 < MidsContext.Character.CurrentBuild.Powers[sPowerLineArray[index4].HistoryID].Slots.Length)
                            {
                                SlotEntry[] slots  = MidsContext.Character.CurrentBuild.Powers[sPowerLineArray[index4].HistoryID].Slots;
                                int         index7 = index5;
                                slots[index7].Enhancement        = new I9Slot();
                                slots[index7].FlippedEnhancement = new I9Slot();
                                slots[index7].Enhancement.Enh    = clsUniversalImport.MatchEnhancement(sPowerLineArray[index4].Slots[index5].Enh);
                                slots[index7].Enhancement.Grade  = Enums.eEnhGrade.SingleO;
                                if (sPowerLineArray[index4].Slots[index5].Enh.IndexOf("-I:") > -1)
                                {
                                    slots[index7].Enhancement.IOLevel = (int)Math.Round(Conversion.Val(sPowerLineArray[index4].Slots[index5].Enh.Substring(sPowerLineArray[index4].Slots[index5].Enh.IndexOf(":") + 1)) - 1.0);
                                }
                                else if (sPowerLineArray[index4].Slots[index5].Enh.IndexOf(":") > -1)
                                {
                                    slots[index7].Enhancement.IOLevel = (int)Math.Round(Conversion.Val(sPowerLineArray[index4].Slots[index5].Enh.Substring(sPowerLineArray[index4].Slots[index5].Enh.IndexOf(":") + 1)) - 1.0);
                                }
                                else
                                {
                                    slots[index7].Enhancement.IOLevel = MidsContext.Config.I9.DefaultIOLevel;
                                }
                                if (index5 == 0)
                                {
                                    slots[index7].Level = MidsContext.Character.CurrentBuild.Powers[sPowerLineArray[index4].HistoryID].Level;
                                }
                                else
                                {
                                    slots[index7].Level = sPowerLineArray[index4].Slots[index5].Level - 1;
                                }
                                if (slots[index7].Level < 0)
                                {
                                    slots[index7].Level = 0;
                                }
                            }
                        }
                    }
                }
                MidsContext.Character.Validate();
                MidsContext.Config.BuildMode = buildMode;
                flag3 = true;
            }
            catch (Exception ex)
            {
                Exception exception = ex;
                MidsContext.Config.BuildMode = buildMode;
                Interaction.MsgBox("Unable to import from forum post:\r\n" + exception.Message + "\r\n\r\nCheck the build was copied correctly.", MsgBoxStyle.Information, "Forum Import Filter");
                flag3 = false;
            }
            return(flag3);
        }
        static clsUniversalImport.sPowerLine BreakLine(string iLine, int nAT)
        {
            clsUniversalImport.sPowerLine sPowerLine = default(clsUniversalImport.sPowerLine);
            string[] strArray = clsUniversalImport.SmartBreak(iLine, nAT);
            sPowerLine.Level = (int)Math.Round(Conversion.Val(strArray[0]));
            sPowerLine.Power = strArray[1];
            sPowerLine.Slots = new clsUniversalImport.sSlot[0];
            string iStr = strArray[2].Replace(" ", "|").Replace(")", "|");

            char[] separator = new char[]
            {
                '|'
            };
            string[] strArray2 = iStr.Split(separator);
            int      num       = strArray2.Length - 1;

            for (int index = 0; index <= num; index++)
            {
                iStr = strArray2[index];
                iStr = clsUniversalImport.EnhNameFix(iStr);
                bool flag  = false;
                bool flag2 = iStr.IndexOf("-I") > -1;
                iStr.IndexOf("-S");
                if (flag2 | iStr.IndexOf(":") > -1)
                {
                    flag = true;
                }
                if (iStr.Length > 0)
                {
                    int num2;
                    int startIndex;
                    if (iStr == "A")
                    {
                        num2       = 0;
                        startIndex = 0;
                    }
                    else
                    {
                        if (flag)
                        {
                            num2       = clsUniversalImport.SeekSepSpecial(iStr, 0);
                            startIndex = clsUniversalImport.SeekNumberSpecial(iStr, num2);
                        }
                        else
                        {
                            num2       = clsUniversalImport.SeekSep(iStr, 0, false);
                            startIndex = clsUniversalImport.SeekNumber(iStr, num2);
                        }
                        if (startIndex < 0)
                        {
                            startIndex = clsUniversalImport.SeekAn(iStr, num2);
                        }
                    }
                    if (num2 > -1 & startIndex > -1)
                    {
                        sPowerLine.Slots = (clsUniversalImport.sSlot[])Utils.CopyArray(sPowerLine.Slots, new clsUniversalImport.sSlot[sPowerLine.Slots.Length + 1]);
                        sPowerLine.Slots[sPowerLine.Slots.Length - 1].Enh   = iStr.Substring(0, num2).Trim();
                        sPowerLine.Slots[sPowerLine.Slots.Length - 1].Level = (int)Math.Round(Conversion.Val(iStr.Substring(startIndex).Trim()));
                        if (iStr.Substring(startIndex).Trim().StartsWith("A"))
                        {
                            sPowerLine.Slots[sPowerLine.Slots.Length - 1].Level = sPowerLine.Level;
                        }
                        sPowerLine.Slots[sPowerLine.Slots.Length - 1].PowerName = sPowerLine.Power;
                    }
                }
            }
            return(sPowerLine);
        }