using System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; 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 void SetPowerEntries(List powerEntries) { 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]; } public float SumPowerBonuses(Enums.eEffectType effectType, Enums.eDamage damageType = Enums.eDamage.None) { float sum = 0.0f; List powerEntries = GetPowerEntries(); foreach (PowerEntry powerEntry in powerEntries) { sum += SumPowerEntryBonusEffect(powerEntry, effectType, damageType); } 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); foreach (EnhancementTypes enhancementType in enhancementTypes) { if (!AllowsEnhancement(powerEntry.Power, enhancementType)) return false; } if (enhancement.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 int GetRuleOfFiveCount(EnhancementSet enhancementSet, int slots) { List bonusPowers = GetBonusPowers(enhancementSet); List powerEntries = GetPowerEntries(); int count = 0; 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; int enhancementCount = kvp.Value.Count; if (enhancementSet.DisplayName == set.DisplayName && powerEntry.Slots.Length >= slots) count++; } } return count; } 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 = 0; int ruleOfFiveCount = GetRuleOfFiveCount(enhancementSet, slots); if (5 <= ruleOfFiveCount) 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 Print() { 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); Debug.Print("=== Powers ==="); List powerEntries = GetPowerEntries(); foreach (PowerEntry powerEntry in powerEntries) { string powerSummary = "* " + powerEntry.Power.DisplayName + ": "; foreach (SlotEntry slot in powerEntry.Slots) { IEnhancement enhancement = GetEnhancementByIndex(slot.Enhancement.Enh); if (null == enhancement) continue; EnhancementSet enhancementSet = GetEnhancementSet(enhancement); if (null != enhancementSet) powerSummary += enhancementSet.DisplayName + " "; powerSummary += enhancement.ShortName + ", "; } Debug.Print(powerSummary); } } } 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 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) { 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) { List bonusPowers = GetBonusPowers(enhancementSet); if (2 > slots || 6 < slots) return false; for (int bonusPowerIndex = 0; bonusPowerIndex < bonusPowers.Count; ++bonusPowerIndex) { if (bonusPowerIndex == slots - 1) return false; IPower bonusPower = bonusPowers[bonusPowerIndex]; 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; } } return false; } public static HashSet GetEnhancementSetsWithBonusEffect(IPower power, int slots, Enums.eEffectType effectType, Enums.eDamage damageType = Enums.eDamage.None, float scale = -1.0f) { 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)) continue; enhancementSets.Add(enhancementSet); } return enhancementSets; } public static EnhancementSet[] SortEnhancementSets(HashSet sets, int slots, Enums.eEffectType effectType, Enums.eDamage damageType = Enums.eDamage.None) { EnhancementSet[] enhancementSetArray = sets.ToArray(); Array.Sort(enhancementSetArray, delegate (EnhancementSet set1, EnhancementSet set2) { float sum1 = SumEnhancementSetBonusEffect(set1, slots, effectType, damageType); float sum2 = SumEnhancementSetBonusEffect(set2, slots, effectType, damageType); 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) { float sum = 0.0f; if (1 > slots || 6 < slots) return sum; List bonusPowers = GetBonusPowers(enhancementSet); for (int bonusPowerIndex = 0; bonusPowerIndex < bonusPowers.Count; ++bonusPowerIndex) { if (bonusPowerIndex == slots - 1) return sum; IPower bonusPower = bonusPowers[bonusPowerIndex]; for (int effectIndex = 0; effectIndex < bonusPower.Effects.Length; ++effectIndex) { IEffect effect = bonusPower.Effects[effectIndex]; if (effect.EffectType != effectType) continue; if (Enums.eDamage.None == damageType || effect.DamageType == damageType) sum += effect.Scale; } } 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) { 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); } return sum; } public static void EvolveToon(AIToon toon, int generations, int mutations, Enums.eEffectType effectType, Enums.eDamage damageType = Enums.eDamage.None) { List powerEntries = toon.GetPowerEntries(); for (int generationCount = 0; generationCount < generations; generationCount++) { for (int powerEntryIndex = 0; powerEntryIndex < powerEntries.Count; powerEntryIndex++) { EvolvePower(toon, powerEntries, powerEntryIndex, mutations, effectType, damageType); toon.SetPowerEntries(powerEntries); } } } public static void EvolvePower(AIToon toon, List powerEntries, int index, int mutations, Enums.eEffectType effectType, Enums.eDamage damageType = Enums.eDamage.None) { Random rnd = new Random(); for (int mutationCount = 0; mutationCount < mutations; mutationCount++) { // int strategy = rnd.Next(1, 3); // if (1 == strategy) EvolvePowerHighestSetStrategy(toon, powerEntries, index, effectType, damageType); // else if (2 == strategy) // EvolvePowerFrankenslotStrategy(powerEntries, index, effectType, damageType); } } public static void EvolvePowerHighestSetStrategy(AIToon toon, List powerEntries, int index, Enums.eEffectType effectType, Enums.eDamage damageType = Enums.eDamage.None) { PowerEntry powerEntry = powerEntries[index]; float sum = SumPowerEntryBonusEffect(powerEntry, effectType, damageType); PowerEntry powerEntryClone = powerEntry.Clone() as PowerEntry; HashSet enhancementSets = GetEnhancementSetsWithBonusEffect(powerEntry.Power, powerEntry.Slots.Length, effectType, damageType); EnhancementSet[] sortedEnhancementSets = SortEnhancementSets(enhancementSets, 6, Enums.eEffectType.Defense); EnhancementSet enhancementSet = toon.GetHighestValidSet(sortedEnhancementSets, powerEntry, powerEntry.Slots.Length, effectType, damageType); if (null == enhancementSet) return; for (int enhancementIndex = 0; enhancementIndex < powerEntry.Slots.Length; enhancementIndex++) { string enhancement = GetLoadString(GetEnhancementByIndex(enhancementSet.Enhancements[enhancementIndex])); powerEntryClone.Slots[enhancementIndex].LoadFromString(enhancement, ":"); } float cloneSum = SumPowerEntryBonusEffect(powerEntryClone, effectType, damageType); if (sum >= cloneSum) powerEntries[index] = powerEntry; else powerEntries[index] = powerEntryClone; } public static void EvolvePowerFrankenslotStrategy(List powerEntries, int index, Enums.eEffectType effectType, Enums.eDamage damageType = Enums.eDamage.None) { PowerEntry powerEntry = powerEntries[index]; float sum = SumPowerEntryBonusEffect(powerEntry, effectType, damageType); // Split slots between multiple enhancement sets. Random rnd = new Random(); if (3 >= powerEntry.Slots.Length) return; int firstSetSlotCount = (int)(powerEntry.Slots.Length / 2); int secondSetSlotCount = powerEntry.Slots.Length - firstSetSlotCount; int thirdSetSlotCount = 0; int swap = rnd.Next(1, 3); if (1 == swap) { int x = firstSetSlotCount; firstSetSlotCount = secondSetSlotCount; secondSetSlotCount = x; } if (3 == firstSetSlotCount && 3 == secondSetSlotCount) { int strategy = rnd.Next(1, 5); if (1 == strategy) { firstSetSlotCount = 2; secondSetSlotCount = 4; } else if (2 == strategy) { firstSetSlotCount = 4; secondSetSlotCount = 2; } else if (3 == strategy) { firstSetSlotCount = 2; secondSetSlotCount = 2; thirdSetSlotCount = 2; } } // Debug.Print("Slots: " + powerEntry.Slots.Length.ToString() + ", firstSetSlotCount: " + firstSetSlotCount.ToString() + ", secondSetSlotCount: " + secondSetSlotCount.ToString() + ", thirdSetSlotCount: " + thirdSetSlotCount); HashSet firstSets = GetEnhancementSetsWithBonusEffect(powerEntry.Power, firstSetSlotCount, effectType, damageType); HashSet secondSets = GetEnhancementSetsWithBonusEffect(powerEntry.Power, secondSetSlotCount, effectType, damageType); HashSet thirdSets = (0 == thirdSetSlotCount) ? null : GetEnhancementSetsWithBonusEffect(powerEntry.Power, thirdSetSlotCount, effectType, damageType); PowerEntry powerEntryClone = powerEntry.Clone() as PowerEntry; HashSet enhancementSets = GetEnhancementSetsWithBonusEffect(powerEntry.Power, powerEntry.Slots.Length, effectType, damageType); EnhancementSet enhancementSet = GetHighestBonusEffect(enhancementSets, powerEntry.Slots.Length, effectType, damageType); if (null == enhancementSet) return; for (int enhancementIndex = 0; enhancementIndex < powerEntry.Slots.Length; enhancementIndex++) { string enhancement = GetLoadString(GetEnhancementByIndex(enhancementSet.Enhancements[enhancementIndex])); powerEntryClone.Slots[enhancementIndex].LoadFromString(enhancement, ":"); } float cloneSum = SumPowerEntryBonusEffect(powerEntryClone, effectType, damageType); if (sum >= cloneSum) powerEntries[index] = powerEntry; else powerEntries[index] = powerEntryClone; } // Call this after all database info has loaded, such as at the end of LoadEnhancementDb() public static void TestNewCode() { TestIsKindaSortaEqual(); TestEnhancementListing(); TestGetEnhancementTypes(); AIToon toon = TestCreateBuild(); AIToon toon2 = TestCreateBuild2(); 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); TestToonGetRuleOfFiveCount(toon2); TestToonCanAddEnhancement(toon); TestGetHighestValidSet(toon2); TestToonEvolve(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!"); } 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 AIToon TestCreateBuild() { 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(1, toon.Fitness.Powers[1]); // Health toon.Stamina = new PowerEntry(1, toon.Fitness.Powers[3]); // Stamina toon.Level1Primary = new PowerEntry(1, toon.Primary.Powers[0]); // Flares toon.Level1Secondary = new PowerEntry(1, toon.Secondary.Powers[0]); // Subdual toon.Level2 = new PowerEntry(2, toon.Primary.Powers[2]); // Fire Ball toon.Level4 = new PowerEntry(4, toon.Pool1.Powers[1]); // Hasten toon.Level6 = new PowerEntry(6, toon.Primary.Powers[3]); // Rain of Fire toon.Level8 = new PowerEntry(8, toon.Pool2.Powers[1]); // Kick toon.Level10 = new PowerEntry(10, toon.Pool3.Powers[1]); // Grant Invisibility toon.Level12 = new PowerEntry(12, toon.Primary.Powers[5]); // Aim toon.Level14 = new PowerEntry(14, toon.Secondary.Powers[3]); // Psychic Scream toon.Level16 = new PowerEntry(16, toon.Secondary.Powers[4]); // Concentration toon.Level18 = new PowerEntry(18, toon.Primary.Powers[6]); // Blaze toon.Level20 = new PowerEntry(20, toon.Pool3.Powers[2]); // Invisibility toon.Level22 = new PowerEntry(22, toon.Pool2.Powers[3]); // Tough toon.Level24 = new PowerEntry(24, toon.Pool2.Powers[4]); // Weave toon.Level26 = new PowerEntry(26, toon.Primary.Powers[7]); // Blazing Bolt toon.Level28 = new PowerEntry(28, toon.Pool4.Powers[1]); // Weaken Resolve toon.Level30 = new PowerEntry(30, toon.Pool1.Powers[2]); // Super Speed toon.Level32 = new PowerEntry(32, toon.Primary.Powers[8]); // Inferno toon.Level35 = new PowerEntry(35, toon.Epic.Powers[0]); // Personal Force Field toon.Level38 = new PowerEntry(38, toon.Secondary.Powers[8]); // Psychic Shockwave toon.Level41 = new PowerEntry(41, toon.Epic.Powers[3]); // Temp Invulnerability toon.Level44 = new PowerEntry(44, toon.Epic.Powers[4]); // Force of Nature toon.Level47 = new PowerEntry(47, toon.Epic.Powers[1]); // Repulsion Field toon.Level49 = new PowerEntry(49, 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!"); toon.Stamina.AddSlot(3); toon.Stamina.AddSlot(3); toon.Stamina.AddSlot(5); toon.Health.AddSlot(5); toon.Level1Primary.AddSlot(11); toon.Level1Primary.AddSlot(11); toon.Level1Primary.AddSlot(21); toon.Level1Primary.AddSlot(36); toon.Level2.AddSlot(7); toon.Level2.AddSlot(7); toon.Level2.AddSlot(17); toon.Level2.AddSlot(36); toon.Level2.AddSlot(50); toon.Level4.AddSlot(13); toon.Level6.AddSlot(9); toon.Level6.AddSlot(9); toon.Level6.AddSlot(21); toon.Level6.AddSlot(37); toon.Level6.AddSlot(50); toon.Level12.AddSlot(13); toon.Level14.AddSlot(15); toon.Level14.AddSlot(15); toon.Level14.AddSlot(23); toon.Level14.AddSlot(37); toon.Level16.AddSlot(17); toon.Level18.AddSlot(19); toon.Level18.AddSlot(19); toon.Level18.AddSlot(23); toon.Level18.AddSlot(37); toon.Level20.AddSlot(31); toon.Level20.AddSlot(31); toon.Level20.AddSlot(31); toon.Level22.AddSlot(34); toon.Level22.AddSlot(34); toon.Level22.AddSlot(36); toon.Level22.AddSlot(45); toon.Level22.AddSlot(45); toon.Level24.AddSlot(25); toon.Level24.AddSlot(25); toon.Level24.AddSlot(29); toon.Level24.AddSlot(43); toon.Level26.AddSlot(27); toon.Level26.AddSlot(27); toon.Level26.AddSlot(29); toon.Level26.AddSlot(40); toon.Level28.AddSlot(40); toon.Level28.AddSlot(43); toon.Level32.AddSlot(33); toon.Level32.AddSlot(33); toon.Level32.AddSlot(33); toon.Level32.AddSlot(34); toon.Level38.AddSlot(39); toon.Level38.AddSlot(39); toon.Level38.AddSlot(39); toon.Level38.AddSlot(40); toon.Level41.AddSlot(42); toon.Level41.AddSlot(42); toon.Level41.AddSlot(42); toon.Level41.AddSlot(43); toon.Level41.AddSlot(45); toon.Level44.AddSlot(46); toon.Level44.AddSlot(46); toon.Level44.AddSlot(46); toon.Level44.AddSlot(48); toon.Level47.AddSlot(48); toon.Level47.AddSlot(48); toon.Level49.AddSlot(50); Debug.Assert(toon.Stamina.Slots.Length == 4, "toon.Stamina.Slots.Length is incorrect!"); Debug.Assert(toon.Health.Slots.Length == 2, "toon.Health.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!"); string acc = GetLoadString(GetEnhancementByIndex(26)); string dam = GetLoadString(GetEnhancementByIndex(29)); string def = GetLoadString(GetEnhancementByIndex(30)); string endMod = GetLoadString(GetEnhancementByIndex(32)); string endRed = GetLoadString(GetEnhancementByIndex(33)); string heal = GetLoadString(GetEnhancementByIndex(36)); string rech = GetLoadString(GetEnhancementByIndex(43)); string res = GetLoadString(GetEnhancementByIndex(44)); toon.Stamina.Slots[0].LoadFromString(endMod, ":"); toon.Stamina.Slots[1].LoadFromString(endMod, ":"); toon.Stamina.Slots[2].LoadFromString(endMod, ":"); toon.Health.Slots[0].LoadFromString(heal, ":"); toon.Health.Slots[1].LoadFromString(heal, ":"); 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, ":"); toon.Level1Secondary.Slots[0].LoadFromString(acc, ":"); 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, ":"); toon.Level4.Slots[0].LoadFromString(rech, ":"); toon.Level4.Slots[1].LoadFromString(rech, ":"); toon.Level6.Slots[0].LoadFromString(acc, ":"); toon.Level6.Slots[1].LoadFromString(dam, ":"); toon.Level6.Slots[2].LoadFromString(dam, ":"); toon.Level6.Slots[3].LoadFromString(dam, ":"); toon.Level6.Slots[4].LoadFromString(rech, ":"); toon.Level6.Slots[5].LoadFromString(rech, ":"); toon.Level8.Slots[0].LoadFromString(acc, ":"); toon.Level10.Slots[0].LoadFromString(def, ":"); toon.Level12.Slots[0].LoadFromString(rech, ":"); toon.Level12.Slots[1].LoadFromString(rech, ":"); toon.Level14.Slots[0].LoadFromString(acc, ":"); toon.Level14.Slots[1].LoadFromString(dam, ":"); toon.Level14.Slots[2].LoadFromString(dam, ":"); toon.Level14.Slots[3].LoadFromString(dam, ":"); toon.Level14.Slots[4].LoadFromString(rech, ":"); toon.Level16.Slots[0].LoadFromString(rech, ":"); toon.Level16.Slots[1].LoadFromString(rech, ":"); toon.Level18.Slots[0].LoadFromString(acc, ":"); toon.Level18.Slots[1].LoadFromString(dam, ":"); toon.Level18.Slots[2].LoadFromString(dam, ":"); toon.Level18.Slots[3].LoadFromString(dam, ":"); toon.Level18.Slots[4].LoadFromString(rech, ":"); toon.Level20.Slots[0].LoadFromString(endRed, ":"); toon.Level20.Slots[1].LoadFromString(def, ":"); toon.Level20.Slots[2].LoadFromString(def, ":"); toon.Level20.Slots[3].LoadFromString(def, ":"); toon.Level22.Slots[0].LoadFromString(endRed, ":"); toon.Level22.Slots[1].LoadFromString(endRed, ":"); toon.Level22.Slots[2].LoadFromString(res, ":"); toon.Level22.Slots[3].LoadFromString(res, ":"); toon.Level22.Slots[4].LoadFromString(res, ":"); toon.Level22.Slots[5].LoadFromString(rech, ":"); toon.Level24.Slots[0].LoadFromString(endRed, ":"); toon.Level24.Slots[1].LoadFromString(endRed, ":"); toon.Level24.Slots[2].LoadFromString(def, ":"); toon.Level24.Slots[3].LoadFromString(def, ":"); toon.Level24.Slots[4].LoadFromString(def, ":"); toon.Level26.Slots[0].LoadFromString(acc, ":"); toon.Level26.Slots[1].LoadFromString(dam, ":"); toon.Level26.Slots[2].LoadFromString(dam, ":"); toon.Level26.Slots[3].LoadFromString(dam, ":"); toon.Level26.Slots[4].LoadFromString(rech, ":"); toon.Level28.Slots[0].LoadFromString(acc, ":"); toon.Level28.Slots[1].LoadFromString(rech, ":"); toon.Level28.Slots[2].LoadFromString(rech, ":"); toon.Level30.Slots[0].LoadFromString(endRed, ":"); toon.Level32.Slots[0].LoadFromString(acc, ":"); toon.Level32.Slots[1].LoadFromString(dam, ":"); toon.Level32.Slots[2].LoadFromString(dam, ":"); toon.Level32.Slots[3].LoadFromString(dam, ":"); toon.Level32.Slots[4].LoadFromString(rech, ":"); toon.Level35.Slots[0].LoadFromString(rech, ":"); toon.Level38.Slots[0].LoadFromString(acc, ":"); toon.Level38.Slots[1].LoadFromString(dam, ":"); toon.Level38.Slots[2].LoadFromString(dam, ":"); toon.Level38.Slots[3].LoadFromString(dam, ":"); toon.Level38.Slots[4].LoadFromString(rech, ":"); toon.Level41.Slots[0].LoadFromString(res, ":"); toon.Level41.Slots[1].LoadFromString(res, ":"); toon.Level41.Slots[2].LoadFromString(res, ":"); toon.Level41.Slots[3].LoadFromString(endRed, ":"); toon.Level41.Slots[4].LoadFromString(endRed, ":"); toon.Level41.Slots[5].LoadFromString(endRed, ":"); toon.Level44.Slots[0].LoadFromString(res, ":"); toon.Level44.Slots[1].LoadFromString(res, ":"); toon.Level44.Slots[2].LoadFromString(res, ":"); toon.Level44.Slots[3].LoadFromString(rech, ":"); toon.Level44.Slots[4].LoadFromString(rech, ":"); toon.Level47.Slots[0].LoadFromString(endRed, ":"); toon.Level47.Slots[1].LoadFromString(endRed, ":"); toon.Level47.Slots[2].LoadFromString(endRed, ":"); toon.Level49.Slots[0].LoadFromString(rech, ":"); toon.Level49.Slots[1].LoadFromString(rech, ":"); Debug.Assert(toon.Stamina.Slots[0].Enhancement.Enh == 32, "toon.Stamina.Slots[0].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Stamina.Slots[1].Enhancement.Enh == 32, "toon.Stamina.Slots[1].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Stamina.Slots[2].Enhancement.Enh == 32, "toon.Stamina.Slots[2].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Health.Slots[0].Enhancement.Enh == 36, "toon.Health.Slots[0].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Health.Slots[1].Enhancement.Enh == 36, "toon.Health.Slots[1].Enhancement.Enh is incorrect!"); 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!"); Debug.Assert(toon.Level1Secondary.Slots[0].Enhancement.Enh == 26, "toon.Level1Secondary.Slots[0].Enhancement.Enh is incorrect!"); 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!"); Debug.Assert(toon.Level4.Slots[0].Enhancement.Enh == 43, "toon.Level4.Slots[0].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level4.Slots[1].Enhancement.Enh == 43, "toon.Level4.Slots[1].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level6.Slots[0].Enhancement.Enh == 26, "toon.Level6.Slots[0].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level6.Slots[1].Enhancement.Enh == 29, "toon.Level6.Slots[1].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level6.Slots[2].Enhancement.Enh == 29, "toon.Level6.Slots[2].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level6.Slots[3].Enhancement.Enh == 29, "toon.Level6.Slots[3].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level6.Slots[4].Enhancement.Enh == 43, "toon.Level6.Slots[4].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level6.Slots[5].Enhancement.Enh == 43, "toon.Level6.Slots[5].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level8.Slots[0].Enhancement.Enh == 26, "toon.Level8.Slots[0].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level10.Slots[0].Enhancement.Enh == 30, "toon.Level10.Slots[0].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level12.Slots[0].Enhancement.Enh == 43, "toon.Level12.Slots[0].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level12.Slots[1].Enhancement.Enh == 43, "toon.Level12.Slots[1].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level14.Slots[0].Enhancement.Enh == 26, "toon.Level14.Slots[0].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level14.Slots[1].Enhancement.Enh == 29, "toon.Level14.Slots[1].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level14.Slots[2].Enhancement.Enh == 29, "toon.Level14.Slots[2].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level14.Slots[3].Enhancement.Enh == 29, "toon.Level14.Slots[3].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level14.Slots[4].Enhancement.Enh == 43, "toon.Level14.Slots[4].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level16.Slots[0].Enhancement.Enh == 43, "toon.Level16.Slots[0].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level16.Slots[1].Enhancement.Enh == 43, "toon.Level16.Slots[1].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level18.Slots[0].Enhancement.Enh == 26, "toon.Level18.Slots[0].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level18.Slots[1].Enhancement.Enh == 29, "toon.Level18.Slots[1].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level18.Slots[2].Enhancement.Enh == 29, "toon.Level18.Slots[2].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level18.Slots[3].Enhancement.Enh == 29, "toon.Level18.Slots[3].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level18.Slots[4].Enhancement.Enh == 43, "toon.Level18.Slots[4].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level20.Slots[0].Enhancement.Enh == 33, "toon.Level20.Slots[0].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level20.Slots[1].Enhancement.Enh == 30, "toon.Level20.Slots[1].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level20.Slots[2].Enhancement.Enh == 30, "toon.Level20.Slots[2].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level20.Slots[3].Enhancement.Enh == 30, "toon.Level20.Slots[3].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level22.Slots[0].Enhancement.Enh == 33, "toon.Level22.Slots[0].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level22.Slots[1].Enhancement.Enh == 33, "toon.Level22.Slots[1].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level22.Slots[2].Enhancement.Enh == 44, "toon.Level22.Slots[2].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level22.Slots[3].Enhancement.Enh == 44, "toon.Level22.Slots[3].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level22.Slots[4].Enhancement.Enh == 44, "toon.Level22.Slots[4].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level22.Slots[5].Enhancement.Enh == 43, "toon.Level22.Slots[5].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level24.Slots[0].Enhancement.Enh == 33, "toon.Level24.Slots[0].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level24.Slots[1].Enhancement.Enh == 33, "toon.Level24.Slots[1].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level24.Slots[2].Enhancement.Enh == 30, "toon.Level24.Slots[2].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level24.Slots[3].Enhancement.Enh == 30, "toon.Level24.Slots[3].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level24.Slots[4].Enhancement.Enh == 30, "toon.Level24.Slots[4].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level26.Slots[0].Enhancement.Enh == 26, "toon.Level26.Slots[0].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level26.Slots[1].Enhancement.Enh == 29, "toon.Level26.Slots[1].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level26.Slots[2].Enhancement.Enh == 29, "toon.Level26.Slots[2].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level26.Slots[3].Enhancement.Enh == 29, "toon.Level26.Slots[3].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level26.Slots[4].Enhancement.Enh == 43, "toon.Level26.Slots[4].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level28.Slots[0].Enhancement.Enh == 26, "toon.Level28.Slots[0].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level28.Slots[1].Enhancement.Enh == 43, "toon.Level28.Slots[1].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level28.Slots[2].Enhancement.Enh == 43, "toon.Level28.Slots[2].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level30.Slots[0].Enhancement.Enh == 33, "toon.Level30.Slots[0].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level32.Slots[0].Enhancement.Enh == 26, "toon.Level32.Slots[0].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level32.Slots[1].Enhancement.Enh == 29, "toon.Level32.Slots[1].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level32.Slots[2].Enhancement.Enh == 29, "toon.Level32.Slots[2].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level32.Slots[3].Enhancement.Enh == 29, "toon.Level32.Slots[3].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level32.Slots[4].Enhancement.Enh == 43, "toon.Level32.Slots[4].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level35.Slots[0].Enhancement.Enh == 43, "toon.Level35.Slots[0].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level38.Slots[0].Enhancement.Enh == 26, "toon.Level38.Slots[0].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level38.Slots[1].Enhancement.Enh == 29, "toon.Level38.Slots[1].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level38.Slots[2].Enhancement.Enh == 29, "toon.Level38.Slots[2].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level38.Slots[3].Enhancement.Enh == 29, "toon.Level38.Slots[3].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level38.Slots[4].Enhancement.Enh == 43, "toon.Level38.Slots[4].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level41.Slots[0].Enhancement.Enh == 44, "toon.Level41.Slots[0].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level41.Slots[1].Enhancement.Enh == 44, "toon.Level41.Slots[1].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level41.Slots[2].Enhancement.Enh == 44, "toon.Level41.Slots[2].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level41.Slots[3].Enhancement.Enh == 33, "toon.Level41.Slots[3].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level41.Slots[4].Enhancement.Enh == 33, "toon.Level41.Slots[4].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level41.Slots[5].Enhancement.Enh == 33, "toon.Level41.Slots[5].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level44.Slots[0].Enhancement.Enh == 44, "toon.Level44.Slots[0].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level44.Slots[1].Enhancement.Enh == 44, "toon.Level44.Slots[1].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level44.Slots[2].Enhancement.Enh == 44, "toon.Level44.Slots[2].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level44.Slots[3].Enhancement.Enh == 43, "toon.Level44.Slots[3].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level44.Slots[4].Enhancement.Enh == 43, "toon.Level44.Slots[4].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level47.Slots[0].Enhancement.Enh == 33, "toon.Level47.Slots[0].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level47.Slots[1].Enhancement.Enh == 33, "toon.Level47.Slots[1].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level47.Slots[2].Enhancement.Enh == 33, "toon.Level47.Slots[2].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level49.Slots[0].Enhancement.Enh == 43, "toon.Level49.Slots[0].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level49.Slots[1].Enhancement.Enh == 43, "toon.Level49.Slots[1].Enhancement.Enh is incorrect!"); return toon; } public static AIToon TestCreateBuild2() { 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(1, toon.Fitness.Powers[1]); // Health toon.Stamina = new PowerEntry(1, toon.Fitness.Powers[3]); // Stamina toon.Level1Primary = new PowerEntry(1, toon.Primary.Powers[0]); // Mesmerize toon.Level1Secondary = new PowerEntry(1, toon.Secondary.Powers[0]); // Personal Force Field toon.Level2 = new PowerEntry(2, toon.Secondary.Powers[1]); // Deflection Shield toon.Level4 = new PowerEntry(4, toon.Primary.Powers[1]); // Levitate toon.Level6 = new PowerEntry(6, toon.Primary.Powers[2]); // Dominate toon.Level8 = new PowerEntry(8, toon.Primary.Powers[3]); // Confuse toon.Level10 = new PowerEntry(10, toon.Pool2.Powers[0]); // Stealth toon.Level12 = new PowerEntry(12, toon.Pool2.Powers[1]); // Grant Invisibility toon.Level14 = new PowerEntry(14, toon.Secondary.Powers[3]); // Insulation Shield toon.Level16 = new PowerEntry(16, toon.Pool2.Powers[2]); // Invisibility toon.Level18 = new PowerEntry(18, toon.Primary.Powers[4]); // Mass Hypnosis toon.Level20 = new PowerEntry(20, toon.Primary.Powers[5]); // Telekinesis toon.Level22 = new PowerEntry(22, toon.Secondary.Powers[5]); // Dispersion Bubble toon.Level24 = new PowerEntry(24, toon.Primary.Powers[6]); // Total Domination toon.Level26 = new PowerEntry(26, toon.Primary.Powers[7]); // Terrify toon.Level28 = new PowerEntry(28, toon.Pool3.Powers[0]); // Boxing toon.Level30 = new PowerEntry(30, toon.Pool3.Powers[3]); // Tough toon.Level32 = new PowerEntry(32, toon.Pool3.Powers[4]); // Weave toon.Level35 = new PowerEntry(35, toon.Primary.Powers[8]); // Mass Confusion toon.Level38 = new PowerEntry(38, toon.Secondary.Powers[8]); // Force Bubble toon.Level41 = new PowerEntry(41, toon.Secondary.Powers[7]); // Repulsion Bomb toon.Level44 = new PowerEntry(44, toon.Secondary.Powers[2]); // Force Bolt toon.Level47 = new PowerEntry(47, toon.Secondary.Powers[6]); // Repulsion Field toon.Level49 = new PowerEntry(49, 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!"); toon.Stamina.AddSlot(3); toon.Stamina.AddSlot(3); toon.Health.AddSlot(5); toon.Health.AddSlot(5); toon.Level1Primary.AddSlot(19); toon.Level1Primary.AddSlot(21); toon.Level1Primary.AddSlot(21); toon.Level1Primary.AddSlot(25); toon.Level1Primary.AddSlot(25); toon.Level1Secondary.AddSlot(3); toon.Level1Secondary.AddSlot(17); toon.Level1Secondary.AddSlot(27); toon.Level1Secondary.AddSlot(27); toon.Level1Secondary.AddSlot(29); toon.Level2.AddSlot(3); toon.Level2.AddSlot(15); toon.Level2.AddSlot(29); toon.Level2.AddSlot(31); toon.Level2.AddSlot(31); toon.Level4.AddSlot(9); toon.Level4.AddSlot(9); toon.Level4.AddSlot(31); toon.Level4.AddSlot(33); toon.Level4.AddSlot(34); toon.Level6.AddSlot(34); toon.Level6.AddSlot(34); toon.Level6.AddSlot(36); toon.Level6.AddSlot(36); toon.Level6.AddSlot(36); toon.Level8.AddSlot(37); toon.Level8.AddSlot(37); toon.Level8.AddSlot(37); toon.Level8.AddSlot(39); toon.Level8.AddSlot(39); toon.Level10.AddSlot(11); toon.Level10.AddSlot(11); toon.Level10.AddSlot(39); toon.Level10.AddSlot(40); toon.Level10.AddSlot(40); toon.Level12.AddSlot(13); toon.Level12.AddSlot(13); toon.Level12.AddSlot(40); toon.Level12.AddSlot(42); toon.Level12.AddSlot(42); toon.Level14.AddSlot(15); toon.Level14.AddSlot(19); toon.Level14.AddSlot(42); toon.Level14.AddSlot(43); toon.Level14.AddSlot(43); toon.Level16.AddSlot(17); toon.Level16.AddSlot(43); toon.Level16.AddSlot(45); toon.Level16.AddSlot(45); toon.Level16.AddSlot(45); toon.Level18.AddSlot(46); toon.Level18.AddSlot(46); toon.Level18.AddSlot(46); toon.Level18.AddSlot(48); toon.Level18.AddSlot(48); toon.Level20.AddSlot(48); toon.Level20.AddSlot(50); toon.Level20.AddSlot(50); toon.Level20.AddSlot(50); toon.Level22.AddSlot(23); toon.Level22.AddSlot(23); toon.Level22.AddSlot(23); toon.Level22.AddSlot(33); 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!"); string acc = GetLoadString(GetEnhancementByIndex(26)); string dam = GetLoadString(GetEnhancementByIndex(29)); string def = GetLoadString(GetEnhancementByIndex(30)); string endMod = GetLoadString(GetEnhancementByIndex(32)); string endRed = GetLoadString(GetEnhancementByIndex(33)); string heal = GetLoadString(GetEnhancementByIndex(36)); string rech = GetLoadString(GetEnhancementByIndex(43)); string res = GetLoadString(GetEnhancementByIndex(44)); toon.Stamina.Slots[0].LoadFromString(endMod, ":"); toon.Stamina.Slots[1].LoadFromString(endMod, ":"); toon.Stamina.Slots[2].LoadFromString(endMod, ":"); toon.Health.Slots[0].LoadFromString(heal, ":"); toon.Health.Slots[1].LoadFromString(heal, ":"); toon.Health.Slots[2].LoadFromString(heal, ":"); 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, ":"); toon.Level1Primary.Slots[5].LoadFromString(rech, ":"); toon.Level1Secondary.Slots[0].LoadFromString(def, ":"); toon.Level1Secondary.Slots[1].LoadFromString(def, ":"); toon.Level1Secondary.Slots[2].LoadFromString(def, ":"); toon.Level1Secondary.Slots[3].LoadFromString(rech, ":"); toon.Level1Secondary.Slots[4].LoadFromString(rech, ":"); toon.Level1Secondary.Slots[5].LoadFromString(rech, ":"); toon.Level2.Slots[0].LoadFromString(def, ":"); toon.Level2.Slots[1].LoadFromString(def, ":"); toon.Level2.Slots[2].LoadFromString(def, ":"); toon.Level2.Slots[3].LoadFromString(endRed, ":"); toon.Level2.Slots[4].LoadFromString(endRed, ":"); toon.Level2.Slots[5].LoadFromString(endRed, ":"); toon.Level4.Slots[0].LoadFromString(acc, ":"); toon.Level4.Slots[1].LoadFromString(dam, ":"); toon.Level4.Slots[2].LoadFromString(dam, ":"); toon.Level4.Slots[3].LoadFromString(dam, ":"); toon.Level4.Slots[4].LoadFromString(rech, ":"); toon.Level4.Slots[5].LoadFromString(rech, ":"); toon.Level6.Slots[0].LoadFromString(acc, ":"); toon.Level6.Slots[1].LoadFromString(dam, ":"); toon.Level6.Slots[2].LoadFromString(dam, ":"); toon.Level6.Slots[3].LoadFromString(dam, ":"); toon.Level6.Slots[4].LoadFromString(rech, ":"); toon.Level6.Slots[5].LoadFromString(rech, ":"); toon.Level8.Slots[0].LoadFromString(acc, ":"); toon.Level8.Slots[1].LoadFromString(acc, ":"); toon.Level8.Slots[2].LoadFromString(acc, ":"); toon.Level8.Slots[3].LoadFromString(rech, ":"); toon.Level8.Slots[4].LoadFromString(rech, ":"); toon.Level8.Slots[5].LoadFromString(rech, ":"); toon.Level10.Slots[0].LoadFromString(def, ":"); toon.Level10.Slots[1].LoadFromString(def, ":"); toon.Level10.Slots[2].LoadFromString(def, ":"); toon.Level10.Slots[3].LoadFromString(endRed, ":"); toon.Level10.Slots[4].LoadFromString(endRed, ":"); toon.Level10.Slots[5].LoadFromString(endRed, ":"); toon.Level12.Slots[0].LoadFromString(def, ":"); toon.Level12.Slots[1].LoadFromString(def, ":"); toon.Level12.Slots[2].LoadFromString(def, ":"); toon.Level12.Slots[3].LoadFromString(endRed, ":"); toon.Level12.Slots[4].LoadFromString(endRed, ":"); toon.Level12.Slots[5].LoadFromString(endRed, ":"); toon.Level14.Slots[0].LoadFromString(def, ":"); toon.Level14.Slots[1].LoadFromString(def, ":"); toon.Level14.Slots[2].LoadFromString(def, ":"); toon.Level14.Slots[3].LoadFromString(endRed, ":"); toon.Level14.Slots[4].LoadFromString(endRed, ":"); toon.Level14.Slots[5].LoadFromString(endRed, ":"); toon.Level16.Slots[0].LoadFromString(def, ":"); toon.Level16.Slots[1].LoadFromString(def, ":"); toon.Level16.Slots[2].LoadFromString(def, ":"); toon.Level16.Slots[3].LoadFromString(endRed, ":"); toon.Level16.Slots[4].LoadFromString(endRed, ":"); toon.Level16.Slots[5].LoadFromString(endRed, ":"); toon.Level18.Slots[0].LoadFromString(acc, ":"); toon.Level18.Slots[1].LoadFromString(rech, ":"); toon.Level18.Slots[2].LoadFromString(rech, ":"); toon.Level18.Slots[3].LoadFromString(rech, ":"); toon.Level18.Slots[4].LoadFromString(endRed, ":"); toon.Level18.Slots[5].LoadFromString(endRed, ":"); toon.Level20.Slots[0].LoadFromString(endRed, ":"); toon.Level20.Slots[1].LoadFromString(endRed, ":"); toon.Level20.Slots[2].LoadFromString(endRed, ":"); toon.Level20.Slots[3].LoadFromString(rech, ":"); toon.Level20.Slots[4].LoadFromString(rech, ":"); toon.Level22.Slots[0].LoadFromString(endRed, ":"); toon.Level22.Slots[1].LoadFromString(endRed, ":"); toon.Level22.Slots[2].LoadFromString(def, ":"); toon.Level22.Slots[3].LoadFromString(def, ":"); toon.Level22.Slots[4].LoadFromString(def, ":"); toon.Level24.Slots[0].LoadFromString(acc, ":"); toon.Level26.Slots[0].LoadFromString(acc, ":"); toon.Level26.Slots[0].LoadFromString(acc, ":"); toon.Level28.Slots[0].LoadFromString(acc, ":"); toon.Level30.Slots[0].LoadFromString(endRed, ":"); toon.Level32.Slots[0].LoadFromString(endRed, ":"); toon.Level35.Slots[0].LoadFromString(acc, ":"); toon.Level38.Slots[0].LoadFromString(endRed, ":"); toon.Level41.Slots[0].LoadFromString(acc, ":"); toon.Level44.Slots[0].LoadFromString(acc, ":"); toon.Level47.Slots[0].LoadFromString(endRed, ":"); toon.Level49.Slots[0].LoadFromString(acc, ":"); Debug.Assert(toon.Stamina.Slots[0].Enhancement.Enh == 32, "toon.Stamina.Slots[0].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Stamina.Slots[1].Enhancement.Enh == 32, "toon.Stamina.Slots[1].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Stamina.Slots[2].Enhancement.Enh == 32, "toon.Stamina.Slots[2].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Health.Slots[0].Enhancement.Enh == 36, "toon.Health.Slots[0].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Health.Slots[1].Enhancement.Enh == 36, "toon.Health.Slots[1].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Health.Slots[2].Enhancement.Enh == 36, "toon.Health.Slots[2].Enhancement.Enh is incorrect!"); 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!"); Debug.Assert(toon.Level1Primary.Slots[5].Enhancement.Enh == 43, "toon.Level1Primary.Slots[5].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level1Secondary.Slots[0].Enhancement.Enh == 30, "toon.Level1Secondary.Slots[0].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level1Secondary.Slots[1].Enhancement.Enh == 30, "toon.Level1Secondary.Slots[1].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level1Secondary.Slots[2].Enhancement.Enh == 30, "toon.Level1Secondary.Slots[2].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level1Secondary.Slots[3].Enhancement.Enh == 43, "toon.Level1Secondary.Slots[3].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level1Secondary.Slots[4].Enhancement.Enh == 43, "toon.Level1Secondary.Slots[4].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level1Secondary.Slots[5].Enhancement.Enh == 43, "toon.Level1Secondary.Slots[5].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level2.Slots[0].Enhancement.Enh == 30, "toon.Level2.Slots[0].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level2.Slots[1].Enhancement.Enh == 30, "toon.Level2.Slots[1].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level2.Slots[2].Enhancement.Enh == 30, "toon.Level2.Slots[2].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level2.Slots[3].Enhancement.Enh == 33, "toon.Level2.Slots[3].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level2.Slots[4].Enhancement.Enh == 33, "toon.Level2.Slots[4].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level2.Slots[5].Enhancement.Enh == 33, "toon.Level2.Slots[5].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level4.Slots[0].Enhancement.Enh == 26, "toon.Level4.Slots[0].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level4.Slots[1].Enhancement.Enh == 29, "toon.Level4.Slots[1].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level4.Slots[2].Enhancement.Enh == 29, "toon.Level4.Slots[2].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level4.Slots[3].Enhancement.Enh == 29, "toon.Level4.Slots[3].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level4.Slots[4].Enhancement.Enh == 43, "toon.Level4.Slots[4].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level4.Slots[5].Enhancement.Enh == 43, "toon.Level4.Slots[5].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level6.Slots[0].Enhancement.Enh == 26, "toon.Level6.Slots[0].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level6.Slots[1].Enhancement.Enh == 29, "toon.Level6.Slots[1].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level6.Slots[2].Enhancement.Enh == 29, "toon.Level6.Slots[2].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level6.Slots[3].Enhancement.Enh == 29, "toon.Level6.Slots[3].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level6.Slots[4].Enhancement.Enh == 43, "toon.Level6.Slots[4].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level6.Slots[5].Enhancement.Enh == 43, "toon.Level6.Slots[5].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level8.Slots[0].Enhancement.Enh == 26, "toon.Level8.Slots[0].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level8.Slots[1].Enhancement.Enh == 26, "toon.Level8.Slots[1].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level8.Slots[2].Enhancement.Enh == 26, "toon.Level8.Slots[2].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level8.Slots[3].Enhancement.Enh == 43, "toon.Level8.Slots[3].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level8.Slots[4].Enhancement.Enh == 43, "toon.Level8.Slots[4].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level8.Slots[5].Enhancement.Enh == 43 , "toon.Level8.Slots[5].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level10.Slots[0].Enhancement.Enh == 30, "toon.Level10.Slots[0].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level10.Slots[1].Enhancement.Enh == 30, "toon.Level10.Slots[1].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level10.Slots[2].Enhancement.Enh == 30, "toon.Level10.Slots[2].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level10.Slots[3].Enhancement.Enh == 33, "toon.Level10.Slots[3].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level10.Slots[4].Enhancement.Enh == 33, "toon.Level10.Slots[4].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level10.Slots[5].Enhancement.Enh == 33, "toon.Level10.Slots[5].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level12.Slots[0].Enhancement.Enh == 30, "toon.Level12.Slots[0].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level12.Slots[1].Enhancement.Enh == 30, "toon.Level12.Slots[1].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level12.Slots[2].Enhancement.Enh == 30, "toon.Level12.Slots[2].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level12.Slots[3].Enhancement.Enh == 33, "toon.Level12.Slots[3].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level12.Slots[4].Enhancement.Enh == 33, "toon.Level12.Slots[4].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level12.Slots[5].Enhancement.Enh == 33, "toon.Level12.Slots[5].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level14.Slots[0].Enhancement.Enh == 30, "toon.Level14.Slots[0].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level14.Slots[1].Enhancement.Enh == 30, "toon.Level14.Slots[1].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level14.Slots[2].Enhancement.Enh == 30, "toon.Level14.Slots[2].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level14.Slots[3].Enhancement.Enh == 33, "toon.Level14.Slots[3].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level14.Slots[4].Enhancement.Enh == 33, "toon.Level14.Slots[4].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level14.Slots[5].Enhancement.Enh == 33, "toon.Level14.Slots[5].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level16.Slots[0].Enhancement.Enh == 30, "toon.Level16.Slots[0].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level16.Slots[1].Enhancement.Enh == 30, "toon.Level16.Slots[1].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level16.Slots[2].Enhancement.Enh == 30, "toon.Level16.Slots[2].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level16.Slots[3].Enhancement.Enh == 33, "toon.Level16.Slots[3].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level16.Slots[4].Enhancement.Enh == 33, "toon.Level16.Slots[4].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level16.Slots[5].Enhancement.Enh == 33, "toon.Level16.Slots[5].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level18.Slots[0].Enhancement.Enh == 26, "toon.Level18.Slots[0].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level18.Slots[1].Enhancement.Enh == 43, "toon.Level18.Slots[1].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level18.Slots[2].Enhancement.Enh == 43, "toon.Level18.Slots[2].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level18.Slots[3].Enhancement.Enh == 43, "toon.Level18.Slots[3].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level18.Slots[4].Enhancement.Enh == 33, "toon.Level18.Slots[4].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level18.Slots[5].Enhancement.Enh == 33, "toon.Level18.Slots[5].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level20.Slots[0].Enhancement.Enh == 33, "toon.Level20.Slots[0].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level20.Slots[1].Enhancement.Enh == 33, "toon.Level20.Slots[1].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level20.Slots[2].Enhancement.Enh == 33, "toon.Level20.Slots[2].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level20.Slots[3].Enhancement.Enh == 43, "toon.Level20.Slots[3].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level20.Slots[4].Enhancement.Enh == 43, "toon.Level20.Slots[4].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level22.Slots[0].Enhancement.Enh == 33, "toon.Level22.Slots[0].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level22.Slots[1].Enhancement.Enh == 33, "toon.Level22.Slots[1].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level22.Slots[2].Enhancement.Enh == 30, "toon.Level22.Slots[2].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level22.Slots[3].Enhancement.Enh == 30, "toon.Level22.Slots[3].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level22.Slots[4].Enhancement.Enh == 30, "toon.Level22.Slots[4].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level24.Slots[0].Enhancement.Enh == 26, "toon.Level24.Slots[0].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level26.Slots[0].Enhancement.Enh == 26, "toon.Level26.Slots[0].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level28.Slots[0].Enhancement.Enh == 26, "toon.Level28.Slots[0].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level30.Slots[0].Enhancement.Enh == 33, "toon.Level30.Slots[0].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level32.Slots[0].Enhancement.Enh == 33, "toon.Level32.Slots[0].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level35.Slots[0].Enhancement.Enh == 26, "toon.Level35.Slots[0].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level38.Slots[0].Enhancement.Enh == 33, "toon.Level38.Slots[0].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level41.Slots[0].Enhancement.Enh == 26, "toon.Level41.Slots[0].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level44.Slots[0].Enhancement.Enh == 26, "toon.Level44.Slots[0].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level47.Slots[0].Enhancement.Enh == 33, "toon.Level47.Slots[0].Enhancement.Enh is incorrect!"); Debug.Assert(toon.Level49.Slots[0].Enhancement.Enh == 26, "toon.Level49.Slots[0].Enhancement.Enh is incorrect!"); 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 == "Recharge 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 TestToonGetRuleOfFiveCount(AIToon toon) { AIToon clone = toon.Clone() as AIToon; EnhancementSet reactiveDefenses = GetEnhancementSetByIndex(GetEnhancementSetIndexByName("Reactive Defenses")); Debug.Assert(clone.GetRuleOfFiveCount(reactiveDefenses, 2) == 0, "GetRuleOfFiveCount 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.GetRuleOfFiveCount(reactiveDefenses, 2) == 1, "GetRuleOfFiveCount 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.GetRuleOfFiveCount(reactiveDefenses, 2) == 2, "GetRuleOfFiveCount 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.GetRuleOfFiveCount(reactiveDefenses, 2) == 3, "GetRuleOfFiveCount 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.GetRuleOfFiveCount(reactiveDefenses, 2) == 4, "GetRuleOfFiveCount 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.GetRuleOfFiveCount(reactiveDefenses, 2) == 5, "GetRuleOfFiveCount 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 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 TestToonEvolve(AIToon toon) { AIToon clone = toon.Clone() as AIToon; clone.Print(); float sumBefore = clone.SumPowerBonuses(Enums.eEffectType.Defense, Enums.eDamage.Smashing); EvolveToon(clone, 100, 10, Enums.eEffectType.Defense, Enums.eDamage.Smashing); float sumAfter = clone.SumPowerBonuses(Enums.eEffectType.Defense, Enums.eDamage.Smashing); clone.Print(); Debug.Print(""); Debug.Print("Toon Smashing Defense Totals: Before: " + sumBefore.ToString() + " After: " + sumAfter.ToString()); Debug.Assert(sumBefore <= sumAfter, "sumAfter is incorrect!"); clone = toon.Clone() as AIToon; clone.Print(); sumBefore = clone.SumPowerBonuses(Enums.eEffectType.Defense, Enums.eDamage.Psionic); EvolveToon(clone, 100, 1, Enums.eEffectType.Defense, Enums.eDamage.Psionic); sumAfter = clone.SumPowerBonuses(Enums.eEffectType.Defense, Enums.eDamage.Psionic); clone.Print(); Debug.Print(""); Debug.Print("Toon Psionic Defense Totals: Before: " + sumBefore.ToString() + " After: " + sumAfter.ToString()); Debug.Assert(sumBefore <= sumAfter, "sumAfter is incorrect!"); clone = toon.Clone() as AIToon; clone.Print(); sumBefore = clone.SumPowerBonuses(Enums.eEffectType.Defense); EvolveToon(clone, 100, 1, Enums.eEffectType.Defense); sumAfter = clone.SumPowerBonuses(Enums.eEffectType.Defense); clone.Print(); Debug.Print(""); Debug.Print("Toon Defense Totals: Before: " + sumBefore.ToString() + " After: " + sumAfter.ToString()); Debug.Assert(sumBefore <= sumAfter, "sumAfter is incorrect!"); } }