public void Assign(sPowerLine iPL) { Level = iPL.Level; Power = iPL.Power; Slots = new sSlot[iPL.Slots.Length - 1 + 1]; HistoryID = iPL.HistoryID; var num = Slots.Length - 1; for (var index = 0; index <= num; ++index) { Slots[index].Assign(iPL.Slots[index]); } }
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); } }
private static sPowerLine BreakLine(string iLine, int nAT) { var sPowerLine = new sPowerLine(); var strArray1 = SmartBreak(iLine, nAT); sPowerLine.Level = Convert.ToInt32(strArray1[0]); sPowerLine.Power = strArray1[1]; sPowerLine.Slots = Array.Empty <sSlot>(); var strArray2 = strArray1[2].Replace(" ", "|").Replace(")", "|").Split('|'); var num1 = strArray2.Length - 1; for (var index = 0; index <= num1; ++index) { var iStr = EnhNameFix(strArray2[index]); var flag1 = false; var flag2 = iStr.IndexOf("-I", StringComparison.Ordinal) > -1; IndexOf = iStr.IndexOf("-S", StringComparison.Ordinal); if (flag2 | (iStr.IndexOf(":", StringComparison.Ordinal) > -1)) { flag1 = true; } if (iStr.Length <= 0) { continue; } int num2; int startIndex; if (iStr == "A") { num2 = 0; startIndex = 0; } else { if (flag1) { num2 = SeekSepSpecial(iStr, 0); startIndex = SeekNumberSpecial(iStr, num2); } else { num2 = SeekSep(iStr, 0, false); startIndex = SeekNumber(iStr, num2); } if (startIndex < 0) { startIndex = SeekAn(iStr, num2); } } if (!((num2 > -1) & (startIndex > -1))) { continue; } Array.Copy(sPowerLine.Slots, new sSlot[sPowerLine.Slots.Length + 1], sPowerLine.Slots.Length + 1); //sPowerLine.Slots = (sSlot[]) Utils.CopyArray(sPowerLine.Slots, new sSlot[sPowerLine.Slots.Length + 1]); sPowerLine.Slots[sPowerLine.Slots.Length - 1].Enh = iStr.Substring(0, num2).Trim(); sPowerLine.Slots[sPowerLine.Slots.Length - 1].Level = Convert.ToInt32(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); }