Skip to content

Commit

Permalink
Refactored spoilor log for Wrap Gates & Rising Tides
Browse files Browse the repository at this point in the history
  • Loading branch information
Jarno458 committed Feb 17, 2023
1 parent 597aefd commit 484ce1f
Show file tree
Hide file tree
Showing 6 changed files with 128 additions and 32 deletions.
2 changes: 1 addition & 1 deletion TsRandomizer/Archipelago/ArchipelagoUnlockingMap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ void SetTeleporterPickupAction(TeleporterGate[] allGates, Requirement gateToUnlo
{
var selectedGate = allGates.First(g => g.Gate == gateToUnlock);

CustomItem.SetDescription(type, $"You feel the twin pyramid key attune to: {selectedGate.Name}", "Twin Pyramid Key");
CustomItem.SetDescription(type, $"You feel the twin pyramid key attune to: {WarpNames.Get(selectedGate.Gate)}", "Twin Pyramid Key");

var unlockingSpecification = new UnlockingSpecification(CustomItem.GetIdentifier(type) , Requirement.None, Requirement.Teleport)
{
Expand Down
43 changes: 17 additions & 26 deletions TsRandomizer/Randomisation/ItemUnlockingMap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ void SetTeleporterPickupAction(Seed seed)
};

pyramidUnlockingSpecification.Unlocks = selectedGate.Gate;
pyramidUnlockingSpecification.WarpName = selectedGate.Name;
}

void SetUnchainedKeyPickupActions(Seed seed)
Expand All @@ -71,14 +70,13 @@ protected void SetUnchainedKeysUnlock(Random random, CustomItemType type, Telepo
var pyramidWarpUnlockingSpecification = new UnlockingSpecification(CustomItem.GetIdentifier(type), R.None);
var pyramidGate = gates.SelectRandom(random);

CustomItem.SetDescription(type, $"You feel the twin pyramid key attune to: {pyramidGate.Name}", "Twin Pyramid Key");
CustomItem.SetDescription(type, $"You feel the twin pyramid key attune to: {WarpNames.Get(pyramidGate.Gate)}", "Twin Pyramid Key");

pyramidWarpUnlockingSpecification.OnPickup = level => {
UnlockRoom(level, pyramidGate.LevelId, pyramidGate.RoomId);
};

pyramidWarpUnlockingSpecification.Unlocks = pyramidGate.Gate;
pyramidWarpUnlockingSpecification.WarpName = pyramidGate.Name;

UnlockingSpecifications.Add(pyramidWarpUnlockingSpecification);
}
Expand All @@ -88,33 +86,33 @@ abstract class ItemUnlockingMap
{
protected static readonly TeleporterGate[] PresentTeleporterGates =
{
new TeleporterGate{Gate = R.GateKittyBoss, LevelId = 2, RoomId = 55, Name = "Sewers"},
new TeleporterGate{Gate = R.GateLeftLibrary, LevelId = 2, RoomId = 54, Name = "Library"},
new TeleporterGate{Gate = R.GateMilitaryGate, LevelId = 10, RoomId = 12, Name = "Military Hangar"},
new TeleporterGate{Gate = R.GateSealedCaves, LevelId = 9, RoomId = 50, Name = "Xarion's Cave Entrance"},
new TeleporterGate{Gate = R.GateKittyBoss, LevelId = 2, RoomId = 55},
new TeleporterGate{Gate = R.GateLeftLibrary, LevelId = 2, RoomId = 54},
new TeleporterGate{Gate = R.GateMilitaryGate, LevelId = 10, RoomId = 12},
new TeleporterGate{Gate = R.GateSealedCaves, LevelId = 9, RoomId = 50},
//new TeleporterGate{Gate = R.GateXarion, LevelId = 9, RoomId = 49}, //dont want to spawn infront of xarion
new TeleporterGate{Gate = R.GateSealedSirensCave, LevelId = 9, RoomId = 51, Name = "Sirens' Cave"},
new TeleporterGate{Gate = R.GateLakeDesolation, LevelId = 1, RoomId = 25, Name = "Lake Desolation"}
new TeleporterGate{Gate = R.GateSealedSirensCave, LevelId = 9, RoomId = 51},
new TeleporterGate{Gate = R.GateLakeDesolation, LevelId = 1, RoomId = 25}
};

protected static readonly TeleporterGate[] PastTeleporterGates =
{
//new TeleporterGate{Gate = Requirement.GateLakeSereneLeft, LevelId = 7, RoomId = 30}, //you dont want to spawn with a boss in your face
new TeleporterGate{Gate = R.GateLakeSereneRight, LevelId = 7, RoomId = 31, Name = "East Lake Serene"},
new TeleporterGate{Gate = R.GateAccessToPast, LevelId = 8, RoomId = 51, Name = "Upper Caves of Banishment"},
new TeleporterGate{Gate = R.GateLakeSereneRight, LevelId = 7, RoomId = 31},
new TeleporterGate{Gate = R.GateAccessToPast, LevelId = 8, RoomId = 51},
//new TeleporterGate{Gate = Requirement.GateAccessToPast, LevelId = 3, RoomId = 6}, //Refugee Camp, Somehow doesnt work ¯\_(ツ)_/¯
new TeleporterGate{Gate = R.GateCastleRamparts, LevelId = 4, RoomId = 23, Name = "Castle Ramparts"},
new TeleporterGate{Gate = R.GateCastleKeep, LevelId = 5, RoomId = 24, Name = "Castle Keep"},
new TeleporterGate{Gate = R.GateRoyalTowers, LevelId = 6, RoomId = 0, Name = "Royal Towers"},
new TeleporterGate{Gate = R.GateMaw, LevelId = 8, RoomId = 49, Name = "Maw's Lair"},
new TeleporterGate{Gate = R.GateCavesOfBanishment, LevelId = 8, RoomId = 50, Name = "Maw's Cave Entrance"}
new TeleporterGate{Gate = R.GateCastleRamparts, LevelId = 4, RoomId = 23},
new TeleporterGate{Gate = R.GateCastleKeep, LevelId = 5, RoomId = 24},
new TeleporterGate{Gate = R.GateRoyalTowers, LevelId = 6, RoomId = 0},
new TeleporterGate{Gate = R.GateMaw, LevelId = 8, RoomId = 49},
new TeleporterGate{Gate = R.GateCavesOfBanishment, LevelId = 8, RoomId = 50}
};

protected static readonly TeleporterGate[] PyramidTeleporterGates =
{
new TeleporterGate{Gate = R.GateGyre, LevelId = 14, RoomId = 1, Name = "Temporal Gyre Entrance"},
new TeleporterGate{Gate = R.GateLeftPyramid, LevelId = 16, RoomId = 12, Name = "Ancient Pyramid Entrance"},
new TeleporterGate{Gate = R.GateRightPyramid, LevelId = 16, RoomId = 19, Name = "Inner Ancient Pyramid"}
new TeleporterGate{Gate = R.GateGyre, LevelId = 14, RoomId = 1},
new TeleporterGate{Gate = R.GateLeftPyramid, LevelId = 16, RoomId = 12},
new TeleporterGate{Gate = R.GateRightPyramid, LevelId = 16, RoomId = 19}
};

protected readonly LookupDictionary<ItemIdentifier, UnlockingSpecification> UnlockingSpecifications;
Expand Down Expand Up @@ -182,11 +180,6 @@ public Action<Level> GetPickupAction(ItemIdentifier identifier) =>
? value.OnPickup
: null;

public string GetWarpName(ItemIdentifier identifier) =>
UnlockingSpecifications.TryGetValue(identifier, out var value)
? value.WarpName
: null;

protected static void UnlockRoom(Level level, int levelId, int roomId)
{
var minimapRoom = level.Minimap.Areas[levelId].Rooms[roomId];
Expand All @@ -205,7 +198,6 @@ protected class UnlockingSpecification
public R AdditionalUnlocks { get; internal set; }
public R AllUnlocks => Unlocks | AdditionalUnlocks;
public Action<Level> OnPickup { get; internal set; }
public string WarpName { get; internal set; }

public UnlockingSpecification(ItemIdentifier item, R unlocks, R? additionalUnlocks = null)
{
Expand All @@ -220,7 +212,6 @@ protected class TeleporterGate
public R Gate { get; internal set; }
public int LevelId { get; internal set; }
public int RoomId { get; internal set; }
public string Name { get; internal set; }
}
}
}
8 changes: 8 additions & 0 deletions TsRandomizer/Randomisation/Requirement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ struct Requirement : IEquatable<Requirement>
{
static readonly Dictionary<Requirement, string> Flags;

public static readonly Requirement AllGates;

public static readonly Requirement None = 0UL;
public static readonly Requirement TimeStop = 1UL << 0;
public static readonly Requirement ForwardDash = 1UL << 1;
Expand Down Expand Up @@ -63,6 +65,12 @@ static Requirement()
.GetFields(BindingFlags.Public | BindingFlags.Static | BindingFlags.DeclaredOnly)
.Where(f => f.Name != nameof(None))
.ToDictionary(f => (Requirement)f.GetValue(null), f => f.Name);

AllGates = typeof(Requirement)
.GetFields(BindingFlags.Public | BindingFlags.Static | BindingFlags.DeclaredOnly)
.Where(f => f.Name.StartsWith("Gate"))
.Select(f => (Requirement)f.GetValue(null))
.Aggregate((a, b) => a | b);
}

Requirement(ulong flags)
Expand Down
56 changes: 56 additions & 0 deletions TsRandomizer/Randomisation/WarpNames.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
using System;

namespace TsRandomizer.Randomisation
{
static class WarpNames
{
public static string Get(Requirement gate)
{
//present
if (gate.Contains(Requirement.GateKittyBoss))
return "Sewers";
if (gate.Contains(Requirement.GateLeftLibrary))
return "Library";
if (gate.Contains(Requirement.GateMilitaryGate))
return "Military Hangar";
if (gate.Contains(Requirement.GateSealedCaves))
return "Xarion's Cave Entrance";
if (gate.Contains(Requirement.GateXarion))
return "Xarion";
if (gate.Contains(Requirement.GateSealedSirensCave))
return "Sirens' Cave";
if (gate.Contains(Requirement.GateLakeDesolation))
return "Lake Desolation";

//past
if (gate.Contains(Requirement.GateLakeSereneLeft))
return "Azure Queen";
if (gate.Contains(Requirement.GateAccessToPast))
return "Upper Caves of Banishment";
if (gate.Contains(Requirement.GateLakeSereneRight))
return "East Lake Serene";
//if (gate.Contains(R.))
// return "Refugee Camp";
if (gate.Contains(Requirement.GateCastleRamparts))
return "Castle Ramparts";
if (gate.Contains(Requirement.GateCastleKeep))
return "Castle Keep";
if (gate.Contains(Requirement.GateRoyalTowers))
return "Royal Towers";
if (gate.Contains(Requirement.GateMaw))
return "Maw's Lair";
if (gate.Contains(Requirement.GateCavesOfBanishment))
return "Maw's Cave Entrance";

//ancient pyramid
if (gate.Contains(Requirement.GateGyre))
return "Temporal Gyre Entrance";
if (gate.Contains(Requirement.GateLeftPyramid))
return "Ancient Pyramid Entrance";
if (gate.Contains(Requirement.GateRightPyramid))
return "Inner Ancient Pyramid";

throw new Exception($"Name for Gate {gate} is not defined");
}
}
}
50 changes: 45 additions & 5 deletions TsRandomizer/Screens/SaveSelectScreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -341,8 +341,11 @@ void OnSpoilerLogCreationAccepted(GameSave save)

var progressionItems = itemLocations.Where(l => l.ItemInfo.Unlocks != Requirement.None);
var otherItems = itemLocations.Where(l => l.ItemInfo.Unlocks == Requirement.None);
var warps = itemLocations.Where(l => Requirement.TeleportationGates.Contains(l.ItemInfo.Unlocks));
WriteWarps(file, warps, (TsRandomizer.Seed)seed);
var warpItems = itemLocations.Where(l => Requirement.AllGates.Contains(l.ItemInfo.Unlocks));

WriteWarps(file, warpItems);
WriteFloodedAreas(file, seed.Value);

var progressionChainLocations = new List<ItemLocation>();

WriteProgressionChain(file, itemLocations, progressionChainLocations);
Expand All @@ -354,6 +357,44 @@ void OnSpoilerLogCreationAccepted(GameSave save)
}
}

