Skip to content

Commit

Permalink
Add setting to prevent low resource dark world runs
Browse files Browse the repository at this point in the history
  • Loading branch information
MattEqualsCoder committed Jan 2, 2025
1 parent 04dc630 commit 0bef8a5
Show file tree
Hide file tree
Showing 22 changed files with 61 additions and 42 deletions.
2 changes: 2 additions & 0 deletions src/TrackerCouncil.Smz3.Data/Logic/ILogic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,6 @@ public interface ILogic
public bool CanWallJump(WallJumpDifficulty difficulty);

public bool CheckAgahnim(Progression items, World world, bool requireRewards);

public bool CanNavigateDarkWorld(Progression items);
}
11 changes: 10 additions & 1 deletion src/TrackerCouncil.Smz3.Data/Logic/Logic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ public Logic(World world)
public bool CanLiftLight(Progression items) => items.Glove;
public bool CanLiftHeavy(Progression items) => items.Mitt;

public bool HasHeartCount(Progression items, int numberOfHearts) => items.HeartCount >= numberOfHearts;

public bool CanLightTorches(Progression items)
{
return items.FireRod || items.Lamp;
Expand Down Expand Up @@ -107,9 +109,16 @@ public bool CanAccessNorfairLowerPortal(Progression items)
return items.Flute && CanLiftHeavy(items);
}

public bool CanNavigateDarkWorld(Progression items)
{
return items.MoonPearl && (!World.Config.LogicConfig.PreventLowResourceDarkWorld ||
(HasHeartCount(items, 6) &&
(items.Sword || items.Hammer || items.Bow || items.FireRod)));
}

