コード例 #1
0
        static clsUniversalImport.SetPair FindPower(string iName, int nAT)
        {
            IPowerset[] powersetIndexes2 = new IPowerset[2];
            clsUniversalImport.SetPair setPair3;
            if (MidsContext.Character != null)
            {
                powersetIndexes2[0] = MidsContext.Character.Powersets[0];
                powersetIndexes2[1] = MidsContext.Character.Powersets[1];
                clsUniversalImport.SetPair setPair2 = clsUniversalImport.ScanSetArray(iName, powersetIndexes2);
                if (setPair2.Powerset > -1)
                {
                    setPair3 = setPair2;
                    return(setPair3);
                }
            }
            int powerByName = DatabaseAPI.GetPowerByName(iName, nAT);

            if (powerByName < 0)
            {
                powerByName = DatabaseAPI.GetPowerByName(iName.Replace("'", ""), nAT);
            }
            if (powerByName > -1)
            {
                setPair3 = new clsUniversalImport.SetPair(DatabaseAPI.Database.Power[powerByName].PowerSetID, DatabaseAPI.Database.Power[powerByName].PowerSetIndex);
            }
            else
            {
                powersetIndexes2 = DatabaseAPI.GetPowersetIndexes(nAT, Enums.ePowerSetType.Ancillary);
                clsUniversalImport.SetPair setPair2 = clsUniversalImport.ScanSetArray(iName, powersetIndexes2);
                if (setPair2.Powerset > -1)
                {
                    setPair3 = setPair2;
                }
                else
                {
                    powersetIndexes2 = DatabaseAPI.GetPowersetIndexes(nAT, Enums.ePowerSetType.Pool);
                    setPair2         = clsUniversalImport.ScanSetArray(iName, powersetIndexes2);
                    if (setPair2.Powerset > -1)
                    {
                        setPair3 = setPair2;
                    }
                    else
                    {
                        setPair3 = new clsUniversalImport.SetPair(-1, -1);
                    }
                }
            }
            return(setPair3);
        }
コード例 #2
0
        static clsUniversalImport.SetPair ScanSetArray(string iName, IPowerset[] sets)
        {
            int num = sets.Length - 1;

            clsUniversalImport.SetPair result;
            for (int index = 0; index <= num; index++)
            {
                if (sets[index] != null)
                {
                    int num2 = sets[index].Powers.Length - 1;
                    for (int iPower = 0; iPower <= num2; iPower++)
                    {
                        if (string.Equals(sets[index].Powers[iPower].DisplayName, iName, StringComparison.OrdinalIgnoreCase))
                        {
                            result = new clsUniversalImport.SetPair(sets[index].nID, iPower);
                            return(result);
                        }
                    }
                }
            }
            result = new clsUniversalImport.SetPair(-1, -1);
            return(result);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
 public SetPair(int iSet, int iPower)
 {
     this          = new clsUniversalImport.SetPair();
     this.Powerset = iSet;
     this.Power    = iPower;
 }