void WriteFloodedAreas(StreamWriter file, Seed seed)
{
file.WriteLine();
file.Write("Rising Tides: ");

if (!seed.Options.RisingTides)
{
file.WriteLine("Disabled");
}
else
{
var tides = seed.FloodFlags;

var strings = new List<string>();

if (tides.Basement)
strings.Add(tides.BasementHigh ? "Casle Basement (High)" : "Casle Basement");
if (tides.Xarion)
strings.Add("Xarion (boss)");
if (tides.Maw)
strings.Add("Maw (caves + boss)");
if (tides.PyramidShaft)
strings.Add("Ancient Pyramid Shaft");
if (tides.BackPyramid)
strings.Add("Sandman\\Nightmare (boss)");
if (tides.CastleMoat)
strings.Add("Castle Moat");
if (tides.CastleCourtyard)
strings.Add("Castle Courtyard");
if (tides.LakeDesolation)
strings.Add("Lake Desolation");
if (tides.DryLakeSerene)
strings.Add("Dry Lake Serene");

file.WriteLine(string.Join(", ", strings));
}
}

static void WriteProgressionChain(
StreamWriter file, ItemLocationMap itemLocations, List<ItemLocation> progressionChainLocations)
{
Expand Down Expand Up @@ -390,15 +431,14 @@ static void WriteItemList(StreamWriter file, IEnumerable<ItemLocation> itemLocat
file.WriteLine(prefix + itemLocation);
}

static void WriteWarps(StreamWriter file, IEnumerable<ItemLocation> itemLocations, Seed seed)
static void WriteWarps(StreamWriter file, IEnumerable<ItemLocation> itemLocations)
{
var defaultUnlockingMap = new DefaultItemUnlockingMap(seed);
file.WriteLine();
file.WriteLine("Warps:");

foreach (var itemLocation in itemLocations)
{
var warp = defaultUnlockingMap.GetWarpName(itemLocation.ItemInfo.Identifier);
var warp = WarpNames.Get(itemLocation.ItemInfo.Unlocks);
file.WriteLine($"{itemLocation} - {warp}");
}
}
Expand Down
1 change: 1 addition & 0 deletions TsRandomizer/TsRandomizer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@
<Compile Include="Archipelago\ArchipelagoUnlockingMap.cs" />
<Compile Include="Randomisation\SpriteManager.cs" />
<Compile Include="LevelObjects\Other\MajorUgly.cs" />
<Compile Include="Randomisation\WarpNames.cs" />
<Compile Include="RisingTides.cs" />
<Compile Include="Randomisation\BestiaryManager.cs" />
<Compile Include="RoomTriggers\Triggers\AncientPyramidPitWarp.cs" />
Expand Down

0 comments on commit 484ce1f

Please sign in to comment.