private void addRandomMiscItems(long seed) { JavaRng rng = new JavaRng(seed); foreach (var miscItem in miscBools.ToArray()) { int nextRandom = rng.NextInt(4); if (nextRandom == 1) { miscBools[miscItem.Key] = true; updateMiscItem(miscItem.Key); } } }
private void addRandomItem(long seed, Slot slot) { JavaRng rng = new JavaRng(seed); ArrayList slotItems = new ArrayList(); foreach (Item item in allItems) { if (item.Slot == slot && !item.Name.Contains("none_")) { slotItems.Add(item); } } int rndIndex = rng.NextInt(slotItems.Count); Item rndItem = (Item)slotItems[rndIndex]; XmlElement newItem = xml.CreateElement("item"); XmlAttribute newType = xml.CreateAttribute("type"); newType.Value = rndItem.Name; newItem.SetAttributeNode(newType); cadence.AppendChild(newItem); }
//-------------------------Generate random build private void generateBuild(long seed) { JavaRng rng = new JavaRng(seed); // remove all items, add cursed slots cadence.RemoveAll(); addSeedCurse(); // add one random item for each slot addRandomItem(seed, Slot.Shovel); addRandomItem(seed, Slot.Weapon); addRandomItem(seed, Slot.Body); addRandomItem(seed, Slot.Head); addRandomItem(seed, Slot.Feet); addRandomItem(seed, Slot.Torch); addRandomItem(seed, Slot.Ring); addRandomItem(seed, Slot.Spell); addRandomItem(seed, Slot.Item); addRandomMiscItems(seed); // if seeded... //force strength charm // swap glass jaw, becoming, glass shovel if (seedActive) { miscBools["charm_strength"] = true; updateMiscItem("charm_strength"); bool problemFound; long modSeed = seed; do { problemFound = false; foreach (XmlNode itemNode in cadence) { if (itemNode.Name == "cursed") { continue; } if (itemNode.Attributes["type"].Value == "head_glass_jaw") { problemFound = true; modSeed += 1; addRandomItem(modSeed, Slot.Head); cadence.RemoveChild(itemNode); break; } while (itemNode.Attributes["type"].Value == "ring_becoming") { problemFound = true; modSeed += 1; addRandomItem(modSeed, Slot.Ring); cadence.RemoveChild(itemNode); break; } while (itemNode.Attributes["type"].Value == "shovel_glass") { problemFound = true; modSeed += 1; addRandomItem(modSeed, Slot.Shovel); cadence.RemoveChild(itemNode); break; } } } while (problemFound); } xml.Save(ND_XMLPATH); updateMainButtons(); }