using System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; using Base; using Base.Data_Classes; using Base.IO_Classes; using Base.Master_Classes; using HeroDesigner.Schema; public static class DatabaseAPI { static readonly IDictionary AttribMod = new Dictionary(); static readonly IDictionary Classes = new Dictionary(); public const int HeroAccolades = 3257; public const int VillainAccolades = 3258; public const int TempPowers = 3259; public static IDatabase Database => Base.Data_Classes.Database.Instance; static void ClearLookups() { AttribMod.Clear(); Classes.Clear(); } public static int NidFromUidAttribMod(string uID) { if (string.IsNullOrEmpty(uID)) return -1; if (AttribMod.ContainsKey(uID)) return AttribMod[uID]; for (int index = 0; index <= Database.AttribMods.Modifier.Length - 1; ++index) { if (!string.Equals(uID, Database.AttribMods.Modifier[index].ID, StringComparison.OrdinalIgnoreCase)) continue; AttribMod.Add(uID, index); return index; } return -1; } public static int NidFromUidClass(string uidClass) { if (string.IsNullOrEmpty(uidClass)) return -1; if (Classes.ContainsKey(uidClass)) return Classes[uidClass]; var index = Database.Classes.TryFindIndex(cls => string.Equals(uidClass, cls.ClassName, StringComparison.OrdinalIgnoreCase)); if (index >= 0) Classes.Add(uidClass, index); return index; } public static string UidFromNidClass(int nIDClass) => nIDClass < 0 || nIDClass > Database.Classes.Length ? string.Empty : Database.Classes[nIDClass].ClassName; public static int NidFromUidOrigin(string uidOrigin, int nIDClass) { if (nIDClass < 0) return -1; return Database.Classes[nIDClass].Origin.TryFindIndex(o => string.Equals(o, uidOrigin, StringComparison.OrdinalIgnoreCase)); } static void FillGroupArray() { Database.PowersetGroups = new Dictionary(); foreach (IPowerset powerset in Database.Powersets) { if (string.IsNullOrEmpty(powerset.GroupName)) continue; if (!Database.PowersetGroups.TryGetValue(powerset.GroupName, out PowersetGroup powersetGroup)) { powersetGroup = new PowersetGroup(powerset.GroupName); Database.PowersetGroups.Add(powerset.GroupName, powersetGroup); } powersetGroup.Powersets.Add(powerset.FullName, powerset); powerset.SetGroup(powersetGroup); } } public static int NidFromUidPowerset(string uidPowerset) => GetPowersetByName(uidPowerset)?.nID ?? -1; public static int NidFromStaticIndexPower(int sidPower) { if (sidPower < 0) return -1; return Database.Power.TryFindIndex(p => p.StaticIndex == sidPower); } public static int NidFromUidPower(string name) => GetPowerByName(name)?.PowerIndex ?? -1; public static int NidFromUidEntity(string uidEntity) => Database.Entities.TryFindIndex(se => string.Equals(se.UID, uidEntity, StringComparison.OrdinalIgnoreCase)); public static int[] NidSets(PowersetGroup group, int nIDClass, Enums.ePowerSetType nType) // clsI12Lookup.vb { if ((nType == Enums.ePowerSetType.Inherent || nType == Enums.ePowerSetType.Pool) && nIDClass > -1 && !Database.Classes[nIDClass].Playable) return Array.Empty(); IPowerset[] powersetArray = Database.Powersets; if (group != null) { powersetArray = group.Powersets.Select(powerset => powerset.Value).ToArray(); } List intList = new List(); bool checkType = nType != Enums.ePowerSetType.None; bool checkClass = nIDClass > -1; foreach (IPowerset powerset in powersetArray) { bool isOk = !checkType || powerset.SetType == nType; if (checkClass & isOk) { if ((powerset.SetType == Enums.ePowerSetType.Primary || powerset.SetType == Enums.ePowerSetType.Secondary) && powerset.nArchetype != nIDClass & powerset.nArchetype > -1) isOk = false; if (powerset.Powers.Length > 0 && isOk && (powerset.SetType != Enums.ePowerSetType.Inherent && powerset.SetType != Enums.ePowerSetType.Accolade) && powerset.SetType != Enums.ePowerSetType.Temp && !powerset.Powers[0].Requires.ClassOk(nIDClass)) isOk = false; } if (isOk) intList.Add(powerset.nID); } return intList.ToArray(); } public static int[] NidSets(string uidGroup, string uidClass, Enums.ePowerSetType nType) => NidSets(Database.PowersetGroups.ContainsKey(uidGroup) ? Database.PowersetGroups[uidGroup] : null, NidFromUidClass(uidClass), nType); public static int[] NidPowers(int nIDPowerset, int nIDClass = -1) { if (nIDPowerset < 0 || nIDPowerset > Database.Powersets.Length - 1) { //return Enumerable.Range(0, Database.Powersets.Length).ToArray(); var array = new int[Database.Power.Length]; for (int index = 0; index < Database.Power.Length; ++index) array[index] = index; return array; } var powerset = Database.Powersets[nIDPowerset]; return powerset.Powers.FindIndexes(pow => pow.Requires.ClassOk(nIDClass)).Select(idx => powerset.Power[idx]).ToArray(); } public static int[] NidPowers(string uidPowerset, string uidClass = "") => NidPowers(NidFromUidPowerset(uidPowerset), NidFromUidClass(uidClass)); public static string[] UidPowers(string uidPowerset, string uidClass = "") { if (!string.IsNullOrEmpty(uidPowerset)) return Database.Power.Where(pow => string.Equals(pow.FullSetName, uidPowerset, StringComparison.OrdinalIgnoreCase) && pow.Requires.ClassOk(uidClass)).Select(pow => pow.FullName).ToArray(); var array = new string[Database.Power.Length]; for (int index = 0; index < Database.Power.Length; ++index) array[index] = Database.Power[index].FullName; return array; } static int[] NidPowersAtLevel(int iLevel, int nIDPowerset) => nIDPowerset < 0 ? Array.Empty() : Database.Powersets[nIDPowerset].Powers.Where(pow => pow.Level - 1 == iLevel).Select(pow => pow.PowerIndex).ToArray(); public static int[] NidPowersAtLevelBranch(int iLevel, int nIDPowerset) { if (nIDPowerset < 0) return Array.Empty(); if (Database.Powersets[nIDPowerset].nIDTrunkSet < 0) return NidPowersAtLevel(iLevel, nIDPowerset); int[] powerset1 = NidPowersAtLevel(iLevel, nIDPowerset); int[] powerset2 = NidPowersAtLevel(iLevel, Database.Powersets[nIDPowerset].nIDTrunkSet); return powerset2.Concat(powerset1).ToArray(); } public static string[] UidMutexAll() { var items = Database.Power.SelectMany(pow => pow.GroupMembership).Distinct(StringComparer.OrdinalIgnoreCase).ToList(); items.Sort(); return items.ToArray(); } public static IPowerset GetPowersetByName(string iName) { string[] strArray = iName.Split('.'); if (strArray.Length < 2) return null; if (strArray.Length > 2) iName = $"{strArray[0]}.{strArray[1]}"; string key = strArray[0]; if (!Database.PowersetGroups.ContainsKey(key)) return null; PowersetGroup powersetGroup = Database.PowersetGroups[key]; return powersetGroup.Powersets.ContainsKey(iName) ? powersetGroup.Powersets[iName] : null; } public static IPowerset GetPowersetByName(string iName, string iArchetype) { int idx = GetArchetypeByName(iArchetype).Idx; foreach (IPowerset powerset1 in Database.Powersets) { if ((idx != powerset1.nArchetype && powerset1.nArchetype != -1) || !string.Equals(iName, powerset1.DisplayName, StringComparison.OrdinalIgnoreCase)) continue; if (powerset1.SetType != Enums.ePowerSetType.Ancillary) return powerset1; if (powerset1.Power.Length > 0 && powerset1.Powers[0].Requires.ClassOk(idx)) return powerset1; } return null; } //Pine public static IPowerset GetPowersetByName(string iName, Enums.ePowerSetType iSet) { return Database.Powersets.FirstOrDefault(powerset => iSet == powerset.SetType && string.Equals(iName, powerset.DisplayName, StringComparison.OrdinalIgnoreCase)); } public static IPowerset GetPowersetByID(string iName, Enums.ePowerSetType iSet) => Database.Powersets.FirstOrDefault(ps => iSet == ps.SetType && string.Equals(iName, ps.SetName, StringComparison.OrdinalIgnoreCase)); public static IPowerset GetInherentPowerset() => Database.Powersets.FirstOrDefault(ps => ps.SetType == Enums.ePowerSetType.Inherent); public static Archetype GetArchetypeByName(string iArchetype) => Database.Classes.FirstOrDefault(cls => string.Equals(iArchetype, cls.DisplayName, StringComparison.OrdinalIgnoreCase)); public static int GetOriginByName(Archetype archetype, string iOrigin) { for (int index = 0; index <= archetype.Origin.Length - 1; ++index) { if (string.Equals(iOrigin, archetype.Origin[index], StringComparison.OrdinalIgnoreCase)) return index; } return 0; } public static int GetPowerByName(string iName, int iArchetype) { for (int index = 0; index <= Database.Power.Length - 1; ++index) { int num = -1; if (Database.Power[index].PowerSetID > -1) num = Database.Powersets[Database.Power[index].PowerSetID].nArchetype; if ((iArchetype == num || num == -1) && string.Equals(iName, Database.Power[index].DisplayName)) return index; } return -1; } public static IPower GetPowerByName(string name) { if (string.IsNullOrEmpty(name)) return null; IPowerset powersetByName = GetPowersetByName(name); return powersetByName?.Powers.FirstOrDefault(power2 => string.Equals(power2.FullName, name, StringComparison.OrdinalIgnoreCase)); } public static string[] GetPowersetNames(int iAT, Enums.ePowerSetType iSet) { List stringList = new List(); if (iSet != Enums.ePowerSetType.Pool && iSet != Enums.ePowerSetType.Inherent) { int[] numArray = Array.Empty(); switch (iSet) { case Enums.ePowerSetType.Primary: numArray = Database.Classes[iAT].Primary; break; case Enums.ePowerSetType.Secondary: numArray = Database.Classes[iAT].Secondary; break; case Enums.ePowerSetType.Ancillary: numArray = Database.Classes[iAT].Ancillary; break; } stringList.AddRange(numArray.Select(index => Database.Powersets[index].DisplayName)); } else { stringList.AddRange(from powerset in Database.Powersets where powerset.SetType == iSet select powerset.DisplayName); } stringList.Sort(); return stringList.Count > 0 ? stringList.ToArray() : new[] { "No " + Enum.GetName(iSet.GetType(), iSet) }; } public static int[] GetPowersetIndexesByGroup(PowersetGroup group) { return group.Powersets.Select(powerset => powerset.Value.nID).ToArray(); } public static int[] GetPowersetIndexesByGroupName(string name) => !string.IsNullOrEmpty(name) && Database.PowersetGroups.ContainsKey(name) ? GetPowersetIndexesByGroup(Database.PowersetGroups[name]) : new int[1]; public static IPowerset[] GetPowersetIndexes(Archetype at, Enums.ePowerSetType iSet) => GetPowersetIndexes(at.Idx, iSet); public static IPowerset[] GetPowersetIndexes(int iAT, Enums.ePowerSetType iSet) { List powersetList = new List(); if (iSet != Enums.ePowerSetType.Pool & iSet != Enums.ePowerSetType.Inherent) { foreach (var ps in Database.Powersets) { if (ps.nArchetype == iAT & ps.SetType == iSet) powersetList.Add(ps); else if (iSet == Enums.ePowerSetType.Ancillary & ps.SetType == iSet && ps.ClassOk(iAT)) powersetList.Add(ps); } } else { for (int index = 0; index <= Database.Powersets.Length - 1; ++index) { if (Database.Powersets[index].SetType == iSet) powersetList.Add(Database.Powersets[index]); } } powersetList.Sort(); return powersetList.ToArray(); } public static int ToDisplayIndex(IPowerset iPowerset, IPowerset[] iIndexes) { for (int index = 0; index <= iIndexes.Length - 1; ++index) { if (iIndexes[index].nID == iPowerset.nID) return index; } return iIndexes.Length > 0 ? 0 : -1; } public static int GetEnhancementByUIDName(string iName) => Database.Enhancements.TryFindIndex(enh => enh.UID.Contains(iName)); public static int GetEnhancementByName(string iName) => Database.Enhancements.TryFindIndex(enh => string.Equals(enh.ShortName, iName, StringComparison.OrdinalIgnoreCase) || string.Equals(enh.Name, iName, StringComparison.OrdinalIgnoreCase)); public static int GetEnhancementByName(string iName, Enums.eType iType) => Database.Enhancements.TryFindIndex(enh => enh.TypeID == iType && string.Equals(enh.ShortName, iName, StringComparison.OrdinalIgnoreCase) || string.Equals(enh.Name, iName, StringComparison.OrdinalIgnoreCase)); public static int GetEnhancementByName(string iName, string iSet) { foreach (EnhancementSet enhancementSet in Database.EnhancementSets) { if (!string.Equals(enhancementSet.ShortName, iSet, StringComparison.OrdinalIgnoreCase)) continue; foreach (int enhancement in enhancementSet.Enhancements) { if (string.Equals(Database.Enhancements[enhancementSet.Enhancements[enhancement]].ShortName, iName, StringComparison.OrdinalIgnoreCase)) return enhancementSet.Enhancements[enhancement]; } } return -1; } public static int FindEnhancement(string setName, string enhName, int iType, int fallBack) { for (int index = 0; index < Database.Enhancements.Length; ++index) { if (Database.Enhancements[index].TypeID != (Enums.eType)iType || !string.Equals(Database.Enhancements[index].ShortName, enhName, StringComparison.OrdinalIgnoreCase)) continue; int num; if (Database.Enhancements[index].TypeID != Enums.eType.SetO) num = index; else if (Database.EnhancementSets[Database.Enhancements[index].nIDSet].DisplayName.Equals(setName, StringComparison.OrdinalIgnoreCase)) num = index; else continue; return num; } if (fallBack > -1 & fallBack < Database.Enhancements.Length) return fallBack; return -1; } //Pine public static int GetRecipeIdxByName(string iName) { for (int index = 0; index <= Database.Recipes.Length - 1; ++index) { if (string.Equals(Database.Recipes[index].InternalName, iName, StringComparison.OrdinalIgnoreCase)) return index; } return -1; } public static Recipe GetRecipeByName(string iName) { return Database.Recipes.FirstOrDefault(recipe => string.Equals(recipe.InternalName, iName, StringComparison.OrdinalIgnoreCase)); } public static string[] UidReferencingPowerFix(string uidPower, string uidNew = "") { string[] array = new string[0]; for (int index1 = 0; index1 <= Database.Power.Length - 1; ++index1) { if (Database.Power[index1].Requires.ReferencesPower(uidPower, uidNew)) { Array.Resize(ref array, array.Length + 1); array[array.Length - 1] = Database.Power[index1].FullName + " (Requirement)"; } for (int index2 = 0; index2 <= Database.Power[index1].Effects.Length - 1; ++index2) { if (Database.Power[index1].Effects[index2].Summon != uidPower) continue; Database.Power[index1].Effects[index2].Summon = uidNew; Array.Resize(ref array, array.Length + 1); array[array.Length - 1] = Database.Power[index1].FullName + " (GrantPower)"; } } return array; } public static int NidFromStaticIndexEnh(int sidEnh) { int num; if (sidEnh < 0) { num = -1; } else { for (int index = 0; index < Database.Enhancements.Length; ++index) { if (Database.Enhancements[index].StaticIndex == sidEnh) return index; } num = -1; } return num; } public static int NidFromUidioSet(string uidSet) { for (int index = 0; index < Database.EnhancementSets.Count; ++index) { if (string.Equals(Database.EnhancementSets[index].Uid, uidSet, StringComparison.OrdinalIgnoreCase)) return index; } return -1; } public static int NidFromUidRecipe(string uidRecipe, ref int subIndex) { bool isSub = subIndex > -1 & uidRecipe.Contains("_"); subIndex = -1; string uid = isSub ? uidRecipe.Substring(0, uidRecipe.LastIndexOf("_", StringComparison.Ordinal)) : uidRecipe; for (int recipeIdx = 0; recipeIdx < Database.Recipes.Length; ++recipeIdx) { if (!string.Equals(Database.Recipes[recipeIdx].InternalName, uid, StringComparison.OrdinalIgnoreCase)) continue; if (!isSub) return recipeIdx; int startIndex = uidRecipe.LastIndexOf("_", StringComparison.Ordinal) + 1; if (startIndex < 0 || startIndex > uidRecipe.Length - 1) return -1; uid = uidRecipe.Substring(startIndex); for (int index2 = 0; index2 < Database.Recipes[recipeIdx].Item.Length; ++index2) { if (Database.Recipes[recipeIdx].Item[index2].Level != startIndex) continue; subIndex = index2; return recipeIdx; } } return -1; } public static int NidFromUidEnh(string uidEnh) { for (int index = 0; index < Database.Enhancements.Length; ++index) { if (string.Equals(Database.Enhancements[index].UID, uidEnh, StringComparison.OrdinalIgnoreCase)) return index; } return -1; } public static int NidFromUidEnhExtended(string uidEnh) { if (!uidEnh.StartsWith("BOOSTS", true, CultureInfo.CurrentCulture)) return NidFromUidEnh(uidEnh); for (int index = 0; index < Database.Enhancements.Length; ++index) { if (string.Equals("BOOSTS." + Database.Enhancements[index].UID + "." + Database.Enhancements[index].UID, uidEnh, StringComparison.OrdinalIgnoreCase)) return index; } return -1; } const string MainDbName = "Mids' Hero Designer Database MK II"; static void SaveMainDbRaw(ISerialize serializer, string fn, string name) { var powersetPowers = Database.Powersets.SelectMany(x => x.Powers).Select(p => p.PowerIndex).Distinct().ToList(); // only powers that aren't in a powerset var powers = Database.Power.Where(p => powersetPowers.Contains(p.PowerIndex) == false).ToList(); var toSerialize = new { name, Database.Version, Database.Date, Database.Issue, Database.ArchetypeVersion, Archetypes = Database.Classes, Database.PowersetVersion, // out of memory exception //Database.Powersets, Powers = new { Database.PowerVersion, Database.PowerLevelVersion, Database.PowerEffectVersion, Database.IOAssignmentVersion, // out of memory exception //Database.Power // just powers not in power sets Powers = powers }, Database.Entities }; ConfigData.SaveRawMhd(serializer, toSerialize, fn, null); var archPowersets = Database.Powersets; // .Where(ps => ps.nArchetype >= 0); var dbPath = Path.Combine(Path.GetDirectoryName(fn), "db"); var playerPath = Path.Combine(dbPath, "Player"); var otherPath = Path.Combine(dbPath, "Other"); var toWrite = new List(); foreach (var path in new[] { dbPath, playerPath, otherPath }.Where(p => !Directory.Exists(p))) Directory.CreateDirectory(path); var metadataPath = Path.Combine(Path.GetDirectoryName(fn), "db_metadata" + Path.GetExtension(fn)); var (hasPrevious, prev) = ConfigData.LoadRawMhd(serializer, metadataPath); foreach (var ps in archPowersets) { var at = Database.Classes.FirstOrDefault(cl => ps.nArchetype != -1 && cl.Idx == ps.nArchetype); var at2 = Database.Classes.Length > ps.nArchetype && ps.nArchetype != -1 ? Database.Classes[ps.nArchetype] : null; if (ps.FullName?.Length == 0 || ps.FullName?.Length > 100) continue; if (ps.FullName?.Contains(";") == true || string.IsNullOrWhiteSpace(ps.FullName)) { Console.Error.WriteLine("hmmm:" + ps.DisplayName); } var psFn = Path.Combine(ps.nArchetype >= 0 ? playerPath : otherPath, ps.ATClass + "_" + ps.FullName + Path.GetExtension(fn)); if (psFn.Length > 240) { continue; } var psPrevious = hasPrevious ? prev.FirstOrDefault(psm => psm.Fullname == ps.FullName && psm.Archetype == ps.ATClass) : null; var lastSaveResult = hasPrevious && psPrevious != null ? new RawSaveResult(hash: psPrevious.Hash, length: psPrevious.Length) : null; var saveresult = ConfigData.SaveRawMhd(serializer, ps, psFn, lastSaveResult); toWrite.Add(new FHash( fullname: ps.FullName, archetype: ps.ATClass, hash: saveresult.Hash, length: saveresult.Length )); } ConfigData.SaveRawMhd(serializer, toWrite, metadataPath, null); } public static void SaveMainDatabase(ISerialize serializer) { string path = Files.SelectDataFileSave(Files.MxdbFileDB); //SaveMainDbRaw(serializer, path, MainDbName); FileStream fileStream; BinaryWriter writer; try { fileStream = new FileStream(path, FileMode.Create); writer = new BinaryWriter(fileStream); } catch (Exception ex) { MessageBox.Show("Main db save failed: " + ex.Message); return; } try { writer.Write(MainDbName); writer.Write(Database.Version); writer.Write(-1); writer.Write(Database.Date.ToBinary()); writer.Write(Database.Issue); writer.Write("BEGIN:ARCHETYPES"); Database.ArchetypeVersion.StoreTo(writer); writer.Write(Database.Classes.Length - 1); for (int index = 0; index <= (Database.Classes.Length - 1); ++index) { Database.Classes[index].StoreTo(ref writer); } /*foreach (var index in Database.Classes) index.StoreTo(ref writer);*/ writer.Write("BEGIN:POWERSETS"); Database.PowersetVersion.StoreTo(writer); writer.Write(Database.Powersets.Length - 1); for (int index = 0; index <= (Database.Powersets.Length - 1); ++index) { Database.Powersets[index].StoreTo(ref writer); } writer.Write("BEGIN:POWERS"); Database.PowerVersion.StoreTo(writer); Database.PowerLevelVersion.StoreTo(writer); Database.PowerEffectVersion.StoreTo(writer); Database.IOAssignmentVersion.StoreTo(writer); writer.Write(Database.Power.Length - 1); for (int index = 0; index <= (Database.Power.Length - 1); ++index) { Database.Power[index].StoreTo(ref writer); } /*foreach (var index in Database.Power) index.StoreTo(ref writer);*/ writer.Write("BEGIN:SUMMONS"); Database.StoreEntities(writer); writer.Close(); fileStream.Close(); } catch (Exception ex) { MessageBox.Show($"Message: {ex.Message}\r\nTrace: {ex.StackTrace}"); writer.Close(); fileStream.Close(); } } public static bool LoadMainDatabase() { ClearLookups(); string path = Files.SelectDataFileLoad(Files.MxdbFileDB); FileStream fileStream; BinaryReader reader; try { fileStream = new FileStream(path, FileMode.Open, FileAccess.Read); reader = new BinaryReader(fileStream); } catch { return false; } try { if (reader.ReadString() != "Mids' Hero Designer Database MK II") { MessageBox.Show("Expected MHD header, got something else!", "Eeeeee!"); } Database.Version = reader.ReadSingle(); int year = reader.ReadInt32(); if (year > 0) { int month = reader.ReadInt32(); int day = reader.ReadInt32(); Database.Date = new DateTime(year, month, day); } else Database.Date = DateTime.FromBinary(reader.ReadInt64()); Database.Issue = reader.ReadInt32(); if (reader.ReadString() != "BEGIN:ARCHETYPES") { MessageBox.Show("Expected Archetype Data, got something else!", "Eeeeee!"); reader.Close(); fileStream.Close(); return false; } Database.ArchetypeVersion.Load(reader); Database.Classes = new Archetype[reader.ReadInt32() + 1]; for (int index = 0; index < Database.Classes.Length; ++index) Database.Classes[index] = new Archetype(reader) { Idx = index }; if (reader.ReadString() != "BEGIN:POWERSETS") { MessageBox.Show("Expected Powerset Data, got something else!", "Eeeeee!"); reader.Close(); fileStream.Close(); return false; } Database.PowersetVersion.Load(reader); int num3 = 0; Database.Powersets = new IPowerset[reader.ReadInt32() + 1]; for (int index = 0; index < Database.Powersets.Length; ++index) { Database.Powersets[index] = new Powerset(reader) { nID = index }; ++num3; if (num3 <= 10) continue; num3 = 0; Application.DoEvents(); } if (reader.ReadString() != "BEGIN:POWERS") { MessageBox.Show("Expected Power Data, got something else!", "Eeeeee!"); reader.Close(); fileStream.Close(); return false; } Database.PowerVersion.Load(reader); Database.PowerLevelVersion.Load(reader); Database.PowerEffectVersion.Load(reader); Database.IOAssignmentVersion.Load(reader); Database.Power = new IPower[reader.ReadInt32() + 1]; for (int index = 0; index <= Database.Power.Length - 1; ++index) { Database.Power[index] = new Power(reader); ++num3; if (num3 <= 50) continue; num3 = 0; Application.DoEvents(); } if (reader.ReadString() != "BEGIN:SUMMONS") { MessageBox.Show("Expected Summon Data, got something else!", "Eeeeee!"); reader.Close(); fileStream.Close(); return false; } Database.LoadEntities(reader); reader.Close(); fileStream.Close(); } catch { reader.Close(); fileStream.Close(); return false; } return true; } public static void LoadDatabaseVersion() { var target = Files.SelectDataFileLoad("I12.mhd"); Database.Version = GetDatabaseVersion(target); } static float GetDatabaseVersion(string fp) { var fName = Debugger.IsAttached ? Files.SearchUp("Data", fp) : fp; float num1 = -1f; float num2; if (!File.Exists(fName)) { num2 = num1; } else { using (FileStream fileStream = new FileStream(fName, FileMode.Open, FileAccess.Read)) { using (BinaryReader binaryReader = new BinaryReader(fileStream)) { try { if (binaryReader.ReadString() != "Mids' Hero Designer Database MK II") { MessageBox.Show("Expected MHD header, got something else!"); } num1 = binaryReader.ReadSingle(); } catch (Exception ex) { MessageBox.Show($"Message: {ex.Message}\r\nTrace: {ex.StackTrace}"); num1 = -1f; } binaryReader.Close(); } fileStream.Close(); } num2 = num1; } return num2; } public static bool LoadLevelsDatabase() { string path = Files.SelectDataFileLoad("Levels.mhd"); Database.Levels = new LevelMap[0]; StreamReader iStream; try { iStream = new StreamReader(path); } catch (Exception ex) { MessageBox.Show($"Message: {ex.Message}\r\nTrace: {ex.StackTrace}", "Error!"); return false; } string[] strArray = FileIO.IOGrab(iStream); while (strArray[0] != "Level") strArray = FileIO.IOGrab(iStream); Database.Levels = new LevelMap[50]; for (int index = 0; index < 50; ++index) Database.Levels[index] = new LevelMap(FileIO.IOGrab(iStream)); List intList = new List { 0 }; for (int index = 0; index <= Database.Levels.Length - 1; ++index) { if (Database.Levels[index].Powers > 0) intList.Add(index); } Database.Levels_MainPowers = intList.ToArray(); iStream.Close(); return true; } public static void LoadOrigins() { string path = Files.SelectDataFileLoad("Origins.mhd"); Database.Origins = new List(); StreamReader streamReader; try { streamReader = new StreamReader(path); } catch (Exception ex) { MessageBox.Show($"Message: {ex.Message}\r\nTrace: {ex.StackTrace}", "Error!"); return; } try { if (string.IsNullOrEmpty(FileIO.IOSeekReturn(streamReader, "Version:"))) throw new EndOfStreamException("Unable to load Enhancement Class data, version header not found!"); if (!FileIO.IOSeek(streamReader, "Origin")) throw new EndOfStreamException("Unable to load Origin data, section header not found!"); string[] strArray; do { strArray = FileIO.IOGrab(streamReader); if (strArray[0] != "End") Database.Origins.Add(new Origin(strArray[0], strArray[1], strArray[2])); else break; } while (strArray[0] != "End"); } catch (Exception ex) { MessageBox.Show($"Message: {ex.Message}\r\nTrace: {ex.StackTrace}"); streamReader.Close(); return; } streamReader.Close(); } public static int GetOriginIDByName(string iOrigin) { for (int index = 0; index <= Database.Origins.Count - 1; ++index) { if (string.Equals(iOrigin, Database.Origins[index].Name, StringComparison.OrdinalIgnoreCase)) return index; } return 0; } public static int IsSpecialEnh(int enhID) { for (int index = 0; index < Database.EnhancementSets[Database.Enhancements[enhID].nIDSet].Enhancements.Length; ++index) { if (enhID == Database.EnhancementSets[Database.Enhancements[enhID].nIDSet].Enhancements[index] && Database.EnhancementSets[Database.Enhancements[enhID].nIDSet].SpecialBonus[index].Index.Length > 0) return index; } return -1; } public static string GetEnhancementNameShortWSet(int iEnh) { string str; if (iEnh < 0 || iEnh > Database.Enhancements.Length - 1) { str = string.Empty; } else { switch (Database.Enhancements[iEnh].TypeID) { case Enums.eType.Normal: case Enums.eType.SpecialO: str = Database.Enhancements[iEnh].ShortName; break; case Enums.eType.InventO: str = "Invention: " + Database.Enhancements[iEnh].ShortName; break; case Enums.eType.SetO: str = Database.EnhancementSets[Database.Enhancements[iEnh].nIDSet].DisplayName + ": " + Database.Enhancements[iEnh].ShortName; break; default: str = string.Empty; break; } } return str; } public static int GetFirstValidEnhancement(int iClass) { for (int index1 = 0; index1 <= Database.Enhancements.Length - 1; ++index1) { for (int index2 = 0; index2 <= Database.Enhancements[index1].ClassID.Length - 1; ++index2) { if (Database.EnhancementClasses[Database.Enhancements[index1].ClassID[index2]].ID == iClass) return index1; } } return -1; } public static void GuessRecipes() { foreach (IEnhancement enhancement in Database.Enhancements) { if (enhancement.TypeID != Enums.eType.InventO && enhancement.TypeID != Enums.eType.SetO) continue; int recipeIdxByName = GetRecipeIdxByName(enhancement.UID); if (recipeIdxByName <= -1) continue; enhancement.RecipeIDX = recipeIdxByName; enhancement.RecipeName = Database.Recipes[recipeIdxByName].InternalName; } } public static void AssignRecipeSalvageIDs() { int[] numArray = new int[7]; string[] strArray = new string[7]; foreach (Recipe recipe in Database.Recipes) { foreach (Recipe.RecipeEntry recipeEntry in recipe.Item) { for (int index1 = 0; index1 <= recipeEntry.Salvage.Length - 1; ++index1) { if (recipeEntry.Salvage[index1] == strArray[index1]) { recipeEntry.SalvageIdx[index1] = numArray[index1]; } else { recipeEntry.SalvageIdx[index1] = -1; string a = recipeEntry.Salvage[index1]; for (int index2 = 0; index2 <= Database.Salvage.Length - 1; ++index2) { if (!string.Equals(a, Database.Salvage[index2].InternalName, StringComparison.OrdinalIgnoreCase)) continue; recipeEntry.SalvageIdx[index1] = index2; numArray[index1] = index2; strArray[index1] = recipeEntry.Salvage[index1]; break; } } } } } } public static void AssignRecipeIDs() { foreach (Recipe recipe in Database.Recipes) { recipe.Enhancement = string.Empty; recipe.EnhIdx = -1; } for (int index1 = 0; index1 <= Database.Enhancements.Length - 1; ++index1) { if (string.IsNullOrEmpty(Database.Enhancements[index1].RecipeName)) continue; Database.Enhancements[index1].RecipeIDX = -1; string recipeName = Database.Enhancements[index1].RecipeName; for (int index2 = 0; index2 <= Database.Recipes.Length - 1; ++index2) { if (!recipeName.Equals(Database.Recipes[index2].InternalName, StringComparison.OrdinalIgnoreCase)) continue; Database.Recipes[index2].Enhancement = Database.Enhancements[index1].UID; Database.Recipes[index2].EnhIdx = index1; Database.Enhancements[index1].RecipeIDX = index2; break; } } } public static void LoadRecipes() { string path = Files.SelectDataFileLoad("Recipe.mhd"); Database.Recipes = new Recipe[0]; FileStream fileStream; BinaryReader reader; try { fileStream = new FileStream(path, FileMode.Open, FileAccess.Read); reader = new BinaryReader(fileStream); } catch (Exception ex) { MessageBox.Show(ex.Message + "\n\nRecipe database couldn't be loaded."); return; } if (reader.ReadString() == "Mids' Hero Designer Recipe Database") { Database.RecipeSource1 = reader.ReadString(); Database.RecipeSource2 = reader.ReadString(); Database.RecipeRevisionDate = DateTime.FromBinary(reader.ReadInt64()); int num = 0; Database.Recipes = new Recipe[reader.ReadInt32() + 1]; for (int index = 0; index < Database.Recipes.Length; ++index) { Database.Recipes[index] = new Recipe(reader); ++num; if (num <= 100) continue; num = 0; Application.DoEvents(); } } else { MessageBox.Show("Recipe Database header wasn't found, file may be corrupt!"); reader.Close(); fileStream.Close(); } } const string RecipeName = "Mids' Hero Designer Recipe Database"; static void SaveRecipesRaw(ISerialize serializer, string fn, string name) { var toSerialize = new { name, Database.RecipeSource1, Database.RecipeSource2, Database.RecipeRevisionDate, Database.Recipes }; ConfigData.SaveRawMhd(serializer, toSerialize, fn, null); } public static void SaveRecipes(ISerialize serializer) { string path = Files.SelectDataFileSave("Recipe.mhd"); SaveRecipesRaw(serializer, path, RecipeName); FileStream fileStream; BinaryWriter writer; try { fileStream = new FileStream(path, FileMode.Create); writer = new BinaryWriter(fileStream); } catch (Exception ex) { MessageBox.Show($"Message: {ex.Message}\r\nTrace: {ex.StackTrace}"); return; } try { writer.Write(RecipeName); writer.Write(Database.RecipeSource1); writer.Write(Database.RecipeSource2); writer.Write(Database.RecipeRevisionDate.ToBinary()); writer.Write(Database.Recipes.Length - 1); for (int index = 0; index <= Database.Recipes.Length - 1; ++index) Database.Recipes[index].StoreTo(writer); writer.Close(); fileStream.Close(); } catch (Exception ex) { MessageBox.Show($"Message: {ex.Message}\r\nTrace: {ex.StackTrace}"); writer.Close(); fileStream.Close(); } } public static void LoadSalvage() { string path = Files.SelectDataFileLoad("Salvage.mhd"); Database.Salvage = new Salvage[0]; FileStream fileStream; BinaryReader reader; try { fileStream = new FileStream(path, FileMode.Open, FileAccess.Read); reader = new BinaryReader(fileStream); } catch (Exception ex) { MessageBox.Show(ex.Message + "\n\nSalvage database couldn't be loaded."); return; } try { if (reader.ReadString() != "Mids' Hero Designer Salvage Database") { MessageBox.Show("Salvage Database header wasn't found, file may be corrupt!"); reader.Close(); fileStream.Close(); } else { Database.Salvage = new Salvage[reader.ReadInt32() + 1]; for (int index = 0; index < Database.Salvage.Length; ++index) Database.Salvage[index] = new Salvage(reader); } } catch (Exception ex) { MessageBox.Show("Salvage Database file isn't how it should be (" + ex.Message + ")\nNo salvage loaded."); Database.Salvage = new Salvage[0]; reader.Close(); fileStream.Close(); } } static void SaveSalvageRaw(ISerialize serializer, string fn, string name) { var toSerialize = new { name, Database.Salvage }; ConfigData.SaveRawMhd(serializer, toSerialize, fn, null); } const string SalvageName = "Mids' Hero Designer Salvage Database"; public static void SaveSalvage(ISerialize serializer) { string path = Files.SelectDataFileSave("Salvage.mhd"); SaveSalvageRaw(serializer, path, SalvageName); FileStream fileStream; BinaryWriter writer; try { fileStream = new FileStream(path, FileMode.Create); writer = new BinaryWriter(fileStream); } catch (Exception ex) { MessageBox.Show($"Message: {ex.Message}\r\nTrace: {ex.StackTrace}"); return; } try { writer.Write(SalvageName); writer.Write(Database.Salvage.Length - 1); for (int index = 0; index <= Database.Salvage.Length - 1; ++index) Database.Salvage[index].StoreTo(writer); writer.Close(); fileStream.Close(); } catch (Exception ex) { MessageBox.Show($"Message: {ex.Message}\r\nTrace: {ex.StackTrace}"); writer.Close(); fileStream.Close(); } } const string EnhancementDbName = "Mids' Hero Designer Enhancement Database"; static void SaveEnhancementDbRaw(ISerialize serializer, string filename, string name) { var toSerialize = new { name, Database.VersionEnhDb, Database.Enhancements, Database.EnhancementSets }; ConfigData.SaveRawMhd(serializer, toSerialize, filename, null); } public static void SaveEnhancementDb(ISerialize serializer) { string path = Files.SelectDataFileSave(Files.MxdbFileEnhDB); SaveEnhancementDbRaw(serializer, path, EnhancementDbName); FileStream fileStream; BinaryWriter writer; try { fileStream = new FileStream(path, FileMode.Create); writer = new BinaryWriter(fileStream); } catch (Exception ex) { MessageBox.Show($"Message: {ex.Message}\r\nTrace: {ex.StackTrace}"); return; } try { writer.Write(EnhancementDbName); writer.Write(Database.VersionEnhDb); writer.Write(Database.Enhancements.Length - 1); for (int index = 0; index <= Database.Enhancements.Length - 1; ++index) Database.Enhancements[index].StoreTo(writer); writer.Write(Database.EnhancementSets.Count - 1); for (int index = 0; index <= Database.EnhancementSets.Count - 1; ++index) Database.EnhancementSets[index].StoreTo(writer); writer.Close(); fileStream.Close(); } catch (Exception ex) { MessageBox.Show($"Message: {ex.Message}\r\nTrace: {ex.StackTrace}"); writer.Close(); fileStream.Close(); } } public static void LoadEnhancementDb() { string path = Files.SelectDataFileLoad("EnhDB.mhd"); Database.Enhancements = new IEnhancement[0]; FileStream fileStream; BinaryReader reader; try { fileStream = new FileStream(path, FileMode.Open, FileAccess.Read); reader = new BinaryReader(fileStream); } catch (Exception ex) { MessageBox.Show(ex.Message + "\n\nNo Enhancements have been loaded.", "EnhDB Load Failed"); return; } try { if (reader.ReadString() != "Mids' Hero Designer Enhancement Database") { MessageBox.Show("Enhancement Database header wasn't found, file may be corrupt!", "Meep!"); reader.Close(); fileStream.Close(); } else { reader.ReadSingle(); float versionEnhDb = Database.VersionEnhDb; int num1 = 0; Database.Enhancements = new IEnhancement[reader.ReadInt32() + 1]; for (int index = 0; index < Database.Enhancements.Length; ++index) { Database.Enhancements[index] = new Enhancement(reader); ++num1; if (num1 <= 5) continue; num1 = 0; Application.DoEvents(); } Database.EnhancementSets = new EnhancementSetCollection(); int num2 = reader.ReadInt32() + 1; for (int index = 0; index < num2; ++index) { Database.EnhancementSets.Add(new EnhancementSet(reader)); ++num1; if (num1 <= 5) continue; num1 = 0; Application.DoEvents(); } reader.Close(); fileStream.Close(); } } catch (Exception ex) { MessageBox.Show("Enhancement Database file isn't how it should be (" + ex.Message + ")\nNo Enhancements have been loaded.", "Huh..."); Database.Enhancements = new IEnhancement[0]; reader.Close(); fileStream.Close(); } } public static bool LoadEnhancementClasses() { using (StreamReader streamReader = new StreamReader(Files.SelectDataFileLoad(Files.MxdbFileEClasses))) { Database.EnhancementClasses = new Enums.sEnhClass[0]; try { if (string.IsNullOrEmpty(FileIO.IOSeekReturn(streamReader, "Version:"))) throw new EndOfStreamException("Unable to load Enhancement Class data, version header not found!"); if (!FileIO.IOSeek(streamReader, "Index")) throw new EndOfStreamException("Unable to load Enhancement Class data, section header not found!"); Enums.sEnhClass[] enhancementClasses = Database.EnhancementClasses; string[] strArray; do { strArray = FileIO.IOGrab(streamReader); if (strArray[0] != "End") { Array.Resize(ref enhancementClasses, enhancementClasses.Length + 1); enhancementClasses[enhancementClasses.Length - 1].ID = int.Parse(strArray[0]); enhancementClasses[enhancementClasses.Length - 1].Name = strArray[1]; enhancementClasses[enhancementClasses.Length - 1].ShortName = strArray[2]; enhancementClasses[enhancementClasses.Length - 1].ClassID = strArray[3]; enhancementClasses[enhancementClasses.Length - 1].Desc = strArray[4]; } else break; } while (strArray[0] != "End"); Database.EnhancementClasses = enhancementClasses; Application.DoEvents(); } catch (Exception ex) { MessageBox.Show($"Message: {ex.Message}\r\nTrace: {ex.StackTrace}"); streamReader.Close(); return false; } streamReader.Close(); } return true; } public static void LoadSetTypeStrings() { string path = Files.SelectDataFileLoad(Files.MxdbFileSetTypes); Database.SetTypeStringLong = new string[0]; Database.SetTypeStringShort = new string[0]; StreamReader streamReader; try { streamReader = new StreamReader(path); } catch (Exception ex) { MessageBox.Show($"Message: {ex.Message}\r\nTrace: {ex.StackTrace}"); return; } try { if (string.IsNullOrEmpty(FileIO.IOSeekReturn(streamReader, "Version:"))) throw new EndOfStreamException("Unable to load SetType data, version header not found!"); if (!FileIO.IOSeek(streamReader, "SetID")) throw new EndOfStreamException("Unable to load SetType data, section header not found!"); string[] setTypeStringLong = Database.SetTypeStringLong; string[] setTypeStringShort = Database.SetTypeStringShort; string[] strArray; do { strArray = FileIO.IOGrab(streamReader); if (strArray[0] != "End") { Array.Resize(ref setTypeStringLong, setTypeStringLong.Length + 1); Array.Resize(ref setTypeStringShort, setTypeStringShort.Length + 1); setTypeStringShort[setTypeStringShort.Length - 1] = strArray[1]; setTypeStringLong[setTypeStringLong.Length - 1] = strArray[2]; } else break; } while (strArray[0] != "End"); Database.SetTypeStringLong = setTypeStringLong; Database.SetTypeStringShort = setTypeStringShort; Database.EnhGradeStringLong = new string[4]; Database.EnhGradeStringShort = new string[4]; Database.EnhGradeStringLong[0] = "None"; Database.EnhGradeStringLong[1] = "Training Origin"; Database.EnhGradeStringLong[2] = "Dual Origin"; Database.EnhGradeStringLong[3] = "Single Origin"; Database.EnhGradeStringShort[0] = "None"; Database.EnhGradeStringShort[1] = "TO"; Database.EnhGradeStringShort[2] = "DO"; Database.EnhGradeStringShort[3] = "SO"; Database.SpecialEnhStringLong = new string[5]; Database.SpecialEnhStringShort = new string[5]; Database.SpecialEnhStringLong[0] = "None"; Database.SpecialEnhStringLong[1] = "Hamidon Origin"; Database.SpecialEnhStringLong[2] = "Hydra Origin"; Database.SpecialEnhStringLong[3] = "Titan Origin"; Database.SpecialEnhStringLong[4] = "Yin's Talisman"; Database.SpecialEnhStringShort[0] = "None"; Database.SpecialEnhStringShort[1] = "HO"; Database.SpecialEnhStringShort[2] = "TnO"; Database.SpecialEnhStringShort[3] = "HyO"; Database.SpecialEnhStringShort[4] = "YinO"; } catch (Exception ex) { MessageBox.Show($"Message: {ex.Message}\r\nTrace: {ex.StackTrace}"); streamReader.Close(); return; } streamReader.Close(); } public static bool LoadMaths() { string path = Files.SelectDataFileLoad(Files.MxdbFileMaths); StreamReader streamReader; try { streamReader = new StreamReader(path); } catch (Exception ex) { MessageBox.Show($"Message: {ex.Message}\r\nTrace: {ex.StackTrace}"); return false; } try { if (string.IsNullOrEmpty(FileIO.IOSeekReturn(streamReader, "Version:"))) throw new EndOfStreamException("Unable to load Enhancement Maths data, version header not found!"); if (!FileIO.IOSeek(streamReader, "EDRT")) throw new EndOfStreamException("Unable to load Maths data, section header not found!"); Database.MultED = new float[4][]; for (int index = 0; index < 4; ++index) Database.MultED[index] = new float[3]; for (int index1 = 0; index1 <= 2; ++index1) { string[] strArray = FileIO.IOGrab(streamReader); for (int index2 = 0; index2 < 4; ++index2) Database.MultED[index2][index1] = float.Parse(strArray[index2 + 1]); } if (!FileIO.IOSeek(streamReader, "EGE")) throw new EndOfStreamException("Unable to load Maths data, section header not found!"); Database.MultTO = new float[1][]; Database.MultDO = new float[1][]; Database.MultSO = new float[1][]; Database.MultHO = new float[1][]; string[] strArray1 = FileIO.IOGrab(streamReader); Database.MultTO[0] = new float[4]; for (int index = 0; index < 4; ++index) Database.MultTO[0][index] = float.Parse(strArray1[index + 1]); string[] strArray2 = FileIO.IOGrab(streamReader); Database.MultDO[0] = new float[4]; for (int index = 0; index < 4; ++index) Database.MultDO[0][index] = float.Parse(strArray2[index + 1]); string[] strArray3 = FileIO.IOGrab(streamReader); Database.MultSO[0] = new float[4]; for (int index = 0; index < 4; ++index) Database.MultSO[0][index] = float.Parse(strArray3[index + 1]); string[] strArray4 = FileIO.IOGrab(streamReader); Database.MultHO[0] = new float[4]; for (int index = 0; index < 4; ++index) Database.MultHO[0][index] = float.Parse(strArray4[index + 1]); if (!FileIO.IOSeek(streamReader, "LBIOE")) throw new EndOfStreamException("Unable to load Maths data, section header not found!"); Database.MultIO = new float[53][]; for (int index1 = 0; index1 < 53; ++index1) { string[] strArray5 = FileIO.IOGrab(streamReader); Database.MultIO[index1] = new float[4]; for (int index2 = 0; index2 < 4; ++index2) Database.MultIO[index1][index2] = float.Parse(strArray5[index2 + 1]); } } catch (Exception ex) { MessageBox.Show($"Message: {ex.Message}\r\nTrace: {ex.StackTrace}"); streamReader.Close(); return false; } streamReader.Close(); return true; } public static void AssignSetBonusIndexes() { foreach (EnhancementSet enhancementSet in Database.EnhancementSets) { foreach (EnhancementSet.BonusItem bonu in enhancementSet.Bonus) { for (int index = 0; index < bonu.Index.Length; ++index) bonu.Index[index] = NidFromUidPower(bonu.Name[index]); } foreach (EnhancementSet.BonusItem specialBonu in enhancementSet.SpecialBonus) { for (int index = 0; index <= specialBonu.Index.Length - 1; ++index) specialBonu.Index[index] = NidFromUidPower(specialBonu.Name[index]); } } } public static float GetModifier(IEffect iEffect) { int iClass = 0; int iLevel = MidsContext.MathLevelBase; var effPower = iEffect.GetPower(); if (effPower == null) { if (iEffect.Enhancement == null) return 1f; } else iClass = string.IsNullOrEmpty(effPower.ForcedClass) ? (iEffect.Absorbed_Class_nID <= -1 ? MidsContext.Archetype.Idx : iEffect.Absorbed_Class_nID) : NidFromUidClass(effPower.ForcedClass); if (MidsContext.MathLevelExemp > -1 && MidsContext.MathLevelExemp < MidsContext.MathLevelBase) iLevel = MidsContext.MathLevelExemp; return GetModifier(iClass, iEffect.nModifierTable, iLevel); } static float GetModifier(int iClass, int iTable, int iLevel) { float num; if (iClass < 0) num = 0.0f; else if (iTable < 0) num = 0.0f; else if (iLevel < 0) num = 0.0f; else if (iClass > Database.Classes.Length - 1) { num = 0.0f; } else { iClass = Database.Classes[iClass].Column; num = iClass >= 0 ? (iTable <= Database.AttribMods.Modifier.Length - 1 ? (iLevel <= Database.AttribMods.Modifier[iTable].Table.Length - 1 ? (iClass <= Database.AttribMods.Modifier[iTable].Table[iLevel].Length - 1 ? Database.AttribMods.Modifier[iTable].Table[iLevel][iClass] : 0.0f) : 0.0f) : 0.0f) : 0.0f; } return num; } public static void MatchAllIDs(IMessager iFrm = null) { UpdateMessage(iFrm, "Matching Group IDs..."); FillGroupArray(); UpdateMessage(iFrm, "Matching Class IDs..."); MatchArchetypeIDs(); UpdateMessage(iFrm, "Matching Powerset IDs..."); MatchPowersetIDs(); UpdateMessage(iFrm, "Matching Power IDs..."); MatchPowerIDs(); UpdateMessage(iFrm, "Propagating Group IDs..."); SetPowersetsFromGroups(); UpdateMessage(iFrm, "Matching Enhancement IDs..."); MatchEnhancementIDs(); UpdateMessage(iFrm, "Matching Modifier IDs..."); MatchModifierIDs(); UpdateMessage(iFrm, "Matching Entity IDs..."); MatchSummonIDs(); TestNewCode(); } static void UpdateMessage(IMessager iFrm, string iMsg) { iFrm?.SetMessage(iMsg); } static void MatchArchetypeIDs() { for (int index = 0; index <= Database.Classes.Length - 1; ++index) { Database.Classes[index].Idx = index; Array.Sort(Database.Classes[index].Origin); Database.Classes[index].Primary = new int[0]; Database.Classes[index].Secondary = new int[0]; Database.Classes[index].Ancillary = new int[0]; } } static void MatchPowersetIDs() { for (int index1 = 0; index1 <= Database.Powersets.Length - 1; ++index1) { IPowerset powerset = Database.Powersets[index1]; powerset.nID = index1; powerset.nArchetype = NidFromUidClass(powerset.ATClass); powerset.nIDTrunkSet = string.IsNullOrEmpty(powerset.UIDTrunkSet) ? -1 : NidFromUidPowerset(powerset.UIDTrunkSet); powerset.nIDLinkSecondary = string.IsNullOrEmpty(powerset.UIDLinkSecondary) ? -1 : NidFromUidPowerset(powerset.UIDLinkSecondary); if (powerset.UIDMutexSets.Length > 0) { powerset.nIDMutexSets = new int[powerset.UIDMutexSets.Length]; for (int index2 = 0; index2 < powerset.UIDMutexSets.Length; ++index2) powerset.nIDMutexSets[index2] = NidFromUidPowerset(powerset.UIDMutexSets[index2]); } powerset.Power = new int[0]; powerset.Powers = new IPower[0]; } } static void MatchPowerIDs() { Database.MutexList = UidMutexAll(); for (int index = 0; index < Database.Power.Length; ++index) { IPower power1 = Database.Power[index]; if (string.IsNullOrEmpty(power1.FullName)) power1.FullName = "Orphan." + power1.DisplayName.Replace(" ", "_"); power1.PowerIndex = index; power1.PowerSetID = NidFromUidPowerset(power1.FullSetName); if (power1.PowerSetID <= -1) continue; var ps = power1.GetPowerSet(); int length = ps.Powers.Length; power1.PowerSetIndex = length; int[] power2 = ps.Power; Array.Resize(ref power2, length + 1); ps.Power = power2; IPower[] powers = ps.Powers; Array.Resize(ref powers, length + 1); ps.Powers = powers; ps.Power[length] = index; ps.Powers[length] = power1; } foreach (IPower power in Database.Power) { bool flag = false; if (power.GetPowerSet().SetType == Enums.ePowerSetType.SetBonus) { flag = power.PowerName.Contains("Slow"); if (flag) { power.BuffMode = Enums.eBuffMode.Debuff; foreach (var index in power.Effects) index.buffMode = Enums.eBuffMode.Debuff; } } foreach (IEffect effect in power.Effects) { if (flag) effect.buffMode = Enums.eBuffMode.Debuff; switch (effect.EffectType) { case Enums.eEffectType.GrantPower: effect.nSummon = NidFromUidPower(effect.Summon); power.HasGrantPowerEffect = true; break; case Enums.eEffectType.EntCreate: effect.nSummon = NidFromUidEntity(effect.Summon); break; case Enums.eEffectType.PowerRedirect: effect.nSummon = NidFromUidPower(effect.Override); power.HasPowerOverrideEffect = true; break; } } power.NGroupMembership = new int[power.GroupMembership.Length]; for (int index1 = 0; index1 < power.GroupMembership.Length; ++index1) { for (int index2 = 0; index2 < Database.MutexList.Length; ++index2) { if (!string.Equals(Database.MutexList[index2], power.GroupMembership[index1], StringComparison.OrdinalIgnoreCase)) continue; power.NGroupMembership[index1] = index2; break; } } power.NIDSubPower = new int[power.UIDSubPower.Length]; for (int index = 0; index < power.UIDSubPower.Length; ++index) power.NIDSubPower[index] = NidFromUidPower(power.UIDSubPower[index]); MatchRequirementId(power); } } static void MatchRequirementId(IPower power) { if (power.Requires.ClassName.Length > 0) { power.Requires.NClassName = new int[power.Requires.ClassName.Length]; for (int index = 0; index < power.Requires.ClassName.Length; ++index) power.Requires.NClassName[index] = NidFromUidClass(power.Requires.ClassName[index]); } if (power.Requires.ClassNameNot.Length > 0) { power.Requires.NClassNameNot = new int[power.Requires.ClassNameNot.Length]; for (int index = 0; index < power.Requires.ClassNameNot.Length; ++index) power.Requires.NClassNameNot[index] = NidFromUidClass(power.Requires.ClassNameNot[index]); } if (power.Requires.PowerID.Length > 0) { power.Requires.NPowerID = new int[power.Requires.PowerID.Length][]; for (int index1 = 0; index1 < power.Requires.PowerID.Length; ++index1) { power.Requires.NPowerID[index1] = new int[power.Requires.PowerID[index1].Length]; for (int index2 = 0; index2 < power.Requires.PowerID[index1].Length; ++index2) power.Requires.NPowerID[index1][index2] = !string.IsNullOrEmpty(power.Requires.PowerID[index1][index2]) ? NidFromUidPower(power.Requires.PowerID[index1][index2]) : -1; } } if (power.Requires.PowerIDNot.Length <= 0) return; power.Requires.NPowerIDNot = new int[power.Requires.PowerIDNot.Length][]; for (int index1 = 0; index1 < power.Requires.PowerIDNot.Length; ++index1) { power.Requires.NPowerIDNot[index1] = new int[power.Requires.PowerIDNot[index1].Length]; for (int index2 = 0; index2 < power.Requires.PowerIDNot[index1].Length; ++index2) power.Requires.NPowerIDNot[index1][index2] = !string.IsNullOrEmpty(power.Requires.PowerIDNot[index1][index2]) ? NidFromUidPower(power.Requires.PowerIDNot[index1][index2]) : -1; } } static void SetPowersetsFromGroups() { for (int index1 = 0; index1 < Database.Classes.Length; ++index1) { Archetype archetype = Database.Classes[index1]; List intList1 = new List(); List intList2 = new List(); List intList3 = new List(); for (int index2 = 0; index2 < Database.Powersets.Length; ++index2) { IPowerset powerset = Database.Powersets[index2]; if (powerset.Powers.Length > 0) powerset.Powers[0].SortOverride = true; if (string.Equals(powerset.GroupName, archetype.PrimaryGroup, StringComparison.OrdinalIgnoreCase)) { intList1.Add(index2); if (powerset.nArchetype < 0) powerset.nArchetype = index1; } if (string.Equals(powerset.GroupName, archetype.SecondaryGroup, StringComparison.OrdinalIgnoreCase)) { intList2.Add(index2); if (powerset.nArchetype < 0) powerset.nArchetype = index1; } if (string.Equals(powerset.GroupName, archetype.EpicGroup, StringComparison.OrdinalIgnoreCase) && (powerset.nArchetype == index1 || powerset.Powers.Length > 0 && powerset.Powers[0].Requires.ClassOk(archetype.ClassName))) intList3.Add(index2); } archetype.Primary = intList1.ToArray(); archetype.Secondary = intList2.ToArray(); archetype.Ancillary = intList3.ToArray(); } } public static void MatchEnhancementIDs() { for (int index1 = 0; index1 <= Database.Power.Length - 1; ++index1) { List intList = new List(); for (int index2 = 0; index2 <= Database.Power[index1].BoostsAllowed.Length - 1; ++index2) { int index3 = EnhancementClassIdFromName(Database.Power[index1].BoostsAllowed[index2]); if (index3 > -1) intList.Add(Database.EnhancementClasses[index3].ID); } if (Database.Power[index1].Enhancements != null) { //do nothing } else { Database.Power[index1].Enhancements = intList.ToArray(); } } for (int index = 0; index <= Database.EnhancementSets.Count - 1; ++index) Database.EnhancementSets[index].Enhancements = new int[0]; bool flag = false; string str = string.Empty; for (int index1 = 0; index1 <= Database.Enhancements.Length - 1; ++index1) { IEnhancement enhancement = Database.Enhancements[index1]; if (enhancement.TypeID != Enums.eType.SetO || string.IsNullOrEmpty(enhancement.UIDSet)) continue; int index2 = NidFromUidioSet(enhancement.UIDSet); if (index2 > -1) { enhancement.nIDSet = index2; Array.Resize(ref Database.EnhancementSets[index2].Enhancements, Database.EnhancementSets[index2].Enhancements.Length + 1); Database.EnhancementSets[index2].Enhancements[Database.EnhancementSets[index2].Enhancements.Length - 1] = index1; } else { str = str + enhancement.UIDSet + enhancement.Name + "\n"; flag = true; } } if (!flag) return; MessageBox.Show("One or more enhancements had difficulty being matched to their invention set. You should check the database for misplaced Invention Set enhancements.\n" + str, "Mismatch Detected"); } static int EnhancementClassIdFromName(string iName) { int num; if (string.IsNullOrEmpty(iName)) { num = -1; } else { for (int index = 0; index <= Database.EnhancementClasses.Length - 1; ++index) { if (string.Equals(Database.EnhancementClasses[index].ClassID, iName, StringComparison.OrdinalIgnoreCase)) return index; } num = -1; } return num; } static void MatchModifierIDs() { foreach (IPower power in Database.Power) { foreach (IEffect effect in power.Effects) effect.nModifierTable = NidFromUidAttribMod(effect.ModifierTable); } } public static void MatchSummonIDs() => SummonedEntity.MatchSummonIDs(NidFromUidClass, NidFromUidPowerset, NidFromUidPower); public static void AssignStaticIndexValues(ISerialize serializer, bool save) { int lastStaticPowerIdx = -2; for (int index = 0; index <= Database.Power.Length - 1; ++index) { if (Database.Power[index].StaticIndex > -1 && Database.Power[index].StaticIndex > lastStaticPowerIdx) lastStaticPowerIdx = Database.Power[index].StaticIndex; } if (lastStaticPowerIdx < -1) lastStaticPowerIdx = -1; for (int index = 0; index <= Database.Power.Length - 1; ++index) { if (Database.Power[index].StaticIndex >= 0) continue; ++lastStaticPowerIdx; Database.Power[index].StaticIndex = lastStaticPowerIdx; } int lastStaticEnhIdx = -2; for (int index = 1; index <= Database.Enhancements.Length - 1; ++index) { if (Database.Enhancements[index].StaticIndex > -1 && Database.Enhancements[index].StaticIndex > lastStaticEnhIdx) lastStaticEnhIdx = Database.Enhancements[index].StaticIndex; } if (lastStaticEnhIdx < -1) lastStaticEnhIdx = -1; for (int index = 1; index <= Database.Enhancements.Length - 1; ++index) { if (Database.Enhancements[index].StaticIndex >= 1) continue; ++lastStaticEnhIdx; Database.Enhancements[index].StaticIndex = lastStaticEnhIdx; } if (!save) return; SaveMainDatabase(serializer); SaveEnhancementDb(serializer); } // NEW CODE FOR DatabaseAPI.cs public static bool IsKindaSortaEqual(float value1, float value2, float tolerance) { if (value1 > (value2 + tolerance)) return false; return !(value1 < (value2 - tolerance)); } public class AIToon : ICloneable { public Base.Data_Classes.Archetype Archetype; public IPowerset Fitness; public IPowerset Primary; public IPowerset Secondary; public IPowerset Pool1; public IPowerset Pool2; public IPowerset Pool3; public IPowerset Pool4; public IPowerset Epic; public PowerEntry Health; public PowerEntry Stamina; public PowerEntry Level1Primary; public PowerEntry Level1Secondary; public PowerEntry Level2; public PowerEntry Level4; public PowerEntry Level6; public PowerEntry Level8; public PowerEntry Level10; public PowerEntry Level12; public PowerEntry Level14; public PowerEntry Level16; public PowerEntry Level18; public PowerEntry Level20; public PowerEntry Level22; public PowerEntry Level24; public PowerEntry Level26; public PowerEntry Level28; public PowerEntry Level30; public PowerEntry Level32; public PowerEntry Level35; public PowerEntry Level38; public PowerEntry Level41; public PowerEntry Level44; public PowerEntry Level47; public PowerEntry Level49; public object Clone() { AIToon toon = new AIToon(); if (null != Archetype) toon.Archetype = new Archetype(Archetype); if (null != Fitness) toon.Fitness = new Powerset(Fitness); if (null != Primary) toon.Primary = new Powerset(Primary); if (null != Secondary) toon.Secondary = new Powerset(Secondary); if (null != Pool1) toon.Pool1 = new Powerset(Pool1); if (null != Pool2) toon.Pool2 = new Powerset(Pool2); if (null != Pool3) toon.Pool3 = new Powerset(Pool3); if (null != Pool4) toon.Pool4 = new Powerset(Pool4); if (null != Epic) toon.Epic = new Powerset(Epic); if (null != Health) toon.Health = Health.Clone() as PowerEntry; if (null != Stamina) toon.Stamina = Stamina.Clone() as PowerEntry; if (null != Level1Primary) toon.Level1Primary = Level1Primary.Clone() as PowerEntry; if (null != Level1Secondary) toon.Level1Secondary = Level1Secondary.Clone() as PowerEntry; if (null != Level2) toon.Level2 = Level2.Clone() as PowerEntry; if (null != Level4) toon.Level4 = Level4.Clone() as PowerEntry; if (null != Level6) toon.Level6 = Level6.Clone() as PowerEntry; if (null != Level8) toon.Level8 = Level8.Clone() as PowerEntry; if (null != Level10) toon.Level10 = Level10.Clone() as PowerEntry; if (null != Level12) toon.Level12 = Level12.Clone() as PowerEntry; if (null != Level14) toon.Level14 = Level14.Clone() as PowerEntry; if (null != Level16) toon.Level16 = Level16.Clone() as PowerEntry; if (null != Level18) toon.Level18 = Level18.Clone() as PowerEntry; if (null != Level20) toon.Level20 = Level20.Clone() as PowerEntry; if (null != Level22) toon.Level22 = Level22.Clone() as PowerEntry; if (null != Level24) toon.Level24 = Level24.Clone() as PowerEntry; if (null != Level26) toon.Level26 = Level26.Clone() as PowerEntry; if (null != Level28) toon.Level28 = Level28.Clone() as PowerEntry; if (null != Level30) toon.Level30 = Level30.Clone() as PowerEntry; if (null != Level32) toon.Level32 = Level32.Clone() as PowerEntry; if (null != Level35) toon.Level35 = Level35.Clone() as PowerEntry; if (null != Level38) toon.Level38 = Level38.Clone() as PowerEntry; if (null != Level41) toon.Level41 = Level41.Clone() as PowerEntry; if (null != Level44) toon.Level44 = Level44.Clone() as PowerEntry; if (null != Level47) toon.Level47 = Level47.Clone() as PowerEntry; if (null != Level49) toon.Level49 = Level49.Clone() as PowerEntry; return toon; } public List GetPowerEntries() { List powerEntries = new List(); powerEntries.Add(Health); powerEntries.Add(Stamina); powerEntries.Add(Level1Primary); powerEntries.Add(Level1Secondary); powerEntries.Add(Level2); powerEntries.Add(Level4); powerEntries.Add(Level6); powerEntries.Add(Level8); powerEntries.Add(Level10); powerEntries.Add(Level12); powerEntries.Add(Level14); powerEntries.Add(Level16); powerEntries.Add(Level18); powerEntries.Add(Level20); powerEntries.Add(Level22); powerEntries.Add(Level24); powerEntries.Add(Level26); powerEntries.Add(Level28); powerEntries.Add(Level30); powerEntries.Add(Level32); powerEntries.Add(Level35); powerEntries.Add(Level38); powerEntries.Add(Level41); powerEntries.Add(Level44); powerEntries.Add(Level47); powerEntries.Add(Level49); return powerEntries; } public bool SetPowerEntries(List powerEntries) { List originalPowerEntries = GetPowerEntries(); Health = powerEntries[0]; Stamina = powerEntries[1]; Level1Primary = powerEntries[2]; Level1Secondary = powerEntries[3]; Level2 = powerEntries[4]; Level4 = powerEntries[5]; Level6 = powerEntries[6]; Level8 = powerEntries[7]; Level10 = powerEntries[8]; Level12 = powerEntries[9]; Level14 = powerEntries[10]; Level16 = powerEntries[11]; Level18 = powerEntries[12]; Level20 = powerEntries[13]; Level22 = powerEntries[14]; Level24 = powerEntries[15]; Level26 = powerEntries[16]; Level28 = powerEntries[17]; Level30 = powerEntries[18]; Level32 = powerEntries[19]; Level35 = powerEntries[20]; Level38 = powerEntries[21]; Level41 = powerEntries[22]; Level44 = powerEntries[23]; Level47 = powerEntries[24]; Level49 = powerEntries[25]; return true; } public bool IsValid() { return FollowsRuleOfFive(); } public float SumPowerBonuses(Enums.eEffectType effectType, Enums.eDamage damageType = Enums.eDamage.None, bool includePvP = false) { float sum = 0.0f; List powerEntries = GetPowerEntries(); foreach (PowerEntry powerEntry in powerEntries) { sum += SumPowerEntryBonusEffect(powerEntry, effectType, damageType, includePvP); } return sum; } public bool HasEnhancement(IEnhancement enhancement) { List powerEntries = GetPowerEntries(); foreach (PowerEntry powerEntry in powerEntries) { if (HasEnhancement(enhancement, powerEntry)) return true; } return false; } public bool HasEnhancement(IEnhancement enhancement, PowerEntry powerEntry) { return 0 < GetEnhancementCount(enhancement, powerEntry); } public int GetEnhancementCount(IEnhancement enhancement, PowerEntry powerEntry) { int count = 0; foreach (SlotEntry slot in powerEntry.Slots) { if (-1 == slot.Enhancement.Enh) continue; IEnhancement e = GetEnhancementByIndex(slot.Enhancement.Enh); if (null == e) continue; if (enhancement.UIDSet == e.UIDSet && enhancement.Name == e.Name) count++; } return count; } public bool CanAddEnhancement(IEnhancement enhancement, PowerEntry powerEntry) { if (enhancement.Unique && HasEnhancement(enhancement)) return false; if ("" != enhancement.UIDSet && HasEnhancement(enhancement, powerEntry)) return false; if ("" == enhancement.UIDSet && 3 <= GetEnhancementCount(enhancement, powerEntry)) return false; EnhancementTypes[] enhancementTypes = GetEnhancementTypes(enhancement); bool allow = enhancementTypes.Length > 0 ? false : true; foreach (EnhancementTypes enhancementType in enhancementTypes) { if (AllowsEnhancement(powerEntry.Power, enhancementType)) { allow = true; break; } } if (!allow) return false; if (enhancement.UIDSet.StartsWith("Superior")) { EnhancementSet superiorEnhancementSet = GetEnhancementSet(enhancement); if (null != superiorEnhancementSet) { string name = superiorEnhancementSet.DisplayName.Remove(0, 9); EnhancementSet enhancementSet = GetEnhancementSetByIndex(GetEnhancementSetIndexByName(name)); if (null != enhancementSet) { for (int enhancementIndex = 0; enhancementIndex < enhancementSet.Enhancements.Length; enhancementIndex++) { IEnhancement checkEnhancement = GetEnhancementByIndex(enhancementSet.Enhancements[enhancementIndex]); if (null != checkEnhancement && checkEnhancement.Name == enhancement.Name && HasEnhancement(checkEnhancement)) return false; } } } } else { EnhancementSet enhancementSet = GetEnhancementSet(enhancement); if (null != enhancementSet) { string name = "Superior " + enhancementSet.DisplayName; EnhancementSet superiorEnhancementSet = GetEnhancementSetByIndex(GetEnhancementSetIndexByName(name)); if (null != superiorEnhancementSet) { for (int enhancementIndex = 0; enhancementIndex < superiorEnhancementSet.Enhancements.Length; enhancementIndex++) { IEnhancement checkEnhancement = GetEnhancementByIndex(superiorEnhancementSet.Enhancements[enhancementIndex]); if (null != checkEnhancement && checkEnhancement.Name == enhancement.Name && HasEnhancement(checkEnhancement)) return false; } } } } return true; } public bool FollowsRuleOfFive() { Dictionary counts = GetBonusCounts(); foreach (KeyValuePair kvp in counts) { if (5 < kvp.Value) return false; } return true; } public bool HasFourOrMoreBonuses(EnhancementSet enhancementSet, int slots) { Dictionary counts = GetBonusCounts(enhancementSet, slots); foreach (KeyValuePair kvp in counts) { if (4 <= kvp.Value) return true; } return false; } public Dictionary GetBonusCounts(EnhancementSet enhancementSet, int slots) { Dictionary counts = new Dictionary(); Dictionary enhancementSetBonusCounts = GetBonusCounts(); for (int bonusIndex = 0; bonusIndex < slots - 1; bonusIndex++) { if (bonusIndex >= enhancementSet.Bonus.Length) break; EnhancementSet.BonusItem bonusItem = enhancementSet.Bonus[bonusIndex]; for (int bonusNameIndex = 0; bonusNameIndex < bonusItem.Name.Length; bonusNameIndex++) { string bonusName = bonusItem.Name[bonusNameIndex]; if (enhancementSetBonusCounts.ContainsKey(bonusName)) { if (!counts.ContainsKey(bonusName)) counts.Add(bonusName, enhancementSetBonusCounts[bonusName]); } else { counts.Add(bonusName, 0); } } } return counts; } public Dictionary GetBonusCounts() { List powerEntries = GetPowerEntries(); Dictionary characterBonusCounts = new Dictionary(); foreach (PowerEntry powerEntry in powerEntries) { Dictionary> enhancementGroups = GetEnhancementsGroupedBySet(powerEntry); foreach (KeyValuePair> kvp in enhancementGroups) { if ("None" == kvp.Key) continue; int enhancementSetIndex = GetEnhancementSetIndexByName(kvp.Key); if (-1 == enhancementSetIndex) continue; EnhancementSet set = GetEnhancementSetByIndex(enhancementSetIndex); if (null == set) continue; for (int bonusIndex = 0; bonusIndex < powerEntry.Slots.Length - 1; bonusIndex++) { if (bonusIndex >= set.Bonus.Length) break; EnhancementSet.BonusItem bonusItem = set.Bonus[bonusIndex]; for (int bonusNameIndex = 0; bonusNameIndex < bonusItem.Name.Length; bonusNameIndex++) { string bonusName = bonusItem.Name[bonusNameIndex]; if (characterBonusCounts.ContainsKey(bonusName)) characterBonusCounts[bonusName] = characterBonusCounts[bonusName] + 1; else characterBonusCounts.Add(bonusName, 1); } } } } return characterBonusCounts; } public EnhancementSet GetHighestValidSet(EnhancementSet[] sortedEnhancementSets, PowerEntry powerEntry, int slots, Enums.eEffectType effectType, Enums.eDamage damageType = Enums.eDamage.None) { foreach (EnhancementSet enhancementSet in sortedEnhancementSets) { int count = 1; if (HasFourOrMoreBonuses(enhancementSet, slots)) continue; foreach (int enhancementIndex in enhancementSet.Enhancements) { IEnhancement enhancement = GetEnhancementByIndex(enhancementIndex); if (!CanAddEnhancement(enhancement, powerEntry)) continue; count++; if (count == slots) return enhancementSet; } } return null; } public void SetDefaultSlotLevels() { Health.Slots[0].Level = 1; Stamina.Slots[0].Level = 1; Level1Primary.Slots[0].Level = 1; Level1Secondary.Slots[0].Level = 1; Level2.Slots[0].Level = 1; Level4.Slots[0].Level = 3; Level6.Slots[0].Level = 5; Level8.Slots[0].Level = 7; Level10.Slots[0].Level = 9; Level12.Slots[0].Level = 11; Level14.Slots[0].Level = 13; Level16.Slots[0].Level = 15; Level18.Slots[0].Level = 17; Level20.Slots[0].Level = 19; Level22.Slots[0].Level = 21; Level24.Slots[0].Level = 23; Level26.Slots[0].Level = 25; Level28.Slots[0].Level = 27; Level30.Slots[0].Level = 29; Level32.Slots[0].Level = 31; Level35.Slots[0].Level = 34; Level38.Slots[0].Level = 37; Level41.Slots[0].Level = 40; Level44.Slots[0].Level = 43; Level47.Slots[0].Level = 46; Level49.Slots[0].Level = 48; int slotsPerLevel = 2; int levelJump = 2; int currentLevel = 3; int slotsAdded = 0; List powerEntries = GetPowerEntries(); for (int powerIndex = 0; powerIndex < powerEntries.Count; powerIndex++) { PowerEntry powerEntry = powerEntries[powerIndex]; if (1 >= powerEntry.Slots.Length) continue; for (int slotIndex = 1; slotIndex < powerEntry.Slots.Length; slotIndex++) { powerEntry.Slots[slotIndex].Level = (currentLevel - 1); slotsAdded++; if (slotsAdded == slotsPerLevel) { currentLevel += levelJump; slotsAdded = 0; if (31 <= currentLevel) slotsPerLevel = 3; if (33 == currentLevel || 36 == currentLevel || 39 == currentLevel || 42 == currentLevel || 45 == currentLevel) levelJump = 1; if (34 == currentLevel || 37 == currentLevel || 40 == currentLevel || 43 == currentLevel || 46 <= currentLevel || 48 == currentLevel) levelJump = 2; } } } } public void Print() { Print(null); } public void Print(Enums.eEffectType effectType = Enums.eEffectType.None, Enums.eDamage damageType = Enums.eDamage.None, bool includePvP = false) { MultiEvolveData[] multiEvolveData = new MultiEvolveData[1]; multiEvolveData[0] = new MultiEvolveData(); multiEvolveData[0].EffectType = effectType; multiEvolveData[0].DamageType = damageType; multiEvolveData[0].IncludePvP = includePvP; multiEvolveData[0].Weight = 1.0f; Print(multiEvolveData); } public void Print(MultiEvolveData[] multiEvolveData) { float[] sum = null; if (null != multiEvolveData) sum = new float[multiEvolveData.Length]; Debug.Print(Archetype.DisplayName); Debug.Print("=== Powersets ==="); Debug.Print("* " + Fitness.DisplayName); Debug.Print("* " + Primary.DisplayName); Debug.Print("* " + Secondary.DisplayName); Debug.Print("* " + Pool1.DisplayName); Debug.Print("* " + Pool2.DisplayName); Debug.Print("* " + Pool3.DisplayName); Debug.Print("* " + Pool4.DisplayName); Debug.Print("* " + Epic.DisplayName); if (null != multiEvolveData) { Debug.Print("=== Optimizations ==="); for (int multiEvolveIndex = 0; multiEvolveIndex < multiEvolveData.Length; multiEvolveIndex++) { MultiEvolveData multiEvolveItem = multiEvolveData[multiEvolveIndex]; string damage = (Enums.eDamage.None == multiEvolveItem.DamageType) ? " All " : " " + multiEvolveItem.DamageType.ToString() + " "; string effect = Enums.eEffectType.Defense == multiEvolveItem.EffectType || Enums.eEffectType.Resistance == multiEvolveItem.EffectType ? damage : " "; string pvp = multiEvolveItem.IncludePvP ? "with PvP bonuses" : "without PvP bonuses"; if (Enums.eEffectType.None != multiEvolveItem.EffectType) { Debug.Print(multiEvolveItem.EffectType.ToString() + effect + pvp + " (Weight: " + multiEvolveItem.Weight + ") "); } sum[multiEvolveIndex] = 0.0f; } } Debug.Print("=== Powers ==="); List powerEntries = GetPowerEntries(); foreach (PowerEntry powerEntry in powerEntries) { string powerSummary = "* " + powerEntry.Power.DisplayName + " (Slots: " + powerEntry.Slots.Length + "): "; string comma = ", "; for (int slotEntryIndex = 0; slotEntryIndex < powerEntry.Slots.Length; slotEntryIndex++) { SlotEntry slot = powerEntry.Slots[slotEntryIndex]; if (slotEntryIndex == powerEntry.Slots.Length - 1) comma = " || Set Bonuses: "; IEnhancement enhancement = GetEnhancementByIndex(slot.Enhancement.Enh); if (null == enhancement) continue; EnhancementSet enhancementSet = GetEnhancementSet(enhancement); if (null != enhancementSet) powerSummary += enhancementSet.DisplayName + " "; powerSummary += enhancement.ShortName + comma; } if (null != multiEvolveData) { for (int multiEvolveIndex = 0; multiEvolveIndex < multiEvolveData.Length; multiEvolveIndex++) { MultiEvolveData multiEvolveItem = multiEvolveData[multiEvolveIndex]; if (Enums.eEffectType.None != multiEvolveItem.EffectType) { float powerEntrySum = SumPowerEntryBonusEffect(powerEntry, multiEvolveItem.EffectType, multiEvolveItem.DamageType, multiEvolveItem.IncludePvP); string damage = (Enums.eDamage.None == multiEvolveItem.DamageType) ? " All " : " " + multiEvolveItem.DamageType.ToString() + ""; string effect = Enums.eEffectType.Defense == multiEvolveItem.EffectType || Enums.eEffectType.Resistance == multiEvolveItem.EffectType ? damage : ""; powerSummary += multiEvolveItem.EffectType.ToString() + effect + ": " + powerEntrySum.ToString() + " " + "(Weighed: " + (powerEntrySum * multiEvolveItem.Weight).ToString() + ") "; sum[multiEvolveIndex] += powerEntrySum; } } } Debug.Print(powerSummary); } if (null != multiEvolveData) { for (int multiEvolveIndex = 0; multiEvolveIndex < multiEvolveData.Length; multiEvolveIndex++) { MultiEvolveData multiEvolveItem = multiEvolveData[multiEvolveIndex]; if (Enums.eEffectType.None != multiEvolveItem.EffectType) { string damage = (Enums.eDamage.None == multiEvolveItem.DamageType) ? " All " : " " + multiEvolveItem.DamageType.ToString() + " "; string effect = Enums.eEffectType.Defense == multiEvolveItem.EffectType || Enums.eEffectType.Resistance == multiEvolveItem.EffectType ? damage : " "; Debug.Print(multiEvolveItem.EffectType.ToString() + effect + "Total Bonus: " + sum[multiEvolveIndex].ToString() + " (Weighed: " + (sum[multiEvolveIndex] * multiEvolveItem.Weight).ToString() + ")"); } } } } public void PrintDebug() { Debug.Print("Archetype: " + Archetype.DisplayName); Debug.Print("Fitness: " + Fitness.DisplayName); Debug.Print("Primary: " + Primary.DisplayName); Debug.Print("Secondary: " + Secondary.DisplayName); if (null != Pool1) Debug.Print("Pool1: " + Pool1.DisplayName); if (null != Pool2) Debug.Print("Pool2: " + Pool2.DisplayName); if (null != Pool3) Debug.Print("Pool3: " + Pool3.DisplayName); if (null != Pool4) Debug.Print("Pool4: " + Pool4.DisplayName); if (null != Epic) Debug.Print("Epic: " + Epic.DisplayName); Func getEnh = (p) => { string enh = ""; for (int slotIndex = 0; slotIndex < p.SlotCount; slotIndex++) { if (0 < slotIndex) enh += ", "; enh += p.Slots[slotIndex].Enhancement.Enh; } return enh; }; Func stringifyPowerEntry = (p, name) => { return name + ": " + p.Name + " Slots: " + p.SlotCount + " Enh: " + getEnh(p); }; Debug.Print(stringifyPowerEntry(Health, "Health")); Debug.Print(stringifyPowerEntry(Stamina, "Stamina")); Debug.Print(stringifyPowerEntry(Level1Primary, "Level1Primary")); Debug.Print(stringifyPowerEntry(Level1Secondary, "Level1Secondary")); Debug.Print(stringifyPowerEntry(Level2, "Level2")); Debug.Print(stringifyPowerEntry(Level4, "Level4")); Debug.Print(stringifyPowerEntry(Level6, "Level6")); Debug.Print(stringifyPowerEntry(Level8, "Level8")); Debug.Print(stringifyPowerEntry(Level10, "Level10")); Debug.Print(stringifyPowerEntry(Level12, "Level12")); Debug.Print(stringifyPowerEntry(Level14, "Level14")); Debug.Print(stringifyPowerEntry(Level16, "Level16")); Debug.Print(stringifyPowerEntry(Level18, "Level18")); Debug.Print(stringifyPowerEntry(Level20, "Level20")); Debug.Print(stringifyPowerEntry(Level22, "Level22")); Debug.Print(stringifyPowerEntry(Level24, "Level24")); Debug.Print(stringifyPowerEntry(Level26, "Level26")); Debug.Print(stringifyPowerEntry(Level28, "Level28")); Debug.Print(stringifyPowerEntry(Level30, "Level30")); Debug.Print(stringifyPowerEntry(Level32, "Level32")); Debug.Print(stringifyPowerEntry(Level35, "Level35")); Debug.Print(stringifyPowerEntry(Level38, "Level38")); Debug.Print(stringifyPowerEntry(Level41, "Level41")); Debug.Print(stringifyPowerEntry(Level44, "Level44")); Debug.Print(stringifyPowerEntry(Level47, "Level47")); Debug.Print(stringifyPowerEntry(Level49, "Level49")); } } public enum EnhancementTypes : int { Accuracy = 26, Interrupt = 27, Confuse = 28, Damage = 29, Defense = 30, DefenseDebuff = 31, EnduranceModification = 32, EnduranceReduction = 33, Fear = 34, Fly = 35, Heal = 36, Hold = 37, Immobilize = 38, Intangible = 39, Jump = 40, Knockback = 41, Range = 42, Recharge = 43, Resistance = 44, Run = 45, Sleep = 46, Slow = 47, Stun = 48, Taunt = 49, ToHit = 50, ToHitDebuff = 51 } public static EnhancementTypes[] GetEnhancementTypes(IEnhancement enhancement) { List result = new List(); foreach (Enums.sEffect effect in enhancement.Effect) { if (Enums.eEnhance.Accuracy == (Enums.eEnhance)effect.Enhance.ID) result.Add(EnhancementTypes.Accuracy); else if (Enums.eEnhance.Damage == (Enums.eEnhance)effect.Enhance.ID) result.Add(EnhancementTypes.Damage); else if (Enums.eEnhance.Defense == (Enums.eEnhance)effect.Enhance.ID) { if (Enums.eBuffDebuff.BuffOnly == effect.BuffMode) result.Add(EnhancementTypes.Defense); else result.Add(EnhancementTypes.DefenseDebuff); } else if (Enums.eEnhance.EnduranceDiscount == (Enums.eEnhance)effect.Enhance.ID) result.Add(EnhancementTypes.EnduranceReduction); else if (Enums.eEnhance.Endurance == (Enums.eEnhance)effect.Enhance.ID) result.Add(EnhancementTypes.EnduranceModification); else if (Enums.eEnhance.SpeedFlying == (Enums.eEnhance)effect.Enhance.ID) { if (Enums.eBuffDebuff.DeBuffOnly == enhancement.BuffMode) continue; result.Add(EnhancementTypes.Fly); } else if (Enums.eEnhance.Heal == (Enums.eEnhance)effect.Enhance.ID) result.Add(EnhancementTypes.Heal); else if (Enums.eEnhance.HitPoints == (Enums.eEnhance)effect.Enhance.ID) result.Add(EnhancementTypes.Heal); else if (Enums.eEnhance.Interrupt == (Enums.eEnhance)effect.Enhance.ID) result.Add(EnhancementTypes.Interrupt); else if (Enums.eEnhance.JumpHeight == (Enums.eEnhance)effect.Enhance.ID) result.Add(EnhancementTypes.Jump); else if (Enums.eEnhance.SpeedJumping == (Enums.eEnhance)effect.Enhance.ID) { if (Enums.eBuffDebuff.DeBuffOnly == enhancement.BuffMode) continue; result.Add(EnhancementTypes.Jump); } else if (Enums.eEnhance.Mez == (Enums.eEnhance)effect.Enhance.ID) { if (Enums.eMez.Confused == (Enums.eMez)effect.Enhance.SubID) result.Add(EnhancementTypes.Confuse); else if (Enums.eMez.Held == (Enums.eMez)effect.Enhance.SubID) result.Add(EnhancementTypes.Hold); else if (Enums.eMez.Immobilized == (Enums.eMez)effect.Enhance.SubID) result.Add(EnhancementTypes.Immobilize); else if (Enums.eMez.Knockback == (Enums.eMez)effect.Enhance.SubID) result.Add(EnhancementTypes.Knockback); else if (Enums.eMez.Knockup == (Enums.eMez)effect.Enhance.SubID) result.Add(EnhancementTypes.Knockback); else if (Enums.eMez.Sleep == (Enums.eMez)effect.Enhance.SubID) result.Add(EnhancementTypes.Sleep); else if (Enums.eMez.Stunned == (Enums.eMez)effect.Enhance.SubID) result.Add(EnhancementTypes.Stun); else if (Enums.eMez.Taunt == (Enums.eMez)effect.Enhance.SubID) result.Add(EnhancementTypes.Taunt); else if (Enums.eMez.Terrorized == (Enums.eMez)effect.Enhance.SubID) result.Add(EnhancementTypes.Fear); else if (Enums.eMez.Untouchable == (Enums.eMez)effect.Enhance.SubID) result.Add(EnhancementTypes.Intangible); else if (Enums.eMez.Afraid == (Enums.eMez)effect.Enhance.SubID) result.Add(EnhancementTypes.Fear); else if (Enums.eMez.Intangible == (Enums.eMez)effect.Enhance.SubID) result.Add(EnhancementTypes.Intangible); } else if (Enums.eEnhance.Range == (Enums.eEnhance)effect.Enhance.ID) result.Add(EnhancementTypes.Range); else if (Enums.eEnhance.RechargeTime == (Enums.eEnhance)effect.Enhance.ID) result.Add(EnhancementTypes.Recharge); else if (Enums.eEnhance.Recovery == (Enums.eEnhance)effect.Enhance.ID) result.Add(EnhancementTypes.EnduranceModification); else if (Enums.eEnhance.Regeneration == (Enums.eEnhance)effect.Enhance.ID) result.Add(EnhancementTypes.Heal); else if (Enums.eEnhance.Resistance == (Enums.eEnhance)effect.Enhance.ID) result.Add(EnhancementTypes.Resistance); else if (Enums.eEnhance.SpeedRunning == (Enums.eEnhance)effect.Enhance.ID) { if (Enums.eBuffDebuff.DeBuffOnly == enhancement.BuffMode) continue; result.Add(EnhancementTypes.Run); } else if (Enums.eEnhance.ToHit == (Enums.eEnhance)effect.Enhance.ID) { if (Enums.eBuffDebuff.BuffOnly == effect.BuffMode) result.Add(EnhancementTypes.ToHit); else result.Add(EnhancementTypes.ToHitDebuff); } else if (Enums.eEnhance.Slow == (Enums.eEnhance)effect.Enhance.ID) result.Add(EnhancementTypes.Slow); else if (Enums.eEnhance.Absorb == (Enums.eEnhance)effect.Enhance.ID) result.Add(EnhancementTypes.Heal); } return result.ToArray(); } public static IPower GetPowerByIndex(int index) { if (index < 0 || index > Database.Power.Length - 1) return null; return Database.Power[index]; } public static IPowerset GetPowersetByFullName(string fullName) { foreach (Powerset powerset in Database.Powersets) { if (powerset.FullName != fullName) continue; return powerset; } return null; } public static IPowerset GetPowersetByArchetypeAndName(Archetype archetype, string name) { foreach (Powerset powerset in Database.Powersets) { if (-1 != powerset.ATClass.IndexOf("Mace") || -1 != powerset.DisplayName.IndexOf("Mace")) Debug.Print(powerset.ATClass + " " + powerset.DisplayName); } foreach (Powerset powerset in Database.Powersets) { if (powerset.ATClass != archetype.ClassName || powerset.DisplayName != name) continue; return powerset; } return null; } public static List GetDefaultSlotting(IPower power) { int[] validEnhancements = power.GetValidEnhancements(Enums.eType.InventO); List defaultEnhancements = new List(); for (int searchIndex = 0; searchIndex < validEnhancements.Length; searchIndex++) { if ((int)EnhancementTypes.Accuracy == validEnhancements[searchIndex]) { defaultEnhancements.Add(GetEnhancementByIndex(validEnhancements[searchIndex])); break; } } int count = defaultEnhancements.Count; while (defaultEnhancements.Count < count + 3) { bool hasDamage = false; for (int searchIndex = 0; searchIndex < validEnhancements.Length; searchIndex++) { if ((int)EnhancementTypes.Damage == validEnhancements[searchIndex]) { defaultEnhancements.Add(GetEnhancementByIndex(validEnhancements[searchIndex])); hasDamage = true; break; } } if (!hasDamage) break; } count = defaultEnhancements.Count; while (defaultEnhancements.Count < count + 3 && defaultEnhancements.Count < 6) { bool hasEnhancement = false; for (int searchIndex = 0; searchIndex < validEnhancements.Length; searchIndex++) { if ((int)EnhancementTypes.Confuse == validEnhancements[searchIndex] || (int)EnhancementTypes.Defense == validEnhancements[searchIndex] || (int)EnhancementTypes.DefenseDebuff == validEnhancements[searchIndex] || (int)EnhancementTypes.EnduranceModification == validEnhancements[searchIndex] || (int)EnhancementTypes.Fear == validEnhancements[searchIndex] || (int)EnhancementTypes.Fly == validEnhancements[searchIndex] || (int)EnhancementTypes.Heal == validEnhancements[searchIndex] || (int)EnhancementTypes.Hold == validEnhancements[searchIndex] || (int)EnhancementTypes.Immobilize == validEnhancements[searchIndex] || (int)EnhancementTypes.Resistance == validEnhancements[searchIndex] || (int)EnhancementTypes.Run == validEnhancements[searchIndex] || (int)EnhancementTypes.Sleep == validEnhancements[searchIndex] || (int)EnhancementTypes.Slow == validEnhancements[searchIndex] || (int)EnhancementTypes.Stun == validEnhancements[searchIndex] || (int)EnhancementTypes.Taunt == validEnhancements[searchIndex] || (int)EnhancementTypes.ToHitDebuff == validEnhancements[searchIndex]) { defaultEnhancements.Add(GetEnhancementByIndex(validEnhancements[searchIndex])); hasEnhancement = true; break; } } if (!hasEnhancement) break; } if (power.EndCost > 1.0f) { count = defaultEnhancements.Count; while (defaultEnhancements.Count < count + 3 && defaultEnhancements.Count < 6) { bool hasEnduranceReduction = false; for (int searchIndex = 0; searchIndex < validEnhancements.Length; searchIndex++) { if ((int)EnhancementTypes.EnduranceReduction == validEnhancements[searchIndex]) { defaultEnhancements.Add(GetEnhancementByIndex(validEnhancements[searchIndex])); hasEnduranceReduction = true; break; } } if (!hasEnduranceReduction) break; } } int rechargeCount = 0; while (defaultEnhancements.Count < 6 && 3 > rechargeCount) { for (int searchIndex = 0; searchIndex < validEnhancements.Length; searchIndex++) { if ((int)EnhancementTypes.Recharge == validEnhancements[searchIndex]) { defaultEnhancements.Add(GetEnhancementByIndex(validEnhancements[searchIndex])); rechargeCount++; break; } } if (0 == rechargeCount) break; } return defaultEnhancements; } public static bool DoDefaultSlotting(PowerEntry powerEntry, int slots) { if (1 > slots || 6 < slots) return false; while (slots < powerEntry.Slots.Length) powerEntry.RemoveSlot(powerEntry.Slots.Length - 1); while (slots > powerEntry.Slots.Length) powerEntry.AddSlot(-1); List defaultSlotting = GetDefaultSlotting(powerEntry.Power); for (int slotsAdded = 0; slotsAdded < defaultSlotting.Count; slotsAdded++) { powerEntry.Slots[slotsAdded].LoadFromString(GetLoadString(defaultSlotting[slotsAdded]), ":"); if (slotsAdded == slots - 1) break; } return true; } public static bool Slot(PowerEntry powerEntry, int[] enhancementIndexes) { if (1 > enhancementIndexes.Length || 6 < enhancementIndexes.Length) return false; while (enhancementIndexes.Length < powerEntry.Slots.Length) powerEntry.RemoveSlot(powerEntry.Slots.Length - 1); while (enhancementIndexes.Length > powerEntry.Slots.Length) powerEntry.AddSlot(-1); for (int slotsAdded = 0; slotsAdded < enhancementIndexes.Length; slotsAdded++) { IEnhancement enhancement = GetEnhancementByIndex(enhancementIndexes[slotsAdded]); powerEntry.Slots[slotsAdded].LoadFromString(GetLoadString(enhancement), ":"); if (slotsAdded == enhancementIndexes.Length - 1) break; } return true; } public static IEnhancement GetEnhancementByIndex(int index) { if (index < 0 || index > Database.Enhancements.Length - 1) return null; return Database.Enhancements[index]; } public static bool HasEffect(IEnhancement enhancement, Enums.eEnhance effectType) { foreach (Enums.sEffect effect in enhancement.Effect) { if (effect.Enhance.ID == (int)effectType) return true; } return false; } public static string GetLoadString(IEnhancement enhancement, int level = 49, string delimiter = ":") { // Set DisplayName(Can be empty):Enhancement Short Name:Type(enum eType):Fallback:Relative Level:Grade(enum eEnhGrade):IO Level EnhancementSet set = GetEnhancementSet(enhancement); string loadString = ((null == set) ? "" : set.DisplayName) + delimiter; loadString += enhancement.ShortName + delimiter; loadString += (int)enhancement.TypeID + delimiter; loadString += "-1" + delimiter; loadString += level.ToString() + delimiter; loadString += "0" + delimiter; loadString += level.ToString(); return loadString; } public static EnhancementSet GetEnhancementSet(IEnhancement enhancement) { if (null == enhancement) return null; foreach (EnhancementSet enhancementSet in Database.EnhancementSets) { if (enhancementSet.Uid == enhancement.UIDSet) return enhancementSet; } return null; } public static int GetEnhancementSetIndexByName(string iName) => Database.EnhancementSets.TryFindIndex(enh => string.Equals(enh.ShortName, iName, StringComparison.OrdinalIgnoreCase) || string.Equals(enh.DisplayName, iName, StringComparison.OrdinalIgnoreCase)); public static EnhancementSet GetEnhancementSetByIndex(int index) { if (0 > index || index >= Database.EnhancementSets.Count) return null; return Database.EnhancementSets[index]; } public static List GetBonusPowers(EnhancementSet enhancementSet) { List bonusPowers = new List(); if (null == enhancementSet) return bonusPowers; foreach (EnhancementSet.BonusItem bonusItem in enhancementSet.Bonus) { for (int bonusIndex = 0; bonusIndex < bonusItem.Index.Length; ++bonusIndex) { int powerIndex = bonusItem.Index[bonusIndex] + 3; // TODO: Why do we need +3? IPower bonusPower = GetPowerByIndex(powerIndex); if (null == bonusPower) continue; bonusPowers.Add(bonusPower); } } return bonusPowers; } public static bool HasBonusEffect(EnhancementSet enhancementSet, int slots, Enums.eEffectType effectType, Enums.eDamage damageType = Enums.eDamage.None, float scale = -1.0f, bool includePvP = false) { List bonusPowers = GetBonusPowers(enhancementSet); if (2 > slots || 6 < slots) return false; int slotCount = 1; foreach (IPower bonusPower in bonusPowers) { if (bonusPower.SetName.Equals("PvP_Set_Bonus", StringComparison.InvariantCultureIgnoreCase)) continue; for (int effectIndex = 0; effectIndex < bonusPower.Effects.Length; ++effectIndex) { IEffect effect = bonusPower.Effects[effectIndex]; if (effect.EffectType != effectType) continue; if (!IsKindaSortaEqual(-1, scale, 0.01f) && !IsKindaSortaEqual(effect.Scale, scale, 0.001f)) continue; if (Enums.eDamage.None == damageType) return true; if (effect.DamageType == damageType) return true; } slotCount++; if (slotCount >= slots) break; } if (false == includePvP) return false; slotCount = 1; foreach (IPower bonusPowerPvP in bonusPowers) { if (!bonusPowerPvP.SetName.Equals("PvP_Set_Bonus", StringComparison.InvariantCultureIgnoreCase)) continue; for (int effectIndex = 0; effectIndex < bonusPowerPvP.Effects.Length; ++effectIndex) { IEffect effect = bonusPowerPvP.Effects[effectIndex]; if (effect.EffectType != effectType) continue; if (!IsKindaSortaEqual(-1, scale, 0.01f) && !IsKindaSortaEqual(effect.Scale, scale, 0.001f)) continue; if (Enums.eDamage.None == damageType) return true; if (effect.DamageType == damageType) return true; } slotCount++; if (slotCount >= slots) break; } return false; } public static HashSet GetEnhancementSetsWithBonusEffect(IPower power, int slots, Enums.eEffectType effectType, Enums.eDamage damageType = Enums.eDamage.None, float scale = -1.0f, bool includePvP = false) { HashSet enhancementSets = new HashSet(); if (1 > slots || 6 < slots) return enhancementSets; int[] validEnhancements = power.GetValidEnhancements(Enums.eType.SetO); for (int validEnhancementsIndex = 0; validEnhancementsIndex <= validEnhancements.Length - 1; ++validEnhancementsIndex) { IEnhancement enhancement = GetEnhancementByIndex(validEnhancements[validEnhancementsIndex]); if (null == enhancement) continue; EnhancementSet enhancementSet = GetEnhancementSet(enhancement); if (null == enhancementSet) continue; if (!HasBonusEffect(enhancementSet, slots, effectType, damageType, scale, includePvP)) continue; enhancementSets.Add(enhancementSet); } return enhancementSets; } public static EnhancementSet[] SortEnhancementSets(HashSet sets, int slots, Enums.eEffectType effectType, Enums.eDamage damageType = Enums.eDamage.None, bool includePvP = false) { EnhancementSet[] enhancementSetArray = sets.ToArray(); Array.Sort(enhancementSetArray, delegate (EnhancementSet set1, EnhancementSet set2) { float sum1 = SumEnhancementSetBonusEffect(set1, slots, effectType, damageType, includePvP); float sum2 = SumEnhancementSetBonusEffect(set2, slots, effectType, damageType, includePvP); return sum1.CompareTo(sum2); }); Array.Reverse(enhancementSetArray, 0, enhancementSetArray.Length); return enhancementSetArray; } public static float SumEnhancementSetBonusEffect(EnhancementSet enhancementSet, int slots, Enums.eEffectType effectType, Enums.eDamage damageType = Enums.eDamage.None, bool includePvP = false) { float sum = 0.0f; if (1 > slots || 6 < slots) return sum; List bonusPowers = GetBonusPowers(enhancementSet); int slotCount = 1; foreach (IPower bonusPower in bonusPowers) { if (bonusPower.SetName.Equals("PvP_Set_Bonus", StringComparison.InvariantCultureIgnoreCase)) continue; for (int effectIndex = 0; effectIndex < bonusPower.Effects.Length; ++effectIndex) { IEffect effect = bonusPower.Effects[effectIndex]; if (effect.EffectType != effectType) continue; if (Enums.eDamage.None == damageType) sum += effect.Scale; else if (effect.DamageType == damageType) sum += effect.Scale; } slotCount++; if (slotCount >= slots) break; } if (false == includePvP) return sum; slotCount = 1; foreach (IPower bonusPower in bonusPowers) { if (!bonusPower.SetName.Equals("PvP_Set_Bonus", StringComparison.InvariantCultureIgnoreCase)) continue; for (int effectIndex = 0; effectIndex < bonusPower.Effects.Length; ++effectIndex) { IEffect effect = bonusPower.Effects[effectIndex]; if (effect.EffectType != effectType) continue; if (Enums.eDamage.None == damageType) sum += effect.Scale; else if (effect.DamageType == damageType) sum += effect.Scale; } slotCount++; if (slotCount >= slots) break; } return sum; } public static EnhancementSet GetHighestBonusEffect(HashSet EnhancementSets, int slots, Enums.eEffectType effectType, Enums.eDamage damageType = Enums.eDamage.None) { EnhancementSet highest = null; if (1 > slots || 6 < slots) return highest; float sum = 0.0f; foreach (EnhancementSet enhancementSet in EnhancementSets) { float setSum = SumEnhancementSetBonusEffect(enhancementSet, slots, effectType, damageType); if (setSum < sum) continue; sum = setSum; highest = enhancementSet; } return highest; } public static bool AllowsEnhancement(IPower power, EnhancementTypes enhancementType) { int[] allowedEnhancements = power.GetValidEnhancements(Enums.eType.InventO); foreach (int enhancementID in allowedEnhancements) { if (enhancementID == (int)enhancementType) return true; } return false; } public static int CompareTo(I9Slot slot1, I9Slot slot2) { if (slot1.Enh != slot2.Enh) return slot1.Enh.CompareTo(slot2.Enh); if (slot1.RelativeLevel != slot2.RelativeLevel) return slot1.RelativeLevel.CompareTo(slot2.RelativeLevel); if (slot1.Grade != slot2.Grade) return slot1.Grade.CompareTo(slot2.Grade); if (slot1.IOLevel != slot2.IOLevel) return slot1.IOLevel.CompareTo(slot2.IOLevel); return 0; } public static int CompareTo(SlotEntry slotEntry1, SlotEntry slotEntry2) { if (slotEntry1.Level != slotEntry2.Level) return slotEntry1.Level.CompareTo(slotEntry2.Level); int result = CompareTo(slotEntry1.Enhancement, slotEntry2.Enhancement); if (0 != result) return result; result = CompareTo(slotEntry1.FlippedEnhancement, slotEntry2.FlippedEnhancement); if (0 != result) return result; return 0; } public static int CompareTo(PowerSubEntry powerSubEntry1, PowerSubEntry powerSubEntry2) { if (powerSubEntry1.Powerset != powerSubEntry2.Powerset) return powerSubEntry1.Powerset.CompareTo(powerSubEntry2.Powerset); if (powerSubEntry1.Power != powerSubEntry2.Power) return powerSubEntry1.Power.CompareTo(powerSubEntry2.Power); if (powerSubEntry1.nIDPower != powerSubEntry2.nIDPower) return powerSubEntry1.nIDPower.CompareTo(powerSubEntry2.nIDPower); if (powerSubEntry1.StatInclude != powerSubEntry2.StatInclude) return powerSubEntry1.StatInclude.CompareTo(powerSubEntry2.StatInclude); return 0; } public static int CompareTo(PowerEntry powerEntry1, PowerEntry powerEntry2) { if (powerEntry1.Level != powerEntry2.Level) return powerEntry1.Level.CompareTo(powerEntry2.Level); if (powerEntry1.NIDPowerset != powerEntry2.NIDPowerset) return powerEntry1.NIDPowerset.CompareTo(powerEntry2.NIDPowerset); if (powerEntry1.IDXPower != powerEntry2.IDXPower) return powerEntry1.IDXPower.CompareTo(powerEntry2.IDXPower); if (powerEntry1.NIDPower != powerEntry2.NIDPower) return powerEntry1.NIDPower.CompareTo(powerEntry2.NIDPower); if (powerEntry1.Tag != powerEntry2.Tag) return powerEntry1.Tag.CompareTo(powerEntry2.Tag); if (powerEntry1.StatInclude != powerEntry2.StatInclude) return powerEntry1.StatInclude.CompareTo(powerEntry2.StatInclude); if (powerEntry1.VariableValue != powerEntry2.VariableValue) return powerEntry1.VariableValue.CompareTo(powerEntry2.VariableValue); if (powerEntry1.Slots.Length != powerEntry2.Slots.Length) return powerEntry1.Slots.Length.CompareTo(powerEntry2.Slots.Length); for (int slotEntryIndex = 0; slotEntryIndex < powerEntry1.Slots.Length; slotEntryIndex++) { int slotResult = CompareTo(powerEntry1.Slots[slotEntryIndex], powerEntry2.Slots[slotEntryIndex]); if (0 != slotResult) return slotResult; } if (powerEntry1.SubPowers.Length != powerEntry2.SubPowers.Length) return powerEntry1.SubPowers.Length.CompareTo(powerEntry2.SubPowers.Length); for (int powerSubEntryIndex = 0; powerSubEntryIndex < powerEntry1.SubPowers.Length; powerSubEntryIndex++) { int powerSubEntryResult = CompareTo(powerEntry1.SubPowers[powerSubEntryIndex], powerEntry2.SubPowers[powerSubEntryIndex]); if (0 != powerSubEntryResult) return powerSubEntryResult; } if (powerEntry1.Chosen != powerEntry2.Chosen) return powerEntry1.Chosen.CompareTo(powerEntry2.Chosen); if (powerEntry1.State != powerEntry2.State) return powerEntry1.State.CompareTo(powerEntry2.State); if (powerEntry1.State != powerEntry2.State) return powerEntry1.State.CompareTo(powerEntry2.State); if (null == powerEntry1.Power && null != powerEntry2.Power) return -1; if (null != powerEntry1.Power && null == powerEntry2.Power) return 1; int powerResult = powerEntry1.Power.CompareTo(powerEntry2.Power); if (0 != powerResult) return powerResult; if (null == powerEntry1.PowerSet && null != powerEntry2.PowerSet) return -1; if (null != powerEntry1.PowerSet && null == powerEntry2.PowerSet) return 1; int powerSetResult = powerEntry1.PowerSet.CompareTo(powerEntry2.PowerSet); if (0 != powerSetResult) return powerSetResult; if (powerEntry1.AllowFrontLoading != powerEntry2.AllowFrontLoading) return powerEntry1.AllowFrontLoading.CompareTo(powerEntry2.AllowFrontLoading); if (powerEntry1.Name != powerEntry2.Name) return powerEntry1.Name.CompareTo(powerEntry2.Name); if (powerEntry1.Virtual != powerEntry2.Virtual) return powerEntry1.Virtual.CompareTo(powerEntry2.Virtual); if (powerEntry1.SlotCount != powerEntry2.SlotCount) return powerEntry1.SlotCount.CompareTo(powerEntry2.SlotCount); return 0; } public static Dictionary> GetEnhancementsGroupedBySet(PowerEntry powerEntry) { Dictionary> enhancementSets = new Dictionary>(); foreach (SlotEntry slotEntry in powerEntry.Slots) { int enhancementIndex = slotEntry.Enhancement.Enh; if (-1 == enhancementIndex) continue; IEnhancement enhancement = GetEnhancementByIndex(enhancementIndex); EnhancementSet enhancementSet = GetEnhancementSet(enhancement); string enhancementSetName = "None"; List enhancementList; if (null != enhancementSet) enhancementSetName = enhancementSet.DisplayName; if (!enhancementSets.ContainsKey(enhancementSetName)) enhancementSets.Add(enhancementSetName, new List()); if (enhancementSets.TryGetValue(enhancementSetName, out enhancementList)) { enhancementList.Add(enhancement); } } return enhancementSets; } public static float SumPowerEntryBonusEffect(PowerEntry powerEntry, Enums.eEffectType effectType, Enums.eDamage damageType = Enums.eDamage.None, bool includePvP = false) { float sum = 0.0f; Dictionary> enhancementGroups = GetEnhancementsGroupedBySet(powerEntry); foreach (KeyValuePair> kvp in enhancementGroups) { if ("None" == kvp.Key) continue; int enhancementsetIndex = GetEnhancementSetIndexByName(kvp.Key); if (-1 == enhancementsetIndex) continue; EnhancementSet enhancementSet = GetEnhancementSetByIndex(enhancementsetIndex); if (null == enhancementSet) continue; int enhancementCount = kvp.Value.Count; sum += SumEnhancementSetBonusEffect(enhancementSet, enhancementCount, effectType, damageType, includePvP); } return sum; } public static void SlotToon(AIToon toon, Enums.eEffectType effectType, Enums.eDamage damageType = Enums.eDamage.None, bool includePvP = false) { MultiEvolveData[] multiEvolveData = new MultiEvolveData[1]; multiEvolveData[0] = new MultiEvolveData(); multiEvolveData[0].EffectType = effectType; multiEvolveData[0].DamageType = damageType; multiEvolveData[0].IncludePvP = includePvP; multiEvolveData[0].Weight = 1.0f; MultiSlotToon(toon, multiEvolveData); } public class SlotResultData { public float Sum; public PowerEntry PowerEntry; } public static void MultiSlotToon(AIToon toon, MultiEvolveData[] multiEvolveData) { List powerEntries = toon.GetPowerEntries(); for (int powerEntryIndex = 0; powerEntryIndex < powerEntries.Count; powerEntryIndex++) { PowerEntry powerEntry = MultiSlotPowerEntry(toon, powerEntries, powerEntryIndex, multiEvolveData); powerEntries[powerEntryIndex] = powerEntry; toon.SetPowerEntries(powerEntries); } } public static PowerEntry SlotPowerEntry(AIToon toon, List powerEntries, int powerEntryIndex, Enums.eEffectType effectType, Enums.eDamage damageType = Enums.eDamage.None, bool includePvP = false) { MultiEvolveData[] multiEvolveData = new MultiEvolveData[1]; multiEvolveData[0] = new MultiEvolveData(); multiEvolveData[0].EffectType = effectType; multiEvolveData[0].DamageType = damageType; multiEvolveData[0].IncludePvP = includePvP; multiEvolveData[0].Weight = 1.0f; return MultiSlotPowerEntry(toon, powerEntries, powerEntryIndex, multiEvolveData); } public static PowerEntry MultiSlotPowerEntry(AIToon toon, List powerEntries, int powerEntryIndex, MultiEvolveData[] multiEvolveData) { PowerEntry powerEntry = powerEntries[powerEntryIndex]; PowerEntry selectedPowerEntry = powerEntry; float sum = 0.0f; SlotResultData[] slotResultData = new SlotResultData[multiEvolveData.Length]; for (int multiEvolveDataIndex = 0; multiEvolveDataIndex < multiEvolveData.Length; multiEvolveDataIndex++) { Enums.eEffectType effectType = multiEvolveData[multiEvolveDataIndex].EffectType; Enums.eDamage damageType = multiEvolveData[multiEvolveDataIndex].DamageType; bool includePvP = multiEvolveData[multiEvolveDataIndex].IncludePvP; float weight = multiEvolveData[multiEvolveDataIndex].Weight; sum = SumPowerEntryBonusEffect(powerEntry, effectType, damageType, includePvP) * weight; PowerEntry highest = HighestSetStrategy(toon, powerEntries, powerEntryIndex, effectType, damageType, includePvP); float newSum = SumPowerEntryBonusEffect(highest, effectType, damageType, includePvP) * weight; selectedPowerEntry = sum < newSum ? highest : selectedPowerEntry; sum = SumPowerEntryBonusEffect(selectedPowerEntry, effectType, damageType, includePvP) * weight; PowerEntry frankenslot = FrankenslotStrategy(toon, powerEntries, powerEntryIndex, effectType, damageType, includePvP); newSum = SumPowerEntryBonusEffect(frankenslot, effectType, damageType, includePvP) * weight; selectedPowerEntry = sum < newSum ? frankenslot : selectedPowerEntry; SlotResultData data = new SlotResultData(); data.Sum = Math.Max(sum, newSum); data.PowerEntry = selectedPowerEntry; slotResultData[multiEvolveDataIndex] = data; } int highestDataIndex = 0; if (1 < slotResultData.Length) { for (int resultIndex = 1; resultIndex < slotResultData.Length; resultIndex++) { if (slotResultData[resultIndex].Sum > slotResultData[highestDataIndex].Sum) highestDataIndex = resultIndex; } } return slotResultData[highestDataIndex].PowerEntry; } public static void EvolveToon(AIToon toon, int generations, int iterations, Enums.eEffectType effectType, Enums.eDamage damageType = Enums.eDamage.None, bool includePvP = false) { List powerEntries = toon.GetPowerEntries(); for (int generationCount = 0; generationCount < generations; generationCount++) { for (int powerEntryIndex = 0; powerEntryIndex < powerEntries.Count; powerEntryIndex++) { EvolvePower(toon, powerEntries, powerEntryIndex, iterations, effectType, damageType, includePvP); toon.SetPowerEntries(powerEntries); } } toon.SetDefaultSlotLevels(); } public class MultiEvolveData { public float Weight; public Enums.eEffectType EffectType; public Enums.eDamage DamageType = Enums.eDamage.None; public bool IncludePvP = false; } public static void MultiEvolveToon(AIToon toon, int generations, int iterations, MultiEvolveData[] multiEvolveData) { List powerEntries = toon.GetPowerEntries(); for (int generationCount = 0; generationCount < generations; generationCount++) { for (int powerEntryIndex = 0; powerEntryIndex < powerEntries.Count; powerEntryIndex++) { MultiEvolvePower(toon, powerEntries, powerEntryIndex, iterations, multiEvolveData); toon.SetPowerEntries(powerEntries); } } toon.SetDefaultSlotLevels(); /* Task[] taskArray = new Task[multiEvolveData.Length]; for (int i = 0; i < multiEvolveData.Length; i++) { taskArray[i] = Task.Factory.StartNew(() => EvolveSlotsStrategy(toon, powerEntries, index, multiEvolveData[i].effectType, multiEvolveData[i].damageType, multiEvolveData[i].includePvP)); } Task.WaitAll(taskArray); float sum = 0.0f; SlotStrategyData result = null; for (int resultIndex = 0; resultIndex < taskArray.Length; resultIndex++) { Task task = taskArray[resultIndex]; SlotStrategyData data = task.Result; if (data == null) continue; float weighedSum = data.Sum * multiEvolveData[resultIndex].weight; if (weighedSum > sum) { result = data; sum = weighedSum; } } if (null != result) { powerEntries[result.PowerEntryIndex1] = result.PowerEntry1; powerEntries[result.PowerEntryIndex2] = result.PowerEntry2; } */ } public static void EvolvePower(AIToon toon, List powerEntries, int index, int iterations, Enums.eEffectType effectType, Enums.eDamage damageType = Enums.eDamage.None, bool includePvP = false) { MultiEvolveData[] multiEvolveData = new MultiEvolveData[1]; multiEvolveData[0] = new MultiEvolveData(); multiEvolveData[0].EffectType = effectType; multiEvolveData[0].DamageType = damageType; multiEvolveData[0].IncludePvP = includePvP; multiEvolveData[0].Weight = 1.0f; MultiEvolvePower(toon, powerEntries, index, iterations, multiEvolveData); } public static void MultiEvolvePower(AIToon toon, List powerEntries, int index, int iterations, MultiEvolveData[] multiEvolveData) { for (int iterationCount = 0; iterationCount < iterations; iterationCount++) { SlotStrategyData[] slotStrategyData = new SlotStrategyData[multiEvolveData.Length]; for (int multiEolveIndex = 0; multiEolveIndex < multiEvolveData.Length; multiEolveIndex++) { Enums.eEffectType effectType = multiEvolveData[multiEolveIndex].EffectType; Enums.eDamage damageType = multiEvolveData[multiEolveIndex].DamageType; bool includePvP = multiEvolveData[multiEolveIndex].IncludePvP; slotStrategyData[multiEolveIndex] = EvolveSlotsStrategy(toon, powerEntries, index, effectType, damageType, includePvP); } int highestIndex = 0; float weighedSum = slotStrategyData[0].Sum * multiEvolveData[0].Weight; if (1 < multiEvolveData.Length) { for ( int i = 0; i < multiEvolveData.Length; i++) { float weightedSumCandidate = slotStrategyData[i].Sum * multiEvolveData[i].Weight; if (weightedSumCandidate > weighedSum) { weighedSum = weightedSumCandidate; highestIndex = i; } } } SlotStrategyData selectedData = slotStrategyData[highestIndex]; powerEntries[selectedData.PowerEntryIndex1] = selectedData.PowerEntry1; powerEntries[selectedData.PowerEntryIndex2] = selectedData.PowerEntry2; } } public static PowerEntry HighestSetStrategy(AIToon toon, List powerEntries, int index, Enums.eEffectType effectType, Enums.eDamage damageType = Enums.eDamage.None, bool includePvP = false) { PowerEntry powerEntry = powerEntries[index]; PowerEntry selectedPowerEntry = powerEntry; if (2 > powerEntry.Slots.Length) return powerEntry; int slots = 2; float sum = SumPowerEntryBonusEffect(powerEntry, effectType, damageType, includePvP); HashSet enhancementSets = null; EnhancementSet[] sortedEnhancementSets = null; EnhancementSet enhancementSet = null; while (powerEntry.Slots.Length >= slots) { PowerEntry powerEntryClone = powerEntry.Clone() as PowerEntry; enhancementSets = GetEnhancementSetsWithBonusEffect(powerEntry.Power, slots, effectType, damageType, -1.0f, includePvP); sortedEnhancementSets = SortEnhancementSets(enhancementSets, slots, effectType, damageType, includePvP); enhancementSet = toon.GetHighestValidSet(sortedEnhancementSets, powerEntry, slots, effectType, damageType); if (null == enhancementSet) { slots++; continue; } int enhancementsAddedCount = 0; for (int enhancementIndex = 0; enhancementIndex < enhancementSet.Enhancements.Length; enhancementIndex++) { IEnhancement enhancement = GetEnhancementByIndex(enhancementSet.Enhancements[enhancementIndex]); if (!toon.CanAddEnhancement(enhancement, powerEntryClone)) continue; powerEntryClone.Slots[enhancementsAddedCount].LoadFromString(GetLoadString(enhancement), ":"); enhancementsAddedCount++; if (enhancementsAddedCount == slots) break; } float cloneSum = SumPowerEntryBonusEffect(powerEntryClone, effectType, damageType, includePvP); if (sum < cloneSum) { selectedPowerEntry = powerEntryClone; sum = cloneSum; } slots++; } return selectedPowerEntry; } public static PowerEntry FrankenslotStrategy(AIToon toon, List powerEntries, int index, Enums.eEffectType effectType, Enums.eDamage damageType = Enums.eDamage.None, bool includePvP = false) { PowerEntry powerEntry = powerEntries[index]; PowerEntry selectedPowerEntry = powerEntry; float sum = SumPowerEntryBonusEffect(selectedPowerEntry, effectType, damageType, includePvP); if (3 >= powerEntry.Slots.Length) return powerEntry; if (4 == powerEntry.Slots.Length) { PowerEntry powerEntry2And2 = Frankenslot2SetsStrategy(toon, powerEntries, index, 2, 2, effectType, damageType, includePvP); float newSum = SumPowerEntryBonusEffect(powerEntry2And2, effectType, damageType, includePvP); if (sum < newSum) selectedPowerEntry = powerEntry2And2; } else if (5 == powerEntry.Slots.Length) { PowerEntry powerEntry2And2 = Frankenslot2SetsStrategy(toon, powerEntries, index, 2, 2, effectType, damageType, includePvP); float newSum = SumPowerEntryBonusEffect(powerEntry2And2, effectType, damageType, includePvP); selectedPowerEntry = sum < newSum ? powerEntry2And2 : selectedPowerEntry; sum = SumPowerEntryBonusEffect(selectedPowerEntry, effectType, damageType, includePvP); PowerEntry powerEntry3And2 = Frankenslot2SetsStrategy(toon, powerEntries, index, 3, 2, effectType, damageType, includePvP); newSum = SumPowerEntryBonusEffect(powerEntry3And2, effectType, damageType, includePvP); selectedPowerEntry = sum < newSum ? powerEntry3And2 : selectedPowerEntry; sum = SumPowerEntryBonusEffect(selectedPowerEntry, effectType, damageType, includePvP); PowerEntry powerEntry2And3 = Frankenslot2SetsStrategy(toon, powerEntries, index, 2, 3, effectType, damageType, includePvP); newSum = SumPowerEntryBonusEffect(powerEntry2And3, effectType, damageType, includePvP); selectedPowerEntry = sum < newSum ? powerEntry2And3 : selectedPowerEntry; } else if (6 == powerEntry.Slots.Length) { PowerEntry powerEntry2And2 = Frankenslot2SetsStrategy(toon, powerEntries, index, 2, 2, effectType, damageType, includePvP); float newSum = SumPowerEntryBonusEffect(powerEntry2And2, effectType, damageType, includePvP); selectedPowerEntry = sum < newSum ? powerEntry2And2 : selectedPowerEntry; sum = SumPowerEntryBonusEffect(selectedPowerEntry, effectType, damageType, includePvP); PowerEntry powerEntry3And2 = Frankenslot2SetsStrategy(toon, powerEntries, index, 3, 2, effectType, damageType, includePvP); newSum = SumPowerEntryBonusEffect(powerEntry3And2, effectType, damageType, includePvP); selectedPowerEntry = sum < newSum ? powerEntry3And2 : selectedPowerEntry; sum = SumPowerEntryBonusEffect(selectedPowerEntry, effectType, damageType, includePvP); PowerEntry powerEntry2And3 = Frankenslot2SetsStrategy(toon, powerEntries, index, 2, 3, effectType, damageType, includePvP); newSum = SumPowerEntryBonusEffect(powerEntry2And3, effectType, damageType, includePvP); selectedPowerEntry = sum < newSum ? powerEntry2And3 : selectedPowerEntry; PowerEntry powerEntry4And2 = Frankenslot2SetsStrategy(toon, powerEntries, index, 4, 2, effectType, damageType, includePvP); newSum = SumPowerEntryBonusEffect(powerEntry4And2, effectType, damageType, includePvP); selectedPowerEntry = sum < newSum ? powerEntry4And2 : selectedPowerEntry; sum = SumPowerEntryBonusEffect(selectedPowerEntry, effectType, damageType, includePvP); PowerEntry powerEntry2And4 = Frankenslot2SetsStrategy(toon, powerEntries, index, 2, 4, effectType, damageType, includePvP); newSum = SumPowerEntryBonusEffect(powerEntry2And4, effectType, damageType, includePvP); selectedPowerEntry = sum < newSum ? powerEntry2And4 : selectedPowerEntry; sum = SumPowerEntryBonusEffect(selectedPowerEntry, effectType, damageType, includePvP); PowerEntry powerEntry3And3 = Frankenslot2SetsStrategy(toon, powerEntries, index, 3, 3, effectType, damageType, includePvP); newSum = SumPowerEntryBonusEffect(powerEntry3And3, effectType, damageType, includePvP); selectedPowerEntry = sum < newSum ? powerEntry3And3 : selectedPowerEntry; sum = SumPowerEntryBonusEffect(selectedPowerEntry, effectType, damageType, includePvP); PowerEntry powerEntry2And2And2 = Frankenslot3SetsStrategy(toon, powerEntries, index, effectType, damageType, includePvP); newSum = SumPowerEntryBonusEffect(powerEntry2And2And2, effectType, damageType, includePvP); selectedPowerEntry = sum < newSum ? powerEntry2And2And2 : selectedPowerEntry; } return selectedPowerEntry; } public static PowerEntry Frankenslot2SetsStrategy(AIToon toon, List powerEntries, int index, int slots1, int slots2, Enums.eEffectType effectType, Enums.eDamage damageType = Enums.eDamage.None, bool includePvP = false) { HashSet firstSets = GetEnhancementSetsWithBonusEffect(powerEntries[index].Power, slots1, effectType, damageType, -1.0f, includePvP); HashSet secondSets = GetEnhancementSetsWithBonusEffect(powerEntries[index].Power, slots2, effectType, damageType, -1.0f, includePvP); if (0 == firstSets.Count || 0 == secondSets.Count) return powerEntries[index]; EnhancementSet[] sortedFirstSets = SortEnhancementSets(firstSets, slots1, effectType, damageType, includePvP); EnhancementSet firstEnhancementSet = toon.GetHighestValidSet(sortedFirstSets, powerEntries[index], slots1, effectType, damageType); if (null == firstEnhancementSet) return powerEntries[index]; secondSets.Remove(firstEnhancementSet); if (0 == secondSets.Count) return powerEntries[index]; EnhancementSet[] sortedSecondSets = SortEnhancementSets(secondSets, slots2, effectType, damageType, includePvP); EnhancementSet secondEnhancementSet = toon.GetHighestValidSet(sortedSecondSets, powerEntries[index], slots2, effectType, damageType); if (null == secondEnhancementSet) return powerEntries[index]; PowerEntry powerEntryClone = powerEntries[index].Clone() as PowerEntry; int slotIndex = 0; int enhancementsAddedCount = 0; for (int enhancementIndex = 0; enhancementIndex < firstEnhancementSet.Enhancements.Length; enhancementIndex++) { IEnhancement enhancement = GetEnhancementByIndex(firstEnhancementSet.Enhancements[enhancementIndex]); if (!toon.CanAddEnhancement(enhancement, powerEntryClone)) continue; powerEntryClone.Slots[slotIndex].LoadFromString(GetLoadString(enhancement), ":"); slotIndex++; enhancementsAddedCount++; if (enhancementsAddedCount == slots1) break; } enhancementsAddedCount = 0; for (int enhancementIndex = 0; enhancementIndex < secondEnhancementSet.Enhancements.Length; enhancementIndex++) { IEnhancement enhancement = GetEnhancementByIndex(secondEnhancementSet.Enhancements[enhancementIndex]); if (!toon.CanAddEnhancement(enhancement, powerEntryClone)) continue; powerEntryClone.Slots[slotIndex].LoadFromString(GetLoadString(enhancement), ":"); slotIndex++; enhancementsAddedCount++; if (enhancementsAddedCount == slots2) break; } return powerEntryClone; } public static PowerEntry Frankenslot3SetsStrategy(AIToon toon, List powerEntries, int index, Enums.eEffectType effectType, Enums.eDamage damageType = Enums.eDamage.None, bool includePvP = false) { HashSet firstSets = GetEnhancementSetsWithBonusEffect(powerEntries[index].Power, 2, effectType, damageType, -1.0f, includePvP); HashSet secondSets = GetEnhancementSetsWithBonusEffect(powerEntries[index].Power, 2, effectType, damageType, -1.0f, includePvP); HashSet thirdSets = GetEnhancementSetsWithBonusEffect(powerEntries[index].Power, 2, effectType, damageType, -1.0f, includePvP); if (0 == firstSets.Count || 0 == secondSets.Count || 0 == thirdSets.Count) return powerEntries[index]; EnhancementSet[] sortedFirstSets = SortEnhancementSets(firstSets, 2, effectType, damageType, includePvP); EnhancementSet firstEnhancementSet = toon.GetHighestValidSet(sortedFirstSets, powerEntries[index], 2, effectType, damageType); if (null == firstEnhancementSet) return powerEntries[index]; secondSets.Remove(firstEnhancementSet); thirdSets.Remove(firstEnhancementSet); if (0 == secondSets.Count || 0 == thirdSets.Count) return powerEntries[index]; EnhancementSet[] sortedSecondSets = SortEnhancementSets(secondSets, 2, effectType, damageType, includePvP); EnhancementSet secondEnhancementSet = toon.GetHighestValidSet(sortedSecondSets, powerEntries[index], 2, effectType, damageType); if (null == secondEnhancementSet) return powerEntries[index]; thirdSets.Remove(secondEnhancementSet); if (0 == thirdSets.Count) return powerEntries[index]; EnhancementSet[] sortedThirdSets = SortEnhancementSets(thirdSets, 2, effectType, damageType, includePvP); EnhancementSet thirdEnhancementSet = toon.GetHighestValidSet(sortedThirdSets, powerEntries[index], 2, effectType, damageType); if (null == thirdEnhancementSet) return powerEntries[index]; PowerEntry powerEntryClone = powerEntries[index].Clone() as PowerEntry; int slotIndex = 0; int enhancementsAddedCount = 0; for (int enhancementIndex = 0; enhancementIndex < firstEnhancementSet.Enhancements.Length; enhancementIndex++) { IEnhancement enhancement = GetEnhancementByIndex(firstEnhancementSet.Enhancements[enhancementIndex]); if (!toon.CanAddEnhancement(enhancement, powerEntryClone)) continue; powerEntryClone.Slots[slotIndex].LoadFromString(GetLoadString(enhancement), ":"); slotIndex++; enhancementsAddedCount++; if (enhancementsAddedCount == 2) break; } enhancementsAddedCount = 0; for (int enhancementIndex = 0; enhancementIndex < secondEnhancementSet.Enhancements.Length; enhancementIndex++) { IEnhancement enhancement = GetEnhancementByIndex(secondEnhancementSet.Enhancements[enhancementIndex]); if (!toon.CanAddEnhancement(enhancement, powerEntryClone)) continue; powerEntryClone.Slots[slotIndex].LoadFromString(GetLoadString(enhancement), ":"); slotIndex++; enhancementsAddedCount++; if (enhancementsAddedCount == 2) break; } enhancementsAddedCount = 0; for (int enhancementIndex = 0; enhancementIndex < thirdEnhancementSet.Enhancements.Length; enhancementIndex++) { IEnhancement enhancement = GetEnhancementByIndex(thirdEnhancementSet.Enhancements[enhancementIndex]); if (!toon.CanAddEnhancement(enhancement, powerEntryClone)) continue; powerEntryClone.Slots[slotIndex].LoadFromString(GetLoadString(enhancement), ":"); slotIndex++; enhancementsAddedCount++; if (enhancementsAddedCount == 2) break; } return powerEntryClone; } public static bool CanMoveSlots(PowerEntry source, PowerEntry dest) { if (null == source || null == dest || null == source.Slots || null == dest.Slots) return false; return source.Slots.Length >= 2 && dest.Slots.Length <= 5; } public static int GetMoveSlotCount(PowerEntry source, PowerEntry dest) { if (!CanMoveSlots(source, dest)) return -1; int maxReceiveSlots = 6 - dest.Slots.Length; int maxSendSlots = source.Slots.Length - 1; int maxSlots = Math.Min(maxReceiveSlots, maxSendSlots); Random rnd = new Random(); int slotsToMove = rnd.Next(1, maxSlots + 1); return slotsToMove; } public static bool MoveSlots(PowerEntry source, PowerEntry dest, int slotsToMove) { if (!CanMoveSlots(source, dest)) return false; if (0 >= slotsToMove || source.Slots.Length - 1 < slotsToMove || dest.Slots.Length + slotsToMove > 6) return false; for (int removeSlotCounter = 0; removeSlotCounter < slotsToMove; removeSlotCounter++) { int level = source.Slots[source.Slots.Length - 1].Level; dest.AddSlot(level); source.RemoveSlot(source.Slots.Length - 1); } return true; } public class SlotStrategyData { public PowerEntry PowerEntry1; public int PowerEntryIndex1; public PowerEntry PowerEntry2; public int PowerEntryIndex2; public float Sum; } public static SlotStrategyData EvolveSlotsStrategy(AIToon toon, List powerEntries, int index, Enums.eEffectType effectType, Enums.eDamage damageType = Enums.eDamage.None, bool includePvP = false) { // Get power entry and a second random power entry. PowerEntry powerEntry = powerEntries[index]; Random rnd = new Random(); int randomPowerEntryIndex = index; while (randomPowerEntryIndex == index || powerEntries[randomPowerEntryIndex].Slots.Length == 1) randomPowerEntryIndex = rnd.Next(1, powerEntries.Count) - 1; PowerEntry randomPowerEntry = powerEntries[randomPowerEntryIndex].Clone() as PowerEntry; // Record the two original power entries. float originalSum = SumPowerEntryBonusEffect(powerEntry, effectType, damageType, includePvP); float originalRandomSum = SumPowerEntryBonusEffect(randomPowerEntry, effectType, damageType, includePvP); SlotStrategyData slotStrategyData = new SlotStrategyData(); slotStrategyData.PowerEntry1 = powerEntry; slotStrategyData.PowerEntryIndex1 = index; slotStrategyData.PowerEntry2 = randomPowerEntry; slotStrategyData.PowerEntryIndex2 = randomPowerEntryIndex; slotStrategyData.Sum = originalSum + originalRandomSum; // Clone the two original power entries. PowerEntry powerEntryClone = powerEntry.Clone() as PowerEntry; PowerEntry randomPowerEntryClone = randomPowerEntry.Clone() as PowerEntry; // Move slots between the two clones. if (!CanMoveSlots(randomPowerEntryClone, powerEntryClone)) return slotStrategyData; int slotsToMove = GetMoveSlotCount(randomPowerEntryClone, powerEntryClone); if (-1 == slotsToMove) return slotStrategyData; if (!MoveSlots(randomPowerEntryClone, powerEntryClone, slotsToMove)) return slotStrategyData; DoDefaultSlotting(powerEntryClone, powerEntryClone.Slots.Length); DoDefaultSlotting(randomPowerEntryClone, randomPowerEntryClone.Slots.Length); // Set the toon to use the two clones. List powerEntriesClone = toon.GetPowerEntries(); powerEntriesClone[index] = powerEntryClone; powerEntriesClone[randomPowerEntryIndex] = randomPowerEntryClone; toon.SetPowerEntries(powerEntriesClone); // Slot the two clones and record their sums. powerEntryClone = SlotPowerEntry(toon, powerEntriesClone, index, effectType, damageType, includePvP); float cloneSum = SumPowerEntryBonusEffect(powerEntryClone, effectType, damageType, includePvP); randomPowerEntryClone = SlotPowerEntry(toon, powerEntriesClone, randomPowerEntryIndex, effectType, damageType, includePvP); float cloneRandomSum = SumPowerEntryBonusEffect(randomPowerEntryClone, effectType, damageType, includePvP); // If the resulting build is not valid, use the original. powerEntriesClone[slotStrategyData.PowerEntryIndex1] = powerEntryClone; powerEntriesClone[slotStrategyData.PowerEntryIndex2] = randomPowerEntryClone; toon.SetPowerEntries(powerEntriesClone); if (!toon.IsValid()) { toon.SetPowerEntries(powerEntries); return slotStrategyData; } // Reset the toon. toon.SetPowerEntries(powerEntries); // If the two clones produced a better result, use them. if (cloneSum + cloneRandomSum > originalSum + originalRandomSum) { slotStrategyData.PowerEntry1 = powerEntryClone; slotStrategyData.PowerEntry2 = randomPowerEntryClone; slotStrategyData.Sum = cloneSum + cloneRandomSum; } return slotStrategyData; } // Call this after all database info has loaded, such as at the end of LoadEnhancementDb() public static void TestNewCode() { TestIsKindaSortaEqual(); TestEnhancementListing(); TestGetEnhancementTypes(); TestGetDefaultSlotting(); TestDoDefaultSlotting(); TestSlot(); AIToon toon = TestCreateBuildBlasterFireMental(); AIToon toon2 = TestCreateBuildControllerMindForceField(); AIToon toon2a = TestCreateBuildControllerMindForceFieldWithIOs(); AIToon toon3 = TestCreateBuildMastermindRoboticsForceField(); AIToon toon4 = TestCreateBuildMastermindDemonsPain(); TestSetDefaultSlotLevels(toon2); TestGetPowerByIndex(); TestGetEnhancementByIndex(); TestHasEffect(); TestGetEnhancementSet(); TestGetLoadSring(); TestGetBonusPowers(); TestHasBonusEffect(); TestGetEnhancementSetsWithBonusEffect(); TestSortEnhancementSets(); TestSumBonusEffect(toon); TestGetHighestBonusEffect(); TestAllowsEnhancement(toon); TestGetEnhancementsGroupedBySet(toon); PowerEntry.TestNewCode(); TestToonGetPowerEntries(toon); TestToonSetPowerEntries(toon); TestToonClone(toon); TestToonSumPowerBonuses(toon); TestToonGetEnhancementCount(toon); TestToonHasEnhancement(toon); TestToonHasFourOrMoreBonuses(toon2); TestToonCanAddEnhancement(toon); TestToonGetBonusCounts(); TestGetHighestValidSet(toon2); TestMultiSlotPowerEntry(); TestToonEvolveHighestSetStrategy(toon2); TestToonEvolveFrakenslotStrategy(toon2); TestCanMoveSlots(); TestGetMoveSlotCount(); TestMoveSlots(); TestToonEvolve(toon2); TestToonMultiEvolve(toon2); } public static void TestIsKindaSortaEqual() { float a = 1.1f; float b = 1.0f; Debug.Assert(IsKindaSortaEqual(a, b, 0.1f) == true, "isKindaSortaEqual is incorrect!"); Debug.Assert(IsKindaSortaEqual(a, b, 0.01f) == false, "isKindaSortaEqual is incorrect!"); } public static void TestGetEnhancementTypes() { for (int enhancementId = (int)EnhancementTypes.Accuracy; enhancementId <= (int)EnhancementTypes.ToHitDebuff; enhancementId++) { IEnhancement enhancement = GetEnhancementByIndex(enhancementId); EnhancementTypes type = GetEnhancementTypes(enhancement)[0]; Debug.Assert(type == (EnhancementTypes)enhancementId, "GetEnhancementTypes is incorrect!"); } } public static void TestGetPowerByIndex() { IPower power = GetPowerByIndex(0); Debug.Assert(power != null, "power is null!"); Debug.Assert(power.DisplayName == "Single Shot", "power.DisplayName is incorrect!"); power = GetPowerByIndex(100); Debug.Assert(power != null, "power is null!"); Debug.Assert(power.DisplayName == "Blaze", "power.DisplayName is incorrect!"); power = GetPowerByIndex(11000); Debug.Assert(power == null, "power is not null!"); } public static void TestGetEnhancementByIndex() { IEnhancement enhancement = GetEnhancementByIndex(0); Debug.Assert(enhancement != null, "enhancement is null!"); Debug.Assert(enhancement.Name == "Accuracy", "enhancement.Name is incorrect!"); enhancement = GetEnhancementByIndex(100); Debug.Assert(enhancement != null, "enhancement is null!"); Debug.Assert(enhancement.Name == "Accuracy/Damage/Endurance", "enhancement.Name is incorrect!"); enhancement = GetEnhancementByIndex(1300); Debug.Assert(enhancement == null, "enhancement is not null!"); } public static void TestHasEffect() { IEnhancement acc = GetEnhancementByIndex(26); IEnhancement dam = GetEnhancementByIndex(29); IEnhancement rech = GetEnhancementByIndex(43); IEnhancement crushingImpactAccDamEnd = GetEnhancementByIndex(100); Debug.Assert(HasEffect(acc, Enums.eEnhance.Accuracy) == true, "HasEffect(acc, Enums.eEffectType.Accuracy) is incorrect!"); Debug.Assert(HasEffect(acc, Enums.eEnhance.Damage) == false, "HasEffect(acc, Enums.eEffectType.Accuracy) is incorrect!"); Debug.Assert(HasEffect(dam, Enums.eEnhance.Damage) == true, "HasEffect(dam, Enums.eEffectType.Accuracy) is incorrect!"); Debug.Assert(HasEffect(dam, Enums.eEnhance.Accuracy) == false, "HasEffect(dam, Enums.eEffectType.Accuracy) is incorrect!"); Debug.Assert(HasEffect(rech, Enums.eEnhance.RechargeTime) == true, "HasEffect(rech, Enums.eEffectType.Accuracy) is incorrect!"); Debug.Assert(HasEffect(rech, Enums.eEnhance.Accuracy) == false, "HasEffect(rech, Enums.eEffectType.Accuracy) is incorrect!"); Debug.Assert(HasEffect(crushingImpactAccDamEnd, Enums.eEnhance.Accuracy) == true, "HasEffect(crushingImpactAccDamEnd, Enums.eEffectType.Accuracy) is incorrect!"); Debug.Assert(HasEffect(crushingImpactAccDamEnd, Enums.eEnhance.Damage) == true, "HasEffect(crushingImpactAccDamEnd, Enums.eEffectType.Accuracy) is incorrect!"); Debug.Assert(HasEffect(crushingImpactAccDamEnd, Enums.eEnhance.EnduranceDiscount) == true, "HasEffect(crushingImpactAccDamEnd, Enums.eEffectType.Accuracy) is incorrect!"); Debug.Assert(HasEffect(crushingImpactAccDamEnd, Enums.eEnhance.RechargeTime) == false, "HasEffect(crushingImpactAccDamEnd, Enums.eEffectType.Accuracy) is incorrect!"); } public static void TestGetEnhancementSet() { IEnhancement enhancement = GetEnhancementByIndex(0); EnhancementSet enhancementSet = GetEnhancementSet(enhancement); Debug.Assert(enhancementSet == null, "enhancementSet is not null!"); enhancement = GetEnhancementByIndex(200); enhancementSet = GetEnhancementSet(enhancement); Debug.Assert(enhancementSet != null, "enhancementSet is null!"); Debug.Assert(enhancementSet.DisplayName == "Executioner's Contract", "enhancementSet.DisplayName is incorrect!"); int index = GetEnhancementSetIndexByName("Superior Winter's Bite"); enhancementSet = GetEnhancementSetByIndex(index); Debug.Assert(enhancementSet.DisplayName == "Superior Winter's Bite", "enhancementSet.DisplayName is incorrect!"); } public static void TestGetLoadSring() { IEnhancement enhancement = GetEnhancementByIndex(200); string loadString = GetLoadString(enhancement); Debug.Assert(loadString == "Executioner's Contract:Stun%:4:-1:49:0:49", "loadString is incorrect!"); enhancement = GetEnhancementByIndex(26); loadString = GetLoadString(enhancement); Debug.Assert(loadString == ":Acc:2:-1:49:0:49", "loadString is incorrect!"); } public static void TestGetBonusPowers() { IEnhancement enhancement = GetEnhancementByIndex(200); EnhancementSet enhancementSet = GetEnhancementSet(enhancement); List bonusPowers = GetBonusPowers(enhancementSet); Debug.Assert(bonusPowers.Count == 5, "bonusPowers.Count is incorrect!"); IPower[] bonusPowersArray = bonusPowers.ToArray(); foreach (IPower power in bonusPowersArray) { Debug.Print(power.DisplayName); } Debug.Assert(bonusPowersArray[0].DisplayName == "Moderate Improved Recovery Bonus", "bonusPowersArray[0].DisplayName is incorrect!"); Debug.Assert(bonusPowersArray[1].DisplayName == "Moderate Fire, Cold and Mez Resistance", "bonusPowersArray[1].DisplayName is incorrect!"); Debug.Assert(bonusPowersArray[2].DisplayName == "Large Improved Regeneration Bonus", "bonusPowersArray[2].DisplayName is incorrect!"); Debug.Assert(bonusPowersArray[3].DisplayName == "Large Lethal, Smash and Mez Resistance", "bonusPowersArray[3].DisplayName is incorrect!"); Debug.Assert(bonusPowersArray[4].DisplayName == "Huge Increased Ranged/Energy/Negative Energy Def Bonus", "bonusPowersArray[4].DisplayName is incorrect!"); bonusPowers = GetBonusPowers(null); Debug.Assert(bonusPowers.Count == 0, "bonusPowers.Count is incorrect!"); } public static void TestHasBonusEffect() { IEnhancement enhancement = GetEnhancementByIndex(200); EnhancementSet enhancementSet = GetEnhancementSet(enhancement); bool hasEnergyDefenseBonus = HasBonusEffect(enhancementSet, 6, Enums.eEffectType.Defense, Enums.eDamage.Energy); Debug.Assert(hasEnergyDefenseBonus == true, "hasEnergyDefenseBonus is incorrect!"); hasEnergyDefenseBonus = HasBonusEffect(enhancementSet, 6, Enums.eEffectType.Defense, Enums.eDamage.Energy, 0.0188f); Debug.Assert(hasEnergyDefenseBonus == true, "hasEnergyDefenseBonus is incorrect!"); hasEnergyDefenseBonus = HasBonusEffect(enhancementSet, 6, Enums.eEffectType.Defense, Enums.eDamage.Energy, 0.05f); Debug.Assert(hasEnergyDefenseBonus == false, "hasEnergyDefenseBonus is incorrect!"); bool hasEnergyResistanceBonus = HasBonusEffect(enhancementSet, 6, Enums.eEffectType.Resistance, Enums.eDamage.Energy); Debug.Assert(hasEnergyResistanceBonus == false, "hasEnergyResistanceBonus is incorrect!"); bool hasDefenseBonus = HasBonusEffect(enhancementSet, 6, Enums.eEffectType.Defense); Debug.Assert(hasDefenseBonus == true, "hasDefenseBonus is incorrect!"); bool hasResistanceBonus = HasBonusEffect(enhancementSet, 6, Enums.eEffectType.Resistance); Debug.Assert(hasResistanceBonus == true, "hasResistanceBonus is incorrect!"); bool hasFireDefenseBonus = HasBonusEffect(enhancementSet, 6, Enums.eEffectType.Defense, Enums.eDamage.Fire); Debug.Assert(hasFireDefenseBonus == false, "hasFireDefenseBonus is incorrect!"); bool hasFireResistanceBonus = HasBonusEffect(enhancementSet, 6, Enums.eEffectType.Resistance, Enums.eDamage.Fire); Debug.Assert(hasFireResistanceBonus == true, "hasFireResistanceBonus is incorrect!"); hasEnergyDefenseBonus = HasBonusEffect(enhancementSet, 5, Enums.eEffectType.Defense, Enums.eDamage.Energy); Debug.Assert(hasEnergyDefenseBonus == false, "hasEnergyDefenseBonus is incorrect!"); bool hasSmashingResistanceBonus = HasBonusEffect(enhancementSet, 5, Enums.eEffectType.Resistance, Enums.eDamage.Smashing); Debug.Assert(hasSmashingResistanceBonus == true, "hasSmashingResistanceBonus is incorrect!"); hasSmashingResistanceBonus = HasBonusEffect(enhancementSet, 4, Enums.eEffectType.Resistance, Enums.eDamage.Smashing); Debug.Assert(hasSmashingResistanceBonus == false, "hasSmashingResistanceBonus is incorrect!"); bool hasRegenerationBonus = HasBonusEffect(enhancementSet, 4, Enums.eEffectType.Regeneration, Enums.eDamage.None); Debug.Assert(hasRegenerationBonus == true, "hasRegenerationBonus is incorrect!"); hasRegenerationBonus = HasBonusEffect(enhancementSet, 3, Enums.eEffectType.Regeneration, Enums.eDamage.None); Debug.Assert(hasRegenerationBonus == false, "hasRegenerationBonus is incorrect!"); hasFireResistanceBonus = HasBonusEffect(enhancementSet, 3, Enums.eEffectType.Resistance, Enums.eDamage.Fire); Debug.Assert(hasFireResistanceBonus == true, "hasFireResistanceBonus is incorrect!"); hasFireResistanceBonus = HasBonusEffect(enhancementSet, 2, Enums.eEffectType.Resistance, Enums.eDamage.Fire); Debug.Assert(hasFireResistanceBonus == false, "hasFireResistanceBonus is incorrect!"); enhancementSet = GetEnhancementSetByIndex(GetEnhancementSetIndexByName("Shield Wall")); Debug.Assert(enhancementSet != null, "enhancementSet is incorrect!"); hasRegenerationBonus = HasBonusEffect(enhancementSet, 6, Enums.eEffectType.Regeneration, Enums.eDamage.None); Debug.Assert(hasRegenerationBonus == true, "hasRegenerationBonus is incorrect!"); hasRegenerationBonus = HasBonusEffect(enhancementSet, 6, Enums.eEffectType.Regeneration, Enums.eDamage.None, 0.1f); Debug.Assert(hasRegenerationBonus == true, "hasRegenerationBonus is incorrect!"); hasRegenerationBonus = HasBonusEffect(enhancementSet, 6, Enums.eEffectType.Regeneration, Enums.eDamage.None, 0.01f); Debug.Assert(hasRegenerationBonus == false, "hasRegenerationBonus is incorrect!"); hasRegenerationBonus = HasBonusEffect(enhancementSet, 6, Enums.eEffectType.Regeneration, Enums.eDamage.None, -1.0f, true); Debug.Assert(hasRegenerationBonus == true, "hasRegenerationBonus is incorrect!"); bool hasRecoveryBonus = HasBonusEffect(enhancementSet, 6, Enums.eEffectType.Recovery, Enums.eDamage.None); Debug.Assert(hasRecoveryBonus == false, "hasRecoveryBonus is incorrect!"); hasRecoveryBonus = HasBonusEffect(enhancementSet, 6, Enums.eEffectType.Recovery, Enums.eDamage.None, -1.0f, true); Debug.Assert(hasRecoveryBonus == true, "hasRecoveryBonus is incorrect!"); } public static void TestGetEnhancementSetsWithBonusEffect() { IPower power = GetPowerByIndex(0); HashSet defenseBonusSets = GetEnhancementSetsWithBonusEffect(power, 6, Enums.eEffectType.Defense); Debug.Print("Defense (6 slots)"); foreach (EnhancementSet enhancementSet in defenseBonusSets) { Debug.Print(enhancementSet.DisplayName); } Debug.Assert(defenseBonusSets.Count == 14, "defenseBonusSets.Count is incorrect!"); EnhancementSet[] defenseBonusSetsArray = defenseBonusSets.ToArray(); Debug.Assert(defenseBonusSetsArray[0].DisplayName == "Maelstrom's Fury", "defenseBonusSetsArray[0].DisplayName is incorrect!"); Debug.Assert(defenseBonusSetsArray[1].DisplayName == "Ruin", "defenseBonusSetsArray[1].DisplayName is incorrect!"); Debug.Assert(defenseBonusSetsArray[2].DisplayName == "Thunderstrike", "defenseBonusSetsArray[2].DisplayName is incorrect!"); Debug.Assert(defenseBonusSetsArray[3].DisplayName == "Devastation", "defenseBonusSetsArray[3].DisplayName is incorrect!"); Debug.Assert(defenseBonusSetsArray[4].DisplayName == "Exploited Vulnerability", "defenseBonusSetsArray[4].DisplayName is incorrect!"); Debug.Assert(defenseBonusSetsArray[5].DisplayName == "Achilles' Heel", "defenseBonusSetsArray[5].DisplayName is incorrect!"); Debug.Assert(defenseBonusSetsArray[6].DisplayName == "Undermined Defenses", "defenseBonusSetsArray[6].DisplayName is incorrect!"); Debug.Assert(defenseBonusSetsArray[7].DisplayName == "Apocalypse", "defenseBonusSetsArray[7].DisplayName is incorrect!"); Debug.Assert(defenseBonusSetsArray[8].DisplayName == "Shield Breaker", "defenseBonusSetsArray[8].DisplayName is incorrect!"); Debug.Assert(defenseBonusSetsArray[9].DisplayName == "Overwhelming Force", "defenseBonusSetsArray[9].DisplayName is incorrect!"); Debug.Assert(defenseBonusSetsArray[10].DisplayName == "Spider's Bite", "defenseBonusSetsArray[10].DisplayName is incorrect!"); Debug.Assert(defenseBonusSetsArray[11].DisplayName == "Superior Spider's Bite", "defenseBonusSetsArray[11].DisplayName is incorrect!"); Debug.Assert(defenseBonusSetsArray[12].DisplayName == "Winter's Bite", "defenseBonusSetsArray[12].DisplayName is incorrect!"); Debug.Assert(defenseBonusSetsArray[13].DisplayName == "Superior Winter's Bite", "defenseBonusSetsArray[13].DisplayName is incorrect!"); HashSet psionicDefenseBonusSets = GetEnhancementSetsWithBonusEffect(power, 6, Enums.eEffectType.Defense, Enums.eDamage.Psionic); Debug.Assert(psionicDefenseBonusSets.Count == 2, "psionicDefenseBonusSets.Count is incorrect!"); EnhancementSet[] psionicDefenseBonusSetsArray = psionicDefenseBonusSets.ToArray(); Debug.Assert(psionicDefenseBonusSetsArray[0].DisplayName == "Devastation", "psionicDefenseBonusSetsArray[0].DisplayName is incorrect!"); Debug.Assert(psionicDefenseBonusSetsArray[1].DisplayName == "Apocalypse", "psionicDefenseBonusSetsArray[1].DisplayName is incorrect!"); Debug.Print(" "); Debug.Print("Psionic Defense (6 slots)"); foreach (EnhancementSet enhancementSet in psionicDefenseBonusSets) { Debug.Print(enhancementSet.DisplayName); } HashSet enduranceDiscountBonusSets = GetEnhancementSetsWithBonusEffect(power, 6, Enums.eEffectType.EnduranceDiscount); Debug.Assert(enduranceDiscountBonusSets.Count == 0, "enduranceDiscountBonusSets.Count is incorrect!"); Debug.Print(" "); Debug.Print("EnduranceDiscount (6 slots)"); foreach (EnhancementSet enhancementSet in enduranceDiscountBonusSets) { Debug.Print(enhancementSet.DisplayName); } Debug.Print(" "); defenseBonusSets = GetEnhancementSetsWithBonusEffect(power, 5, Enums.eEffectType.Defense); Debug.Print("Defense (5 slots)"); foreach (EnhancementSet enhancementSet in defenseBonusSets) { Debug.Print(enhancementSet.DisplayName); } Debug.Assert(defenseBonusSets.Count == 11, "defenseBonusSets.Count is incorrect!"); defenseBonusSetsArray = defenseBonusSets.ToArray(); Debug.Assert(defenseBonusSetsArray[0].DisplayName == "Maelstrom's Fury", "defenseBonusSetsArray[0].DisplayName is incorrect!"); Debug.Assert(defenseBonusSetsArray[1].DisplayName == "Ruin", "defenseBonusSetsArray[1].DisplayName is incorrect!"); Debug.Assert(defenseBonusSetsArray[2].DisplayName == "Thunderstrike", "defenseBonusSetsArray[2].DisplayName is incorrect!"); Debug.Assert(defenseBonusSetsArray[3].DisplayName == "Exploited Vulnerability", "defenseBonusSetsArray[3].DisplayName is incorrect!"); Debug.Assert(defenseBonusSetsArray[4].DisplayName == "Achilles' Heel", "defenseBonusSetsArray[4].DisplayName is incorrect!"); Debug.Assert(defenseBonusSetsArray[5].DisplayName == "Shield Breaker", "defenseBonusSetsArray[5].DisplayName is incorrect!"); Debug.Assert(defenseBonusSetsArray[6].DisplayName == "Overwhelming Force", "defenseBonusSetsArray[6].DisplayName is incorrect!"); Debug.Assert(defenseBonusSetsArray[7].DisplayName == "Spider's Bite", "defenseBonusSetsArray[7].DisplayName is incorrect!"); Debug.Assert(defenseBonusSetsArray[8].DisplayName == "Superior Spider's Bite", "defenseBonusSetsArray[8].DisplayName is incorrect!"); Debug.Assert(defenseBonusSetsArray[9].DisplayName == "Winter's Bite", "defenseBonusSetsArray[9].DisplayName is incorrect!"); Debug.Assert(defenseBonusSetsArray[10].DisplayName == "Superior Winter's Bite", "defenseBonusSetsArray[10].DisplayName is incorrect!"); Debug.Print(" "); defenseBonusSets = GetEnhancementSetsWithBonusEffect(power, 4, Enums.eEffectType.Defense); Debug.Print("Defense (4 slots)"); foreach (EnhancementSet enhancementSet in defenseBonusSets) { Debug.Print(enhancementSet.DisplayName); } Debug.Assert(defenseBonusSets.Count == 7, "defenseBonusSets.Count is incorrect!"); defenseBonusSetsArray = defenseBonusSets.ToArray(); Debug.Assert(defenseBonusSetsArray[0].DisplayName == "Maelstrom's Fury", "defenseBonusSetsArray[0].DisplayName is incorrect!"); Debug.Assert(defenseBonusSetsArray[1].DisplayName == "Thunderstrike", "defenseBonusSetsArray[1].DisplayName is incorrect!"); Debug.Assert(defenseBonusSetsArray[2].DisplayName == "Exploited Vulnerability", "defenseBonusSetsArray[2].DisplayName is incorrect!"); Debug.Assert(defenseBonusSetsArray[3].DisplayName == "Achilles' Heel", "defenseBonusSetsArray[3].DisplayName is incorrect!"); Debug.Assert(defenseBonusSetsArray[4].DisplayName == "Shield Breaker", "defenseBonusSetsArray[4].DisplayName is incorrect!"); Debug.Assert(defenseBonusSetsArray[5].DisplayName == "Spider's Bite", "defenseBonusSetsArray[5].DisplayName is incorrect!"); Debug.Assert(defenseBonusSetsArray[6].DisplayName == "Superior Spider's Bite", "defenseBonusSetsArray[6].DisplayName is incorrect!"); Debug.Print(" "); defenseBonusSets = GetEnhancementSetsWithBonusEffect(power, 3, Enums.eEffectType.Defense); Debug.Print("Defense (3 slots)"); foreach (EnhancementSet enhancementSet in defenseBonusSets) { Debug.Print(enhancementSet.DisplayName); } Debug.Assert(defenseBonusSets.Count == 4, "defenseBonusSets.Count is incorrect!"); defenseBonusSetsArray = defenseBonusSets.ToArray(); Debug.Assert(defenseBonusSetsArray[0].DisplayName == "Maelstrom's Fury", "defenseBonusSetsArray[0].DisplayName is incorrect!"); Debug.Assert(defenseBonusSetsArray[1].DisplayName == "Thunderstrike", "defenseBonusSetsArray[1].DisplayName is incorrect!"); Debug.Assert(defenseBonusSetsArray[2].DisplayName == "Exploited Vulnerability", "defenseBonusSetsArray[2].DisplayName is incorrect!"); Debug.Assert(defenseBonusSetsArray[3].DisplayName == "Achilles' Heel", "defenseBonusSetsArray[3].DisplayName is incorrect!"); Debug.Print(" "); defenseBonusSets = GetEnhancementSetsWithBonusEffect(power, 2, Enums.eEffectType.Defense); Debug.Print("Defense (2 slots)"); foreach (EnhancementSet enhancementSet in defenseBonusSets) { Debug.Print(enhancementSet.DisplayName); } Debug.Assert(defenseBonusSets.Count == 0, "defenseBonusSets.Count is incorrect!"); Debug.Print(" "); } public static void TestSortEnhancementSets() { IPower power = GetPowerByIndex(0); HashSet defenseBonusSets = GetEnhancementSetsWithBonusEffect(power, 6, Enums.eEffectType.Defense); EnhancementSet[] enhancementSets = SortEnhancementSets(defenseBonusSets, 6, Enums.eEffectType.Defense); for (int index1 = 0; index1 < enhancementSets.Length - 2; index1++) { float sum1 = SumEnhancementSetBonusEffect(enhancementSets[index1], 6, Enums.eEffectType.Defense); float sum2 = SumEnhancementSetBonusEffect(enhancementSets[index1 + 1], 6, Enums.eEffectType.Defense); Debug.Assert(sum1 >= sum2, "SortEnhancementSets is incorrect!"); } } public static void TestSumBonusEffect(AIToon toon) { IEnhancement enhancement = GetEnhancementByIndex(200); EnhancementSet enhancementSet = GetEnhancementSet(enhancement); float sum = SumEnhancementSetBonusEffect(enhancementSet, 6, Enums.eEffectType.Defense, Enums.eDamage.None); Debug.Assert(sum >= 0.075 && sum < 0.0752, "sum is incorrect!"); sum = SumEnhancementSetBonusEffect(enhancementSet, 5, Enums.eEffectType.Defense, Enums.eDamage.None); Debug.Assert(sum == 0.0, "sum is incorrect!"); sum = SumEnhancementSetBonusEffect(enhancementSet, 6, Enums.eEffectType.Resistance, Enums.eDamage.None); Debug.Assert(sum > 0.13444 && sum < 0.135, "sum is incorrect!"); PowerEntry fireball = toon.Level2; EnhancementSet[] enhancementSets = GetEnhancementSetsWithBonusEffect(fireball.Power, 3, Enums.eEffectType.Resistance, Enums.eDamage.Fire).ToArray(); EnhancementSet ragnarok = enhancementSets[1]; EnhancementSet positronsBlast = enhancementSets[0]; fireball.Slots[0].LoadFromString(GetLoadString(GetEnhancementByIndex(positronsBlast.Enhancements[0])), ":"); fireball.Slots[1].LoadFromString(GetLoadString(GetEnhancementByIndex(positronsBlast.Enhancements[1])), ":"); fireball.Slots[2].LoadFromString(GetLoadString(GetEnhancementByIndex(positronsBlast.Enhancements[2])), ":"); sum = SumPowerEntryBonusEffect(fireball, Enums.eEffectType.Resistance, Enums.eDamage.Fire); Debug.Assert(sum > 0.0224 && sum < 0.0226, "sum is incorrect!"); fireball.Slots[0].LoadFromString(GetLoadString(GetEnhancementByIndex(ragnarok.Enhancements[0])), ":"); fireball.Slots[1].LoadFromString(GetLoadString(GetEnhancementByIndex(ragnarok.Enhancements[1])), ":"); fireball.Slots[2].LoadFromString(GetLoadString(GetEnhancementByIndex(ragnarok.Enhancements[2])), ":"); sum = SumPowerEntryBonusEffect(fireball, Enums.eEffectType.Resistance, Enums.eDamage.Fire); Debug.Assert(sum > 0.059 && sum < 0.061, "sum is incorrect!"); fireball.Slots[3].LoadFromString(GetLoadString(GetEnhancementByIndex(positronsBlast.Enhancements[0])), ":"); fireball.Slots[4].LoadFromString(GetLoadString(GetEnhancementByIndex(positronsBlast.Enhancements[1])), ":"); fireball.Slots[5].LoadFromString(GetLoadString(GetEnhancementByIndex(positronsBlast.Enhancements[2])), ":"); sum = SumPowerEntryBonusEffect(fireball, Enums.eEffectType.Resistance, Enums.eDamage.Fire); Debug.Assert(sum > 0.0824 && sum < 0.0826, "sum is incorrect!"); string acc = GetLoadString(GetEnhancementByIndex(26)); string dam = GetLoadString(GetEnhancementByIndex(29)); string rech = GetLoadString(GetEnhancementByIndex(43)); toon.Level2.Slots[0].LoadFromString(acc, ":"); toon.Level2.Slots[1].LoadFromString(dam, ":"); toon.Level2.Slots[2].LoadFromString(dam, ":"); toon.Level2.Slots[3].LoadFromString(dam, ":"); toon.Level2.Slots[4].LoadFromString(rech, ":"); toon.Level2.Slots[5].LoadFromString(rech, ":"); Debug.Assert(toon.Level2.Slots[0].Enhancement.Enh == 26, "toon.Level2.Slots[0].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level2.Slots[1].Enhancement.Enh == 29, "toon.Level2.Slots[1].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level2.Slots[2].Enhancement.Enh == 29, "toon.Level2.Slots[2].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level2.Slots[3].Enhancement.Enh == 29, "toon.Level2.Slots[3].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level2.Slots[4].Enhancement.Enh == 43, "toon.Level2.Slots[4].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level2.Slots[5].Enhancement.Enh == 43, "toon.Level2.Slots[5].Enhancement.Enh is incorrect!"); } public static void TestGetHighestBonusEffect() { IPower power = GetPowerByIndex(0); HashSet defenseBonusSets = GetEnhancementSetsWithBonusEffect(power, 6, Enums.eEffectType.Defense); EnhancementSet highestBonusEffect = GetHighestBonusEffect(defenseBonusSets, 6, Enums.eEffectType.Defense); Debug.Print("Highest Defense (6 slots)"); Debug.Print(highestBonusEffect.DisplayName + " " + SumEnhancementSetBonusEffect(highestBonusEffect, 6, Enums.eEffectType.Defense)); Debug.Print(" "); Debug.Assert(highestBonusEffect.DisplayName == "Superior Winter's Bite", "highestBonusEffect.DisplayName is incorrect!"); defenseBonusSets = GetEnhancementSetsWithBonusEffect(power, 5, Enums.eEffectType.Defense); highestBonusEffect = GetHighestBonusEffect(defenseBonusSets, 5, Enums.eEffectType.Defense); Debug.Print("Highest Defense (5 slots)"); Debug.Print(highestBonusEffect.DisplayName + " " + SumEnhancementSetBonusEffect(highestBonusEffect, 5, Enums.eEffectType.Defense)); Debug.Print(" "); Debug.Assert(highestBonusEffect.DisplayName == "Superior Winter's Bite", "highestBonusEffect.DisplayName is incorrect!"); defenseBonusSets = GetEnhancementSetsWithBonusEffect(power, 4, Enums.eEffectType.Defense); highestBonusEffect = GetHighestBonusEffect(defenseBonusSets, 4, Enums.eEffectType.Defense); Debug.Print("Highest Defense (4 slots)"); Debug.Print(highestBonusEffect.DisplayName + " " + SumEnhancementSetBonusEffect(highestBonusEffect, 4, Enums.eEffectType.Defense)); Debug.Print(" "); Debug.Assert(highestBonusEffect.DisplayName == "Superior Spider's Bite", "highestBonusEffect.DisplayName is incorrect!"); defenseBonusSets = GetEnhancementSetsWithBonusEffect(power, 3, Enums.eEffectType.Defense); highestBonusEffect = GetHighestBonusEffect(defenseBonusSets, 3, Enums.eEffectType.Defense); Debug.Print("Highest Defense (3 slots)"); Debug.Print(highestBonusEffect.DisplayName + " " + SumEnhancementSetBonusEffect(highestBonusEffect, 3, Enums.eEffectType.Defense)); Debug.Print(" "); Debug.Assert(highestBonusEffect.DisplayName == "Thunderstrike", "highestBonusEffect.DisplayName is incorrect!"); defenseBonusSets = GetEnhancementSetsWithBonusEffect(power, 2, Enums.eEffectType.Defense); highestBonusEffect = GetHighestBonusEffect(defenseBonusSets, 2, Enums.eEffectType.Defense); Debug.Print("Highest Defense (2 slots)"); if (null != highestBonusEffect) Debug.Print(highestBonusEffect.DisplayName + " " + SumEnhancementSetBonusEffect(highestBonusEffect, 2, Enums.eEffectType.Defense)); Debug.Print(" "); defenseBonusSets = GetEnhancementSetsWithBonusEffect(power, 6, Enums.eEffectType.Defense, Enums.eDamage.Psionic); highestBonusEffect = GetHighestBonusEffect(defenseBonusSets, 6, Enums.eEffectType.Defense, Enums.eDamage.Psionic); Debug.Print(" "); Debug.Print("Highest Psionic Defense"); Debug.Print(highestBonusEffect.DisplayName); Debug.Assert(highestBonusEffect.DisplayName == "Apocalypse", "highestBonusEffect.DisplayName is incorrect!"); } public static void TestAllowsEnhancement(AIToon toon) { Debug.Assert(AllowsEnhancement(toon.Level1Primary.Power, EnhancementTypes.Accuracy) == true, "AllowsEnhancement EnhancementTypes.Accuracy is incorrect!"); Debug.Assert(AllowsEnhancement(toon.Level1Primary.Power, EnhancementTypes.Damage) == true, "AllowsEnhancement EnhancementTypes.Damage is incorrect!"); Debug.Assert(AllowsEnhancement(toon.Level1Primary.Power, EnhancementTypes.EnduranceReduction) == true, "AllowsEnhancement EnhancementTypes.EnduranceReduction is incorrect!"); Debug.Assert(AllowsEnhancement(toon.Level1Primary.Power, EnhancementTypes.Recharge) == true, "AllowsEnhancement EnhancementTypes.Recharge is incorrect!"); Debug.Assert(AllowsEnhancement(toon.Level1Primary.Power, EnhancementTypes.Heal) == false, "AllowsEnhancement EnhancementTypes.Heal is incorrect!"); } public static void TestEnhancementListing() { List linesList = new List(); string headers = "Name, Set Type, Effect Type, Damage/Enhancement/Mez Type, Scale, Slots Required, Min Level, Max Level, PvP Bonus?"; Debug.Print(" "); Debug.Print(headers); linesList.Add(headers); foreach (EnhancementSet enhancementSet in Database.EnhancementSets) { List bonusPowers = GetBonusPowers(enhancementSet); int slotsRequired = 2; foreach (IPower bonusPower in bonusPowers) { for (int effectIndex = 0; effectIndex < bonusPower.Effects.Length; ++effectIndex) { IEffect effect = bonusPower.Effects[effectIndex]; string DEMType = effect.DamageType.ToString(); if (effect.ETModifies != Enums.eEffectType.None) DEMType = effect.ETModifies.ToString(); if (effect.MezType != Enums.eMez.None) DEMType = effect.MezType.ToString(); string line = enhancementSet.DisplayName + ", " + enhancementSet.SetType + ", " + effect.EffectType + ", " + DEMType + ", " + effect.Scale + ", " + slotsRequired + ", " + (enhancementSet.LevelMin + 1) + ", " + (enhancementSet.LevelMax + 1); if (bonusPower.SetName.Equals("PvP_Set_Bonus", StringComparison.InvariantCultureIgnoreCase)) { line += ", True"; } else { line += ", False"; } Debug.Print(line); linesList.Add(line); } ++slotsRequired; if (6 < slotsRequired) slotsRequired = 2; } } string[] lines = linesList.ToArray(); System.IO.File.WriteAllLines(@"D:\src\CoH\enhancement-set-bonus.csv", lines); } public static void TestGetDefaultSlotting() { PowerEntry health = new PowerEntry(1, GetPowersetByName("Inherent Fitness", Enums.ePowerSetType.Inherent).Powers[1]); PowerEntry stamina = new PowerEntry(1, GetPowersetByName("Inherent Fitness", Enums.ePowerSetType.Inherent).Powers[3]); PowerEntry mesmerize = new PowerEntry(1, GetPowersetByName("Mind Control", Enums.ePowerSetType.Primary).Powers[0]); PowerEntry dispersionBubble = new PowerEntry(22, GetPowersetByName("Force Field", Enums.ePowerSetType.Secondary).Powers[5]); PowerEntry repulsionField = new PowerEntry(47, GetPowersetByName("Force Field", Enums.ePowerSetType.Secondary).Powers[6]); List defaultSlotting = GetDefaultSlotting(health.Power); Debug.Assert(defaultSlotting.Count == 3, "health defaultSlotting is incorrect!"); Debug.Assert(defaultSlotting[0] == GetEnhancementByIndex((int)EnhancementTypes.Heal), "health defaultSlotting[0] is incorrect!"); Debug.Assert(defaultSlotting[1] == GetEnhancementByIndex((int)EnhancementTypes.Heal), "health defaultSlotting[1] is incorrect!"); Debug.Assert(defaultSlotting[2] == GetEnhancementByIndex((int)EnhancementTypes.Heal), "health defaultSlotting[2] is incorrect!"); defaultSlotting = GetDefaultSlotting(stamina.Power); Debug.Assert(defaultSlotting.Count == 3, "stamina defaultSlotting is incorrect!"); Debug.Assert(defaultSlotting[0] == GetEnhancementByIndex((int)EnhancementTypes.EnduranceModification), "stamina defaultSlotting[0] is incorrect!"); Debug.Assert(defaultSlotting[1] == GetEnhancementByIndex((int)EnhancementTypes.EnduranceModification), "stamina defaultSlotting[1] is incorrect!"); Debug.Assert(defaultSlotting[2] == GetEnhancementByIndex((int)EnhancementTypes.EnduranceModification), "stamina defaultSlotting[2] is incorrect!"); defaultSlotting = GetDefaultSlotting(mesmerize.Power); Debug.Assert(defaultSlotting.Count == 6, "mesmerize defaultSlotting is incorrect!"); Debug.Assert(defaultSlotting[0] == GetEnhancementByIndex((int)EnhancementTypes.Accuracy), "mesmerize defaultSlotting[0] is incorrect!"); Debug.Assert(defaultSlotting[1] == GetEnhancementByIndex((int)EnhancementTypes.Damage), "mesmerize defaultSlotting[1] is incorrect!"); Debug.Assert(defaultSlotting[2] == GetEnhancementByIndex((int)EnhancementTypes.Damage), "mesmerize defaultSlotting[2] is incorrect!"); Debug.Assert(defaultSlotting[3] == GetEnhancementByIndex((int)EnhancementTypes.Damage), "mesmerize defaultSlotting[3] is incorrect!"); Debug.Assert(defaultSlotting[4] == GetEnhancementByIndex((int)EnhancementTypes.Sleep), "mesmerize defaultSlotting[4] is incorrect!"); Debug.Assert(defaultSlotting[5] == GetEnhancementByIndex((int)EnhancementTypes.Sleep), "mesmerize defaultSlotting[5] is incorrect!"); defaultSlotting = GetDefaultSlotting(dispersionBubble.Power); Debug.Assert(defaultSlotting.Count == 6, "dispersionBubble defaultSlotting is incorrect!"); Debug.Assert(defaultSlotting[0] == GetEnhancementByIndex((int)EnhancementTypes.Defense), "dispersionBubble defaultSlotting[0] is incorrect!"); Debug.Assert(defaultSlotting[1] == GetEnhancementByIndex((int)EnhancementTypes.Defense), "dispersionBubble defaultSlotting[1] is incorrect!"); Debug.Assert(defaultSlotting[2] == GetEnhancementByIndex((int)EnhancementTypes.Defense), "dispersionBubble defaultSlotting[2] is incorrect!"); Debug.Assert(defaultSlotting[3] == GetEnhancementByIndex((int)EnhancementTypes.EnduranceReduction), "dispersionBubble defaultSlotting[3] is incorrect!"); Debug.Assert(defaultSlotting[4] == GetEnhancementByIndex((int)EnhancementTypes.EnduranceReduction), "dispersionBubble defaultSlotting[4] is incorrect!"); Debug.Assert(defaultSlotting[5] == GetEnhancementByIndex((int)EnhancementTypes.EnduranceReduction), "dispersionBubble defaultSlotting[5] is incorrect!"); defaultSlotting = GetDefaultSlotting(repulsionField.Power); Debug.Assert(defaultSlotting.Count == 3, "repulsionField defaultSlotting is incorrect!"); Debug.Assert(defaultSlotting[0] == GetEnhancementByIndex((int)EnhancementTypes.Recharge), "repulsionField defaultSlotting[0] is incorrect!"); Debug.Assert(defaultSlotting[1] == GetEnhancementByIndex((int)EnhancementTypes.Recharge), "repulsionField defaultSlotting[1] is incorrect!"); Debug.Assert(defaultSlotting[2] == GetEnhancementByIndex((int)EnhancementTypes.Recharge), "repulsionField defaultSlotting[2] is incorrect!"); } public static void TestDoDefaultSlotting() { PowerEntry health = new PowerEntry(1, GetPowersetByName("Inherent Fitness", Enums.ePowerSetType.Inherent).Powers[1]); PowerEntry stamina = new PowerEntry(1, GetPowersetByName("Inherent Fitness", Enums.ePowerSetType.Inherent).Powers[3]); PowerEntry mesmerize = new PowerEntry(1, GetPowersetByName("Mind Control", Enums.ePowerSetType.Primary).Powers[0]); PowerEntry dispersionBubble = new PowerEntry(22, GetPowersetByName("Force Field", Enums.ePowerSetType.Secondary).Powers[5]); PowerEntry repulsionField = new PowerEntry(47, GetPowersetByName("Force Field", Enums.ePowerSetType.Secondary).Powers[6]); Debug.Assert(DoDefaultSlotting(health, 3) == true, "health DoDefaultSlotting is incorrect!"); Debug.Assert(health.Slots.Length == 3, "health.Slots.Length is incorrect!"); Debug.Assert(health.Slots[0].Enhancement.Enh == (int)EnhancementTypes.Heal, "health.Slots[0].Enhancement.Enh is incorrect!"); Debug.Assert(health.Slots[1].Enhancement.Enh == (int)EnhancementTypes.Heal, "health.Slots[1].Enhancement.Enh is incorrect!"); Debug.Assert(health.Slots[2].Enhancement.Enh == (int)EnhancementTypes.Heal, "health.Slots[2].Enhancement.Enh is incorrect!"); Debug.Assert(DoDefaultSlotting(stamina, 3) == true, "stamina DoDefaultSlotting is incorrect!"); Debug.Assert(stamina.Slots.Length == 3, "stamina.Slots.Length is incorrect!"); Debug.Assert(stamina.Slots[0].Enhancement.Enh == (int)EnhancementTypes.EnduranceModification, "stamina.Slots[0].Enhancement.Enh is incorrect!"); Debug.Assert(stamina.Slots[1].Enhancement.Enh == (int)EnhancementTypes.EnduranceModification, "stamina.Slots[1].Enhancement.Enh is incorrect!"); Debug.Assert(stamina.Slots[2].Enhancement.Enh == (int)EnhancementTypes.EnduranceModification, "stamina.Slots[2].Enhancement.Enh is incorrect!"); Debug.Assert(DoDefaultSlotting(mesmerize, 6) == true, "mesmerize DoDefaultSlotting is incorrect!"); Debug.Assert(mesmerize.Slots.Length == 6, "mesmerize.Slots.Length is incorrect!"); Debug.Assert(mesmerize.Slots[0].Enhancement.Enh == (int)EnhancementTypes.Accuracy, "mesmerize.Slots[0].Enhancement.Enh is incorrect!"); Debug.Assert(mesmerize.Slots[1].Enhancement.Enh == (int)EnhancementTypes.Damage, "mesmerize.Slots[1].Enhancement.Enh is incorrect!"); Debug.Assert(mesmerize.Slots[2].Enhancement.Enh == (int)EnhancementTypes.Damage, "mesmerize.Slots[2].Enhancement.Enh is incorrect!"); Debug.Assert(mesmerize.Slots[3].Enhancement.Enh == (int)EnhancementTypes.Damage, "mesmerize.Slots[3].Enhancement.Enh is incorrect!"); Debug.Assert(mesmerize.Slots[4].Enhancement.Enh == (int)EnhancementTypes.Sleep, "mesmerize.Slots[4].Enhancement.Enh is incorrect!"); Debug.Assert(mesmerize.Slots[5].Enhancement.Enh == (int)EnhancementTypes.Sleep, "mesmerize.Slots[5].Enhancement.Enh is incorrect!"); Debug.Assert(DoDefaultSlotting(dispersionBubble, 6) == true, "dispersionBubble DoDefaultSlotting is incorrect!"); Debug.Assert(dispersionBubble.Slots.Length == 6, "dispersionBubble.Slots.Length is incorrect!"); Debug.Assert(dispersionBubble.Slots[0].Enhancement.Enh == (int)EnhancementTypes.Defense, "dispersionBubble.Slots[0].Enhancement.Enh is incorrect!"); Debug.Assert(dispersionBubble.Slots[1].Enhancement.Enh == (int)EnhancementTypes.Defense, "dispersionBubble.Slots[1].Enhancement.Enh is incorrect!"); Debug.Assert(dispersionBubble.Slots[2].Enhancement.Enh == (int)EnhancementTypes.Defense, "dispersionBubble.Slots[2].Enhancement.Enh is incorrect!"); Debug.Assert(dispersionBubble.Slots[3].Enhancement.Enh == (int)EnhancementTypes.EnduranceReduction, "dispersionBubble.Slots[3].Enhancement.Enh is incorrect!"); Debug.Assert(dispersionBubble.Slots[4].Enhancement.Enh == (int)EnhancementTypes.EnduranceReduction, "dispersionBubble.Slots[4].Enhancement.Enh is incorrect!"); Debug.Assert(dispersionBubble.Slots[5].Enhancement.Enh == (int)EnhancementTypes.EnduranceReduction, "dispersionBubble.Slots[5].Enhancement.Enh is incorrect!"); Debug.Assert(DoDefaultSlotting(repulsionField, 3) == true, "repulsionField DoDefaultSlotting is incorrect!"); Debug.Assert(repulsionField.Slots.Length == 3, "repulsionField.Slots.Length is incorrect!"); Debug.Assert(repulsionField.Slots[0].Enhancement.Enh == (int)EnhancementTypes.Recharge, "repulsionField.Slots[0].Enhancement.Enh is incorrect!"); Debug.Assert(repulsionField.Slots[1].Enhancement.Enh == (int)EnhancementTypes.Recharge, "repulsionField.Slots[1].Enhancement.Enh is incorrect!"); Debug.Assert(repulsionField.Slots[2].Enhancement.Enh == (int)EnhancementTypes.Recharge, "repulsionField.Slots[2].Enhancement.Enh is incorrect!"); Debug.Assert(DoDefaultSlotting(repulsionField, 1) == true, "repulsionField DoDefaultSlotting is incorrect!"); Debug.Assert(repulsionField.Slots.Length == 1, "repulsionField.Slots.Length is incorrect!"); Debug.Assert(repulsionField.Slots[0].Enhancement.Enh == (int)EnhancementTypes.Recharge, "repulsionField.Slots[0].Enhancement.Enh is incorrect!"); } public static void TestSetDefaultSlotLevels(AIToon toon) { toon.SetDefaultSlotLevels(); Debug.Assert(toon.Health.Slots[0].Level == 1, "toon.Health.Slots[0].Level is incorrect!"); Debug.Assert(toon.Health.Slots[1].Level == 2, "toon.Health.Slots[1].Level is incorrect!"); Debug.Assert(toon.Health.Slots[2].Level == 2, "toon.Health.Slots[2].Level is incorrect!"); Debug.Assert(toon.Stamina.Slots[0].Level == 1, "toon.Stamina.Slots[0].Level is incorrect!"); Debug.Assert(toon.Stamina.Slots[1].Level == 4, "toon.Stamina.Slots[1].Level is incorrect!"); Debug.Assert(toon.Stamina.Slots[2].Level == 4, "toon.Stamina.Slots[2].Level is incorrect!"); Debug.Assert(toon.Level1Primary.Slots[0].Level == 1, "toon.Level1Primary.Slots[0].Level is incorrect!"); Debug.Assert(toon.Level1Primary.Slots[1].Level == 6, "toon.Level1Primary.Slots[1].Level is incorrect!"); Debug.Assert(toon.Level1Primary.Slots[2].Level == 6, "toon.Level1Primary.Slots[2].Level is incorrect!"); Debug.Assert(toon.Level1Primary.Slots[3].Level == 8, "toon.Level1Primary.Slots[3].Level is incorrect!"); Debug.Assert(toon.Level1Primary.Slots[4].Level == 8, "toon.Level1Primary.Slots[4].Level is incorrect!"); Debug.Assert(toon.Level1Primary.Slots[5].Level == 10, "toon.Level1Primary.Slots[5].Level is incorrect!"); Debug.Assert(toon.Level1Secondary.Slots[0].Level == 1, "toon.Level1Secondary.Slots[0].Level is incorrect!"); Debug.Assert(toon.Level1Secondary.Slots[1].Level == 10, "toon.Level1Secondary.Slots[1].Level is incorrect!"); Debug.Assert(toon.Level1Secondary.Slots[2].Level == 12, "toon.Level1Secondary.Slots[2].Level is incorrect!"); Debug.Assert(toon.Level1Secondary.Slots[3].Level == 12, "toon.Level1Secondary.Slots[3].Level is incorrect!"); Debug.Assert(toon.Level1Secondary.Slots[4].Level == 14, "toon.Level1Secondary.Slots[4].Level is incorrect!"); Debug.Assert(toon.Level1Secondary.Slots[5].Level == 14, "toon.Level1Secondary.Slots[5].Level is incorrect!"); Debug.Assert(toon.Level2.Slots[0].Level == 1, "toon.Level2.Slots[0].Level is incorrect!"); Debug.Assert(toon.Level2.Slots[1].Level == 16, "toon.Level2.Slots[1].Level is incorrect!"); Debug.Assert(toon.Level2.Slots[2].Level == 16, "toon.Level2.Slots[2].Level is incorrect!"); Debug.Assert(toon.Level2.Slots[3].Level == 18, "toon.Level2.Slots[3].Level is incorrect!"); Debug.Assert(toon.Level2.Slots[4].Level == 18, "toon.Level2.Slots[4].Level is incorrect!"); Debug.Assert(toon.Level2.Slots[5].Level == 20, "toon.Level2.Slots[5].Level is incorrect!"); Debug.Assert(toon.Level4.Slots[0].Level == 3, "toon.Level4.Slots[0].Level is incorrect!"); Debug.Assert(toon.Level4.Slots[1].Level == 20, "toon.Level4.Slots[1].Level is incorrect!"); Debug.Assert(toon.Level4.Slots[2].Level == 22, "toon.Level4.Slots[2].Level is incorrect!"); Debug.Assert(toon.Level4.Slots[3].Level == 22, "toon.Level4.Slots[3].Level is incorrect!"); Debug.Assert(toon.Level4.Slots[4].Level == 24, "toon.Level4.Slots[4].Level is incorrect!"); Debug.Assert(toon.Level4.Slots[5].Level == 24, "toon.Level4.Slots[5].Level is incorrect!"); Debug.Assert(toon.Level6.Slots[0].Level == 5, "toon.Level6.Slots[0].Level is incorrect!"); Debug.Assert(toon.Level6.Slots[1].Level == 26, "toon.Level6.Slots[1].Level is incorrect!"); Debug.Assert(toon.Level6.Slots[2].Level == 26, "toon.Level6.Slots[2].Level is incorrect!"); Debug.Assert(toon.Level6.Slots[3].Level == 28, "toon.Level6.Slots[3].Level is incorrect!"); Debug.Assert(toon.Level6.Slots[4].Level == 28, "toon.Level6.Slots[4].Level is incorrect!"); Debug.Assert(toon.Level6.Slots[5].Level == 30, "toon.Level6.Slots[5].Level is incorrect!"); Debug.Assert(toon.Level8.Slots[0].Level == 7, "toon.Level8.Slots[0].Level is incorrect!"); Debug.Assert(toon.Level8.Slots[1].Level == 30, "toon.Level8.Slots[1].Level is incorrect!"); Debug.Assert(toon.Level8.Slots[2].Level == 30, "toon.Level8.Slots[2].Level is incorrect!"); Debug.Assert(toon.Level8.Slots[3].Level == 32, "toon.Level8.Slots[3].Level is incorrect!"); Debug.Assert(toon.Level8.Slots[4].Level == 32, "toon.Level8.Slots[4].Level is incorrect!"); Debug.Assert(toon.Level8.Slots[5].Level == 32, "toon.Level8.Slots[5].Level is incorrect!"); Debug.Assert(toon.Level10.Slots[0].Level == 9, "toon.Level10.Slots[0].Level is incorrect!"); Debug.Assert(toon.Level10.Slots[1].Level == 33, "toon.Level10.Slots[1].Level is incorrect!"); Debug.Assert(toon.Level10.Slots[2].Level == 33, "toon.Level10.Slots[2].Level is incorrect!"); Debug.Assert(toon.Level10.Slots[3].Level == 33, "toon.Level10.Slots[3].Level is incorrect!"); Debug.Assert(toon.Level10.Slots[4].Level == 35, "toon.Level10.Slots[4].Level is incorrect!"); Debug.Assert(toon.Level10.Slots[5].Level == 35, "toon.Level10.Slots[5].Level is incorrect!"); Debug.Assert(toon.Level12.Slots[0].Level == 11, "toon.Level12.Slots[0].Level is incorrect!"); Debug.Assert(toon.Level12.Slots[1].Level == 35, "toon.Level12.Slots[1].Level is incorrect!"); Debug.Assert(toon.Level12.Slots[2].Level == 36, "toon.Level12.Slots[2].Level is incorrect!"); Debug.Assert(toon.Level12.Slots[3].Level == 36, "toon.Level12.Slots[3].Level is incorrect!"); Debug.Assert(toon.Level12.Slots[4].Level == 36, "toon.Level12.Slots[4].Level is incorrect!"); Debug.Assert(toon.Level12.Slots[5].Level == 38, "toon.Level12.Slots[5].Level is incorrect!"); Debug.Assert(toon.Level14.Slots[0].Level == 13, "toon.Level14.Slots[0].Level is incorrect!"); Debug.Assert(toon.Level14.Slots[1].Level == 38, "toon.Level14.Slots[1].Level is incorrect!"); Debug.Assert(toon.Level14.Slots[2].Level == 38, "toon.Level14.Slots[2].Level is incorrect!"); Debug.Assert(toon.Level14.Slots[3].Level == 39, "toon.Level14.Slots[3].Level is incorrect!"); Debug.Assert(toon.Level14.Slots[4].Level == 39, "toon.Level14.Slots[4].Level is incorrect!"); Debug.Assert(toon.Level14.Slots[5].Level == 39, "toon.Level14.Slots[5].Level is incorrect!"); Debug.Assert(toon.Level16.Slots[0].Level == 15, "toon.Level16.Slots[0].Level is incorrect!"); Debug.Assert(toon.Level16.Slots[1].Level == 41, "toon.Level16.Slots[1].Level is incorrect!"); Debug.Assert(toon.Level16.Slots[2].Level == 41, "toon.Level16.Slots[2].Level is incorrect!"); Debug.Assert(toon.Level16.Slots[3].Level == 41, "toon.Level16.Slots[3].Level is incorrect!"); Debug.Assert(toon.Level16.Slots[4].Level == 42, "toon.Level16.Slots[4].Level is incorrect!"); Debug.Assert(toon.Level16.Slots[5].Level == 42, "toon.Level16.Slots[5].Level is incorrect!"); Debug.Assert(toon.Level18.Slots[0].Level == 17, "toon.Level18.Slots[0].Level is incorrect!"); Debug.Assert(toon.Level18.Slots[1].Level == 42, "toon.Level18.Slots[1].Level is incorrect!"); Debug.Assert(toon.Level18.Slots[2].Level == 44, "toon.Level18.Slots[2].Level is incorrect!"); Debug.Assert(toon.Level18.Slots[3].Level == 44, "toon.Level18.Slots[3].Level is incorrect!"); Debug.Assert(toon.Level18.Slots[4].Level == 44, "toon.Level18.Slots[4].Level is incorrect!"); Debug.Assert(toon.Level18.Slots[5].Level == 45, "toon.Level18.Slots[5].Level is incorrect!"); Debug.Assert(toon.Level20.Slots[0].Level == 19, "toon.Level20.Slots[0].Level is incorrect!"); Debug.Assert(toon.Level20.Slots[1].Level == 45, "toon.Level20.Slots[1].Level is incorrect!"); Debug.Assert(toon.Level20.Slots[2].Level == 45, "toon.Level20.Slots[2].Level is incorrect!"); Debug.Assert(toon.Level20.Slots[3].Level == 47, "toon.Level20.Slots[3].Level is incorrect!"); Debug.Assert(toon.Level20.Slots[4].Level == 47, "toon.Level20.Slots[4].Level is incorrect!"); Debug.Assert(toon.Level22.Slots[0].Level == 21, "toon.Level22.Slots[0].Level is incorrect!"); Debug.Assert(toon.Level22.Slots[1].Level == 47, "toon.Level22.Slots[1].Level is incorrect!"); Debug.Assert(toon.Level22.Slots[2].Level == 49, "toon.Level22.Slots[2].Level is incorrect!"); Debug.Assert(toon.Level22.Slots[3].Level == 49, "toon.Level22.Slots[3].Level is incorrect!"); Debug.Assert(toon.Level22.Slots[4].Level == 49, "toon.Level22.Slots[4].Level is incorrect!"); Debug.Assert(toon.Level24.Slots[0].Level == 23, "toon.Level24.Slots[0].Level is incorrect!"); Debug.Assert(toon.Level26.Slots[0].Level == 25, "toon.Level26.Slots[0].Level is incorrect!"); Debug.Assert(toon.Level28.Slots[0].Level == 27, "toon.Level28.Slots[0].Level is incorrect!"); Debug.Assert(toon.Level30.Slots[0].Level == 29, "toon.Level30.Slots[0].Level is incorrect!"); Debug.Assert(toon.Level32.Slots[0].Level == 31, "toon.Level32.Slots[0].Level is incorrect!"); Debug.Assert(toon.Level35.Slots[0].Level == 34, "toon.Level35.Slots[0].Level is incorrect!"); Debug.Assert(toon.Level38.Slots[0].Level == 37, "toon.Level38.Slots[0].Level is incorrect!"); Debug.Assert(toon.Level41.Slots[0].Level == 40, "toon.Level41.Slots[0].Level is incorrect!"); Debug.Assert(toon.Level44.Slots[0].Level == 43, "toon.Level44.Slots[0].Level is incorrect!"); Debug.Assert(toon.Level47.Slots[0].Level == 46, "toon.Level47.Slots[0].Level is incorrect!"); Debug.Assert(toon.Level49.Slots[0].Level == 48, "toon.Level49.Slots[0].Level is incorrect!"); } public static void TestSlot() { AIToon toon = TestCreateBuildControllerMindForceField(); int[] enhancementIndexes = { 272, 273, 274, 275, 276, 277 }; Slot(toon.Level1Secondary, enhancementIndexes); Debug.Assert(toon.Level1Secondary.SlotCount == 6, "toon.Level1Secondary.SlotCount is incorrect!"); Debug.Assert(toon.Level1Secondary.Slots[0].Enhancement.Enh == 272, "toon.Level1Secondary.Slots[0].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level1Secondary.Slots[1].Enhancement.Enh == 273, "toon.Level1Secondary.Slots[1].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level1Secondary.Slots[2].Enhancement.Enh == 274, "toon.Level1Secondary.Slots[2].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level1Secondary.Slots[3].Enhancement.Enh == 275, "toon.Level1Secondary.Slots[3].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level1Secondary.Slots[4].Enhancement.Enh == 276, "toon.Level1Secondary.Slots[4].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level1Secondary.Slots[5].Enhancement.Enh == 277, "toon.Level1Secondary.Slots[5].Enhancement.Enh is incorrect!"); } public static AIToon TestCreateBuildBlasterFireMental() { AIToon toon = new AIToon(); toon.Archetype = DatabaseAPI.GetArchetypeByName("Blaster"); Debug.Assert(toon.Archetype.DisplayName == "Blaster", "toon.Archetype.DisplayName is incorrect!"); toon.Fitness = GetPowersetByName("Inherent Fitness", Enums.ePowerSetType.Inherent); toon.Primary = GetPowersetByName("Fire Blast", Enums.ePowerSetType.Primary); toon.Secondary = GetPowersetByName("Mental Manipulation", Enums.ePowerSetType.Secondary); toon.Pool1 = GetPowersetByName("Speed", Enums.ePowerSetType.Pool); toon.Pool2 = GetPowersetByName("Fighting", Enums.ePowerSetType.Pool); toon.Pool3 = GetPowersetByName("Concealment", Enums.ePowerSetType.Pool); toon.Pool4 = GetPowersetByName("Force of Will", Enums.ePowerSetType.Pool); toon.Epic = GetPowersetByName("Force Mastery", Enums.ePowerSetType.Ancillary); Debug.Assert(toon.Fitness.DisplayName == "Inherent Fitness", "toon.Fitness.DisplayName is incorrect!"); Debug.Assert(toon.Primary.DisplayName == "Fire Blast", "toon.Primary.DisplayName is incorrect!"); Debug.Assert(toon.Secondary.DisplayName == "Mental Manipulation", "toon.Secondary.DisplayName is incorrect!"); Debug.Assert(toon.Pool1.DisplayName == "Speed", "toon.Pool1.DisplayName is incorrect!"); Debug.Assert(toon.Pool2.DisplayName == "Fighting", "toon.Pool2.DisplayName is incorrect!"); Debug.Assert(toon.Pool3.DisplayName == "Concealment", "toon.Pool3.DisplayName is incorrect!"); Debug.Assert(toon.Pool4.DisplayName == "Force of Will", "toon.Pool4.DisplayName is incorrect!"); Debug.Assert(toon.Epic.DisplayName == "Force Mastery", "toon.Epic.DisplayName is incorrect!"); toon.Health = new PowerEntry(0, toon.Fitness.Powers[1]); // Health toon.Stamina = new PowerEntry(0, toon.Fitness.Powers[3]); // Stamina toon.Level1Primary = new PowerEntry(0, toon.Primary.Powers[0]); // Flares toon.Level1Secondary = new PowerEntry(0, toon.Secondary.Powers[0]); // Subdual toon.Level2 = new PowerEntry(1, toon.Primary.Powers[2]); // Fire Ball toon.Level4 = new PowerEntry(3, toon.Pool1.Powers[1]); // Hasten toon.Level6 = new PowerEntry(5, toon.Primary.Powers[3]); // Rain of Fire toon.Level8 = new PowerEntry(7, toon.Pool2.Powers[1]); // Kick toon.Level10 = new PowerEntry(9, toon.Pool3.Powers[1]); // Grant Invisibility toon.Level12 = new PowerEntry(11, toon.Primary.Powers[5]); // Aim toon.Level14 = new PowerEntry(13, toon.Secondary.Powers[3]); // Psychic Scream toon.Level16 = new PowerEntry(15, toon.Secondary.Powers[4]); // Concentration toon.Level18 = new PowerEntry(17, toon.Primary.Powers[6]); // Blaze toon.Level20 = new PowerEntry(19, toon.Pool3.Powers[2]); // Invisibility toon.Level22 = new PowerEntry(21, toon.Pool2.Powers[3]); // Tough toon.Level24 = new PowerEntry(23, toon.Pool2.Powers[4]); // Weave toon.Level26 = new PowerEntry(25, toon.Primary.Powers[7]); // Blazing Bolt toon.Level28 = new PowerEntry(27, toon.Pool4.Powers[1]); // Weaken Resolve toon.Level30 = new PowerEntry(29, toon.Pool1.Powers[2]); // Super Speed toon.Level32 = new PowerEntry(31, toon.Primary.Powers[8]); // Inferno toon.Level35 = new PowerEntry(34, toon.Epic.Powers[0]); // Personal Force Field toon.Level38 = new PowerEntry(37, toon.Secondary.Powers[8]); // Psychic Shockwave toon.Level41 = new PowerEntry(40, toon.Epic.Powers[3]); // Temp Invulnerability toon.Level44 = new PowerEntry(43, toon.Epic.Powers[4]); // Force of Nature toon.Level47 = new PowerEntry(46, toon.Epic.Powers[1]); // Repulsion Field toon.Level49 = new PowerEntry(48, toon.Pool1.Powers[3]); // Burnout Debug.Assert(toon.Health.Power.DisplayName == "Health", "toon.Health.Power.DisplayName is incorrect!"); Debug.Assert(toon.Stamina.Power.DisplayName == "Stamina", "toon.Stamina.Power.DisplayName is incorrect!"); Debug.Assert(toon.Level1Primary.Power.DisplayName == "Flares", "toon.Level1Primary.Power.DisplayName is incorrect!"); Debug.Assert(toon.Level1Secondary.Power.DisplayName == "Subdual", "toon.Level1Secondary.Power.DisplayName is incorrect!"); Debug.Assert(toon.Level2.Power.DisplayName == "Fire Ball", "toon.Level2.Power.DisplayName is incorrect!"); Debug.Assert(toon.Level4.Power.DisplayName == "Hasten", "toon.Level4.Power.DisplayName is incorrect!"); Debug.Assert(toon.Level6.Power.DisplayName == "Rain of Fire", "toon.Level6.Power.DisplayName is incorrect!"); Debug.Assert(toon.Level8.Power.DisplayName == "Kick", "toon.Level8.Power.DisplayName is incorrect!"); Debug.Assert(toon.Level10.Power.DisplayName == "Grant Invisibility", "toon.Level10.Power.DisplayName is incorrect!"); Debug.Assert(toon.Level12.Power.DisplayName == "Aim", "toon.Level12.Power.DisplayName is incorrect!"); Debug.Assert(toon.Level14.Power.DisplayName == "Psychic Scream", "toon.Level14.Power.DisplayName is incorrect!"); Debug.Assert(toon.Level16.Power.DisplayName == "Concentration", "toon.Level16.Power.DisplayName is incorrect!"); Debug.Assert(toon.Level18.Power.DisplayName == "Blaze", "toon.Level18.Power.DisplayName is incorrect!"); Debug.Assert(toon.Level20.Power.DisplayName == "Invisibility", "toon.Level20.Power.DisplayName is incorrect!"); Debug.Assert(toon.Level22.Power.DisplayName == "Tough", "toon.Level22.Power.DisplayName is incorrect!"); Debug.Assert(toon.Level24.Power.DisplayName == "Weave", "toon.Level24.Power.DisplayName is incorrect!"); Debug.Assert(toon.Level26.Power.DisplayName == "Blazing Bolt", "toon.Level26.Power.DisplayName is incorrect!"); Debug.Assert(toon.Level28.Power.DisplayName == "Weaken Resolve", "toon.Level28.Power.DisplayName is incorrect!"); Debug.Assert(toon.Level30.Power.DisplayName == "Super Speed", "toon.Level30.Power.DisplayName is incorrect!"); Debug.Assert(toon.Level32.Power.DisplayName == "Inferno", "toon.Level32.Power.DisplayName is incorrect!"); Debug.Assert(toon.Level35.Power.DisplayName == "Personal Force Field", "toon.Level35.Power.DisplayName is incorrect!"); Debug.Assert(toon.Level38.Power.DisplayName == "Psychic Shockwave", "toon.Level38.Power.DisplayName is incorrect!"); Debug.Assert(toon.Level41.Power.DisplayName == "Temp Invulnerability", "toon.Level41.Power.DisplayName is incorrect!"); Debug.Assert(toon.Level44.Power.DisplayName == "Force of Nature", "toon.Level44.Power.DisplayName is incorrect!"); Debug.Assert(toon.Level47.Power.DisplayName == "Repulsion Field", "toon.Level47.Power.DisplayName is incorrect!"); Debug.Assert(toon.Level49.Power.DisplayName == "Burnout", "toon.Level49.Power.DisplayName is incorrect!"); DoDefaultSlotting(toon.Health, 2); DoDefaultSlotting(toon.Stamina, 4); DoDefaultSlotting(toon.Level1Primary, 5); DoDefaultSlotting(toon.Level1Secondary, 1); DoDefaultSlotting(toon.Level2, 6); DoDefaultSlotting(toon.Level4, 2); DoDefaultSlotting(toon.Level6, 6); DoDefaultSlotting(toon.Level8, 1); DoDefaultSlotting(toon.Level10, 1); DoDefaultSlotting(toon.Level12, 2); DoDefaultSlotting(toon.Level14, 5); DoDefaultSlotting(toon.Level16, 2); DoDefaultSlotting(toon.Level18, 5); DoDefaultSlotting(toon.Level20, 4); DoDefaultSlotting(toon.Level22, 6); DoDefaultSlotting(toon.Level24, 5); DoDefaultSlotting(toon.Level26, 5); DoDefaultSlotting(toon.Level28, 3); DoDefaultSlotting(toon.Level30, 1); DoDefaultSlotting(toon.Level32, 5); DoDefaultSlotting(toon.Level35, 1); DoDefaultSlotting(toon.Level38, 5); DoDefaultSlotting(toon.Level41, 6); DoDefaultSlotting(toon.Level44, 5); DoDefaultSlotting(toon.Level47, 3); DoDefaultSlotting(toon.Level49, 2); toon.SetDefaultSlotLevels(); Debug.Assert(toon.Health.Slots.Length == 2, "toon.Health.Slots.Length is incorrect!"); Debug.Assert(toon.Stamina.Slots.Length == 4, "toon.Stamina.Slots.Length is incorrect!"); Debug.Assert(toon.Level1Primary.Slots.Length == 5, "toon.Level1Primary.Slots.Length is incorrect!"); Debug.Assert(toon.Level1Secondary.Slots.Length == 1, "toon.Level1Secondary.Slots.Length is incorrect!"); Debug.Assert(toon.Level2.Slots.Length == 6, "toon.Level2.Slots.Length is incorrect!"); Debug.Assert(toon.Level4.Slots.Length == 2, "toon.Level4.Slots.Length is incorrect!"); Debug.Assert(toon.Level6.Slots.Length == 6, "toon.Level6.Slots.Length is incorrect!"); Debug.Assert(toon.Level8.Slots.Length == 1, "toon.Level8.Slots.Length is incorrect!"); Debug.Assert(toon.Level10.Slots.Length == 1, "toon.Level10.Slots.Length is incorrect!"); Debug.Assert(toon.Level12.Slots.Length == 2, "toon.Level12.Slots.Length is incorrect!"); Debug.Assert(toon.Level14.Slots.Length == 5, "toon.Level14.Slots.Length is incorrect!"); Debug.Assert(toon.Level16.Slots.Length == 2, "toon.Level16.Slots.Length is incorrect!"); Debug.Assert(toon.Level18.Slots.Length == 5, "toon.Level18.Slots.Length is incorrect!"); Debug.Assert(toon.Level20.Slots.Length == 4, "toon.Level20.Slots.Length is incorrect!"); Debug.Assert(toon.Level22.Slots.Length == 6, "toon.Level22.Slots.Length is incorrect!"); Debug.Assert(toon.Level24.Slots.Length == 5, "toon.Level24.Slots.Length is incorrect!"); Debug.Assert(toon.Level26.Slots.Length == 5, "toon.Level26.Slots.Length is incorrect!"); Debug.Assert(toon.Level28.Slots.Length == 3, "toon.Level28.Slots.Length is incorrect!"); Debug.Assert(toon.Level30.Slots.Length == 1, "toon.Level30.Slots.Length is incorrect!"); Debug.Assert(toon.Level32.Slots.Length == 5, "toon.Level32.Slots.Length is incorrect!"); Debug.Assert(toon.Level35.Slots.Length == 1, "toon.Level35.Slots.Length is incorrect!"); Debug.Assert(toon.Level38.Slots.Length == 5, "toon.Level38.Slots.Length is incorrect!"); Debug.Assert(toon.Level41.Slots.Length == 6, "toon.Level41.Slots.Length is incorrect!"); Debug.Assert(toon.Level44.Slots.Length == 5, "toon.Level44.Slots.Length is incorrect!"); Debug.Assert(toon.Level47.Slots.Length == 3, "toon.Level47.Slots.Length is incorrect!"); Debug.Assert(toon.Level49.Slots.Length == 2, "toon.Level49.Slots.Length is incorrect!"); Debug.Assert(toon.Health.Slots[0].Enhancement.Enh == (int)EnhancementTypes.Heal, "toon.Health.Slots[0].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Health.Slots[1].Enhancement.Enh == (int)EnhancementTypes.Heal, "toon.Health.Slots[1].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Stamina.Slots[0].Enhancement.Enh == (int)EnhancementTypes.EnduranceModification, "toon.Stamina.Slots[0].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Stamina.Slots[1].Enhancement.Enh == (int)EnhancementTypes.EnduranceModification, "toon.Stamina.Slots[1].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Stamina.Slots[2].Enhancement.Enh == (int)EnhancementTypes.EnduranceModification, "toon.Stamina.Slots[2].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level1Primary.Slots[0].Enhancement.Enh == (int)EnhancementTypes.Accuracy, "toon.Level1Primary.Slots[0].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level1Primary.Slots[1].Enhancement.Enh == (int)EnhancementTypes.Damage, "toon.Level1Primary.Slots[1].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level1Primary.Slots[2].Enhancement.Enh == (int)EnhancementTypes.Damage, "toon.Level1Primary.Slots[2].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level1Primary.Slots[3].Enhancement.Enh == (int)EnhancementTypes.Damage, "toon.Level1Primary.Slots[3].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level1Primary.Slots[4].Enhancement.Enh == (int)EnhancementTypes.EnduranceReduction, "toon.Level1Primary.Slots[4].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level1Secondary.Slots[0].Enhancement.Enh == (int)EnhancementTypes.Accuracy, "toon.Level1Secondary.Slots[0].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level2.Slots[0].Enhancement.Enh == (int)EnhancementTypes.Accuracy, "toon.Level2.Slots[0].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level2.Slots[1].Enhancement.Enh == (int)EnhancementTypes.Damage, "toon.Level2.Slots[1].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level2.Slots[2].Enhancement.Enh == (int)EnhancementTypes.Damage, "toon.Level2.Slots[2].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level2.Slots[3].Enhancement.Enh == (int)EnhancementTypes.Damage, "toon.Level2.Slots[3].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level2.Slots[4].Enhancement.Enh == (int)EnhancementTypes.EnduranceReduction, "toon.Level2.Slots[4].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level2.Slots[5].Enhancement.Enh == (int)EnhancementTypes.EnduranceReduction, "toon.Level2.Slots[5].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level4.Slots[0].Enhancement.Enh == (int)EnhancementTypes.Recharge, "toon.Level4.Slots[0].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level4.Slots[1].Enhancement.Enh == (int)EnhancementTypes.Recharge, "toon.Level4.Slots[1].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level6.Slots[0].Enhancement.Enh == (int)EnhancementTypes.Accuracy, "toon.Level6.Slots[0].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level6.Slots[1].Enhancement.Enh == (int)EnhancementTypes.Damage, "toon.Level6.Slots[1].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level6.Slots[2].Enhancement.Enh == (int)EnhancementTypes.Damage, "toon.Level6.Slots[2].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level6.Slots[3].Enhancement.Enh == (int)EnhancementTypes.Damage, "toon.Level6.Slots[3].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level6.Slots[4].Enhancement.Enh == (int)EnhancementTypes.EnduranceReduction, "toon.Level6.Slots[4].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level6.Slots[5].Enhancement.Enh == (int)EnhancementTypes.EnduranceReduction, "toon.Level6.Slots[5].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level8.Slots[0].Enhancement.Enh == (int)EnhancementTypes.Accuracy, "toon.Level8.Slots[0].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level10.Slots[0].Enhancement.Enh == (int)EnhancementTypes.Defense, "toon.Level10.Slots[0].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level12.Slots[0].Enhancement.Enh == (int)EnhancementTypes.EnduranceReduction, "toon.Level12.Slots[0].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level12.Slots[1].Enhancement.Enh == (int)EnhancementTypes.EnduranceReduction, "toon.Level12.Slots[1].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level14.Slots[0].Enhancement.Enh == (int)EnhancementTypes.Accuracy, "toon.Level14.Slots[0].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level14.Slots[1].Enhancement.Enh == (int)EnhancementTypes.Damage, "toon.Level14.Slots[1].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level14.Slots[2].Enhancement.Enh == (int)EnhancementTypes.Damage, "toon.Level14.Slots[2].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level14.Slots[3].Enhancement.Enh == (int)EnhancementTypes.Damage, "toon.Level14.Slots[3].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level14.Slots[4].Enhancement.Enh == (int)EnhancementTypes.EnduranceReduction, "toon.Level14.Slots[4].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level16.Slots[0].Enhancement.Enh == (int)EnhancementTypes.EnduranceReduction, "toon.Level16.Slots[0].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level16.Slots[1].Enhancement.Enh == (int)EnhancementTypes.EnduranceReduction, "toon.Level16.Slots[1].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level18.Slots[0].Enhancement.Enh == (int)EnhancementTypes.Accuracy, "toon.Level18.Slots[0].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level18.Slots[1].Enhancement.Enh == (int)EnhancementTypes.Damage, "toon.Level18.Slots[1].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level18.Slots[2].Enhancement.Enh == (int)EnhancementTypes.Damage, "toon.Level18.Slots[2].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level18.Slots[3].Enhancement.Enh == (int)EnhancementTypes.Damage, "toon.Level18.Slots[3].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level18.Slots[4].Enhancement.Enh == (int)EnhancementTypes.EnduranceReduction, "toon.Level18.Slots[4].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level20.Slots[0].Enhancement.Enh == (int)EnhancementTypes.Defense, "toon.Level20.Slots[0].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level20.Slots[1].Enhancement.Enh == (int)EnhancementTypes.Defense, "toon.Level20.Slots[1].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level20.Slots[2].Enhancement.Enh == (int)EnhancementTypes.Defense, "toon.Level20.Slots[2].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level20.Slots[3].Enhancement.Enh == (int)EnhancementTypes.Recharge, "toon.Level20.Slots[3].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level22.Slots[0].Enhancement.Enh == (int)EnhancementTypes.Resistance, "toon.Level22.Slots[0].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level22.Slots[1].Enhancement.Enh == (int)EnhancementTypes.Resistance, "toon.Level22.Slots[1].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level22.Slots[2].Enhancement.Enh == (int)EnhancementTypes.Resistance, "toon.Level22.Slots[2].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level22.Slots[3].Enhancement.Enh == (int)EnhancementTypes.Recharge, "toon.Level22.Slots[3].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level22.Slots[4].Enhancement.Enh == (int)EnhancementTypes.Recharge, "toon.Level22.Slots[4].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level22.Slots[5].Enhancement.Enh == (int)EnhancementTypes.Recharge, "toon.Level22.Slots[5].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level24.Slots[0].Enhancement.Enh == (int)EnhancementTypes.Defense, "toon.Level24.Slots[0].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level24.Slots[1].Enhancement.Enh == (int)EnhancementTypes.Defense, "toon.Level24.Slots[1].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level24.Slots[2].Enhancement.Enh == (int)EnhancementTypes.Defense, "toon.Level24.Slots[2].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level24.Slots[3].Enhancement.Enh == (int)EnhancementTypes.Recharge, "toon.Level24.Slots[3].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level24.Slots[4].Enhancement.Enh == (int)EnhancementTypes.Recharge, "toon.Level24.Slots[4].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level26.Slots[0].Enhancement.Enh == (int)EnhancementTypes.Accuracy, "toon.Level26.Slots[0].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level26.Slots[1].Enhancement.Enh == (int)EnhancementTypes.Damage, "toon.Level26.Slots[1].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level26.Slots[2].Enhancement.Enh == (int)EnhancementTypes.Damage, "toon.Level26.Slots[2].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level26.Slots[3].Enhancement.Enh == (int)EnhancementTypes.Damage, "toon.Level26.Slots[3].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level26.Slots[4].Enhancement.Enh == (int)EnhancementTypes.EnduranceReduction, "toon.Level26.Slots[4].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level28.Slots[0].Enhancement.Enh == (int)EnhancementTypes.Accuracy, "toon.Level28.Slots[0].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level28.Slots[1].Enhancement.Enh == (int)EnhancementTypes.DefenseDebuff, "toon.Level28.Slots[1].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level28.Slots[2].Enhancement.Enh == (int)EnhancementTypes.DefenseDebuff, "toon.Level28.Slots[2].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level30.Slots[0].Enhancement.Enh == (int)EnhancementTypes.Run, "toon.Level30.Slots[0].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level32.Slots[0].Enhancement.Enh == (int)EnhancementTypes.Accuracy, "toon.Level32.Slots[0].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level32.Slots[1].Enhancement.Enh == (int)EnhancementTypes.Damage, "toon.Level32.Slots[1].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level32.Slots[2].Enhancement.Enh == (int)EnhancementTypes.Damage, "toon.Level32.Slots[2].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level32.Slots[3].Enhancement.Enh == (int)EnhancementTypes.Damage, "toon.Level32.Slots[3].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level32.Slots[4].Enhancement.Enh == (int)EnhancementTypes.EnduranceReduction, "toon.Level32.Slots[4].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level35.Slots[0].Enhancement.Enh == (int)EnhancementTypes.Defense, "toon.Level35.Slots[0].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level38.Slots[0].Enhancement.Enh == (int)EnhancementTypes.Accuracy, "toon.Level38.Slots[0].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level38.Slots[1].Enhancement.Enh == (int)EnhancementTypes.Damage, "toon.Level38.Slots[1].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level38.Slots[2].Enhancement.Enh == (int)EnhancementTypes.Damage, "toon.Level38.Slots[2].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level38.Slots[3].Enhancement.Enh == (int)EnhancementTypes.Damage, "toon.Level38.Slots[3].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level38.Slots[4].Enhancement.Enh == (int)EnhancementTypes.Stun, "toon.Level38.Slots[4].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level41.Slots[0].Enhancement.Enh == (int)EnhancementTypes.Resistance, "toon.Level41.Slots[0].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level41.Slots[1].Enhancement.Enh == (int)EnhancementTypes.Resistance, "toon.Level41.Slots[1].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level41.Slots[2].Enhancement.Enh == (int)EnhancementTypes.Resistance, "toon.Level41.Slots[2].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level41.Slots[3].Enhancement.Enh == (int)EnhancementTypes.Recharge, "toon.Level41.Slots[3].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level41.Slots[4].Enhancement.Enh == (int)EnhancementTypes.Recharge, "toon.Level41.Slots[4].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level41.Slots[5].Enhancement.Enh == (int)EnhancementTypes.Recharge, "toon.Level41.Slots[5].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level44.Slots[0].Enhancement.Enh == (int)EnhancementTypes.EnduranceModification, "toon.Level44.Slots[0].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level44.Slots[1].Enhancement.Enh == (int)EnhancementTypes.EnduranceModification, "toon.Level44.Slots[1].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level44.Slots[2].Enhancement.Enh == (int)EnhancementTypes.EnduranceModification, "toon.Level44.Slots[2].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level44.Slots[3].Enhancement.Enh == (int)EnhancementTypes.EnduranceReduction, "toon.Level44.Slots[3].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level44.Slots[4].Enhancement.Enh == (int)EnhancementTypes.EnduranceReduction, "toon.Level44.Slots[4].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level47.Slots[0].Enhancement.Enh == (int)EnhancementTypes.Recharge, "toon.Level47.Slots[0].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level47.Slots[1].Enhancement.Enh == (int)EnhancementTypes.Recharge, "toon.Level47.Slots[1].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level47.Slots[2].Enhancement.Enh == (int)EnhancementTypes.Recharge, "toon.Level47.Slots[2].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level49.Slots[0].Enhancement.Enh == (int)EnhancementTypes.Recharge, "toon.Level49.Slots[0].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level49.Slots[1].Enhancement.Enh == (int)EnhancementTypes.Recharge, "toon.Level49.Slots[1].Enhancement.Enh is incorrect!"); return toon; } public static AIToon TestCreateBuildControllerMindForceField() { AIToon toon = new AIToon(); toon.Archetype = DatabaseAPI.GetArchetypeByName("Controller"); Debug.Assert(toon.Archetype.DisplayName == "Controller", "toon.Archetype.DisplayName is incorrect!"); toon.Fitness = GetPowersetByName("Inherent Fitness", Enums.ePowerSetType.Inherent); toon.Primary = GetPowersetByName("Mind Control", Enums.ePowerSetType.Primary); toon.Secondary = GetPowersetByName("Force Field", Enums.ePowerSetType.Secondary); toon.Pool1 = GetPowersetByName("Speed", Enums.ePowerSetType.Pool); toon.Pool2 = GetPowersetByName("Concealment", Enums.ePowerSetType.Pool); toon.Pool3 = GetPowersetByName("Fighting", Enums.ePowerSetType.Pool); toon.Pool4 = GetPowersetByName("Force of Will", Enums.ePowerSetType.Pool); toon.Epic = GetPowersetByName("Primal Forces Mastery", Enums.ePowerSetType.Ancillary); Debug.Assert(toon.Fitness.DisplayName == "Inherent Fitness", "toon.Fitness.DisplayName is incorrect!"); Debug.Assert(toon.Primary.DisplayName == "Mind Control", "toon.Primary.DisplayName is incorrect!"); Debug.Assert(toon.Secondary.DisplayName == "Force Field", "toon.Secondary.DisplayName is incorrect!"); Debug.Assert(toon.Pool1.DisplayName == "Speed", "toon.Pool1.DisplayName is incorrect!"); Debug.Assert(toon.Pool2.DisplayName == "Concealment", "toon.Pool2.DisplayName is incorrect!"); Debug.Assert(toon.Pool3.DisplayName == "Fighting", "toon.Pool3.DisplayName is incorrect!"); Debug.Assert(toon.Pool4.DisplayName == "Force of Will", "toon.Pool4.DisplayName is incorrect!"); Debug.Assert(toon.Epic.DisplayName == "Primal Forces Mastery", "toon.Epic.DisplayName is incorrect!"); toon.Health = new PowerEntry(0, toon.Fitness.Powers[1]); // Health toon.Stamina = new PowerEntry(0, toon.Fitness.Powers[3]); // Stamina toon.Level1Primary = new PowerEntry(0, toon.Primary.Powers[0]); // Mesmerize toon.Level1Secondary = new PowerEntry(0, toon.Secondary.Powers[0]); // Personal Force Field toon.Level2 = new PowerEntry(1, toon.Secondary.Powers[1]); // Deflection Shield toon.Level4 = new PowerEntry(3, toon.Primary.Powers[1]); // Levitate toon.Level6 = new PowerEntry(5, toon.Primary.Powers[2]); // Dominate toon.Level8 = new PowerEntry(7, toon.Primary.Powers[3]); // Confuse toon.Level10 = new PowerEntry(9, toon.Pool2.Powers[0]); // Stealth toon.Level12 = new PowerEntry(11, toon.Pool2.Powers[1]); // Grant Invisibility toon.Level14 = new PowerEntry(13, toon.Secondary.Powers[3]); // Insulation Shield toon.Level16 = new PowerEntry(15, toon.Pool2.Powers[2]); // Invisibility toon.Level18 = new PowerEntry(17, toon.Primary.Powers[4]); // Mass Hypnosis toon.Level20 = new PowerEntry(19, toon.Primary.Powers[5]); // Telekinesis toon.Level22 = new PowerEntry(21, toon.Secondary.Powers[5]); // Dispersion Bubble toon.Level24 = new PowerEntry(23, toon.Primary.Powers[6]); // Total Domination toon.Level26 = new PowerEntry(25, toon.Primary.Powers[7]); // Terrify toon.Level28 = new PowerEntry(27, toon.Pool3.Powers[0]); // Boxing toon.Level30 = new PowerEntry(29, toon.Pool3.Powers[3]); // Tough toon.Level32 = new PowerEntry(31, toon.Pool3.Powers[4]); // Weave toon.Level35 = new PowerEntry(34, toon.Primary.Powers[8]); // Mass Confusion toon.Level38 = new PowerEntry(37, toon.Secondary.Powers[8]); // Force Bubble toon.Level41 = new PowerEntry(40, toon.Secondary.Powers[7]); // Repulsion Bomb toon.Level44 = new PowerEntry(43, toon.Secondary.Powers[2]); // Force Bolt toon.Level47 = new PowerEntry(46, toon.Secondary.Powers[6]); // Repulsion Field toon.Level49 = new PowerEntry(48, toon.Secondary.Powers[4]); // Detention Field Debug.Assert(toon.Health.Power.DisplayName == "Health", "toon.Health.Power.DisplayName is incorrect!"); Debug.Assert(toon.Stamina.Power.DisplayName == "Stamina", "toon.Stamina.Power.DisplayName is incorrect!"); Debug.Assert(toon.Level1Primary.Power.DisplayName == "Mesmerize", "toon.Level1Primary.Power.DisplayName is incorrect!"); Debug.Assert(toon.Level1Secondary.Power.DisplayName == "Personal Force Field", "toon.Level1Secondary.Power.DisplayName is incorrect!"); Debug.Assert(toon.Level2.Power.DisplayName == "Deflection Shield", "toon.Level2.Power.DisplayName is incorrect!"); Debug.Assert(toon.Level4.Power.DisplayName == "Levitate", "toon.Level4.Power.DisplayName is incorrect!"); Debug.Assert(toon.Level6.Power.DisplayName == "Dominate", "toon.Level6.Power.DisplayName is incorrect!"); Debug.Assert(toon.Level8.Power.DisplayName == "Confuse", "toon.Level8.Power.DisplayName is incorrect!"); Debug.Assert(toon.Level10.Power.DisplayName == "Stealth", "toon.Level10.Power.DisplayName is incorrect!"); Debug.Assert(toon.Level12.Power.DisplayName == "Grant Invisibility", "toon.Level12.Power.DisplayName is incorrect!"); Debug.Assert(toon.Level14.Power.DisplayName == "Insulation Shield", "toon.Level14.Power.DisplayName is incorrect!"); Debug.Assert(toon.Level16.Power.DisplayName == "Invisibility", "toon.Level16.Power.DisplayName is incorrect!"); Debug.Assert(toon.Level18.Power.DisplayName == "Mass Hypnosis", "toon.Level18.Power.DisplayName is incorrect!"); Debug.Assert(toon.Level20.Power.DisplayName == "Telekinesis", "toon.Level20.Power.DisplayName is incorrect!"); Debug.Assert(toon.Level22.Power.DisplayName == "Dispersion Bubble", "toon.Level22.Power.DisplayName is incorrect!"); Debug.Assert(toon.Level24.Power.DisplayName == "Total Domination", "toon.Level24.Power.DisplayName is incorrect!"); Debug.Assert(toon.Level26.Power.DisplayName == "Terrify", "toon.Level26.Power.DisplayName is incorrect!"); Debug.Assert(toon.Level28.Power.DisplayName == "Boxing", "toon.Level28.Power.DisplayName is incorrect!"); Debug.Assert(toon.Level30.Power.DisplayName == "Tough", "toon.Level30.Power.DisplayName is incorrect!"); Debug.Assert(toon.Level32.Power.DisplayName == "Weave", "toon.Level32.Power.DisplayName is incorrect!"); Debug.Assert(toon.Level35.Power.DisplayName == "Mass Confusion", "toon.Level35.Power.DisplayName is incorrect!"); Debug.Assert(toon.Level38.Power.DisplayName == "Force Bubble", "toon.Level38.Power.DisplayName is incorrect!"); Debug.Assert(toon.Level41.Power.DisplayName == "Repulsion Bomb", "toon.Level41.Power.DisplayName is incorrect!"); Debug.Assert(toon.Level44.Power.DisplayName == "Force Bolt", "toon.Level44.Power.DisplayName is incorrect!"); Debug.Assert(toon.Level47.Power.DisplayName == "Repulsion Field", "toon.Level47.Power.DisplayName is incorrect!"); Debug.Assert(toon.Level49.Power.DisplayName == "Detention Field", "toon.Level49.Power.DisplayName is incorrect!"); DoDefaultSlotting(toon.Health, 3); DoDefaultSlotting(toon.Stamina, 3); DoDefaultSlotting(toon.Level1Primary, 6); DoDefaultSlotting(toon.Level1Secondary, 6); DoDefaultSlotting(toon.Level2, 6); DoDefaultSlotting(toon.Level4, 6); DoDefaultSlotting(toon.Level6, 6); DoDefaultSlotting(toon.Level8, 6); DoDefaultSlotting(toon.Level10, 6); DoDefaultSlotting(toon.Level12, 6); DoDefaultSlotting(toon.Level14, 6); DoDefaultSlotting(toon.Level16, 6); DoDefaultSlotting(toon.Level18, 6); DoDefaultSlotting(toon.Level20, 5); DoDefaultSlotting(toon.Level22, 5); DoDefaultSlotting(toon.Level24, 1); DoDefaultSlotting(toon.Level26, 1); DoDefaultSlotting(toon.Level28, 1); DoDefaultSlotting(toon.Level30, 1); DoDefaultSlotting(toon.Level32, 1); DoDefaultSlotting(toon.Level35, 1); DoDefaultSlotting(toon.Level38, 1); DoDefaultSlotting(toon.Level41, 1); DoDefaultSlotting(toon.Level44, 1); DoDefaultSlotting(toon.Level47, 1); DoDefaultSlotting(toon.Level49, 1); toon.SetDefaultSlotLevels(); Debug.Assert(toon.Stamina.Slots.Length == 3, "toon.Stamina.Slots.Length is incorrect!"); Debug.Assert(toon.Health.Slots.Length == 3, "toon.Health.Slots.Length is incorrect!"); Debug.Assert(toon.Level1Primary.Slots.Length == 6, "toon.Level1Primary.Slots.Length is incorrect!"); Debug.Assert(toon.Level1Secondary.Slots.Length == 6, "toon.Level1Secondary.Slots.Length is incorrect!"); Debug.Assert(toon.Level2.Slots.Length == 6, "toon.Level2.Slots.Length is incorrect!"); Debug.Assert(toon.Level4.Slots.Length == 6, "toon.Level4.Slots.Length is incorrect!"); Debug.Assert(toon.Level6.Slots.Length == 6, "toon.Level6.Slots.Length is incorrect!"); Debug.Assert(toon.Level8.Slots.Length == 6, "toon.Level8.Slots.Length is incorrect!"); Debug.Assert(toon.Level10.Slots.Length == 6, "toon.Level10.Slots.Length is incorrect!"); Debug.Assert(toon.Level12.Slots.Length == 6, "toon.Level12.Slots.Length is incorrect!"); Debug.Assert(toon.Level14.Slots.Length == 6, "toon.Level14.Slots.Length is incorrect!"); Debug.Assert(toon.Level16.Slots.Length == 6, "toon.Level16.Slots.Length is incorrect!"); Debug.Assert(toon.Level18.Slots.Length == 6, "toon.Level18.Slots.Length is incorrect!"); Debug.Assert(toon.Level20.Slots.Length == 5, "toon.Level20.Slots.Length is incorrect!"); Debug.Assert(toon.Level22.Slots.Length == 5, "toon.Level22.Slots.Length is incorrect!"); Debug.Assert(toon.Level24.Slots.Length == 1, "toon.Level24.Slots.Length is incorrect!"); Debug.Assert(toon.Level26.Slots.Length == 1, "toon.Level26.Slots.Length is incorrect!"); Debug.Assert(toon.Level28.Slots.Length == 1, "toon.Level28.Slots.Length is incorrect!"); Debug.Assert(toon.Level30.Slots.Length == 1, "toon.Level30.Slots.Length is incorrect!"); Debug.Assert(toon.Level32.Slots.Length == 1, "toon.Level32.Slots.Length is incorrect!"); Debug.Assert(toon.Level35.Slots.Length == 1, "toon.Level35.Slots.Length is incorrect!"); Debug.Assert(toon.Level38.Slots.Length == 1, "toon.Level38.Slots.Length is incorrect!"); Debug.Assert(toon.Level41.Slots.Length == 1, "toon.Level41.Slots.Length is incorrect!"); Debug.Assert(toon.Level44.Slots.Length == 1, "toon.Level44.Slots.Length is incorrect!"); Debug.Assert(toon.Level47.Slots.Length == 1, "toon.Level47.Slots.Length is incorrect!"); Debug.Assert(toon.Level49.Slots.Length == 1, "toon.Level49.Slots.Length is incorrect!"); Debug.Assert(toon.Health.Slots[0].Enhancement.Enh == (int)EnhancementTypes.Heal, "toon.Health.Slots[0].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Health.Slots[1].Enhancement.Enh == (int)EnhancementTypes.Heal, "toon.Health.Slots[1].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Health.Slots[2].Enhancement.Enh == (int)EnhancementTypes.Heal, "toon.Health.Slots[2].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Stamina.Slots[0].Enhancement.Enh == (int)EnhancementTypes.EnduranceModification, "toon.Stamina.Slots[0].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Stamina.Slots[1].Enhancement.Enh == (int)EnhancementTypes.EnduranceModification, "toon.Stamina.Slots[1].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Stamina.Slots[2].Enhancement.Enh == (int)EnhancementTypes.EnduranceModification, "toon.Stamina.Slots[2].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level1Primary.Slots[0].Enhancement.Enh == (int)EnhancementTypes.Accuracy, "toon.Level1Primary.Slots[0].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level1Primary.Slots[1].Enhancement.Enh == (int)EnhancementTypes.Damage, "toon.Level1Primary.Slots[1].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level1Primary.Slots[2].Enhancement.Enh == (int)EnhancementTypes.Damage, "toon.Level1Primary.Slots[2].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level1Primary.Slots[3].Enhancement.Enh == (int)EnhancementTypes.Damage, "toon.Level1Primary.Slots[3].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level1Primary.Slots[4].Enhancement.Enh == (int)EnhancementTypes.Sleep, "toon.Level1Primary.Slots[4].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level1Primary.Slots[5].Enhancement.Enh == (int)EnhancementTypes.Sleep, "toon.Level1Primary.Slots[5].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level1Secondary.Slots[0].Enhancement.Enh == (int)EnhancementTypes.Defense, "toon.Level1Secondary.Slots[0].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level1Secondary.Slots[1].Enhancement.Enh == (int)EnhancementTypes.Defense, "toon.Level1Secondary.Slots[1].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level1Secondary.Slots[2].Enhancement.Enh == (int)EnhancementTypes.Defense, "toon.Level1Secondary.Slots[2].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level1Secondary.Slots[3].Enhancement.Enh == (int)EnhancementTypes.Recharge, "toon.Level1Secondary.Slots[3].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level1Secondary.Slots[4].Enhancement.Enh == (int)EnhancementTypes.Recharge, "toon.Level1Secondary.Slots[4].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level1Secondary.Slots[5].Enhancement.Enh == (int)EnhancementTypes.Recharge, "toon.Level1Secondary.Slots[5].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level2.Slots[0].Enhancement.Enh == (int)EnhancementTypes.Defense, "toon.Level2.Slots[0].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level2.Slots[1].Enhancement.Enh == (int)EnhancementTypes.Defense, "toon.Level2.Slots[1].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level2.Slots[2].Enhancement.Enh == (int)EnhancementTypes.Defense, "toon.Level2.Slots[2].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level2.Slots[3].Enhancement.Enh == (int)EnhancementTypes.EnduranceReduction, "toon.Level2.Slots[3].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level2.Slots[4].Enhancement.Enh == (int)EnhancementTypes.EnduranceReduction, "toon.Level2.Slots[4].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level2.Slots[5].Enhancement.Enh == (int)EnhancementTypes.EnduranceReduction, "toon.Level2.Slots[5].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level4.Slots[0].Enhancement.Enh == (int)EnhancementTypes.Accuracy, "toon.Level4.Slots[0].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level4.Slots[1].Enhancement.Enh == (int)EnhancementTypes.Damage, "toon.Level4.Slots[1].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level4.Slots[2].Enhancement.Enh == (int)EnhancementTypes.Damage, "toon.Level4.Slots[2].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level4.Slots[3].Enhancement.Enh == (int)EnhancementTypes.Damage, "toon.Level4.Slots[3].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level4.Slots[4].Enhancement.Enh == (int)EnhancementTypes.EnduranceReduction, "toon.Level4.Slots[4].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level4.Slots[5].Enhancement.Enh == (int)EnhancementTypes.EnduranceReduction, "toon.Level4.Slots[5].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level6.Slots[0].Enhancement.Enh == (int)EnhancementTypes.Accuracy, "toon.Level6.Slots[0].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level6.Slots[1].Enhancement.Enh == (int)EnhancementTypes.Damage, "toon.Level6.Slots[1].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level6.Slots[2].Enhancement.Enh == (int)EnhancementTypes.Damage, "toon.Level6.Slots[2].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level6.Slots[3].Enhancement.Enh == (int)EnhancementTypes.Damage, "toon.Level6.Slots[3].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level6.Slots[4].Enhancement.Enh == (int)EnhancementTypes.Hold, "toon.Level6.Slots[4].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level6.Slots[5].Enhancement.Enh == (int)EnhancementTypes.Hold, "toon.Level6.Slots[5].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level8.Slots[0].Enhancement.Enh == (int)EnhancementTypes.Accuracy, "toon.Level8.Slots[0].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level8.Slots[1].Enhancement.Enh == (int)EnhancementTypes.Confuse, "toon.Level8.Slots[1].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level8.Slots[2].Enhancement.Enh == (int)EnhancementTypes.Confuse, "toon.Level8.Slots[2].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level8.Slots[3].Enhancement.Enh == (int)EnhancementTypes.Confuse, "toon.Level8.Slots[3].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level8.Slots[4].Enhancement.Enh == (int)EnhancementTypes.EnduranceReduction, "toon.Level8.Slots[4].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level8.Slots[5].Enhancement.Enh == (int)EnhancementTypes.EnduranceReduction, "toon.Level8.Slots[5].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level10.Slots[0].Enhancement.Enh == (int)EnhancementTypes.Defense, "toon.Level10.Slots[0].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level10.Slots[1].Enhancement.Enh == (int)EnhancementTypes.Defense, "toon.Level10.Slots[1].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level10.Slots[2].Enhancement.Enh == (int)EnhancementTypes.Defense, "toon.Level10.Slots[2].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level10.Slots[3].Enhancement.Enh == (int)EnhancementTypes.Recharge, "toon.Level10.Slots[3].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level10.Slots[4].Enhancement.Enh == (int)EnhancementTypes.Recharge, "toon.Level10.Slots[4].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level10.Slots[5].Enhancement.Enh == (int)EnhancementTypes.Recharge, "toon.Level10.Slots[5].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level12.Slots[0].Enhancement.Enh == (int)EnhancementTypes.Defense, "toon.Level12.Slots[0].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level12.Slots[1].Enhancement.Enh == (int)EnhancementTypes.Defense, "toon.Level12.Slots[1].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level12.Slots[2].Enhancement.Enh == (int)EnhancementTypes.Defense, "toon.Level12.Slots[2].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level12.Slots[3].Enhancement.Enh == (int)EnhancementTypes.EnduranceReduction, "toon.Level12.Slots[3].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level12.Slots[4].Enhancement.Enh == (int)EnhancementTypes.EnduranceReduction, "toon.Level12.Slots[4].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level12.Slots[5].Enhancement.Enh == (int)EnhancementTypes.EnduranceReduction, "toon.Level12.Slots[5].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level14.Slots[0].Enhancement.Enh == (int)EnhancementTypes.Defense, "toon.Level14.Slots[0].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level14.Slots[1].Enhancement.Enh == (int)EnhancementTypes.Defense, "toon.Level14.Slots[1].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level14.Slots[2].Enhancement.Enh == (int)EnhancementTypes.Defense, "toon.Level14.Slots[2].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level14.Slots[3].Enhancement.Enh == (int)EnhancementTypes.EnduranceReduction, "toon.Level14.Slots[3].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level14.Slots[4].Enhancement.Enh == (int)EnhancementTypes.EnduranceReduction, "toon.Level14.Slots[4].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level14.Slots[5].Enhancement.Enh == (int)EnhancementTypes.EnduranceReduction, "toon.Level14.Slots[5].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level16.Slots[0].Enhancement.Enh == (int)EnhancementTypes.Defense, "toon.Level16.Slots[0].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level16.Slots[1].Enhancement.Enh == (int)EnhancementTypes.Defense, "toon.Level16.Slots[1].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level16.Slots[2].Enhancement.Enh == (int)EnhancementTypes.Defense, "toon.Level16.Slots[2].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level16.Slots[3].Enhancement.Enh == (int)EnhancementTypes.Recharge, "toon.Level16.Slots[3].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level16.Slots[4].Enhancement.Enh == (int)EnhancementTypes.Recharge, "toon.Level16.Slots[4].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level16.Slots[5].Enhancement.Enh == (int)EnhancementTypes.Recharge, "toon.Level16.Slots[5].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level18.Slots[0].Enhancement.Enh == (int)EnhancementTypes.Accuracy, "toon.Level18.Slots[0].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level18.Slots[1].Enhancement.Enh == (int)EnhancementTypes.Sleep, "toon.Level18.Slots[1].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level18.Slots[2].Enhancement.Enh == (int)EnhancementTypes.Sleep, "toon.Level18.Slots[2].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level18.Slots[3].Enhancement.Enh == (int)EnhancementTypes.Sleep, "toon.Level18.Slots[3].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level18.Slots[4].Enhancement.Enh == (int)EnhancementTypes.EnduranceReduction, "toon.Level18.Slots[4].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level18.Slots[5].Enhancement.Enh == (int)EnhancementTypes.EnduranceReduction, "toon.Level18.Slots[5].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level20.Slots[0].Enhancement.Enh == (int)EnhancementTypes.EnduranceReduction, "toon.Level20.Slots[0].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level20.Slots[1].Enhancement.Enh == (int)EnhancementTypes.EnduranceReduction, "toon.Level20.Slots[1].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level20.Slots[2].Enhancement.Enh == (int)EnhancementTypes.EnduranceReduction, "toon.Level20.Slots[2].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level20.Slots[3].Enhancement.Enh == (int)EnhancementTypes.Recharge, "toon.Level20.Slots[3].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level20.Slots[4].Enhancement.Enh == (int)EnhancementTypes.Recharge, "toon.Level20.Slots[4].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level22.Slots[0].Enhancement.Enh == (int)EnhancementTypes.Defense, "toon.Level22.Slots[0].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level22.Slots[1].Enhancement.Enh == (int)EnhancementTypes.Defense, "toon.Level22.Slots[1].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level22.Slots[2].Enhancement.Enh == (int)EnhancementTypes.Defense, "toon.Level22.Slots[2].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level22.Slots[3].Enhancement.Enh == (int)EnhancementTypes.EnduranceReduction, "toon.Level22.Slots[3].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level22.Slots[4].Enhancement.Enh == (int)EnhancementTypes.EnduranceReduction, "toon.Level22.Slots[4].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level24.Slots[0].Enhancement.Enh == (int)EnhancementTypes.Accuracy, "toon.Level24.Slots[0].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level26.Slots[0].Enhancement.Enh == (int)EnhancementTypes.Accuracy, "toon.Level26.Slots[0].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level28.Slots[0].Enhancement.Enh == (int)EnhancementTypes.Accuracy, "toon.Level28.Slots[0].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level30.Slots[0].Enhancement.Enh == (int)EnhancementTypes.Resistance, "toon.Level30.Slots[0].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level32.Slots[0].Enhancement.Enh == (int)EnhancementTypes.Defense, "toon.Level32.Slots[0].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level35.Slots[0].Enhancement.Enh == (int)EnhancementTypes.Accuracy, "toon.Level35.Slots[0].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level38.Slots[0].Enhancement.Enh == (int)EnhancementTypes.Recharge, "toon.Level38.Slots[0].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level41.Slots[0].Enhancement.Enh == (int)EnhancementTypes.Accuracy, "toon.Level41.Slots[0].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level44.Slots[0].Enhancement.Enh == (int)EnhancementTypes.Accuracy, "toon.Level44.Slots[0].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level47.Slots[0].Enhancement.Enh == (int)EnhancementTypes.Recharge, "toon.Level47.Slots[0].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level49.Slots[0].Enhancement.Enh == (int)EnhancementTypes.Accuracy, "toon.Level49.Slots[0].Enhancement.Enh is incorrect!"); return toon; } public static AIToon TestCreateBuildControllerMindForceFieldWithIOs() { AIToon toon = TestCreateBuildControllerMindForceField(); Slot(toon.Health, new int[] { 36 }); Slot(toon.Stamina, new int[] { 32 }); Slot(toon.Level1Primary, new int[] { 26, 29, 29 }); Slot(toon.Level1Secondary, new int[] { 260, 261, 262, 263, 264, 265 }); Slot(toon.Level2, new int[] { 260, 261 }); Slot(toon.Level4, new int[] { 146, 147, 124, 125 }); Slot(toon.Level6, new int[] { 354, 355, 29 }); Slot(toon.Level8, new int[] { 26, 28, 28 }); Slot(toon.Level10, new int[] { 838, 839, 840, 841, 842, 843 }); Slot(toon.Level12, new int[] { 30 }); Slot(toon.Level14, new int[] { 260, 261, 249, 250, 33 }); Slot(toon.Level16, new int[] { 272, 273, 274, 275, 276, 277 }); Slot(toon.Level18, new int[] { 446, 447, 448, 449 }); Slot(toon.Level20, new int[] { 33, 33 }); Slot(toon.Level22, new int[] { 260, 261, 249, 250 }); Slot(toon.Level24, new int[] { 26, 37, 37, 37 }); Slot(toon.Level26, new int[] { 179, 180 }); Slot(toon.Level28, new int[] { 586, 587 }); Slot(toon.Level30, new int[] { 1012, 1013, 1014, 1015 }); Slot(toon.Level32, new int[] { 272, 273, 274, 275, 276, 277 }); Slot(toon.Level35, new int[] { 604, 605, 498, 499 }); Slot(toon.Level38, new int[] { 43 }); Slot(toon.Level41, new int[] { 588, 589, 562, 563, 383, 384 }); Slot(toon.Level44, new int[] { 1192, 1193, 1194, 1195, 809, 810 }); Slot(toon.Level47, new int[] { 43 }); Slot(toon.Level49, new int[] { 26, 33, 33, 33, 43, 43 }); toon.SetDefaultSlotLevels(); Debug.Assert(toon.IsValid(), "toon.IsValid() is incorrect!"); return toon; } public static AIToon TestCreateBuildMastermindRoboticsForceField() { AIToon toon = new AIToon(); toon.Archetype = DatabaseAPI.GetArchetypeByName("Mastermind"); toon.Fitness = GetPowersetByName("Inherent Fitness", Enums.ePowerSetType.Inherent); toon.Primary = GetPowersetByName("Robotics", Enums.ePowerSetType.Primary); toon.Secondary = GetPowersetByArchetypeAndName(toon.Archetype, "Force Field"); toon.Pool1 = GetPowersetByName("Flight", Enums.ePowerSetType.Pool); toon.Pool2 = GetPowersetByName("Teleportation", Enums.ePowerSetType.Pool); toon.Pool3 = GetPowersetByName("Concealment", Enums.ePowerSetType.Pool); toon.Pool4 = GetPowersetByName("Leadership", Enums.ePowerSetType.Pool); toon.Epic = GetPowersetByFullName("Epic.Mastermind_Mace_Mastery"); toon.Health = new PowerEntry(0, toon.Fitness.Powers[1]); // Health toon.Stamina = new PowerEntry(0, toon.Fitness.Powers[3]); // Stamina toon.Level1Primary = new PowerEntry(0, toon.Primary.Powers[4]); // Battle Drones toon.Level1Secondary = new PowerEntry(0, toon.Secondary.Powers[0]); // Force Bolt toon.Level2 = new PowerEntry(1, toon.Secondary.Powers[1]); // Deflection Shield toon.Level4 = new PowerEntry(3, toon.Secondary.Powers[2]); // Insulation Shield toon.Level6 = new PowerEntry(5, toon.Primary.Powers[6]); // Equip Robot toon.Level8 = new PowerEntry(7, toon.Pool1.Powers[2]); // Hover toon.Level10 = new PowerEntry(9, toon.Pool2.Powers[0]); // Recall Friend toon.Level12 = new PowerEntry(11, toon.Primary.Powers[8]); // Protector Bots toon.Level14 = new PowerEntry(11, toon.Pool3.Powers[1]); // Grant Invisibility toon.Level16 = new PowerEntry(13, toon.Secondary.Powers[4]); // Personal Force Field toon.Level18 = new PowerEntry(15, toon.Primary.Powers[9]); // Repair toon.Level20 = new PowerEntry(17, toon.Secondary.Powers[5]); // Dispersion Bubble toon.Level22 = new PowerEntry(21, toon.Pool3.Powers[2]); // Invisibility toon.Level24 = new PowerEntry(23, toon.Pool4.Powers[1]); // Assault toon.Level26 = new PowerEntry(25, toon.Primary.Powers[10]); // Assault Bot toon.Level28 = new PowerEntry(27, toon.Pool4.Powers[0]); // Maneuvers toon.Level30 = new PowerEntry(29, toon.Pool4.Powers[2]); // Tactics toon.Level32 = new PowerEntry(31, toon.Primary.Powers[11]); // Upgrade Robot toon.Level35 = new PowerEntry(34, toon.Epic.Powers[1]); // Scorpion Shield toon.Level38 = new PowerEntry(37, toon.Secondary.Powers[6]); // Repulsion Field toon.Level41 = new PowerEntry(40, toon.Epic.Powers[3]); // Power Boost toon.Level44 = new PowerEntry(43, toon.Pool4.Powers[4]); // Victory Rush toon.Level47 = new PowerEntry(46, toon.Primary.Powers[7]); // Photon Grenade toon.Level49 = new PowerEntry(48, toon.Secondary.Powers[7]); // Repulsion Bomb DoDefaultSlotting(toon.Health, 3); DoDefaultSlotting(toon.Stamina, 3); DoDefaultSlotting(toon.Level1Primary, 6); DoDefaultSlotting(toon.Level1Secondary, 6); DoDefaultSlotting(toon.Level2, 6); DoDefaultSlotting(toon.Level4, 6); DoDefaultSlotting(toon.Level6, 6); DoDefaultSlotting(toon.Level8, 6); DoDefaultSlotting(toon.Level10, 6); DoDefaultSlotting(toon.Level12, 6); DoDefaultSlotting(toon.Level14, 6); DoDefaultSlotting(toon.Level16, 6); DoDefaultSlotting(toon.Level18, 6); DoDefaultSlotting(toon.Level20, 5); DoDefaultSlotting(toon.Level22, 5); DoDefaultSlotting(toon.Level24, 1); DoDefaultSlotting(toon.Level26, 1); DoDefaultSlotting(toon.Level28, 1); DoDefaultSlotting(toon.Level30, 1); DoDefaultSlotting(toon.Level32, 1); DoDefaultSlotting(toon.Level35, 1); DoDefaultSlotting(toon.Level38, 1); DoDefaultSlotting(toon.Level41, 1); DoDefaultSlotting(toon.Level44, 1); DoDefaultSlotting(toon.Level47, 1); DoDefaultSlotting(toon.Level49, 1); toon.SetDefaultSlotLevels(); return toon; } public static AIToon TestCreateBuildMastermindDemonsPain() { AIToon toon = new AIToon(); toon.Archetype = DatabaseAPI.GetArchetypeByName("Mastermind"); toon.Fitness = GetPowersetByName("Inherent Fitness", Enums.ePowerSetType.Inherent); toon.Primary = GetPowersetByName("Demon Summoning", Enums.ePowerSetType.Primary); toon.Secondary = GetPowersetByArchetypeAndName(toon.Archetype, "Pain Domination"); toon.Pool1 = GetPowersetByName("Flight", Enums.ePowerSetType.Pool); toon.Pool2 = GetPowersetByName("Teleportation", Enums.ePowerSetType.Pool); toon.Pool3 = GetPowersetByName("Speed", Enums.ePowerSetType.Pool); toon.Pool4 = GetPowersetByName("Leadership", Enums.ePowerSetType.Pool); toon.Epic = GetPowersetByFullName("Epic.Mastermind_Soul_Mastery"); toon.Health = new PowerEntry(0, toon.Fitness.Powers[1]); // Health toon.Stamina = new PowerEntry(0, toon.Fitness.Powers[3]); // Stamina toon.Level1Primary = new PowerEntry(0, toon.Primary.Powers[7]); // Summon Demonlings toon.Level1Secondary = new PowerEntry(0, toon.Secondary.Powers[0]); // Nullify Pain toon.Level2 = new PowerEntry(1, toon.Secondary.Powers[1]); // Soothe toon.Level4 = new PowerEntry(3, toon.Pool1.Powers[2]); // Hover toon.Level6 = new PowerEntry(5, toon.Primary.Powers[9]); // Enchant Demon toon.Level8 = new PowerEntry(7, toon.Pool2.Powers[0]); // Recall Friend toon.Level10 = new PowerEntry(9, toon.Secondary.Powers[3]); // Conduit of Pain toon.Level12 = new PowerEntry(11, toon.Primary.Powers[11]); // Summon Demons toon.Level14 = new PowerEntry(11, toon.Pool3.Powers[1]); // Hasten toon.Level16 = new PowerEntry(13, toon.Pool3.Powers[2]); // Super Speed toon.Level18 = new PowerEntry(15, toon.Primary.Powers[12]); // Hell on Earth toon.Level20 = new PowerEntry(17, toon.Secondary.Powers[5]); // Supress Pain toon.Level22 = new PowerEntry(21, toon.Pool3.Powers[3]); // Burnout toon.Level24 = new PowerEntry(23, toon.Pool4.Powers[1]); // Assault toon.Level26 = new PowerEntry(25, toon.Primary.Powers[13]); // Summon Demon Prince toon.Level28 = new PowerEntry(27, toon.Pool4.Powers[2]); // Tactics toon.Level30 = new PowerEntry(29, toon.Pool4.Powers[0]); // Maneuvers toon.Level32 = new PowerEntry(31, toon.Primary.Powers[14]); // Abysmal Empowerment toon.Level35 = new PowerEntry(34, toon.Epic.Powers[1]); // Dark Embrace toon.Level38 = new PowerEntry(37, toon.Pool3.Powers[4]); // Whirlwind toon.Level41 = new PowerEntry(40, toon.Epic.Powers[2]); // Opressive Gloom toon.Level44 = new PowerEntry(43, toon.Secondary.Powers[6]); // World of Pain toon.Level47 = new PowerEntry(46, toon.Secondary.Powers[8]); // Painbringer toon.Level49 = new PowerEntry(48, toon.Secondary.Powers[7]); // Anguishing Cry DoDefaultSlotting(toon.Health, 3); DoDefaultSlotting(toon.Stamina, 3); DoDefaultSlotting(toon.Level1Primary, 6); DoDefaultSlotting(toon.Level1Secondary, 6); DoDefaultSlotting(toon.Level2, 6); DoDefaultSlotting(toon.Level4, 6); DoDefaultSlotting(toon.Level6, 6); DoDefaultSlotting(toon.Level8, 6); DoDefaultSlotting(toon.Level10, 6); DoDefaultSlotting(toon.Level12, 6); DoDefaultSlotting(toon.Level14, 6); DoDefaultSlotting(toon.Level16, 6); DoDefaultSlotting(toon.Level18, 6); DoDefaultSlotting(toon.Level20, 5); DoDefaultSlotting(toon.Level22, 5); DoDefaultSlotting(toon.Level24, 1); DoDefaultSlotting(toon.Level26, 1); DoDefaultSlotting(toon.Level28, 1); DoDefaultSlotting(toon.Level30, 1); DoDefaultSlotting(toon.Level32, 1); DoDefaultSlotting(toon.Level35, 1); DoDefaultSlotting(toon.Level38, 1); DoDefaultSlotting(toon.Level41, 1); DoDefaultSlotting(toon.Level44, 1); DoDefaultSlotting(toon.Level47, 1); DoDefaultSlotting(toon.Level49, 1); toon.SetDefaultSlotLevels(); return toon; } public static void TestGetEnhancementsGroupedBySet(AIToon toon) { Dictionary> enhancementSets = GetEnhancementsGroupedBySet(toon.Level1Primary); List enhancementList; Debug.Assert(enhancementSets.Count == 1, "enhancementSets.Count is incorrect!"); Debug.Assert(enhancementSets.ContainsKey("None"), "enhancementSets.ContainsKey is incorrect!"); Debug.Assert(enhancementSets.TryGetValue("None", out enhancementList), "enhancementSets.TryGetValue is incorrect!"); if (enhancementSets.TryGetValue("None", out enhancementList)) { Debug.Assert(enhancementList.Count == 5, "enhancementList.Count is incorrect!"); Debug.Assert(enhancementList[0].Name == "Accuracy", "enhancementList[0].Name is incorrect!"); Debug.Assert(enhancementList[1].Name == "Damage Increase", "enhancementList[1].Name is incorrect!"); Debug.Assert(enhancementList[2].Name == "Damage Increase", "enhancementList[2].Name is incorrect!"); Debug.Assert(enhancementList[3].Name == "Damage Increase", "enhancementList[3].Name is incorrect!"); Debug.Assert(enhancementList[4].Name == "Endurance Reduction", "enhancementList[4].Name is incorrect!"); } EnhancementSet[] defenseBonusSets = GetEnhancementSetsWithBonusEffect(toon.Level1Primary.Power, 6, Enums.eEffectType.Defense).ToArray(); EnhancementSet set1 = defenseBonusSets[0]; EnhancementSet set2 = defenseBonusSets[1]; toon.Level1Primary.Slots[0].LoadFromString(GetLoadString(GetEnhancementByIndex(set1.Enhancements[0])), ":"); toon.Level1Primary.Slots[1].LoadFromString(GetLoadString(GetEnhancementByIndex(set1.Enhancements[1])), ":"); toon.Level1Primary.Slots[2].LoadFromString(GetLoadString(GetEnhancementByIndex(set1.Enhancements[2])), ":"); toon.Level1Primary.Slots[3].LoadFromString(GetLoadString(GetEnhancementByIndex(set2.Enhancements[0])), ":"); toon.Level1Primary.Slots[4].LoadFromString(GetLoadString(GetEnhancementByIndex(set2.Enhancements[1])), ":"); Debug.Assert(toon.Level1Primary.Slots[0].Enhancement.Enh == set1.Enhancements[0], "toon.Level1Primary.Slots[0].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level1Primary.Slots[1].Enhancement.Enh == set1.Enhancements[1], "toon.Level1Primary.Slots[1].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level1Primary.Slots[2].Enhancement.Enh == set1.Enhancements[2], "toon.Level1Primary.Slots[2].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level1Primary.Slots[3].Enhancement.Enh == set2.Enhancements[0], "toon.Level1Primary.Slots[3].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level1Primary.Slots[4].Enhancement.Enh == set2.Enhancements[1], "toon.Level1Primary.Slots[4].Enhancement.Enh is incorrect!"); enhancementSets = GetEnhancementsGroupedBySet(toon.Level1Primary); Debug.Assert(enhancementSets.Count == 2, "enhancementSets.Count is incorrect!"); Debug.Assert(enhancementSets.ContainsKey("Maelstrom's Fury"), "enhancementSets.ContainsKey is incorrect!"); Debug.Assert(enhancementSets.ContainsKey("Ruin"), "enhancementSets.ContainsKey is incorrect!"); Debug.Assert(enhancementSets.TryGetValue("Maelstrom's Fury", out enhancementList), "enhancementSets.TryGetValue is incorrect!"); Debug.Assert(enhancementSets.TryGetValue("Ruin", out enhancementList), "enhancementSets.TryGetValue is incorrect!"); if (enhancementSets.TryGetValue("Maelstrom's Fury", out enhancementList)) { Debug.Assert(enhancementList.Count == 3, "enhancementList.Count is incorrect!"); Debug.Assert(enhancementList[0].Name == "Accuracy/Damage", "enhancementList[0].Name is incorrect!"); Debug.Assert(enhancementList[1].Name == "Damage/Endurance", "enhancementList[1].Name is incorrect!"); Debug.Assert(enhancementList[2].Name == "Damage/Recharge", "enhancementList[2].Name is incorrect!"); } if (enhancementSets.TryGetValue("Ruin", out enhancementList)) { Debug.Assert(enhancementList.Count == 2, "enhancementList.Count is incorrect!"); Debug.Assert(enhancementList[0].Name == "Accuracy/Damage", "enhancementList[0].Name is incorrect!"); Debug.Assert(enhancementList[1].Name == "Damage/Endurance", "enhancementList[2].Name is incorrect!"); } string acc = GetLoadString(GetEnhancementByIndex(26)); string dam = GetLoadString(GetEnhancementByIndex(29)); string rech = GetLoadString(GetEnhancementByIndex(43)); toon.Level1Primary.Slots[0].LoadFromString(acc, ":"); toon.Level1Primary.Slots[1].LoadFromString(dam, ":"); toon.Level1Primary.Slots[2].LoadFromString(dam, ":"); toon.Level1Primary.Slots[3].LoadFromString(dam, ":"); toon.Level1Primary.Slots[4].LoadFromString(rech, ":"); Debug.Assert(toon.Level1Primary.Slots[0].Enhancement.Enh == 26, "toon.Level1Primary.Slots[0].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level1Primary.Slots[1].Enhancement.Enh == 29, "toon.Level1Primary.Slots[1].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level1Primary.Slots[2].Enhancement.Enh == 29, "toon.Level1Primary.Slots[2].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level1Primary.Slots[3].Enhancement.Enh == 29, "toon.Level1Primary.Slots[3].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level1Primary.Slots[4].Enhancement.Enh == 43, "toon.Level1Primary.Slots[4].Enhancement.Enh is incorrect!"); } public static void TestToonGetPowerEntries(AIToon toon) { List powerEntries = toon.GetPowerEntries(); Debug.Assert(powerEntries[0] == toon.Health, "powerEntries[0] is incorrect!"); Debug.Assert(powerEntries[1] == toon.Stamina, "powerEntries[1] is incorrect!"); Debug.Assert(powerEntries[2] == toon.Level1Primary, "powerEntries[2] is incorrect!"); Debug.Assert(powerEntries[3] == toon.Level1Secondary, "powerEntries[3] is incorrect!"); Debug.Assert(powerEntries[4] == toon.Level2, "powerEntries[4] is incorrect!"); Debug.Assert(powerEntries[5] == toon.Level4, "powerEntries[5] is incorrect!"); Debug.Assert(powerEntries[6] == toon.Level6, "powerEntries[6] is incorrect!"); Debug.Assert(powerEntries[7] == toon.Level8, "powerEntries[7] is incorrect!"); Debug.Assert(powerEntries[8] == toon.Level10, "powerEntries[8] is incorrect!"); Debug.Assert(powerEntries[9] == toon.Level12, "powerEntries[9] is incorrect!"); Debug.Assert(powerEntries[10] == toon.Level14, "powerEntries[10] is incorrect!"); Debug.Assert(powerEntries[11] == toon.Level16, "powerEntries[11] is incorrect!"); Debug.Assert(powerEntries[12] == toon.Level18, "powerEntries[12] is incorrect!"); Debug.Assert(powerEntries[13] == toon.Level20, "powerEntries[13] is incorrect!"); Debug.Assert(powerEntries[14] == toon.Level22, "powerEntries[14] is incorrect!"); Debug.Assert(powerEntries[15] == toon.Level24, "powerEntries[15] is incorrect!"); Debug.Assert(powerEntries[16] == toon.Level26, "powerEntries[16] is incorrect!"); Debug.Assert(powerEntries[17] == toon.Level28, "powerEntries[17] is incorrect!"); Debug.Assert(powerEntries[18] == toon.Level30, "powerEntries[18] is incorrect!"); Debug.Assert(powerEntries[19] == toon.Level32, "powerEntries[19] is incorrect!"); Debug.Assert(powerEntries[20] == toon.Level35, "powerEntries[20] is incorrect!"); Debug.Assert(powerEntries[21] == toon.Level38, "powerEntries[21] is incorrect!"); Debug.Assert(powerEntries[22] == toon.Level41, "powerEntries[22] is incorrect!"); Debug.Assert(powerEntries[23] == toon.Level44, "powerEntries[23] is incorrect!"); Debug.Assert(powerEntries[24] == toon.Level47, "powerEntries[24] is incorrect!"); Debug.Assert(powerEntries[25] == toon.Level49, "powerEntries[25] is incorrect!"); } public static void TestToonSetPowerEntries(AIToon toon) { List powerEntries = toon.GetPowerEntries(); PowerEntry temp = powerEntries[25]; powerEntries[25] = powerEntries[24]; powerEntries[24] = temp; toon.SetPowerEntries(powerEntries); powerEntries = toon.GetPowerEntries(); Debug.Assert(powerEntries[24] == temp, "powerEntries[24] is incorrect!"); } public static void TestToonClone(AIToon toon) { AIToon clone = toon.Clone() as AIToon; Debug.Assert(0 == clone.Archetype.CompareTo(toon.Archetype), "clone.Archetype is incorrect!"); clone.Archetype.Playable = !clone.Archetype.Playable; Debug.Assert(0 != clone.Archetype.CompareTo(toon.Archetype), "clone.Archetype is incorrect!"); Debug.Assert(0 == clone.Fitness.CompareTo(toon.Fitness), "clone.Fitness is incorrect!"); Debug.Assert(0 == clone.Primary.CompareTo(toon.Primary), "clone.Primary is incorrect!"); Debug.Assert(0 == clone.Secondary.CompareTo(toon.Secondary), "clone.Secondary is incorrect!"); Debug.Assert(0 == clone.Pool1.CompareTo(toon.Pool1), "clone.Pool1 is incorrect!"); Debug.Assert(0 == clone.Pool2.CompareTo(toon.Pool2), "clone.Pool2 is incorrect!"); Debug.Assert(0 == clone.Pool3.CompareTo(toon.Pool3), "clone.Pool3 is incorrect!"); Debug.Assert(0 == clone.Pool4.CompareTo(toon.Pool4), "clone.Pool4 is incorrect!"); Debug.Assert(0 == clone.Epic.CompareTo(toon.Epic), "clone.Epic is incorrect!"); clone.Fitness.GroupName = "Clone"; Debug.Assert(0 != clone.Fitness.CompareTo(toon.Fitness), "clone.Fitness is incorrect!"); Debug.Assert(0 == CompareTo(clone.Health, toon.Health), "clone.Health is incorrect!"); Debug.Assert(0 == CompareTo(clone.Stamina, toon.Stamina), "clone.Stamina is incorrect!"); Debug.Assert(0 == CompareTo(clone.Level1Primary, toon.Level1Primary), "clone.Level1Primary is incorrect!"); Debug.Assert(0 == CompareTo(clone.Level1Secondary, toon.Level1Secondary), "clone.Level1Secondary is incorrect!"); Debug.Assert(0 == CompareTo(clone.Level2, toon.Level2), "clone.Level2 is incorrect!"); Debug.Assert(0 == CompareTo(clone.Level4, toon.Level4), "clone.Level4 is incorrect!"); Debug.Assert(0 == CompareTo(clone.Level6, toon.Level6), "clone.Level6 is incorrect!"); Debug.Assert(0 == CompareTo(clone.Level8, toon.Level8), "clone.Level8 is incorrect!"); Debug.Assert(0 == CompareTo(clone.Level10, toon.Level10), "clone.Level10 is incorrect!"); Debug.Assert(0 == CompareTo(clone.Level12, toon.Level12), "clone.Level12 is incorrect!"); Debug.Assert(0 == CompareTo(clone.Level14, toon.Level14), "clone.Level14 is incorrect!"); Debug.Assert(0 == CompareTo(clone.Level16, toon.Level16), "clone.Level16 is incorrect!"); Debug.Assert(0 == CompareTo(clone.Level18, toon.Level18), "clone.Level18 is incorrect!"); Debug.Assert(0 == CompareTo(clone.Level20, toon.Level20), "clone.Level20 is incorrect!"); Debug.Assert(0 == CompareTo(clone.Level22, toon.Level22), "clone.Level22 is incorrect!"); Debug.Assert(0 == CompareTo(clone.Level24, toon.Level24), "clone.Level24 is incorrect!"); Debug.Assert(0 == CompareTo(clone.Level26, toon.Level26), "clone.Level26 is incorrect!"); Debug.Assert(0 == CompareTo(clone.Level28, toon.Level28), "clone.Level28 is incorrect!"); Debug.Assert(0 == CompareTo(clone.Level30, toon.Level30), "clone.Level30 is incorrect!"); Debug.Assert(0 == CompareTo(clone.Level32, toon.Level32), "clone.Level32 is incorrect!"); Debug.Assert(0 == CompareTo(clone.Level35, toon.Level35), "clone.Level35 is incorrect!"); Debug.Assert(0 == CompareTo(clone.Level38, toon.Level38), "clone.Level38 is incorrect!"); Debug.Assert(0 == CompareTo(clone.Level41, toon.Level41), "clone.Level41 is incorrect!"); Debug.Assert(0 == CompareTo(clone.Level44, toon.Level44), "clone.Level44 is incorrect!"); Debug.Assert(0 == CompareTo(clone.Level47, toon.Level47), "clone.Level47 is incorrect!"); Debug.Assert(0 == CompareTo(clone.Level49, toon.Level49), "clone.Level49 is incorrect!"); clone.Health.Level = toon.Health.Level + 1; Debug.Assert(0 != CompareTo(clone.Health, toon.Health), "clone.Health is incorrect!"); } public static void TestToonSumPowerBonuses(AIToon toon) { AIToon clone = toon.Clone() as AIToon; float sum = clone.SumPowerBonuses(Enums.eEffectType.Defense, Enums.eDamage.Energy); Debug.Assert(IsKindaSortaEqual(sum, 0.0f, 0.001f), "sum is incorrect!"); EnhancementSet thunderstrike = GetEnhancementSetByIndex(GetEnhancementSetIndexByName("Thunderstrike")); clone.Level1Primary.Slots[0].LoadFromString(GetLoadString(GetEnhancementByIndex(thunderstrike.Enhancements[0])), ":"); clone.Level1Primary.Slots[1].LoadFromString(GetLoadString(GetEnhancementByIndex(thunderstrike.Enhancements[1])), ":"); clone.Level1Primary.Slots[2].LoadFromString(GetLoadString(GetEnhancementByIndex(thunderstrike.Enhancements[2])), ":"); sum = clone.SumPowerBonuses(Enums.eEffectType.Defense, Enums.eDamage.Energy); Debug.Assert(IsKindaSortaEqual(sum, 0.025f, 0.001f), "sum is incorrect!"); } public static void TestToonGetEnhancementCount(AIToon toon) { AIToon clone = toon.Clone() as AIToon; IEnhancement endRed = GetEnhancementByIndex((int)EnhancementTypes.EnduranceReduction); IEnhancement damage = GetEnhancementByIndex((int)EnhancementTypes.Damage); clone.Level1Primary.Slots[0].LoadFromString(GetLoadString(endRed), ":"); clone.Level1Primary.Slots[1].LoadFromString(GetLoadString(endRed), ":"); clone.Level1Primary.Slots[2].LoadFromString(GetLoadString(endRed), ":"); clone.Level1Primary.Slots[3].LoadFromString(GetLoadString(endRed), ":"); clone.Level1Primary.Slots[4].LoadFromString(GetLoadString(endRed), ":"); Debug.Assert(clone.GetEnhancementCount(damage, clone.Level1Primary) == 0, "GetEnhancementCount is incorrect!"); clone.Level1Primary.Slots[0].LoadFromString(GetLoadString(damage), ":"); Debug.Assert(clone.GetEnhancementCount(damage, clone.Level1Primary) == 1, "GetEnhancementCount is incorrect!"); clone.Level1Primary.Slots[1].LoadFromString(GetLoadString(damage), ":"); Debug.Assert(clone.GetEnhancementCount(damage, clone.Level1Primary) == 2, "GetEnhancementCount is incorrect!"); clone.Level1Primary.Slots[2].LoadFromString(GetLoadString(damage), ":"); Debug.Assert(clone.GetEnhancementCount(damage, clone.Level1Primary) == 3, "GetEnhancementCount is incorrect!"); } public static void TestToonHasEnhancement(AIToon toon) { AIToon clone = toon.Clone() as AIToon; EnhancementSet thunderstrike = GetEnhancementSetByIndex(GetEnhancementSetIndexByName("Thunderstrike")); IEnhancement thunderstrike0 = GetEnhancementByIndex(thunderstrike.Enhancements[0]); Debug.Assert(clone.HasEnhancement(thunderstrike0) == false, "HasEnhancement is incorrect!"); clone.Level1Primary.Slots[0].LoadFromString(GetLoadString(thunderstrike0), ":"); Debug.Assert(clone.HasEnhancement(thunderstrike0) == true, "HasEnhancement is incorrect!"); Debug.Assert(clone.HasEnhancement(thunderstrike0, clone.Level1Primary) == true, "HasEnhancement is incorrect!"); Debug.Assert(clone.HasEnhancement(thunderstrike0, clone.Level2) == false, "HasEnhancement is incorrect!"); } public static void TestToonHasFourOrMoreBonuses(AIToon toon) { AIToon clone = toon.Clone() as AIToon; EnhancementSet reactiveDefenses = GetEnhancementSetByIndex(GetEnhancementSetIndexByName("Reactive Defenses")); Debug.Assert(clone.HasFourOrMoreBonuses(reactiveDefenses, 2) == false, "HasFiveOrMoreBonuses is incorrect!"); clone.Level1Secondary.Slots[0].LoadFromString(GetLoadString(GetEnhancementByIndex(reactiveDefenses.Enhancements[0])), ":"); clone.Level1Secondary.Slots[1].LoadFromString(GetLoadString(GetEnhancementByIndex(reactiveDefenses.Enhancements[1])), ":"); Debug.Assert(clone.HasFourOrMoreBonuses(reactiveDefenses, 2) == false, "HasFiveOrMoreBonuses is incorrect!"); clone.Level2.Slots[0].LoadFromString(GetLoadString(GetEnhancementByIndex(reactiveDefenses.Enhancements[0])), ":"); clone.Level2.Slots[1].LoadFromString(GetLoadString(GetEnhancementByIndex(reactiveDefenses.Enhancements[1])), ":"); Debug.Assert(clone.HasFourOrMoreBonuses(reactiveDefenses, 2) == false, "HasFiveOrMoreBonuses is incorrect!"); clone.Level10.Slots[0].LoadFromString(GetLoadString(GetEnhancementByIndex(reactiveDefenses.Enhancements[0])), ":"); clone.Level10.Slots[1].LoadFromString(GetLoadString(GetEnhancementByIndex(reactiveDefenses.Enhancements[1])), ":"); Debug.Assert(clone.HasFourOrMoreBonuses(reactiveDefenses, 2) == false, "HasFiveOrMoreBonuses is incorrect!"); clone.Level12.Slots[0].LoadFromString(GetLoadString(GetEnhancementByIndex(reactiveDefenses.Enhancements[0])), ":"); clone.Level12.Slots[1].LoadFromString(GetLoadString(GetEnhancementByIndex(reactiveDefenses.Enhancements[1])), ":"); Debug.Assert(clone.HasFourOrMoreBonuses(reactiveDefenses, 2) == true, "HasFiveOrMoreBonuses is incorrect!"); clone.Level14.Slots[0].LoadFromString(GetLoadString(GetEnhancementByIndex(reactiveDefenses.Enhancements[0])), ":"); clone.Level14.Slots[1].LoadFromString(GetLoadString(GetEnhancementByIndex(reactiveDefenses.Enhancements[1])), ":"); Debug.Assert(clone.HasFourOrMoreBonuses(reactiveDefenses, 2) == true, "HasFiveOrMoreBonuses is incorrect!"); } public static void TestToonCanAddEnhancement(AIToon toon) { AIToon clone = toon.Clone() as AIToon; EnhancementSet apocalypse = GetEnhancementSetByIndex(GetEnhancementSetIndexByName("Apocalypse")); IEnhancement apocalypse0 = GetEnhancementByIndex(apocalypse.Enhancements[0]); IEnhancement apocalypse1 = GetEnhancementByIndex(apocalypse.Enhancements[1]); clone.Level1Primary.Slots[0].LoadFromString(GetLoadString(apocalypse0), ":"); Debug.Assert(clone.CanAddEnhancement(apocalypse0, clone.Level1Primary) == false, "CanAddEnhancement is incorrect!"); Debug.Assert(clone.CanAddEnhancement(apocalypse1, clone.Level1Primary) == true, "CanAddEnhancement is incorrect!"); Debug.Assert(clone.CanAddEnhancement(apocalypse0, clone.Level2) == false, "CanAddEnhancement is incorrect!"); Debug.Assert(clone.CanAddEnhancement(apocalypse1, clone.Level2) == true, "CanAddEnhancement is incorrect!"); IEnhancement damage = GetEnhancementByIndex((int)EnhancementTypes.Damage); IEnhancement slow = GetEnhancementByIndex((int)EnhancementTypes.Slow); IEnhancement endRed = GetEnhancementByIndex((int)EnhancementTypes.EnduranceReduction); clone.Level1Primary.Slots[0].LoadFromString(GetLoadString(endRed), ":"); clone.Level1Primary.Slots[1].LoadFromString(GetLoadString(endRed), ":"); clone.Level1Primary.Slots[2].LoadFromString(GetLoadString(endRed), ":"); clone.Level1Primary.Slots[3].LoadFromString(GetLoadString(endRed), ":"); clone.Level1Primary.Slots[4].LoadFromString(GetLoadString(endRed), ":"); Debug.Assert(clone.CanAddEnhancement(damage, clone.Level1Primary) == true, "CanAddEnhancement is incorrect!"); Debug.Assert(clone.CanAddEnhancement(slow, clone.Level1Primary) == false, "CanAddEnhancement is incorrect!"); clone.Level1Primary.Slots[0].LoadFromString(GetLoadString(damage), ":"); clone.Level1Primary.Slots[1].LoadFromString(GetLoadString(damage), ":"); clone.Level1Primary.Slots[2].LoadFromString(GetLoadString(damage), ":"); Debug.Assert(clone.CanAddEnhancement(damage, clone.Level1Primary) == false, "CanAddEnhancement is incorrect!"); EnhancementSet blastersWrath = GetEnhancementSetByIndex(GetEnhancementSetIndexByName("Blaster's Wrath")); EnhancementSet superiorBlastersWrath = GetEnhancementSetByIndex(GetEnhancementSetIndexByName("Superior Blaster's Wrath")); IEnhancement blastersWrath0 = GetEnhancementByIndex(blastersWrath.Enhancements[0]); IEnhancement blastersWrath1 = GetEnhancementByIndex(blastersWrath.Enhancements[1]); IEnhancement superiorBlastersWrath0 = GetEnhancementByIndex(superiorBlastersWrath.Enhancements[0]); IEnhancement superiorBlastersWrath1 = GetEnhancementByIndex(superiorBlastersWrath.Enhancements[1]); string name = superiorBlastersWrath.DisplayName.Remove(0, 9); Debug.Assert(clone.CanAddEnhancement(blastersWrath0, clone.Level1Primary) == true, "CanAddEnhancement is incorrect!"); Debug.Assert(clone.CanAddEnhancement(blastersWrath0, clone.Level2) == true, "CanAddEnhancement is incorrect!"); Debug.Assert(clone.CanAddEnhancement(superiorBlastersWrath0, clone.Level1Primary) == true, "CanAddEnhancement is incorrect!"); Debug.Assert(clone.CanAddEnhancement(superiorBlastersWrath0, clone.Level2) == true, "CanAddEnhancement is incorrect!"); clone.Level1Primary.Slots[0].LoadFromString(GetLoadString(superiorBlastersWrath0), ":"); Debug.Assert(clone.CanAddEnhancement(blastersWrath0, clone.Level1Primary) == false, "CanAddEnhancement is incorrect!"); Debug.Assert(clone.CanAddEnhancement(blastersWrath0, clone.Level2) == false, "CanAddEnhancement is incorrect!"); Debug.Assert(clone.CanAddEnhancement(superiorBlastersWrath0, clone.Level2) == false, "CanAddEnhancement is incorrect!"); Debug.Assert(clone.CanAddEnhancement(superiorBlastersWrath1, clone.Level1Primary) == true, "CanAddEnhancement is incorrect!"); Debug.Assert(clone.CanAddEnhancement(blastersWrath1, clone.Level1Primary) == true, "CanAddEnhancement is incorrect!"); clone.Level1Primary.Slots[0].LoadFromString(GetLoadString(blastersWrath0), ":"); Debug.Assert(clone.CanAddEnhancement(superiorBlastersWrath0, clone.Level1Primary) == false, "CanAddEnhancement is incorrect!"); Debug.Assert(clone.CanAddEnhancement(superiorBlastersWrath0, clone.Level2) == false, "CanAddEnhancement is incorrect!"); Debug.Assert(clone.CanAddEnhancement(blastersWrath0, clone.Level2) == false, "CanAddEnhancement is incorrect!"); Debug.Assert(clone.CanAddEnhancement(superiorBlastersWrath1, clone.Level1Primary) == true, "CanAddEnhancement is incorrect!"); Debug.Assert(clone.CanAddEnhancement(blastersWrath1, clone.Level1Primary) == true, "CanAddEnhancement is incorrect!"); } public static void TestToonGetBonusCounts() { AIToon toon = TestCreateBuildControllerMindForceFieldWithIOs(); Dictionary counts = toon.GetBonusCounts(); Debug.Assert(counts.Count == 45, "counts.Count is incorrect!"); Debug.Assert(counts.ContainsKey("Set_Bonus.Set_Bonus.Improved_Recovery_3"), "counts.ContainsKey(Set_Bonus.Set_Bonus.Set_Bonus.Improved_Recovery_3) is incorrect!"); Debug.Assert(counts["Set_Bonus.Set_Bonus.Improved_Recovery_3"] == 4, "counts[Set_Bonus.Set_Bonus.Improved_Recovery_3] is incorrect!"); Debug.Assert(counts.ContainsKey("Set_Bonus.Set_Bonus.Fire_Cold_Mez_Res_2"), "counts.ContainsKey(Set_Bonus.Set_Bonus.Fire_Cold_Mez_Res_2) is incorrect!"); Debug.Assert(counts["Set_Bonus.Set_Bonus.Fire_Cold_Mez_Res_2"] == 3, "counts[Set_Bonus.Set_Bonus.Fire_Cold_Mez_Res_2] is incorrect!"); Debug.Assert(counts.ContainsKey("Set_Bonus.Set_Bonus.Increased_Endurance_3"), "counts.ContainsKey(Set_Bonus.Set_Bonus.Increased_Endurance_3) is incorrect!"); Debug.Assert(counts["Set_Bonus.Set_Bonus.Increased_Endurance_3"] == 3, "counts[Set_Bonus.Set_Bonus.Increased_Endurance_3] is incorrect!"); Debug.Assert(counts.ContainsKey("Set_Bonus.Set_Bonus.Energy_Neg_Mez_Res_4"), "counts.ContainsKey(Set_Bonus.Set_Bonus.Energy_Neg_Mez_Res_4) is incorrect!"); Debug.Assert(counts["Set_Bonus.Set_Bonus.Energy_Neg_Mez_Res_4"] == 2, "counts[Set_Bonus.Set_Bonus.Energy_Neg_Mez_Res_4] is incorrect!"); Debug.Assert(counts.ContainsKey("Set_Bonus.Set_Bonus.Toxic_Psi_Mez_Res_5"), "counts.ContainsKey(Set_Bonus.Set_Bonus.Toxic_Psi_Mez_Res_5) is incorrect!"); Debug.Assert(counts["Set_Bonus.Set_Bonus.Toxic_Psi_Mez_Res_5"] == 3, "counts[Set_Bonus.Set_Bonus.Toxic_Psi_Mez_Res_5] is incorrect!"); Debug.Assert(counts.ContainsKey("Set_Bonus.Set_Bonus.Toxic_Psi_Mez_Res_1"), "counts.ContainsKey(Set_Bonus.Set_Bonus.Toxic_Psi_Mez_Res_1) is incorrect!"); Debug.Assert(counts["Set_Bonus.Set_Bonus.Toxic_Psi_Mez_Res_1"] == 3, "counts[Set_Bonus.Set_Bonus.Toxic_Psi_Mez_Res_1] is incorrect!"); Debug.Assert(counts.ContainsKey("Set_Bonus.Set_Bonus.Increased_Health_2"), "counts.ContainsKey(Set_Bonus.Set_Bonus.Increased_Health_2) is incorrect!"); Debug.Assert(counts["Set_Bonus.Set_Bonus.Increased_Health_2"] == 3, "counts[Set_Bonus.Set_Bonus.Increased_Health_2] is incorrect!"); Debug.Assert(counts.ContainsKey("Set_Bonus.Set_Bonus.Improved_Recovery_2"), "counts.ContainsKey(Set_Bonus.Set_Bonus.Improved_Recovery_2) is incorrect!"); Debug.Assert(counts["Set_Bonus.Set_Bonus.Improved_Recovery_2"] == 3, "counts[Set_Bonus.Set_Bonus.Improved_Recovery_2] is incorrect!"); Debug.Assert(counts.ContainsKey("Set_Bonus.Set_Bonus.Increased_Health_1"), "counts.ContainsKey(Set_Bonus.Set_Bonus.Increased_Health_1) is incorrect!"); Debug.Assert(counts["Set_Bonus.Set_Bonus.Increased_Health_1"] == 1, "counts[Set_Bonus.Set_Bonus.Increased_Health_1] is incorrect!"); Debug.Assert(counts.ContainsKey("Set_Bonus.Set_Bonus.Fire_Cold_Mez_Res_1"), "counts.ContainsKey(Set_Bonus.Set_Bonus.Fire_Cold_Mez_Res_1) is incorrect!"); Debug.Assert(counts["Set_Bonus.Set_Bonus.Fire_Cold_Mez_Res_1"] == 1, "counts[Set_Bonus.Set_Bonus.Fire_Cold_Mez_Res_1] is incorrect!"); Debug.Assert(counts.ContainsKey("Set_Bonus.Set_Bonus.Improved_Regeneration_4"), "counts.ContainsKey(Set_Bonus.Set_Bonus.Improved_Regeneration_4) is incorrect!"); Debug.Assert(counts["Set_Bonus.Set_Bonus.Improved_Regeneration_4"] == 3, "counts[Set_Bonus.Set_Bonus.Improved_Regeneration_4] is incorrect!"); Debug.Assert(counts.ContainsKey("Set_Bonus.PVP_Set_Bonus.Improved_Recovery_4"), "counts.ContainsKey(Set_Bonus.PVP_Set_Bonus.Improved_Recovery_4) is incorrect!"); Debug.Assert(counts["Set_Bonus.PVP_Set_Bonus.Improved_Recovery_4"] == 1, "counts[Set_Bonus.PVP_Set_Bonus.Improved_Recovery_4] is incorrect!"); Debug.Assert(counts.ContainsKey("Set_Bonus.Set_Bonus.Increased_Health_5"), "counts.ContainsKey(Set_Bonus.Set_Bonus.Increased_Health_5) is incorrect!"); Debug.Assert(counts["Set_Bonus.PVP_Set_Bonus.Improved_Recovery_4"] == 1, "counts[Set_Bonus.Set_Bonus.Increased_Health_5] is incorrect!"); Debug.Assert(counts.ContainsKey("Set_Bonus.PVP_Set_Bonus.Repel_Resist_3"), "counts.ContainsKey(Set_Bonus.PVP_Set_Bonus.Repel_Resist_3) is incorrect!"); Debug.Assert(counts["Set_Bonus.PVP_Set_Bonus.Repel_Resist_3"] == 1, "counts[Set_Bonus.PVP_Set_Bonus.Repel_Resist_3] is incorrect!"); Debug.Assert(counts.ContainsKey("Set_Bonus.Set_Bonus.Energy_Neg_Mez_Res_5"), "counts.ContainsKey(Set_Bonus.Set_Bonus.Energy_Neg_Mez_Res_5) is incorrect!"); Debug.Assert(counts["Set_Bonus.Set_Bonus.Energy_Neg_Mez_Res_5"] == 1, "counts[Set_Bonus.Set_Bonus.Energy_Neg_Mez_Res_5] is incorrect!"); Debug.Assert(counts.ContainsKey("Set_Bonus.Set_Bonus.Lethal_Smash_Mez_Res_2"), "counts.ContainsKey(Set_Bonus.Set_Bonus.Lethal_Smash_Mez_Res_2) is incorrect!"); Debug.Assert(counts["Set_Bonus.Set_Bonus.Lethal_Smash_Mez_Res_2"] == 2, "counts[Set_Bonus.Set_Bonus.Lethal_Smash_Mez_Res_2] is incorrect!"); Debug.Assert(counts.ContainsKey("Set_Bonus.Set_Bonus.Improved_Regeneration_2"), "counts.ContainsKey(Set_Bonus.Set_Bonus.Improved_Regeneration_2) is incorrect!"); Debug.Assert(counts["Set_Bonus.Set_Bonus.Improved_Regeneration_2"] == 2, "counts[Set_Bonus.Set_Bonus.Improved_Regeneration_2] is incorrect!"); Debug.Assert(counts.ContainsKey("Set_Bonus.Set_Bonus.Improved_Recharge_Time_2"), "counts.ContainsKey(Set_Bonus.Set_Bonus.Improved_Recharge_Time_2) is incorrect!"); Debug.Assert(counts["Set_Bonus.Set_Bonus.Improved_Recharge_Time_2"] == 1, "counts[Set_Bonus.Set_Bonus.Improved_Recharge_Time_2] is incorrect!"); Debug.Assert(counts.ContainsKey("Set_Bonus.Set_Bonus.Accuracy_4"), "counts.ContainsKey(Set_Bonus.Set_Bonus.Accuracy_4) is incorrect!"); Debug.Assert(counts["Set_Bonus.Set_Bonus.Accuracy_4"] == 2, "counts[Set_Bonus.Set_Bonus.Accuracy_4] is incorrect!"); Debug.Assert(counts.ContainsKey("Set_Bonus.Set_Bonus.Lethal_Smash_Mez_Res_4"), "counts.ContainsKey(Set_Bonus.Set_Bonus.Lethal_Smash_Mez_Res_4) is incorrect!"); Debug.Assert(counts["Set_Bonus.Set_Bonus.Lethal_Smash_Mez_Res_4"] == 2, "counts[Set_Bonus.Set_Bonus.Lethal_Smash_Mez_Res_4] is incorrect!"); Debug.Assert(counts.ContainsKey("Set_Bonus.Set_Bonus.Sleep_Dur_3"), "counts.ContainsKey(Set_Bonus.Set_Bonus.Sleep_Dur_3) is incorrect!"); Debug.Assert(counts["Set_Bonus.Set_Bonus.Sleep_Dur_3"] == 1, "counts[Set_Bonus.Set_Bonus.Sleep_Dur_3] is incorrect!"); Debug.Assert(counts.ContainsKey("Set_Bonus.Set_Bonus.Increased_Energy_Neg_Ranged_Def_2"), "counts.ContainsKey(Set_Bonus.Set_Bonus.Increased_Energy_Neg_Ranged_Def_2) is incorrect!"); Debug.Assert(counts["Set_Bonus.Set_Bonus.Increased_Energy_Neg_Ranged_Def_2"] == 1, "counts[Set_Bonus.Set_Bonus.Increased_Energy_Neg_Ranged_Def_2] is incorrect!"); Debug.Assert(counts.ContainsKey("Set_Bonus.Set_Bonus.Increased_Lethal_Smash_Melee_Def_2"), "counts.ContainsKey(Set_Bonus.Set_Bonus.Increased_Lethal_Smash_Melee_Def_2) is incorrect!"); Debug.Assert(counts["Set_Bonus.Set_Bonus.Increased_Lethal_Smash_Melee_Def_2"] == 1, "counts[Set_Bonus.Set_Bonus.Increased_Lethal_Smash_Melee_Def_2] is incorrect!"); Debug.Assert(counts.ContainsKey("Set_Bonus.Set_Bonus.Improved_Recovery_4"), "counts.ContainsKey(Set_Bonus.Set_Bonus.Improved_Recovery_4) is incorrect!"); Debug.Assert(counts["Set_Bonus.Set_Bonus.Improved_Recovery_4"] == 4, "counts[Set_Bonus.Set_Bonus.Improved_Recovery_4] is incorrect!"); Debug.Assert(counts.ContainsKey("Set_Bonus.Set_Bonus.Improved_Recovery_7"), "counts.ContainsKey(Set_Bonus.Set_Bonus.Improved_Recovery_7) is incorrect!"); Debug.Assert(counts["Set_Bonus.Set_Bonus.Improved_Recovery_7"] == 5, "counts[Set_Bonus.Set_Bonus.Improved_Recovery_7] is incorrect!"); Debug.Assert(counts.ContainsKey("Set_Bonus.Set_Bonus.Endurance_Discount_3"), "counts.ContainsKey(Set_Bonus.Set_Bonus.Endurance_Discount_3) is incorrect!"); Debug.Assert(counts["Set_Bonus.Set_Bonus.Endurance_Discount_3"] == 1, "counts[Set_Bonus.Set_Bonus.Endurance_Discount_3] is incorrect!"); Debug.Assert(counts.ContainsKey("Set_Bonus.Set_Bonus.Energy_Neg_Mez_Res_2"), "counts.ContainsKey(Set_Bonus.Set_Bonus.Energy_Neg_Mez_Res_2) is incorrect!"); Debug.Assert(counts["Set_Bonus.Set_Bonus.Energy_Neg_Mez_Res_2"] == 1, "counts[Set_Bonus.Set_Bonus.Energy_Neg_Mez_Res_2] is incorrect!"); Debug.Assert(counts.ContainsKey("Set_Bonus.Set_Bonus.Increased_Melee_Lethal_Smash_Def_4"), "counts.ContainsKey(Set_Bonus.Set_Bonus.Increased_Melee_Lethal_Smash_Def_4) is incorrect!"); Debug.Assert(counts["Set_Bonus.Set_Bonus.Increased_Melee_Lethal_Smash_Def_4"] == 1, "counts[Set_Bonus.Set_Bonus.Increased_Melee_Lethal_Smash_Def_4] is incorrect!"); Debug.Assert(counts.ContainsKey("Set_Bonus.Set_Bonus.Confuse_Dur_7"), "counts.ContainsKey(Set_Bonus.Set_Bonus.Confuse_Dur_7) is incorrect!"); Debug.Assert(counts["Set_Bonus.Set_Bonus.Confuse_Dur_7"] == 1, "counts[Set_Bonus.Set_Bonus.Confuse_Dur_7] is incorrect!"); Debug.Assert(counts.ContainsKey("Set_Bonus.Set_Bonus.Increased_Damage_7"), "counts.ContainsKey(Set_Bonus.Set_Bonus.Increased_Damage_7) is incorrect!"); Debug.Assert(counts["Set_Bonus.Set_Bonus.Increased_Damage_7"] == 1, "counts[Set_Bonus.Set_Bonus.Increased_Damage_7] is incorrect!"); Debug.Assert(counts.ContainsKey("Set_Bonus.Set_Bonus.Confuse_Dur_4"), "counts.ContainsKey(Set_Bonus.Set_Bonus.Confuse_Dur_4) is incorrect!"); Debug.Assert(counts["Set_Bonus.Set_Bonus.Confuse_Dur_4"] == 1, "counts[Set_Bonus.Set_Bonus.Confuse_Dur_4] is incorrect!"); Debug.Assert(counts.ContainsKey("Set_Bonus.Set_Bonus.Increased_Damage_4"), "counts.ContainsKey(Set_Bonus.Set_Bonus.Increased_Damage_4) is incorrect!"); Debug.Assert(counts["Set_Bonus.Set_Bonus.Increased_Damage_4"] == 2, "counts[Set_Bonus.Set_Bonus.Increased_Damage_4] is incorrect!"); Debug.Assert(counts.ContainsKey("Set_Bonus.Set_Bonus.Fire_Cold_Mez_Res_7"), "counts.ContainsKey(Set_Bonus.Set_Bonus.Fire_Cold_Mez_Res_7) is incorrect!"); Debug.Assert(counts["Set_Bonus.Set_Bonus.Fire_Cold_Mez_Res_7"] == 3, "counts[Set_Bonus.Set_Bonus.Fire_Cold_Mez_Res_7] is incorrect!"); Debug.Assert(counts.ContainsKey("Set_Bonus.Set_Bonus.Accuracy_7"), "counts.ContainsKey(Set_Bonus.Set_Bonus.Accuracy_7) is incorrect!"); Debug.Assert(counts["Set_Bonus.Set_Bonus.Accuracy_7"] == 2, "counts[Set_Bonus.Set_Bonus.Accuracy_7] is incorrect!"); Debug.Assert(counts.ContainsKey("Set_Bonus.Set_Bonus.Improved_Recharge_Time_7"), "counts.ContainsKey(Set_Bonus.Set_Bonus.Improved_Recharge_Time_7) is incorrect!"); Debug.Assert(counts["Set_Bonus.Set_Bonus.Improved_Recharge_Time_7"] == 2, "counts[Set_Bonus.Set_Bonus.Improved_Recharge_Time_7] is incorrect!"); Debug.Assert(counts.ContainsKey("Set_Bonus.Set_Bonus.Toxic_Psi_Mez_Res_7"), "counts.ContainsKey(Set_Bonus.Set_Bonus.Toxic_Psi_Mez_Res_7) is incorrect!"); Debug.Assert(counts["Set_Bonus.Set_Bonus.Toxic_Psi_Mez_Res_7"] == 2, "counts[Set_Bonus.Set_Bonus.Toxic_Psi_Mez_Res_7] is incorrect!"); Debug.Assert(counts.ContainsKey("Set_Bonus.Set_Bonus.Increased_Health_4"), "counts.ContainsKey(Set_Bonus.Set_Bonus.Increased_Health_4) is incorrect!"); Debug.Assert(counts["Set_Bonus.Set_Bonus.Increased_Health_4"] == 2, "counts[Set_Bonus.Set_Bonus.Increased_Health_4] is incorrect!"); Debug.Assert(counts.ContainsKey("Set_Bonus.Set_Bonus.Stun_Dur_5"), "counts.ContainsKey(Set_Bonus.Set_Bonus.Stun_Dur_5) is incorrect!"); Debug.Assert(counts["Set_Bonus.Set_Bonus.Stun_Dur_5"] == 1, "counts[Set_Bonus.Set_Bonus.Stun_Dur_5] is incorrect!"); Debug.Assert(counts.ContainsKey("Set_Bonus.Set_Bonus.Improved_Recharge_Time_4"), "counts.ContainsKey(Set_Bonus.Set_Bonus.Improved_Recharge_Time_4) is incorrect!"); Debug.Assert(counts["Set_Bonus.Set_Bonus.Improved_Recharge_Time_4"] == 1, "counts[Set_Bonus.Set_Bonus.Improved_Recharge_Time_4] is incorrect!"); Debug.Assert(counts.ContainsKey("Set_Bonus.Set_Bonus.Increased_Ranged_Energy_Neg_Def_4"), "counts.ContainsKey(Set_Bonus.Set_Bonus.Increased_Ranged_Energy_Neg_Def_4) is incorrect!"); Debug.Assert(counts["Set_Bonus.Set_Bonus.Increased_Ranged_Energy_Neg_Def_4"] == 1, "counts[Set_Bonus.Set_Bonus.Increased_Ranged_Energy_Neg_Def_4] is incorrect!"); Debug.Assert(counts.ContainsKey("Set_Bonus.Set_Bonus.Slow_Resist_5"), "counts.ContainsKey(Set_Bonus.Set_Bonus.Slow_Resist_5) is incorrect!"); Debug.Assert(counts["Set_Bonus.Set_Bonus.Slow_Resist_5"] == 1, "counts[Set_Bonus.Set_Bonus.Slow_Resist_5] is incorrect!"); Debug.Assert(counts.ContainsKey("Set_Bonus.Set_Bonus.Increased_Energy_Neg_Ranged_Def_7"), "counts.ContainsKey(Set_Bonus.Set_Bonus.Increased_Energy_Neg_Ranged_Def_7) is incorrect!"); Debug.Assert(counts["Set_Bonus.Set_Bonus.Increased_Energy_Neg_Ranged_Def_7"] == 1, "counts[Set_Bonus.Set_Bonus.Increased_Energy_Neg_Ranged_Def_7] is incorrect!"); Debug.Assert(counts.ContainsKey("Set_Bonus.Set_Bonus.Increased_Fire_Cold_AoE_Def_7"), "counts.ContainsKey(Set_Bonus.Set_Bonus.Increased_Fire_Cold_AoE_Def_7) is incorrect!"); Debug.Assert(counts["Set_Bonus.Set_Bonus.Increased_Fire_Cold_AoE_Def_7"] == 1, "counts[Set_Bonus.Set_Bonus.Increased_Fire_Cold_AoE_Def_7] is incorrect!"); Debug.Assert(counts.ContainsKey("Set_Bonus.PVP_Set_Bonus.Increased_Range_2"), "counts.ContainsKey(Set_Bonus.PVP_Set_Bonus.Increased_Range_2) is incorrect!"); Debug.Assert(counts["Set_Bonus.PVP_Set_Bonus.Increased_Range_2"] == 1, "counts[Set_Bonus.PVP_Set_Bonus.Increased_Range_2] is incorrect!"); Debug.Assert(counts.ContainsKey("Set_Bonus.PVP_Set_Bonus.Lethal_Smash_Mez_Res_2"), "counts.ContainsKey(Set_Bonus.PVP_Set_Bonus.Lethal_Smash_Mez_Res_2) is incorrect!"); Debug.Assert(counts["Set_Bonus.PVP_Set_Bonus.Lethal_Smash_Mez_Res_2"] == 1, "counts[Set_Bonus.PVP_Set_Bonus.Lethal_Smash_Mez_Res_2] is incorrect!"); EnhancementSet shieldWall = GetEnhancementSetByIndex(GetEnhancementSetIndexByName("Shield Wall")); counts = toon.GetBonusCounts(shieldWall, 6); Debug.Assert(counts.Count == 5, "counts.Count is incorrect!"); Debug.Assert(counts.ContainsKey("Set_Bonus.Set_Bonus.Improved_Regeneration_4"), "counts.ContainsKey(Set_Bonus.Set_Bonus.Improved_Regeneration_4) is incorrect!"); Debug.Assert(counts["Set_Bonus.Set_Bonus.Improved_Regeneration_4"] == 3, "counts[Set_Bonus.Set_Bonus.Improved_Regeneration_4] is incorrect!"); Debug.Assert(counts.ContainsKey("Set_Bonus.PVP_Set_Bonus.Improved_Recovery_4"), "counts.ContainsKey(Set_Bonus.PVP_Set_Bonus.Improved_Recovery_4) is incorrect!"); Debug.Assert(counts["Set_Bonus.PVP_Set_Bonus.Improved_Recovery_4"] == 1, "counts[Set_Bonus.PVP_Set_Bonus.Improved_Recovery_4] is incorrect!"); Debug.Assert(counts.ContainsKey("Set_Bonus.Set_Bonus.Increased_Health_5"), "counts.ContainsKey(Set_Bonus.Set_Bonus.Increased_Health_5) is incorrect!"); Debug.Assert(counts["Set_Bonus.Set_Bonus.Increased_Health_5"] == 1, "counts[Set_Bonus.Set_Bonus.Increased_Health_5] is incorrect!"); Debug.Assert(counts.ContainsKey("Set_Bonus.PVP_Set_Bonus.Repel_Resist_3"), "counts.ContainsKey(Set_Bonus.PVP_Set_Bonus.Repel_Resist_3) is incorrect!"); Debug.Assert(counts["Set_Bonus.PVP_Set_Bonus.Repel_Resist_3"] == 1, "counts[Set_Bonus.PVP_Set_Bonus.Repel_Resist_3] is incorrect!"); Debug.Assert(counts.ContainsKey("Set_Bonus.Set_Bonus.Energy_Neg_Mez_Res_5"), "counts.ContainsKey(Set_Bonus.Set_Bonus.Energy_Neg_Mez_Res_5) is incorrect!"); Debug.Assert(counts["Set_Bonus.Set_Bonus.Energy_Neg_Mez_Res_5"] == 1, "counts[Set_Bonus.Set_Bonus.Energy_Neg_Mez_Res_5] is incorrect!"); counts = toon.GetBonusCounts(shieldWall, 3); Debug.Assert(counts.Count == 2, "counts.Count is incorrect!"); Debug.Assert(counts.ContainsKey("Set_Bonus.Set_Bonus.Improved_Regeneration_4"), "counts.ContainsKey(Set_Bonus.Set_Bonus.Improved_Regeneration_4) is incorrect!"); Debug.Assert(counts["Set_Bonus.Set_Bonus.Improved_Regeneration_4"] == 3, "counts[Set_Bonus.Set_Bonus.Improved_Regeneration_4] is incorrect!"); Debug.Assert(counts.ContainsKey("Set_Bonus.PVP_Set_Bonus.Improved_Recovery_4"), "counts.ContainsKey(Set_Bonus.PVP_Set_Bonus.Improved_Recovery_4) is incorrect!"); Debug.Assert(counts["Set_Bonus.PVP_Set_Bonus.Improved_Recovery_4"] == 1, "counts[Set_Bonus.PVP_Set_Bonus.Improved_Recovery_4] is incorrect!"); } public static void TestGetHighestValidSet(AIToon toon) { AIToon clone = toon.Clone() as AIToon; HashSet defenseBonusSets = GetEnhancementSetsWithBonusEffect(clone.Level1Primary.Power, 6, Enums.eEffectType.Defense); EnhancementSet[] sortedEnhancementSets = SortEnhancementSets(defenseBonusSets, 6, Enums.eEffectType.Defense); EnhancementSet highestSet = clone.GetHighestValidSet(sortedEnhancementSets, clone.Level1Primary, 6, Enums.eEffectType.Defense); Debug.Assert(highestSet.DisplayName == "Superior Winter's Bite", "highestSet is incorrect!"); clone.Level6.Slots[0].LoadFromString(GetLoadString(GetEnhancementByIndex(highestSet.Enhancements[0])), ":"); clone.Level6.Slots[1].LoadFromString(GetLoadString(GetEnhancementByIndex(highestSet.Enhancements[1])), ":"); clone.Level6.Slots[2].LoadFromString(GetLoadString(GetEnhancementByIndex(highestSet.Enhancements[2])), ":"); clone.Level6.Slots[3].LoadFromString(GetLoadString(GetEnhancementByIndex(highestSet.Enhancements[3])), ":"); clone.Level6.Slots[4].LoadFromString(GetLoadString(GetEnhancementByIndex(highestSet.Enhancements[4])), ":"); clone.Level6.Slots[5].LoadFromString(GetLoadString(GetEnhancementByIndex(highestSet.Enhancements[5])), ":"); highestSet = clone.GetHighestValidSet(sortedEnhancementSets, clone.Level1Primary, 6, Enums.eEffectType.Defense); Debug.Assert(highestSet.DisplayName == "Lethargic Repose", "highestSet is incorrect!"); } public static void TestMultiSlotPowerEntry() { AIToon toon = TestCreateBuildControllerMindForceField(); List powerEntries = toon.GetPowerEntries(); MultiEvolveData[] multiEvolveData = new MultiEvolveData[1]; multiEvolveData[0] = new MultiEvolveData(); multiEvolveData[0].EffectType = Enums.eEffectType.Defense; multiEvolveData[0].DamageType = Enums.eDamage.Smashing; multiEvolveData[0].IncludePvP = false; multiEvolveData[0].Weight = 1.0f; PowerEntry result = MultiSlotPowerEntry(toon, powerEntries, 2, multiEvolveData); Debug.Assert(6 == result.Slots.Length, "result is incorrect!"); Debug.Assert(GetEnhancementByIndex(result.Slots[0].Enhancement.Enh).UIDSet == "Lethargic_Repose", "enhancement[0] is incorrect!"); Debug.Assert(GetEnhancementByIndex(result.Slots[1].Enhancement.Enh).UIDSet == "Lethargic_Repose", "enhancement[1] is incorrect!"); Debug.Assert(GetEnhancementByIndex(result.Slots[2].Enhancement.Enh).UIDSet == "Lethargic_Repose", "enhancement[2] is incorrect!"); Debug.Assert(GetEnhancementByIndex(result.Slots[3].Enhancement.Enh).UIDSet == "Lethargic_Repose", "enhancement[3] is incorrect!"); Debug.Assert(GetEnhancementByIndex(result.Slots[4].Enhancement.Enh).UIDSet == "", "enhancement[4] is incorrect!"); Debug.Assert(GetEnhancementByIndex(result.Slots[5].Enhancement.Enh).UIDSet == "", "enhancement[5] is incorrect!"); multiEvolveData[0].EffectType = Enums.eEffectType.Recovery; multiEvolveData[0].DamageType = Enums.eDamage.None; multiEvolveData[0].IncludePvP = true; result = MultiSlotPowerEntry(toon, powerEntries, 3, multiEvolveData); Debug.Assert(GetEnhancementByIndex(result.Slots[0].Enhancement.Enh).UIDSet == "Shield_Wall", "enhancement[0] is incorrect!"); Debug.Assert(GetEnhancementByIndex(result.Slots[1].Enhancement.Enh).UIDSet == "Shield_Wall", "enhancement[1] is incorrect!"); Debug.Assert(GetEnhancementByIndex(result.Slots[2].Enhancement.Enh).UIDSet == "Gift_of_the_Ancients", "enhancement[2] is incorrect!"); Debug.Assert(GetEnhancementByIndex(result.Slots[3].Enhancement.Enh).UIDSet == "Gift_of_the_Ancients", "enhancement[3] is incorrect!"); Debug.Assert(GetEnhancementByIndex(result.Slots[4].Enhancement.Enh).UIDSet == "Kismet", "enhancement[4] is incorrect!"); Debug.Assert(GetEnhancementByIndex(result.Slots[5].Enhancement.Enh).UIDSet == "Kismet", "enhancement[5] is incorrect!"); } public static void TestToonEvolveHighestSetStrategy(AIToon toon) { PowerEntry result = HighestSetStrategy(toon, toon.GetPowerEntries(), 2, Enums.eEffectType.Defense, Enums.eDamage.Smashing, false); Debug.Assert(6 == result.Slots.Length, "result is incorrect!"); Debug.Assert(GetEnhancementByIndex(result.Slots[0].Enhancement.Enh).UIDSet == "Lethargic_Repose", "enhancement[0] is incorrect!"); Debug.Assert(GetEnhancementByIndex(result.Slots[1].Enhancement.Enh).UIDSet == "Lethargic_Repose", "enhancement[1] is incorrect!"); Debug.Assert(GetEnhancementByIndex(result.Slots[2].Enhancement.Enh).UIDSet == "Lethargic_Repose", "enhancement[2] is incorrect!"); Debug.Assert(GetEnhancementByIndex(result.Slots[3].Enhancement.Enh).UIDSet == "Lethargic_Repose", "enhancement[3] is incorrect!"); Debug.Assert(GetEnhancementByIndex(result.Slots[4].Enhancement.Enh).UIDSet == "", "enhancement[4] is incorrect!"); Debug.Assert(GetEnhancementByIndex(result.Slots[5].Enhancement.Enh).UIDSet == "", "enhancement[5] is incorrect!"); } public static void TestToonEvolveFrakenslotStrategy(AIToon toon) { PowerEntry result = FrankenslotStrategy(toon, toon.GetPowerEntries(), 3, Enums.eEffectType.Recovery, Enums.eDamage.None, true); Debug.Assert(6 == result.Slots.Length, "result is incorrect!"); Debug.Assert(GetEnhancementByIndex(result.Slots[0].Enhancement.Enh).UIDSet == "Shield_Wall", "enhancement[0] is incorrect!"); Debug.Assert(GetEnhancementByIndex(result.Slots[1].Enhancement.Enh).UIDSet == "Shield_Wall", "enhancement[1] is incorrect!"); Debug.Assert(GetEnhancementByIndex(result.Slots[2].Enhancement.Enh).UIDSet == "Gift_of_the_Ancients", "enhancement[2] is incorrect!"); Debug.Assert(GetEnhancementByIndex(result.Slots[3].Enhancement.Enh).UIDSet == "Gift_of_the_Ancients", "enhancement[3] is incorrect!"); Debug.Assert(GetEnhancementByIndex(result.Slots[4].Enhancement.Enh).UIDSet == "Kismet", "enhancement[4] is incorrect!"); Debug.Assert(GetEnhancementByIndex(result.Slots[5].Enhancement.Enh).UIDSet == "Kismet", "enhancement[5] is incorrect!"); result = FrankenslotStrategy(toon, toon.GetPowerEntries(), 3, Enums.eEffectType.Recovery, Enums.eDamage.None, false); Debug.Assert(6 == result.Slots.Length, "result is incorrect!"); Debug.Assert(GetEnhancementByIndex(result.Slots[0].Enhancement.Enh).UIDSet == "Gift_of_the_Ancients", "enhancement[0] is incorrect!"); Debug.Assert(GetEnhancementByIndex(result.Slots[1].Enhancement.Enh).UIDSet == "Gift_of_the_Ancients", "enhancement[1] is incorrect!"); Debug.Assert(GetEnhancementByIndex(result.Slots[2].Enhancement.Enh).UIDSet == "Kismet", "enhancement[2] is incorrect!"); Debug.Assert(GetEnhancementByIndex(result.Slots[3].Enhancement.Enh).UIDSet == "Kismet", "enhancement[3] is incorrect!"); Debug.Assert(GetEnhancementByIndex(result.Slots[4].Enhancement.Enh).UIDSet == "", "enhancement[4] is incorrect!"); Debug.Assert(GetEnhancementByIndex(result.Slots[5].Enhancement.Enh).UIDSet == "", "enhancement[5] is incorrect!"); } public static void TestCanMoveSlots() { AIToon toon = TestCreateBuildControllerMindForceField(); // Bad data checks. Debug.Assert(CanMoveSlots(null, toon.Level22) == false, "CanMoveSlots(null, toon.Level22) is incorrect!"); Debug.Assert(CanMoveSlots(toon.Level22, null) == false, "CanMoveSlots(toon.Level22, null) is incorrect!"); PowerEntry powerEntryClone = toon.Level22.Clone() as PowerEntry; powerEntryClone.Slots = null; Debug.Assert(CanMoveSlots(powerEntryClone, toon.Level22) == false, "CanMoveSlots(powerEntryClone, toon.Level22) is incorrect!"); Debug.Assert(CanMoveSlots(toon.Level22, powerEntryClone) == false, "CanMoveSlots(toon.Level22, powerEntryClone) is incorrect!"); // Source slots = 6, dest slots = 6, result = false Debug.Assert(CanMoveSlots(toon.Level1Primary, toon.Level1Secondary) == false, "CanMoveSlots(toon.Level1Primary, toon.Level1Secondary) is incorrect!"); // Source slots = 1, dest slots = 1, result = false Debug.Assert(CanMoveSlots(toon.Level26, toon.Level28) == false, "CanMoveSlots(toon.Level26, toon.Level28) is incorrect!"); // Source slots = 1, dest slots = 6, result = false Debug.Assert(CanMoveSlots(toon.Level26, toon.Level1Primary) == false, "CanMoveSlots(toon.Level26, toon.Level1Primary) is incorrect!"); // Source slots = 6, dest slots = 1, result = true Debug.Assert(CanMoveSlots(toon.Level1Primary, toon.Level26) == true, "CanMoveSlots(toon.Level1Primary, toon.Level26) is incorrect!"); // Source slots = 5, dest slots = 5, result = true Debug.Assert(CanMoveSlots(toon.Level20, toon.Level22) == true, "CanMoveSlots(toon.Level20, toon.Level22) is incorrect!"); } public static void TestGetMoveSlotCount() { AIToon toon = TestCreateBuildControllerMindForceField(); // Bad data checks. Debug.Assert(GetMoveSlotCount(null, toon.Level22) == -1, "GetMoveSlotCount(null, toon.Level22) is incorrect!"); Debug.Assert(GetMoveSlotCount(toon.Level22, null) == -1, "GetMoveSlotCount(toon.Level22, null) is incorrect!"); PowerEntry powerEntryClone = toon.Level22.Clone() as PowerEntry; powerEntryClone.Slots = null; Debug.Assert(GetMoveSlotCount(powerEntryClone, toon.Level22) == -1, "GetMoveSlotCount(powerEntryClone, toon.Level22) is incorrect!"); Debug.Assert(GetMoveSlotCount(toon.Level22, powerEntryClone) == -1, "GetMoveSlotCount(toon.Level22, powerEntryClone) is incorrect!"); // Source slots = 6, dest slots = 6, result = -1 Debug.Assert(GetMoveSlotCount(toon.Level1Primary, toon.Level1Secondary) == -1, "GetMoveSlotCount(toon.Level1Primary, toon.Level1Secondary) is incorrect!"); // Source slots = 1, dest slots = 1, result = -1 Debug.Assert(GetMoveSlotCount(toon.Level26, toon.Level28) == -1, "GetMoveSlotCount(toon.Level26, toon.Level28) is incorrect!"); // Source slots = 1, dest slots = 6, result = -1 Debug.Assert(GetMoveSlotCount(toon.Level26, toon.Level1Primary) == -1, "GetMoveSlotCount(toon.Level26, toon.Level1Primary) is incorrect!"); // Source slots = 6, dest slots = 1, result > 0 and < 6 int count = GetMoveSlotCount(toon.Level1Primary, toon.Level26); Debug.Assert(count > 0, "GetMoveSlotCount(toon.Level1Primary, toon.Level26) is incorrect!"); Debug.Assert(count < 6, "GetMoveSlotCount(toon.Level1Primary, toon.Level26) is incorrect!"); // Source slots = 5, dest slots = 5, result = 1 Debug.Assert(GetMoveSlotCount(toon.Level20, toon.Level22) == 1, "GetMoveSlotCount(toon.Level20, toon.Level22) is incorrect!"); } public static void TestMoveSlots() { AIToon toon = TestCreateBuildControllerMindForceField(); // Bad data checks. Debug.Assert(MoveSlots(null, toon.Level22, 1) == false, "MoveSlots(null, toon.Level22) is incorrect!"); Debug.Assert(MoveSlots(toon.Level22, null, 1) == false, "MoveSlots(toon.Level22, null) is incorrect!"); PowerEntry powerEntryClone20 = toon.Level20.Clone() as PowerEntry; powerEntryClone20.Slots = null; Debug.Assert(MoveSlots(powerEntryClone20, toon.Level22, 1) == false, "MoveSlots(powerEntryClone, toon.Level22) is incorrect!"); Debug.Assert(MoveSlots(toon.Level22, powerEntryClone20, 1) == false, "MoveSlots(toon.Level22, powerEntryClone) is incorrect!"); // Trying to move too much // Source slots = 5, dest slots = 5, move = 2, result = false Debug.Assert(MoveSlots(toon.Level20, toon.Level22, 2) == false, "MoveSlots(toon.Level20, toon.Level22, 2) is incorrect!"); // Trying to move too little // Source slots = 5, dest slots = 5, move = 0, result = false Debug.Assert(MoveSlots(toon.Level20, toon.Level22, 0) == false, "MoveSlots(toon.Level20, toon.Level22, 0) is incorrect!"); powerEntryClone20 = toon.Level20.Clone() as PowerEntry; PowerEntry powerEntryClone22 = toon.Level22.Clone() as PowerEntry; Debug.Assert(MoveSlots(powerEntryClone20, powerEntryClone22, 1) == true, "GetMoveSlotCount(powerEntryClone20, powerEntryClone22) is incorrect!"); Debug.Assert(powerEntryClone20.Slots.Length == 4, "powerEntryClone20.Slots.Length is incorrect!"); Debug.Assert(powerEntryClone22.Slots.Length == 6, "powerEntryClone22.Slots.Length is incorrect!"); } public static void TestToonEvolve(AIToon toon) { AIToon clone = toon.Clone() as AIToon; clone.Print(Enums.eEffectType.Defense, Enums.eDamage.Smashing); float sumBefore = clone.SumPowerBonuses(Enums.eEffectType.Defense, Enums.eDamage.Smashing); SlotToon(clone, Enums.eEffectType.Defense, Enums.eDamage.Smashing); EvolveToon(clone, 1, 1, Enums.eEffectType.Defense, Enums.eDamage.Smashing); float sumAfter = clone.SumPowerBonuses(Enums.eEffectType.Defense, Enums.eDamage.Smashing); clone.Print(Enums.eEffectType.Defense, Enums.eDamage.Smashing); Debug.Print(""); Debug.Assert(sumBefore <= sumAfter, "sumAfter is incorrect!"); clone = toon.Clone() as AIToon; sumBefore = clone.SumPowerBonuses(Enums.eEffectType.Defense, Enums.eDamage.Psionic); SlotToon(clone, Enums.eEffectType.Defense, Enums.eDamage.Psionic); EvolveToon(clone, 1, 1, Enums.eEffectType.Defense, Enums.eDamage.Psionic); sumAfter = clone.SumPowerBonuses(Enums.eEffectType.Defense, Enums.eDamage.Psionic); clone.Print(Enums.eEffectType.Defense, Enums.eDamage.Psionic); Debug.Print(""); Debug.Assert(sumBefore <= sumAfter, "sumAfter is incorrect!"); clone = toon.Clone() as AIToon; sumBefore = clone.SumPowerBonuses(Enums.eEffectType.Defense); SlotToon(clone, Enums.eEffectType.Defense); EvolveToon(clone, 1, 1, Enums.eEffectType.Defense); sumAfter = clone.SumPowerBonuses(Enums.eEffectType.Defense); clone.Print(Enums.eEffectType.Defense); Debug.Print(""); Debug.Assert(sumBefore <= sumAfter, "sumAfter is incorrect!"); clone = toon.Clone() as AIToon; sumBefore = clone.SumPowerBonuses(Enums.eEffectType.Recovery); SlotToon(clone, Enums.eEffectType.Recovery, Enums.eDamage.None, true); EvolveToon(clone, 1, 1, Enums.eEffectType.Recovery, Enums.eDamage.None, true); sumAfter = clone.SumPowerBonuses(Enums.eEffectType.Recovery); clone.Print(Enums.eEffectType.Recovery, Enums.eDamage.None, true); Debug.Print(""); Debug.Assert(sumBefore <= sumAfter, "sumAfter is incorrect!"); clone = toon.Clone() as AIToon; sumBefore = clone.SumPowerBonuses(Enums.eEffectType.Recovery); SlotToon(clone, Enums.eEffectType.Recovery, Enums.eDamage.None, false); EvolveToon(clone, 1, 1, Enums.eEffectType.Recovery, Enums.eDamage.None, false); sumAfter = clone.SumPowerBonuses(Enums.eEffectType.Recovery); clone.Print(Enums.eEffectType.Recovery); Debug.Print(""); Debug.Assert(sumBefore <= sumAfter, "sumAfter is incorrect!"); } public static void TestToonMultiEvolve(AIToon toon) { MultiEvolveData[] multiEvolveData = new MultiEvolveData[3]; multiEvolveData[0] = new MultiEvolveData(); multiEvolveData[1] = new MultiEvolveData(); multiEvolveData[2] = new MultiEvolveData(); multiEvolveData[0].EffectType = Enums.eEffectType.Defense; multiEvolveData[0].DamageType = Enums.eDamage.Smashing; multiEvolveData[0].IncludePvP = false; multiEvolveData[0].Weight = 1.0f; multiEvolveData[1].EffectType = Enums.eEffectType.Resistance; multiEvolveData[1].DamageType = Enums.eDamage.Psionic; multiEvolveData[1].IncludePvP = false; multiEvolveData[1].Weight = 1.0f; multiEvolveData[2].EffectType = Enums.eEffectType.Recovery; multiEvolveData[2].DamageType = Enums.eDamage.None; multiEvolveData[2].IncludePvP = false; multiEvolveData[2].Weight = 1.0f; AIToon clone = toon.Clone() as AIToon; float sumSmashingDefenseBefore = clone.SumPowerBonuses(Enums.eEffectType.Defense, Enums.eDamage.Smashing); float sumPsionicResistanceBefore = clone.SumPowerBonuses(Enums.eEffectType.Resistance, Enums.eDamage.Psionic); float sumRecoveryBefore = clone.SumPowerBonuses(Enums.eEffectType.Recovery, Enums.eDamage.None); MultiSlotToon(clone, multiEvolveData); MultiEvolveToon(clone, 100, 10, multiEvolveData); float sumSmashingDefenseAfter = clone.SumPowerBonuses(Enums.eEffectType.Defense, Enums.eDamage.Smashing); float sumPsionicResistanceAfter = clone.SumPowerBonuses(Enums.eEffectType.Resistance, Enums.eDamage.Psionic); float sumRecoveryAfter = clone.SumPowerBonuses(Enums.eEffectType.Recovery, Enums.eDamage.None); clone.Print(multiEvolveData); Debug.Print(""); Debug.Assert(sumSmashingDefenseBefore <= sumSmashingDefenseAfter, "sumSmashingDefenseAfter is incorrect!"); Debug.Assert(sumPsionicResistanceBefore <= sumPsionicResistanceAfter, "sumPsionicResistanceAfter is incorrect!"); Debug.Assert(sumRecoveryBefore <= sumRecoveryAfter, "sumRecoveryAfter is incorrect!"); Debug.Assert(clone.IsValid() == true, "clone.IsValid() is incorrect!"); multiEvolveData[1].Weight = 0.5f; multiEvolveData[2].Weight = 0.25f; clone = toon.Clone() as AIToon; sumSmashingDefenseBefore = clone.SumPowerBonuses(Enums.eEffectType.Defense, Enums.eDamage.Smashing); sumPsionicResistanceBefore = clone.SumPowerBonuses(Enums.eEffectType.Resistance, Enums.eDamage.Psionic); sumRecoveryBefore = clone.SumPowerBonuses(Enums.eEffectType.Recovery, Enums.eDamage.None); MultiSlotToon(clone, multiEvolveData); MultiEvolveToon(clone, 100, 10, multiEvolveData); sumSmashingDefenseAfter = clone.SumPowerBonuses(Enums.eEffectType.Defense, Enums.eDamage.Smashing); sumPsionicResistanceAfter = clone.SumPowerBonuses(Enums.eEffectType.Resistance, Enums.eDamage.Psionic); sumRecoveryAfter = clone.SumPowerBonuses(Enums.eEffectType.Recovery, Enums.eDamage.None); clone.Print(multiEvolveData); Debug.Print(""); Debug.Assert(sumSmashingDefenseBefore <= sumSmashingDefenseAfter, "sumSmashingDefenseAfter is incorrect!"); Debug.Assert(sumPsionicResistanceBefore <= sumPsionicResistanceAfter, "sumPsionicResistanceAfter is incorrect!"); Debug.Assert(sumRecoveryBefore <= sumRecoveryAfter, "sumRecoveryAfter is incorrect!"); Debug.Assert(clone.IsValid() == true, "clone.IsValid() is incorrect!"); multiEvolveData[1].Weight = 0.25f; multiEvolveData[2].Weight = 0.125f; clone = toon.Clone() as AIToon; sumSmashingDefenseBefore = clone.SumPowerBonuses(Enums.eEffectType.Defense, Enums.eDamage.Smashing); sumPsionicResistanceBefore = clone.SumPowerBonuses(Enums.eEffectType.Resistance, Enums.eDamage.Psionic); sumRecoveryBefore = clone.SumPowerBonuses(Enums.eEffectType.Recovery, Enums.eDamage.None); MultiSlotToon(clone, multiEvolveData); MultiEvolveToon(clone, 100, 10, multiEvolveData); sumSmashingDefenseAfter = clone.SumPowerBonuses(Enums.eEffectType.Defense, Enums.eDamage.Smashing); sumPsionicResistanceAfter = clone.SumPowerBonuses(Enums.eEffectType.Resistance, Enums.eDamage.Psionic); sumRecoveryAfter = clone.SumPowerBonuses(Enums.eEffectType.Recovery, Enums.eDamage.None); clone.Print(multiEvolveData); Debug.Print(""); Debug.Assert(sumSmashingDefenseBefore <= sumSmashingDefenseAfter, "sumSmashingDefenseAfter is incorrect!"); Debug.Assert(sumPsionicResistanceBefore <= sumPsionicResistanceAfter, "sumPsionicResistanceAfter is incorrect!"); Debug.Assert(sumRecoveryBefore <= sumRecoveryAfter, "sumRecoveryAfter is incorrect!"); Debug.Assert(clone.IsValid() == true, "clone.IsValid() is incorrect!"); clone.PrintDebug(); } }