public bool CanReach(string areaName) { Area area = Randomiser.GetArea(areaName); if (area.Equals(Randomiser.GetArea("Village of Departure"))) { return(true); } if (areaChecks.TryGetValue(area.Name, out bool cached)) { return(cached); } else { if (area.Checking) { return(false); } area.Checking = true; bool canReach = area.CanReach(this); area.Checking = false; areaChecks.Add(area.Name, canReach); return(canReach); } }
public PlayerState(Randomiser randomiser) { this.randomiser = randomiser; StartingArea = randomiser.GetArea("Village of Departure"); areaChecks = new Dictionary <string, bool>(); entraceChecks = new Dictionary <string, bool>(); collectedLocations = new Dictionary <string, bool>(); collectedItems = new Dictionary <string, int>(); }
public bool CanReach(string areaName) { Area area = randomiser.GetArea(areaName); if (area.Equals(StartingArea)) { return(true); } if (areaChecks.TryGetValue(area.Name, out bool cached)) { return(cached); } if (area.Checking) { return(false); } area.Checking = true; bool canReach = area.CanReach(this); area.Checking = false; //when writing the spoiler log playthrough only care about caching areas that can be reached, caching areas that can't //be reached sometimes leads to the playthorugh being incorrect if (IgnoreFalseChecks && canReach) { areaChecks.Add(area.Name, canReach); } else { areaChecks.Add(area.Name, canReach); } return(canReach); }
public static bool EntrancePlacementCheck(Randomiser randomiser) { PlayerState state = new PlayerState(randomiser); ItemPool itemPool = new ItemPool(FileUtils.LoadItemFile()); if (randomiser.Settings.ShopPlacement == ShopPlacement.Original) { randomiser.PlaceShopItems(itemPool); } if (randomiser.Settings.MantraPlacement == MantraPlacement.Original) { randomiser.PlaceMantras(itemPool); } foreach (Item item in itemPool) { state.CollectItem(item); } List <Location> requiredLocations = randomiser.GetPlacedLocations(); List <Location> reachableLocations; do { reachableLocations = state.GetReachableLocations(requiredLocations); foreach (Location location in reachableLocations) { state.CollectItem(location.Item); state.collectedLocations.Add(location.Name, true); } state.RemoveFalseCheckedAreasAndEntrances(); } while (reachableLocations.Count > 0); //check to see if its possible to beat the game with this configuration if (!state.CanBeatGame()) { return(false); } //check to see if all locations are accessable foreach (Location location in randomiser.GetLocations()) { if (!location.CanReach(state)) { return(false); } } //check to see if its possible to actually escape state.EscapeCheck = true; state.StartingArea = randomiser.GetArea("Immortal Battlefield Main"); List <string> exitNames = new List <string>() { "Cliff", "Gate of Guidance", "Mausoleum of Giants", "Village of Departure", "Gate of Illusion", "Nibiru" }; foreach (string exitName in exitNames) { state.ClearCheckedAreasAndEntrances(); if (state.CanReach(exitName)) { return(true); } } return(false); }