protected void SetCharacterInfo()
        {
            // Warning: DatabaseAPI.GetArchetypeByName looks up archetype info by display name, not by internal name.
            // Meaning underscores have to be replaced with spaces for VEATs...
            MidsContext.Character.Archetype = DatabaseAPI.GetArchetypeByName(CharacterInfo.Archetype.Replace("_", " "));
            MidsContext.Character.Origin    =
                DatabaseAPI.GetOriginByName(MidsContext.Character.Archetype, CharacterInfo.Origin);
            MidsContext.Character.Reset(MidsContext.Character.Archetype, MidsContext.Character.Origin);
            MidsContext.Character.Name      = CharacterInfo.Name;
            MidsContext.Character.Alignment = CharacterInfo.Alignment switch
            {
                "Hero" => Enums.Alignment.Hero,
                "Vigilante" => Enums.Alignment.Vigilante,
                "Rogue" => Enums.Alignment.Rogue,
                "Villain" => Enums.Alignment.Villain,
                "Loyalist" => Enums.Alignment.Loyalist,
                "Resistance" => Enums.Alignment.Resistance,
                _ => MidsContext.Character.IsHero() ? Enums.Alignment.Hero : Enums.Alignment.Villain
            };

            MidsContext.Character.SetLevelTo(CharacterInfo.Level - 1);
        }
