Skip to content

Commit 245261f

Browse files
committed
committing before doing a gigantic refactor
1 parent ab6b216 commit 245261f

File tree

6 files changed

+342
-73
lines changed

6 files changed

+342
-73
lines changed

RandomizerCore/Randomizer/Logic/Dependency/NotItemDependency.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@ namespace RandomizerCore.Randomizer.Logic.Dependency;
44

55
public class NotItemDependency : DependencyBase
66
{
7-
private readonly Item _requiredItem;
7+
private readonly Item _excludedItem;
88

99
public NotItemDependency(Item item)
1010
{
11-
_requiredItem = item;
11+
_excludedItem = item;
1212
}
1313

1414
public override bool DependencyFulfilled(List<Item> availableItems, List<Location.Location> locations, Item? itemToPlace = null)
1515
{
16-
return !_requiredItem.Equals(itemToPlace);
16+
return !_excludedItem.EqualsIgnoreShufflePool(itemToPlace);
1717

1818
//Console.WriteLine($"Missing {RequiredItem.Type}");
1919
}

RandomizerCore/Randomizer/Logic/Location/Location.cs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,9 @@ public bool CanPlace(Item itemToPlace, List<Item> availableItems, List<Location>
162162
if (!SecondaryAddressed && itemToPlace.SubValue != 0) return false;
163163

164164
// Can only place in correct dungeon
165-
if (itemToPlace.Dungeon != "" && !Dungeons.Contains(itemToPlace.Dungeon)) return false;
165+
if (itemToPlace.Dungeon != "" && !Dungeons.Contains(itemToPlace.Dungeon)) return false;
166+
167+
if ((Type == LocationType.DungeonPrize && itemToPlace.ShufflePool is not ItemPool.DungeonPrize) || (itemToPlace.ShufflePool is ItemPool.DungeonPrize && Type != LocationType.DungeonPrize)) return false;
166168

167169
return ShufflerConstraints.All(constraint => constraint.Invoke(this, itemToPlace, availableItems, locations));
168170

@@ -175,20 +177,20 @@ public bool IsAccessible(List<Item> availableItems, List<Location> locations, It
175177

176178
RecursionCount++;
177179

178-
if (_availableCache != null)
179-
{
180-
RecursionCount--;
181-
return (bool)_availableCache;
182-
}
180+
//if (_availableCache != null)
181+
//{
182+
// RecursionCount--;
183+
// return (bool)_availableCache;
184+
//}
183185

184186
if (Dependencies.Any(dependency => !dependency.DependencyFulfilled(availableItems, locations, itemToPlace)))
185187
{
186-
_availableCache = false;
188+
//_availableCache = false;
187189
RecursionCount--;
188190
return false;
189191
}
190192

191-
_availableCache = true;
193+
//_availableCache = true;
192194
RecursionCount--;
193195
return true;
194196
}

RandomizerCore/Randomizer/Models/Item.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,13 @@ public override bool Equals(object? obj)
7272
{
7373
if (obj == null || GetType() != obj.GetType()) return false;
7474
var asItem = (Item)obj;
75-
return asItem.Type == Type && (asItem.SubValue == SubValue || asItem.UseAny || UseAny);
75+
return asItem.Type == Type && (asItem.SubValue == SubValue || asItem.UseAny || UseAny) && asItem.ShufflePool == ShufflePool;
76+
}
77+
78+
public bool EqualsIgnoreShufflePool(Item? item)
79+
{
80+
if (item == null) return false;
81+
return item.Value.Type == Type && (item.Value.SubValue == SubValue || item.Value.UseAny || UseAny);
7682
}
7783

7884
public override int GetHashCode()

RandomizerCore/Randomizer/Models/Sphere.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,20 @@ public class Sphere
1111
public int SphereNumber { get; set; }
1212

1313
public int TotalShuffledLocations { get; set; }
14+
15+
public int MaxRetryCount { get; set; }
16+
17+
public int CurrentAttemptCount { get; set; }
18+
19+
public List<Item> PreFilledItemsAddedThisSphere { get; set; }
20+
21+
public List<Location> PreFilledLocationsAddedThisSphere { get; set; }
22+
23+
//public List<Item> ElementsPlacedThisSphere { get; set; }
24+
25+
//public List<Location> ElementLocationsThisSphere { get; set; }
26+
27+
//public List<Item> DungeonItemsPlacedThisSphere { get; set; }
28+
29+
//public List<Location> DungeonLocationsPlacedThisSphere { get; set; }
1430
}

0 commit comments

Comments
 (0)