From ffc0a2bf40aa72aa30d23c02139c2fa7c4454c0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Gallet?= Date: Fri, 8 Dec 2017 12:48:01 +0100 Subject: [PATCH] Fix a logic Some escapes require an upgraded pressure bomb, so we cannot gain the pressure bomb from the cave upgrade --- SWD2Randomizer/Location.cs | 2 ++ SWD2Randomizer/LocationsCasual.cs | 5 +++-- SWD2Randomizer/LocationsSpeedrunner.cs | 9 ++++++--- SWD2Randomizer/Randomizer.cs | 2 +- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/SWD2Randomizer/Location.cs b/SWD2Randomizer/Location.cs index 054835e..7af5f69 100644 --- a/SWD2Randomizer/Location.cs +++ b/SWD2Randomizer/Location.cs @@ -16,12 +16,14 @@ public enum RandomizeType public Access CanAccess { get; set; } public string Grant { get; set; } public Access CanEscape { get; set; } + public Access CanEscapeWithoutNew { get; set; } public Location() { Type = RandomizeType.None; CanAccess = have => true; CanEscape = have => true; + CanEscapeWithoutNew = have => true; } } } diff --git a/SWD2Randomizer/LocationsCasual.cs b/SWD2Randomizer/LocationsCasual.cs index 00b8497..bc590dc 100644 --- a/SWD2Randomizer/LocationsCasual.cs +++ b/SWD2Randomizer/LocationsCasual.cs @@ -133,7 +133,7 @@ public LocationsCasual() { Grant = "pressurebomb.launcher", Type = Location.RandomizeType.Upgrade, CanAccess = have => have.Contains("top_yarrow"), - CanEscape = have => have.Contains("pressurebomb") || (have.Contains("steampack") && have.Contains("steampack.slayer")) + CanEscape = have => (have.Contains("pressurebomb") && have.Contains("pressurebomb.launcher")) || (have.Contains("steampack") && have.Contains("steampack.slayer")) }, new Location { @@ -156,7 +156,8 @@ public LocationsCasual() { Grant = "hook", Type = Location.RandomizeType.Upgrade, CanAccess = have => have.Contains("oasis"), - CanEscape = have => have.Contains("hook") || have.Contains("pressurebomb") || have.Contains("steampack") + CanEscape = have => have.Contains("hook") || have.Contains("steampack"), + CanEscapeWithoutNew = have => have.Contains("pressurebomb") }, new Location { diff --git a/SWD2Randomizer/LocationsSpeedrunner.cs b/SWD2Randomizer/LocationsSpeedrunner.cs index 52d9a85..d727aac 100644 --- a/SWD2Randomizer/LocationsSpeedrunner.cs +++ b/SWD2Randomizer/LocationsSpeedrunner.cs @@ -132,7 +132,8 @@ public LocationsSpeedrunner() Grant = "pressurebomb.launcher", Type = Location.RandomizeType.Upgrade, CanAccess = have => have.Contains("top_yarrow"), - CanEscape = have => have.Contains("pressurebomb") || (have.Contains("steampack") && have.Contains("steampack.slayer")) + CanEscape = have => (have.Contains("pressurebomb") && have.Contains("pressurebomb.launcher")) || (have.Contains("steampack") && have.Contains("steampack.slayer")), + CanEscapeWithoutNew = have => have.Contains("pressurebomb") }, new Location { @@ -155,7 +156,8 @@ public LocationsSpeedrunner() Grant = "hook", Type = Location.RandomizeType.Upgrade, CanAccess = have => have.Contains("oasis"), - CanEscape = have => have.Contains("hook") || have.Contains("pressurebomb") || have.Contains("steampack") + CanEscape = have => have.Contains("hook") || (have.Contains("pressurebomb") && have.Contains("pressurebomb.launcher")) || have.Contains("steampack"), + CanEscapeWithoutNew = have => have.Contains("pressurebomb") }, new Location { @@ -163,7 +165,8 @@ public LocationsSpeedrunner() Grant = "steampack.slayer", Type = Location.RandomizeType.Upgrade, CanAccess = have => have.Contains("yarrow_barrier_1") && (have.Contains("steampack") || (have.Contains("pressurebomb") && have.Contains("pressurebomb.launcher")) || have.Contains("hook")), - CanEscape = have => (have.Contains("steampack") && have.Contains("steampack.slayer")) || have.Contains("pressurebomb") + CanEscape = have => have.Contains("steampack") && have.Contains("steampack.slayer"), + CanEscapeWithoutNew = have => have.Contains("pressurebomb") }, new Location { diff --git a/SWD2Randomizer/Randomizer.cs b/SWD2Randomizer/Randomizer.cs index bb48288..f34ceb6 100644 --- a/SWD2Randomizer/Randomizer.cs +++ b/SWD2Randomizer/Randomizer.cs @@ -125,7 +125,7 @@ private bool CheckValid() /* Make a copy of our items and add the granted item, then check if we can escape */ List itemsAdded = new List(haveFlags); itemsAdded.Add(location.Grant); - if (location.CanEscape(itemsAdded)) + if (location.CanEscape(itemsAdded) || location.CanEscapeWithoutNew(haveFlags)) { /* We can successfully grab the item and escape! Add the item to our list */ haveFlags.Add(location.Grant);