Exemple #2
0
        public static bool InterpretForumPost(string iPost)
        {
            var buildMode = MidsContext.Config.BuildMode;

            MidsContext.Config.BuildMode = Enums.dmModes.Normal;
            try
            {
                iPost = PowerNameFix(iPost);
                char[] chArray =
                {
                    '`'
                };
                iPost = iPost.Replace("\r\n", "`");
                iPost = iPost.Replace("\n", "`");
                iPost = iPost.Replace("\r", "`");
                var haystack = iPost.Split(chArray);
                var num1     = 0;
                var dest     = "";
                MidsContext.Character.Reset();
                var character = MidsContext.Character;
                var name      = character.Name;
                character.Name = name;
                if (FindValue("Name", haystack, ref name) < 0)
                {
                    MidsContext.Character.Name = "Unknown";
                }
                if (SmartFind("Archetype", haystack, ref dest) < 0)
                {
                    var index1 = -1;
                    var num2   = DatabaseAPI.Database.Classes.Length - 1;
                    for (var index2 = 0; index2 <= num2; ++index2)
                    {
                        if (FindString(DatabaseAPI.Database.Classes[index2].DisplayName, haystack) <= -1)
                        {
                            continue;
                        }
                        index1 = index2;
                        break;
                    }

                    if (index1 <= -1)
                    {
                        throw new Exception("Archetype value not found.");
                    }
                    MidsContext.Character.Archetype = DatabaseAPI.Database.Classes[index1];
                }
                else
                {
                    MidsContext.Character.Archetype = DatabaseAPI.GetArchetypeByName(dest);
                }

                var index3 = -1;
                if (FindValue("Primary", haystack, ref dest) > -1)
                {
                    index3 = DatabaseAPI.GetPowersetByName(dest, MidsContext.Character.Archetype.DisplayName).nID;
                }
                if (index3 < 0)
                {
                    index3 = 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];
                var index4 = -1;
                if (FindValue("Secondary", haystack, ref dest) > -1)
                {
                    index4 = DatabaseAPI.GetPowersetByName(dest, MidsContext.Character.Archetype.DisplayName).nID;
                }
                if (index4 < 0)
                {
                    index4 = FindPowerSetAdvanced("Secondary", Enums.ePowerSetType.Secondary,
                                                  MidsContext.Character.Archetype.Idx, haystack);
                    if (index4 < 0)
                    {
                        throw new Exception("Secondary Powerset value not found.");
                    }
                }

                MidsContext.Character.Powersets[1] = DatabaseAPI.Database.Powersets[index4];
                if ((MidsContext.Character.Powersets[0] == null) | (MidsContext.Character.Powersets[1] == null))
                {
                    throw new Exception("Powerset Name value couldn't be interpreted.");
                }
                var firstPower = FindFirstPower(haystack, MidsContext.Character.Archetype.Idx);
                if (firstPower < 0)
                {
                    throw new Exception("First power entry couldn't be located.");
                }
                var sPowerLineArray = new sPowerLine[0];
                var iPL             = new sPowerLine();
                var num3            = haystack.Length - 1;
                for (var index1 = firstPower; index1 <= num3; ++index1)
                {
                    iPL.Assign(BreakLine(haystack[index1], MidsContext.Character.Archetype.Idx));
                    if (!((iPL.Level > 0) & (iPL.Power != "")))
                    {
                        continue;
                    }
                    //sPowerLineArray = (sPowerLine[]) Utils.CopyArray(sPowerLineArray, new sPowerLine[sPowerLineArray.Length + 1]);
                    Array.Copy(sPowerLineArray, new sPowerLine[sPowerLineArray.Length + 1], sPowerLineArray.Length + 1);
                    sPowerLineArray[sPowerLineArray.Length - 1].Assign(iPL);
                }

                for (var index1 = 0; index1 <= sPowerLineArray.Length - 1; ++index1)
                {
                    if (sPowerLineArray[index1].Level > num1)
                    {
                        num1 = sPowerLineArray[index1].Level;
                    }
                    var num2 = sPowerLineArray[index1].Slots.Length - 1;
                    for (var index2 = 0; index2 <= num2; ++index2)
                    {
                        if (sPowerLineArray[index1].Slots[index2].Level > num1)
                        {
                            num1 = sPowerLineArray[index1].Slots[index2].Level;
                        }
                    }
                }

                MainModule.MidsController.Toon.Locked = true;
                if (sPowerLineArray.Length < 1)
                {
                    return(false);
                }
                var num5 = sPowerLineArray.Length - 1;
                for (var index1 = 0; index1 <= num5; ++index1)
                {
                    sPowerLineArray[index1].HistoryID = -1;
                    var flag2 = false;
                    var power = FindPower(sPowerLineArray[index1].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)
                    {
                        continue;
                    }
                    MainModule.MidsController.Toon.RequestedLevel = sPowerLineArray[index1].Level - 1;
                    MainModule.MidsController.Toon.BuildPower(power.Powerset, power.Power);
                    switch (DatabaseAPI.Database.Powersets[power.Powerset].SetType)
                    {
                    case Enums.ePowerSetType.Pool:
                    {
                        var num2 = MainModule.MidsController.Toon.PoolLocked.Length - 2;
                        for (var index2 = 0;
                             index2 <= num2 && !(MainModule.MidsController.Toon.PoolLocked[index2] &
                                                 (MidsContext.Character.Powersets[3 + index2].nID ==
                                                  power.Powerset));
                             ++index2)
                        {
                            if (MainModule.MidsController.Toon.PoolLocked[index2])
                            {
                                continue;
                            }
                            MidsContext.Character.Powersets[3 + index2].nID   = power.Powerset;
                            MainModule.MidsController.Toon.PoolLocked[index2] = true;
                            break;
                        }

                        break;
                    }

                    case Enums.ePowerSetType.Ancillary
                        when !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;
                        break;
                    }
                }

                var num6 = sPowerLineArray.Length - 1;
                for (var index1 = 0; index1 <= num6; ++index1)
                {
                    sPowerLineArray[index1].HistoryID =
                        MidsContext.Character.CurrentBuild.FindInToonHistory(
                            DatabaseAPI.NidFromUidPower(sPowerLineArray[index1].Power));
                    if (sPowerLineArray[index1].HistoryID == -1 &&
                        (index1 > -1) & (index1 < MidsContext.Character.CurrentBuild.Powers.Count))
                    {
                        sPowerLineArray[index1].HistoryID = index1;
                    }
                    if (!((sPowerLineArray[index1].HistoryID > -1) & (sPowerLineArray[index1].Slots.Length > 0)))
                    {
                        continue;
                    }
                    if (sPowerLineArray[index1].Slots.Length > 1)
                    {
                        MidsContext.Character.CurrentBuild.Powers[sPowerLineArray[index1].HistoryID].Slots =
                            new SlotEntry[sPowerLineArray[index1].Slots.Length - 1 + 1];
                    }
                    var num2 = sPowerLineArray[index1].Slots.Length - 1;
                    for (var index2 = 0; index2 <= num2; ++index2)
                    {
                        if (index2 >= MidsContext.Character.CurrentBuild.Powers[sPowerLineArray[index1].HistoryID].Slots
                            .Length)
                        {
                            continue;
                        }
                        var slots  = MidsContext.Character.CurrentBuild.Powers[sPowerLineArray[index1].HistoryID].Slots;
                        var index5 = index2;
                        slots[index5].Enhancement         = new I9Slot();
                        slots[index5].FlippedEnhancement  = new I9Slot();
                        slots[index5].Enhancement.Enh     = MatchEnhancement(sPowerLineArray[index1].Slots[index2].Enh);
                        slots[index5].Enhancement.Grade   = Enums.eEnhGrade.SingleO;
                        slots[index5].Enhancement.IOLevel =
                            sPowerLineArray[index1].Slots[index2].Enh.IndexOf("-I:", StringComparison.Ordinal) <= -1
                                ? sPowerLineArray[index1].Slots[index2].Enh.IndexOf(":", StringComparison.Ordinal) <=
                            -1 ? MidsContext.Config.I9.DefaultIOLevel :
                            (int)Math.Round(Convert.ToInt32(sPowerLineArray[index1].Slots[index2].Enh
                                                            .Substring(sPowerLineArray[index1].Slots[index2].Enh
                                                                       .IndexOf(":", StringComparison.Ordinal) + 1)) - 1.0)
                                : (int)Math.Round(Convert.ToInt32(sPowerLineArray[index1].Slots[index2].Enh
                                                                  .Substring(sPowerLineArray[index1].Slots[index2].Enh
                                                                             .IndexOf(":", StringComparison.Ordinal) + 1)) - 1.0);
                        slots[index5].Level = index2 != 0
                            ? sPowerLineArray[index1].Slots[index2].Level - 1
                            : MidsContext.Character.CurrentBuild.Powers[sPowerLineArray[index1].HistoryID].Level;
                        if (slots[index5].Level < 0)
                        {
                            slots[index5].Level = 0;
                        }
                    }
                }

                MidsContext.Character.Validate();
                MidsContext.Config.BuildMode = buildMode;
                return(true);
            }
            catch (Exception ex)
            {
                MidsContext.Config.BuildMode = buildMode;
                MessageBox.Show($"Unable to import from forum post:\r\n{ex.Message}\r\n\r\nCheck that the build was copied correctly.", @"Forum Import", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return(false);
            }
        }
        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);
        }
        public List <PowerEntry>?Parse()
        {
            Regex  r;
            Regex  rs;
            Match  m;
            Match  ms;
            string cnt;
            int    i;

            var p = new RawPowerData {
                Valid = false
            };
            var powerSlots = new List <RawEnhData>();
            var e          = new RawEnhData();

            var listPowers = new List <PowerEntry>();

            try
            {
                cnt = File.ReadAllText(BuildString);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace);
                return(null);
            }

            cnt = Regex.Replace(cnt, @"[\r\n]", "\r\n");          // Line conversion to PC/Win format (just in case)
            cnt = Regex.Replace(cnt, @"\<br \/\>", string.Empty); // For good ol' Mids 1.962 support
            cnt = Regex.Replace(cnt, @"\&nbsp\;", " ");           // Nbsp html entities to spaces
            cnt = Regex.Replace(cnt, @" {2,}", "\t");             // Note: [JS] Use of \s here break newlines

            // Compact a little those modern builds
            cnt = Regex.Replace(cnt, @"\t{2,}", "\t");
            cnt = Regex.Replace(cnt, @"(\r\n){2,}", "\r\n");

            // Alignment, builder software and version
            // Note: old Pine Hero Designer is listed as 'Hero Hero Designer'
            // Extended: Rogue/Vigilante will be added in a later release.
            r = new Regex(@"(Hero|Villain|Rogue|Vigilante) Plan by ([a-zA-Z\:\'\s]+) ([0-9\.]+)");
            m = r.Match(cnt);

            if (!m.Success)
            {
                _ = MessageBox.Show(
                    "This build cannot be recovered because it doesn't contain a valid plain text part.", "Error",
                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(null);
            }

            CharacterInfo.Alignment = m.Groups[1].Value;
            BuilderApp.Software     = m.Groups[2].Value;
            BuilderApp.Version      = m.Groups[3].Value;

            // Character name, level, origin and archetype
            r = new Regex(@"([^\r\n\t]+)\: Level ([0-9]{1,2}) ([a-zA-Z]+) ([a-zA-Z ]+)");
            m = r.Match(cnt);
            if (!m.Success)
            {
                // Name is empty
                rs = new Regex(@"Level ([0-9]{1,2}) ([a-zA-Z]+) ([a-zA-Z ]+)");
                ms = rs.Match(cnt);
                CharacterInfo.Name      = string.Empty;
                CharacterInfo.Level     = Convert.ToInt32(ms.Groups[1].Value, null);
                CharacterInfo.Origin    = ms.Groups[2].Value;
                CharacterInfo.Archetype = ms.Groups[3].Value;
            }
            else
            {
                CharacterInfo.Name      = m.Groups[1].Value;
                CharacterInfo.Level     = Convert.ToInt32(m.Groups[2].Value, null);
                CharacterInfo.Origin    = m.Groups[3].Value;
                CharacterInfo.Archetype = m.Groups[4].Value;
            }

            SetCharacterInfo();

            // Main powersets
            r = new Regex(@"(Primary|Secondary) Power Set\: ([^\r\n\t]+)");
            m = r.Match(cnt);
            while (m.Success)
            {
                PowerSets.Add(m.Groups[2].Value);
                m = m.NextMatch();
            }

            // Pools and Ancillary/Epic powersets
            r = new Regex(@"(Power|Ancillary) Pool\: ([^\r\n\t]+)");
            m = r.Match(cnt);
            while (m.Success)
            {
                if (m.Groups[2].Value != "Fitness")
                {
                    PowerSets.Add(m.Groups[2].Value);
                }
                m = m.NextMatch();
            }

            // Powers
            string PSlotsStr;

            string[] PSlots;
            string[] s;
            string?  sContentEnh;

            r = new Regex(@"Level ([0-9]{1,2})\:\t([^\t]+)\t([^\r\n\t]+)");
            m = r.Match(cnt);
            while (m.Success)
            {
                p       = new RawPowerData();
                e       = new RawEnhData();
                p.Slots = new List <RawEnhData>();

                p.DisplayName = m.Groups[2].Value.Trim();
                p.Level       = Convert.ToInt32(m.Groups[1].Value, null);
                p.pData       = DatabaseAPI.GetPowerByDisplayName(p.DisplayName,
                                                                  DatabaseAPI.GetArchetypeByName(CharacterInfo.Archetype).Idx);
                p.Powerset = p.pData != null?DatabaseAPI.GetPowersetByIndex(p.pData.PowerSetIndex) : null;

                p.Valid   = CheckValid(p.pData);
                PSlotsStr = m.Groups.Count > 3 ? m.Groups[3].Value.Trim() : string.Empty;
                if (!string.IsNullOrEmpty(PSlotsStr))
                {
                    // Extract enhancement name and slot level ('A' for power inherent slot)
                    // Handle special enhancements with parenthesis like ExpRnf-+Res(Pets)(50)
                    PSlotsStr = Regex.Replace(PSlotsStr, @"\(([^A0-9]+)\)", "[$1]");
                    PSlots    = Regex.Split(PSlotsStr, @",\s");

                    for (i = 0; i < PSlots.Length; i++)
                    {
                        s = Regex.Split(PSlots[i], @"/[\(\)]");
                        s = Array.FindAll(s, e => !string.IsNullOrWhiteSpace(e));

                        sContentEnh =
                            s[0] == "Empty"
                                ? null
                                : ShortNamesConversion(s[0]); // Enhancement name (Enhancement.ShortName)
                        try
                        {
                            e.InternalName = s[0];
                            e.Level        = s[1] == "A"
                                ? 0
                                : Convert.ToInt32(s[1], null); // Slot level ("A" is the auto-granted one)
                            e.Boosters    = 0;                 // Not handled
                            e.HasCatalyst = false;
                            e.eData       = DatabaseAPI.GetEnhancementByUIDName(e.InternalName);
                            p.Slots.Add(e);
                        }
                        catch (FormatException) // if (isNaN(s[1]
                        {
                            e.InternalName = "Empty";
                            e.Level        = 0;
                            e.Boosters     = 0;
                            e.HasCatalyst  = false;
                            e.eData        = -1;
                            p.Slots.Add(e);
                        }
                    }
                }

                if (p.Valid)
                {
                    if (CheckValid(p.Powerset))
                    {
                        PowerSets.Add(p.Powerset.FullName);
                    }
                    AddPowerToBuildSheet(p, ref listPowers);
                }
            }

            return(listPowers);
        }