public bool CanAccessMaridiaPortal(Progression items, bool requireRewards)
{
return items.MoonPearl && items.Flippers &&
return CanNavigateDarkWorld(items) && items.Flippers &&
items.Gravity && items.Morph &&
(CheckAgahnim(items, World, requireRewards) || items.Hammer && CanLiftLight(items) || CanLiftHeavy(items));
}
Expand Down
3 changes: 3 additions & 0 deletions src/TrackerCouncil.Smz3.Data/Logic/LogicConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ public LogicConfig(bool enableAllCasOptions, bool enableAllTricks, WallJumpDiffi
[DynamicFormFieldCheckBox(checkBoxText: "Include Quarter Magic", toolTipText: "Adds an additional progressive half magic to the item pool.", groupName: "CasMiddle")]
public bool QuarterMagic { get; set; }

[DynamicFormFieldCheckBox(checkBoxText: "Prevent Low Resource Dark World", toolTipText: "You're expected to at least 6 hearts total and some weapon that can deal damage before going to the Dark World.", groupName: "CasMiddle")]
public bool PreventLowResourceDarkWorld { get; set; }

[YamlIgnore, Newtonsoft.Json.JsonIgnore]
[DynamicFormFieldText(groupName: "TricksTop")]
public string TricksDescription => "Logic settings that will make the game more difficult by requiring you to do techniques or maneuvers not typically required in the vanilla games.";
Expand Down
1 change: 1 addition & 0 deletions src/TrackerCouncil.Smz3.Data/WorldData/Progression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ public Progression(IEnumerable<Item> items, IEnumerable<Reward> rewards, IEnumer
public int CrystalCount => Rewards.Count(r => r is RewardType.CrystalBlue or RewardType.CrystalRed);
public int Count => Items.Count;
public bool IsReadOnly => false;
public int HeartCount => 3 + GetCount(ItemType.HeartContainer) + GetCount(ItemType.HeartContainerRefill) + GetCount(ItemType.HeartPiece) / 4;

protected List<ItemType> Items { get; }
protected List<RewardType> Rewards { get; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ public MireShedRoom(Region region, IMetadataService? metadata, TrackerState? tra
new Location(this, LocationId.MireShedLeft, 0x1EA73, LocationType.Regular,
name: "Mire Shed - Left",
vanillaItem: ItemType.HeartPiece,
access: items => items.MoonPearl,
access: items => World.Logic.CanNavigateDarkWorld(items),
memoryAddress: 0x10D,
memoryFlag: 0x4,
metadata: metadata,
trackerState: trackerState),
new Location(this, LocationId.MireShedRight, 0x1EA76, LocationType.Regular,
name: "Mire Shed - Right",
vanillaItem: ItemType.TwentyRupees,
access: items => items.MoonPearl,
access: items => World.Logic.CanNavigateDarkWorld(items),
memoryAddress: 0x10D,
memoryFlag: 0x5,
metadata: metadata,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public DarkWorldNorthEast(World world, Config config, IMetadataService? metadata
Catfish = new Location(this, LocationId.Catfish, 0x1DE185, LocationType.Regular,
name: "Catfish",
vanillaItem: ItemType.Quake,
access: items => items.MoonPearl && Logic.CanLiftLight(items),
access: items => World.Logic.CanNavigateDarkWorld(items) && Logic.CanLiftLight(items),
memoryAddress: 0x190,
memoryFlag: 0x20,
memoryType: LocationMemoryType.ZeldaMisc,
Expand Down Expand Up @@ -52,7 +52,7 @@ public DarkWorldNorthEast(World world, Config config, IMetadataService? metadata
public override bool CanEnter(Progression items, bool requireRewards)
{
return Logic.CheckAgahnim(items, World, requireRewards) ||
(items.MoonPearl && (
(World.Logic.CanNavigateDarkWorld(items) && (
(items.Hammer && Logic.CanLiftLight(items)) ||
(Logic.CanLiftHeavy(items) && items.Flippers) ||
(Logic.CanAccessDarkWorldPortal(items) && items.Flippers)
Expand Down Expand Up @@ -94,7 +94,7 @@ public PyramidFairyChamber(Region region, IMetadataService? metadata, TrackerSta

private bool CanAccessPyramidFairy(Progression items, bool requireRewards) =>
(items.BothRedCrystals || (!requireRewards && World.CanAquireAll(items, RewardType.CrystalRed))) &&
items.MoonPearl && World.DarkWorldSouth.CanEnter(items, requireRewards) &&
World.Logic.CanNavigateDarkWorld(items) && World.DarkWorldSouth.CanEnter(items, requireRewards) &&
(items.Hammer || (items.Mirror && Logic.CheckAgahnim(items, World, requireRewards)));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,12 @@ public DarkWorldNorthWest(World world, Config config, IMetadataService? metadata

public override bool CanEnter(Progression items, bool requireRewards)
{
return items.MoonPearl && (((
Logic.CheckAgahnim(items, World, requireRewards) ||
(Logic.CanAccessDarkWorldPortal(items) && items.Flippers)
) && items.Hookshot && (items.Flippers || Logic.CanLiftLight(items) || items.Hammer)) ||
(items.Hammer && Logic.CanLiftLight(items)) ||
Logic.CanLiftHeavy(items)
return World.Logic.CanNavigateDarkWorld(items) && (((
Logic.CheckAgahnim(items, World, requireRewards) ||
(Logic.CanAccessDarkWorldPortal(items) && items.Flippers)
) && items.Hookshot && (items.Flippers || Logic.CanLiftLight(items) || items.Hammer)) ||
(items.Hammer && Logic.CanLiftLight(items)) ||
Logic.CanLiftHeavy(items)
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ public DarkWorldSouth(World world, Config config, IMetadataService? metadata, Tr

public override bool CanEnter(Progression items, bool requireRewards)
{
return items.MoonPearl && (((
Logic.CheckAgahnim(items, World, requireRewards) ||
(Logic.CanAccessDarkWorldPortal(items) && items.Flippers)
) && (items.Hammer || (items.Hookshot && (items.Flippers || Logic.CanLiftLight(items))))) ||
(items.Hammer && Logic.CanLiftLight(items)) ||
Logic.CanLiftHeavy(items)
return World.Logic.CanNavigateDarkWorld(items) && (((
Logic.CheckAgahnim(items, World, requireRewards) ||
(Logic.CanAccessDarkWorldPortal(items) && items.Flippers)
) && (items.Hammer || (items.Hookshot && (items.Flippers || Logic.CanLiftLight(items))))) ||
(items.Hammer && Logic.CanLiftLight(items)) ||
Logic.CanLiftHeavy(items)
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,31 +44,31 @@ public HookshotCaveRoom(Region region, IMetadataService? metadata, TrackerState?
new Location(this, LocationId.HookshotCaveTopRight, 0x1EB51, LocationType.Regular,
name: "Hookshot Cave - Top Right",
vanillaItem: ItemType.FiftyRupees,
access: items => items.MoonPearl && items.Hookshot,
access: items => World.Logic.CanNavigateDarkWorld(items) && items.Hookshot,
memoryAddress: 0x3C,
memoryFlag: 0x4,
metadata: metadata,
trackerState: trackerState),
new Location(this, LocationId.HookshotCaveTopLeft, 0x1EB54, LocationType.Regular,
name: "Hookshot Cave - Top Left",
vanillaItem: ItemType.FiftyRupees,
access: items => items.MoonPearl && items.Hookshot,
access: items => World.Logic.CanNavigateDarkWorld(items) && items.Hookshot,
memoryAddress: 0x3C,
memoryFlag: 0x5,
metadata: metadata,
trackerState: trackerState),
new Location(this, LocationId.HookshotCaveBottomLeft, 0x1EB57, LocationType.Regular,
name: "Hookshot Cave - Bottom Left",
vanillaItem: ItemType.FiftyRupees,
access: items => items.MoonPearl && items.Hookshot,
access: items => World.Logic.CanNavigateDarkWorld(items) && items.Hookshot,
memoryAddress: 0x3C,
memoryFlag: 0x6,
metadata: metadata,
trackerState: trackerState),
new Location(this, LocationId.HookshotCaveBottomRight, 0x1EB5A, LocationType.Regular,
name: "Hookshot Cave - Bottom Right",
vanillaItem: ItemType.FiftyRupees,
access: items => items.MoonPearl && (items.Hookshot || items.Boots),
access: items => World.Logic.CanNavigateDarkWorld(items) && (items.Hookshot || items.Boots),
memoryAddress: 0x3C,
memoryFlag: 0x7,
metadata: metadata,
Expand All @@ -86,14 +86,14 @@ public SuperbunnyCaveRoom(Region region, IMetadataService? metadata, TrackerStat
{
new Location(this, LocationId.SuperbunnyCaveTop, 0x1EA7C, LocationType.Regular,
name: "Superbunny Cave - Top",
access: items => items.MoonPearl,
access: items => World.Logic.CanNavigateDarkWorld(items),
memoryAddress: 0xF8,
memoryFlag: 0x4,
metadata: metadata,
trackerState: trackerState),
new Location(this, LocationId.SuperbunnyCaveBottom, 0x1EA7F, LocationType.Regular,
name: "Superbunny Cave - Bottom",
access: items => items.MoonPearl,
access: items => World.Logic.CanNavigateDarkWorld(items),
memoryAddress: 0xF8,
memoryFlag: 0x5,
metadata: metadata,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public SpikeCaveRoom(Region region, IMetadataService? metadata, TrackerState? tr
{
new Location(this, LocationId.SpikeCave, 0x1EA8B, LocationType.Regular,
name: "Spike Cave",
access: items => items.MoonPearl && items.Hammer && Logic.CanLiftLight(items) &&
access: items => World.Logic.CanNavigateDarkWorld(items) && items.Hammer && Logic.CanLiftLight(items) &&
((Logic.CanExtendMagic(items, 2) && items.Cape) || items.Byrna) &&
World.LightWorldDeathMountainWest.CanEnter(items, true),
memoryAddress: 0x117,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ public override bool CanEnter(Progression items, bool requireRewards)
var haveEnoughCrystals = items.CrystalCount >= Config.GanonsTowerCrystalCount;
var gtOpenBeforeGanon = Config.GanonsTowerCrystalCount < Config.GanonCrystalCount;
var canBeatMetroid = World.CanDefeatBossCount(items, smBosses) >= Config.TourianBossCount;
return items.MoonPearl && canEnterDDMEast && haveEnoughCrystals && (gtOpenBeforeGanon || canBeatMetroid);
return World.Logic.CanNavigateDarkWorld(items) && canEnterDDMEast && haveEnoughCrystals && (gtOpenBeforeGanon || canBeatMetroid);
}

public override bool CanFill(Item item, Progression items)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public IcePalace(World world, Config config, IMetadataService? metadata, Tracker

public override bool CanEnter(Progression items, bool requireRewards)
{
return items.MoonPearl && items.Flippers && Logic.CanLiftHeavy(items) && Logic.CanMeltFreezors(items);
return World.Logic.CanNavigateDarkWorld(items) && items.Flippers && Logic.CanLiftHeavy(items) && Logic.CanMeltFreezors(items);
}

public bool CanBeatBoss(Progression items) => KholdstareReward.IsAvailable(items);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public LightWorldDeathMountainEast(World world, Config config, IMetadataService?
FloatingIsland = new Location(this, LocationId.FloatingIsland, 0x308141, LocationType.Regular,
name: "Floating Island",
vanillaItem: ItemType.HeartPiece,
access: items => items.Mirror && items.MoonPearl && Logic.CanLiftHeavy(items),
access: items => items.Mirror && World.Logic.CanNavigateDarkWorld(items) && Logic.CanLiftHeavy(items),
memoryAddress: 0x5,
memoryFlag: 0x40,
memoryType: LocationMemoryType.ZeldaMisc,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ public LightWorldNorthWest(World world, Config config, IMetadataService? metadat
GraveyardLedge = new Location(this, LocationId.GraveyardLedge, 0x308004, LocationType.Regular,
name: "Graveyard Ledge",
vanillaItem: ItemType.HeartPiece,
access: items => items.Mirror && items.MoonPearl && World.DarkWorldNorthWest.CanEnter(items, true),
relevanceRequirement: items => items.Mirror && items.MoonPearl && World.DarkWorldNorthWest.CanEnter(items, false),
access: items => items.Mirror && World.Logic.CanNavigateDarkWorld(items) && World.DarkWorldNorthWest.CanEnter(items, true),
relevanceRequirement: items => items.Mirror && World.Logic.CanNavigateDarkWorld(items) && World.DarkWorldNorthWest.CanEnter(items, false),
memoryAddress: 0x11B,
memoryFlag: 0x9,
metadata: metadata,
Expand All @@ -78,10 +78,10 @@ public LightWorldNorthWest(World world, Config config, IMetadataService? metadat
vanillaItem: ItemType.Cape,
access: items => items.Boots && (
Logic.CanLiftHeavy(items) ||
(items.Mirror && items.MoonPearl && World.DarkWorldNorthWest.CanEnter(items, true))),
(items.Mirror && World.Logic.CanNavigateDarkWorld(items) && World.DarkWorldNorthWest.CanEnter(items, true))),
relevanceRequirement: items => items.Boots && (
Logic.CanLiftHeavy(items) ||
(items.Mirror && items.MoonPearl && World.DarkWorldNorthWest.CanEnter(items, false))),
(items.Mirror && World.Logic.CanNavigateDarkWorld(items) && World.DarkWorldNorthWest.CanEnter(items, false))),
memoryAddress: 0x113,
memoryFlag: 0x4,
metadata: metadata,
Expand Down Expand Up @@ -141,7 +141,7 @@ public LightWorldNorthWest(World world, Config config, IMetadataService? metadat
vanillaItem: ItemType.HalfMagic,
access: items => items.Powder
&& (items.Hammer
|| (items.MoonPearl && items.Mirror && Logic.CanLiftHeavy(items))),
|| (World.Logic.CanNavigateDarkWorld(items) && items.Mirror && Logic.CanLiftHeavy(items))),
memoryAddress: 0x191,
memoryFlag: 0x80,
memoryType: LocationMemoryType.ZeldaMisc,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,10 @@ public LightWorldSouth(World world, Config config, IMetadataService? metadata, T
LakeHyliaIsland = new Location(this, LocationId.LakeHyliaIsland, 0x308144, LocationType.Regular,
name: "Lake Hylia Island",
vanillaItem: ItemType.HeartPiece,
access: items => items.Flippers && items.MoonPearl && items.Mirror && (
access: items => items.Flippers && World.Logic.CanNavigateDarkWorld(items) && items.Mirror && (
World.DarkWorldSouth.CanEnter(items, true) ||
World.DarkWorldNorthEast.CanEnter(items, true)),
relevanceRequirement: items => items.Flippers && items.MoonPearl && items.Mirror && (
relevanceRequirement: items => items.Flippers && World.Logic.CanNavigateDarkWorld(items) && items.Mirror && (
World.DarkWorldSouth.CanEnter(items, false) ||
World.DarkWorldNorthEast.CanEnter(items, false)),
memoryAddress: 0x35,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public MiseryMire(World world, Config config, IMetadataService? metadata, Tracke
// Need "CanKillManyEnemies" if implementing swordless
public override bool CanEnter(Progression items, bool requireRewards)
{
return items.Contains(PrerequisiteState.RequiredItem) && items is { Sword: true, MoonPearl: true } &&
return items.Contains(PrerequisiteState.RequiredItem) && items.Sword && World.Logic.CanNavigateDarkWorld(items) &&
(items.Boots || items.Hookshot) && World.DarkWorldMire.CanEnter(items, requireRewards);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ public PalaceOfDarkness(World world, Config config, IMetadataService? metadata,

public override bool CanEnter(Progression items, bool requireRewards)
{
return items.MoonPearl && World.DarkWorldNorthEast.CanEnter(items, requireRewards);
return World.Logic.CanNavigateDarkWorld(items) && World.DarkWorldNorthEast.CanEnter(items, requireRewards);
}

public bool CanBeatBoss(Progression items) => HelmasaurKingReward.IsAvailable(items);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public SkullWoods(World world, Config config, IMetadataService? metadata, Tracke

public override bool CanEnter(Progression items, bool requireRewards)
{
return items.MoonPearl && World.DarkWorldNorthWest.CanEnter(items, requireRewards);
return World.Logic.CanNavigateDarkWorld(items) && World.DarkWorldNorthWest.CanEnter(items, requireRewards);
}

public bool CanBeatBoss(Progression items) => MothulaReward.IsAvailable(items);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public SwampPalace(World world, Config config, IMetadataService? metadata, Track

public override bool CanEnter(Progression items, bool requireRewards)
{
return items.MoonPearl && items.Mirror && items.Flippers && World.DarkWorldSouth.CanEnter(items, requireRewards);
return World.Logic.CanNavigateDarkWorld(items) && items.Mirror && items.Flippers && World.DarkWorldSouth.CanEnter(items, requireRewards);
}

public bool CanBeatBoss(Progression items) => ArrghusReward.IsAvailable(items);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public ThievesTown(World world, Config config, IMetadataService? metadata, Track

public override bool CanEnter(Progression items, bool requireRewards)
{
return items.MoonPearl && World.DarkWorldNorthWest.CanEnter(items, requireRewards);
return World.Logic.CanNavigateDarkWorld(items) && World.DarkWorldNorthWest.CanEnter(items, requireRewards);
}

public bool CanBeatBoss(Progression items) =>BlindReward.IsAvailable(items);
Expand Down
Loading

0 comments on commit 0bef8a5

Please sign in to comment.