public static void CheckSeed(LogicObjects.TrackerInstance Instance, bool InitialRun, List <int> Ignored) { if (InitialRun) { LogicEditing.ForceFreshCalculation(Instance.Logic); } bool recalculate = false; foreach (var item in Instance.Logic) { item.Available = LogicEditing.RequirementsMet(item.Required, Instance.Logic) && LogicEditing.CondtionalsMet(item.Conditionals, Instance.Logic); Console.WriteLine($"{item.DictionaryName} Avalable {item.Available}"); int Special = LogicEditing.SetAreaClear(item, Instance); if (Special == 2) { recalculate = true; } if (item.Aquired != item.Available && Special == 0 && item.IsFake) { item.Aquired = item.Available; recalculate = true; } if (!item.IsFake && item.RandomizedItem > -1 && item.Available != Instance.Logic[item.RandomizedItem].Aquired && !Ignored.Contains(item.ID)) { Instance.Logic[item.RandomizedItem].Aquired = item.Available; recalculate = true; } } if (recalculate) { CheckSeed(Instance, false, Ignored); } }
public static bool UnlockAllFake(List <LogicObjects.LogicEntry> logic, List <int> ImportantItems, int sphere, List <LogicObjects.PlaythroughItem> Playthrough) { var recalculate = false; foreach (var item in logic) { List <int> UsedItems = new List <int>(); item.Available = (LogicEditing.RequirementsMet(item.Required, logic, UsedItems) && LogicEditing.CondtionalsMet(item.Conditionals, logic, UsedItems)); bool changed = false; if (item.Aquired != item.Available && item.IsFake) { item.Aquired = item.Available; recalculate = true; changed = true; } if (changed && ImportantItems.Contains(item.SpoilerRandom) && item.Available) { Playthrough.Add(new LogicObjects.PlaythroughItem { SphereNumber = sphere, Check = item, ItemsUsed = UsedItems }); } } if (recalculate) { UnlockAllFake(logic, ImportantItems, sphere, Playthrough); } return(recalculate); }
public static LogicObjects.ItemUnlockData FindRequirements(LogicObjects.LogicEntry Item, List <LogicObjects.LogicEntry> logic) { List <int> ImportantItems = new List <int>(); List <LogicObjects.PlaythroughItem> playthrough = new List <LogicObjects.PlaythroughItem>(); var LogicCopy = Utility.CloneLogicList(logic); foreach (var i in LogicCopy) { if (i.Unrandomized()) { i.IsFake = true; } } var ItemCopy = LogicCopy[Item.ID]; LogicEditing.ForceFreshCalculation(LogicCopy); foreach (var i in LogicCopy) { ImportantItems.Add(i.ID); if (i.IsFake) { i.SpoilerRandom = i.ID; } } PlaythroughGenerator.UnlockAllFake(LogicCopy, ImportantItems, 0, playthrough); List <int> UsedItems = new List <int>(); bool isAvailable = (LogicEditing.RequirementsMet(ItemCopy.Required, LogicCopy, UsedItems) && LogicEditing.CondtionalsMet(ItemCopy.Conditionals, LogicCopy, UsedItems)); if (!isAvailable) { return(new LogicObjects.ItemUnlockData()); } List <int> NeededItems = Tools.ResolveFakeToRealItems(new LogicObjects.PlaythroughItem { SphereNumber = 0, Check = ItemCopy, ItemsUsed = UsedItems }, playthrough, LogicCopy); List <int> FakeItems = Tools.FindAllFakeItems(new LogicObjects.PlaythroughItem { SphereNumber = 0, Check = ItemCopy, ItemsUsed = UsedItems }, playthrough, LogicCopy); NeededItems = NeededItems.Distinct().ToList(); return(new LogicObjects.ItemUnlockData { playthrough = playthrough, FakeItems = FakeItems, ResolvedRealItems = NeededItems, UsedItems = UsedItems }); }
public static void CalculatePlaythrough(List <LogicObjects.LogicEntry> logic, List <LogicObjects.PlaythroughItem> Playthrough, int sphere, List <int> ImportantItems) { bool RealItemObtained = false; bool recalculate = false; List <LogicObjects.LogicEntry> itemCheckList = new List <LogicObjects.LogicEntry>(); foreach (var item in logic) { List <int> UsedItems = new List <int>(); item.Available = (LogicEditing.RequirementsMet(item.Required, logic, UsedItems) && LogicEditing.CondtionalsMet(item.Conditionals, logic, UsedItems)); bool changed = false; if (!item.IsFake && item.SpoilerRandom > -1 && item.Available != logic[item.SpoilerRandom].Aquired) { itemCheckList.Add(item); recalculate = true; changed = true; } if (changed && ImportantItems.Contains(item.SpoilerRandom) && item.Available) { Playthrough.Add(new LogicObjects.PlaythroughItem { SphereNumber = sphere, Check = item, ItemsUsed = UsedItems }); RealItemObtained = true; } } foreach (var item in itemCheckList) { logic[item.SpoilerRandom].Aquired = item.Available; } int NewSphere = (RealItemObtained) ? sphere + 1 : sphere; if (UnlockAllFake(logic, ImportantItems, NewSphere, Playthrough)) { recalculate = true; } if (recalculate) { CalculatePlaythrough(logic, Playthrough, NewSphere, ImportantItems); } }
public static bool CheckAvailability(this LogicObjects.LogicEntry entry, LogicObjects.TrackerInstance Instance, List <int> usedItems = null) { var logic = Instance.Logic; usedItems = usedItems ?? new List <int>(); if (string.IsNullOrWhiteSpace(entry.LocationName) && !entry.IsFake) { return(false); } //Check for a "Combinations" Entry if (entry.Required != null && entry.Conditionals != null && entry.Required.Where(x => logic[x].DictionaryName.StartsWith("MMRTCombinations")).Any()) { List <int> CondItemsUsed = new List <int>(); int ComboEntry = entry.Required.ToList().Find(x => logic[x].DictionaryName.StartsWith("MMRTCombinations")); var Required = entry.Required.Where(x => !logic[x].DictionaryName.StartsWith("MMRTCombinations")).ToArray(); int ConditionalsAquired = 0; if (int.TryParse(logic[ComboEntry].DictionaryName.Replace("MMRTCombinations", ""), out int ConditionalsNeeded)) { if (!Required.Any() || LogicEditing.RequirementsMet(Required, Instance, CondItemsUsed)) { foreach (var i in entry.Conditionals) { List <int> ReqItemsUsed = new List <int>(); if (LogicEditing.RequirementsMet(i, Instance, ReqItemsUsed)) { foreach (var q in ReqItemsUsed) { CondItemsUsed.Add(q); } ConditionalsAquired++; } if (ConditionalsAquired >= ConditionalsNeeded) { foreach (var q in CondItemsUsed) { usedItems.Add(q); } return(true); } } } } return(false); } //Check for a "Check contains Item" Entry else if (entry.Required != null && entry.Conditionals != null && entry.Required.Where(x => logic[x].DictionaryName == "MMRTCheckContains").Any()) { var Checks = entry.Required.Where(x => logic[x].DictionaryName != "MMRTCheckContains").ToArray(); if (!Checks.Any()) { return(false); } var entries = Math.Min(Checks.Count(), entry.Conditionals.Count()); for (var i = 0; i < entries; i++) { var Check = logic[entry.Required[i]].RandomizedItem; var Items = entry.Conditionals[i]; foreach (var j in Items) { if (Check == j) { usedItems.Add(j); return(true); } } } return(false); } //Check for a MMR Dungeon clear Entry else if (Instance.IsMM() && entry.IsFake && Instance.EntranceAreaDic.Count > 0 && Instance.EntranceAreaDic.ContainsKey(entry.ID)) { var RandClearLogic = entry.ClearRandomizedDungeonInThisArea(Instance); if (RandClearLogic == null) { return(false); } else { return(LogicEditing.RequirementsMet(RandClearLogic.Required, Instance, usedItems) && LogicEditing.CondtionalsMet(RandClearLogic.Conditionals, Instance, usedItems)); } } //Check availability the standard way else { return(LogicEditing.RequirementsMet(entry.Required, Instance, usedItems) && LogicEditing.CondtionalsMet(entry.Conditionals, Instance, usedItems)); } }