public void ReloadData(FormMain main) { dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.None; dataTable.Clear(); DataStoreWDB <DataStoreEquip, DataStoreID> equips = new DataStoreWDB <DataStoreEquip, DataStoreID>(); equips.LoadData(File.ReadAllBytes($"{main.RandoPath}\\original\\db\\resident\\item_weapon.wdb")); Items.items.Where(i => (i.ID.StartsWith("acc") || i.ID.StartsWith("wea")) && i.EquipPassive.Item1.LockingLevel > LockingLevel.Fixed && i.EquipPassive.Item2 == 0).ForEach(i => { List <Item> upgrades = new List <Item>(); for (Item i2 = i; ; i2 = Items.items.Find(i3 => i3.ID == equips[i2].UpgradeInto)) { upgrades.Add(i2); if (equips[i2].UpgradeInto == "") { break; } } List <string> names = Items.items.Where(i2 => i2.EquipPassive != null && i2.EquipPassive.Item1 == i.EquipPassive.Item1 && upgrades.Contains(i2)).OrderBy(i2 => i2.EquipPassive.Item2).Select(i2 => i2.Name).ToList(); AddEntry(i, String.Join("/", names)); }); foreach (DataRow row in dataTable.Rows) { DataStoreEquip equip = equips[row.Field <string>(0)]; Item item = Items.items.Find(i => i.ID == row.Field <string>(0)); row.SetField <string>(2, String.Join("/", item.EquipPassive.Item1.GetPassives().Select(p => p.Name))); } dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; dataGridView1.Refresh(); }
public void ReloadData(FormMain main) { dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.None; dataTable.Clear(); DataStoreWDB <DataStoreEquip, DataStoreID> equips = new DataStoreWDB <DataStoreEquip, DataStoreID>(); equips.LoadData(File.ReadAllBytes($"{main.RandoPath}\\original\\db\\resident\\item_weapon.wdb")); DataStoreWDB <DataStoreItem, DataStoreID> items = new DataStoreWDB <DataStoreItem, DataStoreID>(); items.LoadData(File.ReadAllBytes($"{main.RandoPath}\\original\\db\\resident\\item.wdb")); Items.items.Where(i => i.ID.StartsWith("acc") || i.ID.StartsWith("wea")).ForEach(i => AddEntry(i)); foreach (DataRow row in dataTable.Rows) { DataStoreEquip equip = equips[row.Field <string>(0)]; Item item = Items.items.Find(i => i.ID == row.Field <string>(0)); row.SetField <string>(2, equip.StrengthInitial.ToString() + (equip.StrengthIncrease > 0 ? $" (+{equip.StrengthIncrease}/Lv)" : "")); row.SetField <string>(5, equip.MagicInitial.ToString() + (equip.MagicIncrease > 0 ? $" (+{equip.MagicIncrease}/Lv)" : "")); PassiveSet.Passive passive = item.EquipPassive.Item1.GetPassiveDirect(item.EquipPassive.Item2, Int32.MaxValue); string passiveName = passive.Name; if (passive.StatInitial == -1) { passiveName = passiveName.Replace("X", equip.StatInitial.ToString()); if (equip.StatIncrease > 0) { passiveName += $" (+{equip.StatIncrease}/Lv)"; } } row.SetField <string>(8, passiveName); row.SetField <string>(11, ((SynthesisGroup)items[item].SynthesisGroup).SeparateWords()); row.SetField <string>(13, items[item].Rank.ToString()); } dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; dataGridView1.Refresh(); }
public override void Randomize(BackgroundWorker backgroundWorker) { if (Flags.ItemFlags.EquipmentStatsPassives) { Flags.ItemFlags.EquipmentStatsPassives.SetRand(); Dictionary <Item, PassiveSet> plandoPassives = main.equipPassivesPlando1.GetPassives(); Dictionary <Item, Tuple <int[], int[]> > plandoStats = main.equipPlando1.GetEquipment(); if (plandoPassives.Where(p => p.Value.LockingLevel == LockingLevel.SameType && p.Key.EquipPassive.Item1.Type != p.Value.Type).Count() > 0) { KeyValuePair <Item, PassiveSet> pair = plandoPassives.Where(p => p.Key.EquipPassive.Item1.LockingLevel == LockingLevel.SameType && p.Key.EquipPassive.Item1.Type != p.Value.Type).First(); throw new Exception($"{pair.Value.GetPassives()[0].Name} on {pair.Key.Name} cannot be applied to this type of equipment ({pair.Key.EquipPassive.Item1.Type})"); } Dictionary <PassiveSet, PassiveSet> mappings = GetMappings(plandoPassives); Dictionary <Character, List <PassiveSet> > sets = ((Character[])(Enum.GetValues(typeof(Character)))).ToDictionary(c => c, c => { List <PassiveSet> list = Passives.passives .Where(s => s.Type == PassiveType.Weapon) .Select(s => mappings[s]) .Where(s => s.HasCharacter(Abilities.GetCharID(c.ToString().ToLower())) && s.LockingLevel > LockingLevel.Fixed) .ToList(); list = list.ShuffleWeighted(list.Select(s => s == Passives.None ? 3 : 1).ToList()).ToList(); return(list.Take(Items.items.Where(i => i.ID.StartsWith("wea") && i.EquipPassive.Item1 != Passives.Uncapped && GetCharacter(i.ID) == c && i.EquipPassive.Item1.LockingLevel > LockingLevel.Fixed && i.EquipPassive.Item2 == 0 && !plandoPassives.ContainsKey(i)).Select(i => i.EquipPassive.Item1).Count()).ToList()); }); Dictionary <Item, Tuple <float, float> > weaponMults = GetWeaponMults(plandoPassives, sets.ToDictionary(p => p.Key, p => new List <PassiveSet>(p.Value))); Dictionary <PassiveSet, int> tierCounts = Passives.passives.ToDictionary(s => s, s => Items.items.Where(i => (i.ID.StartsWith("wea") || i.ID.StartsWith("acc")) && i.EquipPassive.Item1 == s).Max(i => i.EquipPassive.Item2) + 1); plandoPassives.Keys.ToList().Where(i => equips[i].UpgradeInto != "").ForEach(i => { for (Item i2 = Items.items.Find(i3 => i3.ID == equips[i].UpgradeInto); ; i2 = Items.items.Find(i3 => i3.ID == equips[i2].UpgradeInto)) { if (i2.EquipPassive.Item1 != i.EquipPassive.Item1) { break; } plandoPassives.Add(i2, plandoPassives[i]); if (equips[i2].UpgradeInto == "") { break; } } }); Items.items.Where(i => i.ID.StartsWith("wea") || i.ID.StartsWith("acc")).ForEach(i => { DataStoreEquip equip = equips[i]; Character curChar = GetCharacter(i.ID); int tier = i.EquipPassive.Item2; PassiveSet initPassiveSet = i.EquipPassive.Item1; PassiveSet finalPassiveSet = i.EquipPassive.Item1; Passive initPassive = i.EquipPassive.Item1.GetPassive(Abilities.GetCharID(curChar.ToString().ToLower()), tier, tierCounts[i.EquipPassive.Item1]); Passive finalPassive = initPassive; if (i.EquipPassive.Item1.LockingLevel > LockingLevel.Fixed) { PassiveSet newSet; if (plandoPassives.ContainsKey(i)) { newSet = plandoPassives[i]; } else { newSet = i.ID.StartsWith("wea") ? sets[curChar][0] : mappings[i.EquipPassive.Item1]; } Passive passive = newSet.GetPassive(Abilities.GetCharID(curChar.ToString().ToLower()), tier, tierCounts[i.EquipPassive.Item1]); finalPassive = passive; finalPassiveSet = newSet; equip.Passive = passive.ID; equip.PassiveDisplayName = passive.PassiveDisplayName; equip.HelpDisplay = passive.PassiveHelp; equip.StatType1 = passive.StatType1; equip.StatType2 = passive.StatType2; equip.StatInitial = passive.StatInitial; } if (i.ID.StartsWith("wea")) { float strMult = (float)Math.Pow(finalPassive.StrengthModifier, 1f / Math.Pow(tier + 1, 1.2f)) * weaponMults[i].Item1; float magMult = (float)Math.Pow(finalPassive.MagicModifier, 1f / Math.Pow(tier + 1, 1.2f)) * weaponMults[i].Item2; float avgInit = ((initPassive.StrengthModifier == 0 ? 0 : equip.StrengthInitial / (float)Math.Pow(initPassive.StrengthModifier, 1f / Math.Pow(tier + 1, 1.2f))) + (initPassive.MagicModifier == 0 ? 0 : equip.MagicInitial / (float)Math.Pow(initPassive.MagicModifier, 1f / Math.Pow(tier + 1, 1.2f)))) / (equip.StrengthInitial == 0 || equip.MagicInitial == 0 || initPassive.StrengthModifier == 0 || initPassive.MagicModifier == 0 ? .75f : 2f); float avgInc = ((initPassive.StrengthModifier == 0 ? 0 : equip.StrengthIncrease / (float)Math.Pow(initPassive.StrengthModifier, 0.75f)) + (initPassive.MagicModifier == 0 ? 0 : equip.MagicIncrease / (float)Math.Pow(initPassive.MagicModifier, 0.75f))) / (equip.StrengthIncrease == 0 || equip.MagicIncrease == 0 || initPassive.StrengthModifier == 0 || initPassive.MagicModifier == 0 ? .75f : 2f); equip.StrengthInitial = (short)(avgInit * strMult); equip.StrengthIncrease = (ushort)(avgInc * Math.Pow(strMult, 0.75f)); equip.MagicInitial = (short)(avgInit * magMult); equip.MagicIncrease = (ushort)(avgInc * Math.Pow(magMult, 0.75f)); if (equips[i].UpgradeInto == "") { if (initPassiveSet.LockingLevel > LockingLevel.Fixed && !plandoPassives.ContainsKey(i)) { sets[curChar].RemoveAt(0); } } } if (plandoStats.ContainsKey(i)) { if (plandoStats[i].Item1[0] != -1) { equip.StrengthInitial = (short)plandoStats[i].Item1[0]; } if (plandoStats[i].Item2[0] != -1) { equip.StrengthIncrease = (ushort)plandoStats[i].Item2[0]; } if (plandoStats[i].Item1[1] != -1) { equip.MagicInitial = (short)plandoStats[i].Item1[1]; } if (plandoStats[i].Item2[1] != -1) { equip.MagicIncrease = (ushort)plandoStats[i].Item2[1]; } if (plandoStats[i].Item1[2] != -1) { equip.StatInitial = (short)plandoStats[i].Item1[2]; } if (plandoStats[i].Item2[2] != -1) { equip.StatIncrease = (ushort)plandoStats[i].Item2[2]; } } }); RandomNum.ClearRand(); } }