private void Btn_restore_Click(object sender, EventArgs e) { IO.Log("Restore Click"); DialogResult dr = MessageBox.Show("This doesn't actually restore your backups, but it will really place the items in their vanilla locations. Continue?", "Please Remove Quarter", MessageBoxButtons.YesNo); if (dr == DialogResult.No) { IO.Log("msgBox: No"); return; } IO.Log("msgBox: Yes"); IO.Log("Init Data"); List <RandoLocation> locs = RandoData.GetAllLocations(); List <RandoItem> itms = RandoData.GetAllItems(); IO.Log("Loop default data"); foreach (RandoItem item in itms) { locs.First(v => v.ID == item.OrigLoc).PlaceItem(item); } IO.Log("IO Write"); IO.WriteData(locs.ToList(), true); IO.Log("Restore Done!"); MessageBox.Show("Unrandomization Complete!", "I hope you hate this! ;)"); }
public static string Dumps() { List <RandoLocation> locs = RandoData.GetAllLocations(); StringBuilder sb = new StringBuilder(); char area = 'L'; foreach (RandoLocation location in locs) { if (area != location.ID.First()) { area = location.ID.First(); sb.AppendLine(); } sb.AppendLine($"{location.ID}: {RPN.Parse(location.LogicBase, false)}"); } return(sb.ToString()); }
public List <RandoLocation> Randomize() { IO.Log("Get Stuff"); unusedItems = RandoData.GetAllItems(); unusedLocations = RandoData.GetAllLocations(); obtainedLocations = new List <RandoLocation>(); obtainedItems = new List <RandoItem>(); IO.Log("Main Rando Loop"); while (unusedLocations.Count > 0) { IO.Log($"Top of Loop: {unusedLocations.Count} locs left"); availCount = countAvailableLocations(obtainedItems, out List <RandoLocation> allAvailLocations); RandoItem chosenItem; RandoLocation chosenLocation; if (unusedLocations.Count == 1 && unusedItems.Count == 1) { IO.Log("Almost done! Last location."); // The last metroid is in captivity. The galaxy is almost complete. chosenItem = unusedItems[0]; chosenLocation = unusedLocations[0]; } else { bool canCompleteGame = Logic.Eval(RandoData.Macros["CAN_COMPLETE_GAME"].LogicBase, obtainedItems); if (availCount == 1 && !canCompleteGame) { IO.Log("Must force!", IO.LogType.Warn); // Force Progression List <RandoItem> candItems = getItemCandidates(obtainedItems, availCount); if (candItems.Count == 0) { if (unusedItems.Count == 2) { int vhsCount = unusedItems.Where(v => v.Name == "vhs").Count(); if (vhsCount == 2) { IO.Log("A wild Panic Swap appeared!", IO.LogType.Warn); logCurrentItems(null, unusedLocations, unusedItems); // Last Loc VHS Problem RandoItem panicItem = unusedItems[0]; RandoLocation panicLocation = chooseLocation(obtainedLocations.Where(v => v.Locked == false && v.Item.Name != "vhs")); RandoItem swapItem = panicLocation.Item; removeFromLocation(swapItem, panicLocation); placeAtLocation(panicItem, panicLocation); vhsCount--; IO.Log($"Okay, panic resolved."); IO.Log($"I put {panicItem} at {panicLocation.ID} and will find a new home for {swapItem}", IO.LogType.Debug); logCurrentItems(null, unusedLocations, unusedItems); continue; } IO.Log($"I am reasonably certain something has gone wrong... I know you're upset, but please refrain from turning people into animals JUST yet."); logCurrentItems(obtainedLocations, unusedLocations, unusedItems); throw new RandoException("No Candidate Items Left!"); } } // Pick an item chosenItem = candItems[rnd.Next(candItems.Count - 1)]; } else { // Choose a totes random item. chosenItem = unusedItems[rnd.Next(unusedItems.Count - 1)]; } // Choose the spot chosenLocation = chooseLocation(allAvailLocations.Except(obtainedLocations)); } // Place the item; remove from pools placeAtLocation(chosenItem, chosenLocation); IO.Log($"{chosenLocation.ID}: I got put a {chosenItem.Name} on me.", IO.LogType.Debug); } IO.Log("Rando Finish"); logCurrentItems(obtainedLocations, null, null); return(obtainedLocations); }