From a90286578c3c9786842c2d51ccc86737b7f5babb Mon Sep 17 00:00:00 2001 From: Kara Alexandra Date: Sun, 4 Jan 2026 00:43:18 -0600 Subject: [PATCH] Add DungeonMapRandomizer --- .dockerignore | 2 +- .gitmodules | 3 +++ ALttPRandomizer/Model/SeedSettings.cs | 25 +++++++++++++++++-- ALttPRandomizer/Program.cs | 1 + ALttPRandomizer/Randomizers/BaseRandomizer.cs | 14 +++++------ .../Settings/CommonSettingsProcessor.cs | 13 ++++++++++ ALttPRandomizer/appsettings.Docker.json | 5 ++-- BaseRandomizer | 2 +- Dockerfile | 8 ++++++ DungeonMapRandomizer | 1 + 10 files changed, 61 insertions(+), 13 deletions(-) create mode 160000 DungeonMapRandomizer diff --git a/.dockerignore b/.dockerignore index 79fe4c6..3ec5ed9 100644 --- a/.dockerignore +++ b/.dockerignore @@ -10,4 +10,4 @@ ALttPRandomizer/[Bb]in */DR_* */ER_* */OR_* -BaseRandomizer/data/base2current.json +*/data/base2current.json diff --git a/.gitmodules b/.gitmodules index ce65ba4..67db478 100644 --- a/.gitmodules +++ b/.gitmodules @@ -7,3 +7,6 @@ [submodule "Apr2025Randomizer"] path = Apr2025Randomizer url = https://github.com/ardnaxelarak/ALttPDoorRandomizer +[submodule "DungeonMapRandomizer"] + path = DungeonMapRandomizer + url = git@github.com:ardnaxelarak/ALttPDoorRandomizer diff --git a/ALttPRandomizer/Model/SeedSettings.cs b/ALttPRandomizer/Model/SeedSettings.cs index 93bc4f4..93722c8 100644 --- a/ALttPRandomizer/Model/SeedSettings.cs +++ b/ALttPRandomizer/Model/SeedSettings.cs @@ -125,7 +125,7 @@ public BookSettings Book { get; set; } = BookSettings.Normal; [SettingName("door_shuffle")] - [RequiredSetting([Apr2025], DoorShuffle.Vanilla)] + [RequiredSetting([Apr2025, DungeonMap], DoorShuffle.Vanilla)] [NoSettingName([Apr2025])] public DoorShuffle DoorShuffle { get; set; } = DoorShuffle.Vanilla; @@ -145,6 +145,14 @@ [RequiredSetting([Apr2025], FollowerShuffle.Vanilla)] public FollowerShuffle FollowerShuffle { get; set; } = FollowerShuffle.Vanilla; + [SettingName("ow_fluteshuffle")] + [NoSettingName([Apr2025])] + public FluteShuffle FluteShuffle { get; set; } = FluteShuffle.Vanilla; + + [NoSettingName] + [RequiredSetting([Apr2025], TileSwap.Vanilla)] + public TileSwap TileSwap { get; set; } = TileSwap.Vanilla; + [SettingName("damage_challenge")] [NoSettingName([Apr2025])] public DamageChallengeMode DamageChallenge { get; set; } = DamageChallengeMode.Normal; @@ -153,9 +161,11 @@ public Hints Hints { get; set; } = Hints.Off; } - public enum RandomizerInstance { + public enum RandomizerInstance + { [RandomizerName(BaseRandomizer.Name)] Base, [RandomizerName(Apr2025Randomizer.Name)] Apr2025, + [RandomizerName(BaseRandomizer.DungeonMapName)] DungeonMap, } public enum RaceMode { @@ -359,11 +369,22 @@ [SettingName("oneway")] RemoveAll, } + public enum FluteShuffle { + Vanilla, + Random, + Balanced, + } + public enum FollowerShuffle { Vanilla, [AdditionalSetting("--shuffle_followers")] Shuffled, } + public enum TileSwap { + Vanilla, + [AdditionalSetting("--ow_mixed")] TileSwap, + } + public enum DamageChallengeMode { Normal, OHKO, diff --git a/ALttPRandomizer/Program.cs b/ALttPRandomizer/Program.cs index 25b5424..7a0c9c8 100644 --- a/ALttPRandomizer/Program.cs +++ b/ALttPRandomizer/Program.cs @@ -71,6 +71,7 @@ builder.Services.AddSingleton(); builder.Services.AddKeyedScoped(BaseRandomizer.Name); + builder.Services.AddKeyedScoped(BaseRandomizer.DungeonMapName); builder.Services.AddKeyedScoped(Apr2025Randomizer.Name); builder.Services.AddScoped(); diff --git a/ALttPRandomizer/Randomizers/BaseRandomizer.cs b/ALttPRandomizer/Randomizers/BaseRandomizer.cs index f791f0d..fbdc540 100644 --- a/ALttPRandomizer/Randomizers/BaseRandomizer.cs +++ b/ALttPRandomizer/Randomizers/BaseRandomizer.cs @@ -16,7 +16,7 @@ public class BaseRandomizer : IRandomizer { public const string Name = "base"; - public const RandomizerInstance Instance = RandomizerInstance.Base; + public const string DungeonMapName = "dungeon_map"; public BaseRandomizer( AzureStorage azureStorage, @@ -39,7 +39,7 @@ private ServiceOptions Configuration => OptionsMonitor.CurrentValue; public void Validate(SeedSettings settings) { - this.SettingsProcessor.ValidateSettings(Instance, settings); + this.SettingsProcessor.ValidateSettings(settings.Randomizer, settings); } public void ValidateAll(IList settings) { @@ -63,7 +63,7 @@ settings.DoorTypeMode = DoorTypeMode.Original; } - foreach (var arg in SettingsProcessor.GetSettings(Instance, settings)) { + foreach (var arg in SettingsProcessor.GetSettings(settings.Randomizer, settings)) { args.Add(arg); } @@ -75,10 +75,10 @@ return args; } - private async Task StartProcess(string id, IEnumerable settings, Func completed) { + private async Task StartProcess(string randomizerName, string id, IEnumerable settings, Func completed) { var start = new ProcessStartInfo() { FileName = Configuration.PythonPath, - WorkingDirectory = Configuration.RandomizerPaths[Name], + WorkingDirectory = Configuration.RandomizerPaths[randomizerName], RedirectStandardOutput = true, RedirectStandardError = true, }; @@ -127,7 +127,7 @@ public async Task Randomize(string id, SeedSettings settings) { Logger.LogDebug("Recieved request for id {id} to randomize settings {@settings}", id, settings); - await StartProcess(id, this.GetArgs(settings), async exitcode => { + await StartProcess(this.SettingsProcessor.GetRandomizerName(settings.Randomizer), id, this.GetArgs(settings), async exitcode => { if (exitcode != 0) { await GenerationFailed(id, exitcode); } else { @@ -149,7 +149,7 @@ .Append(string.Format("--names={0}", string.Join(",", names))) .Append(string.Format("--multi={0}", settings.Count)); - await StartProcess(id, args, async exitcode => { + await StartProcess(Name, id, args, async exitcode => { if (exitcode != 0) { await GenerationFailed(id, exitcode); } else { diff --git a/ALttPRandomizer/Settings/CommonSettingsProcessor.cs b/ALttPRandomizer/Settings/CommonSettingsProcessor.cs index c08b17b..a47d54d 100644 --- a/ALttPRandomizer/Settings/CommonSettingsProcessor.cs +++ b/ALttPRandomizer/Settings/CommonSettingsProcessor.cs @@ -64,6 +64,19 @@ } } } + + public string GetRandomizerName(RandomizerInstance randomizer) + { + var fi = typeof(RandomizerInstance).GetField(randomizer.ToString(), BindingFlags.Static | BindingFlags.Public); + + var randomizerKey = fi?.GetCustomAttribute()?.Name; + + if (randomizerKey == null) { + throw new InvalidSettingsException("Invalid randomizer: {0}", randomizerKey); + } + + return randomizerKey; + } } public class SettingsLookupException : Exception { diff --git a/ALttPRandomizer/appsettings.Docker.json b/ALttPRandomizer/appsettings.Docker.json index aa6bec2..3dbe1af 100644 --- a/ALttPRandomizer/appsettings.Docker.json +++ b/ALttPRandomizer/appsettings.Docker.json @@ -14,7 +14,8 @@ }, "randomizerPaths": { "base": "/randomizer", - "apr2025": "/apr2025_randomizer" + "apr2025": "/apr2025_randomizer", + "dungeon_map": "/dungeon_map_randomizer" } }, "Serilog": { @@ -25,4 +26,4 @@ ], "Enrich": [ "FromLogContext", "WithMachineName", "WithThreadId" ] } -} \ No newline at end of file +} diff --git a/BaseRandomizer b/BaseRandomizer index 3782313..7bec1f8 160000 --- a/BaseRandomizer +++ b/BaseRandomizer @@ -1 +1 @@ -Subproject commit 37823134db60deeccdf098572de23769875b246c +Subproject commit 7bec1f899c25fa051b6da4ea63e81e50c34e56aa diff --git a/Dockerfile b/Dockerfile index 1cf3798..eee2cf3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -28,6 +28,10 @@ RUN mkdir -p /randomizer/data RUN touch /randomizer/data/base2current.json RUN chown $APP_UID:$APP_UID /randomizer/data/base2current.json +RUN mkdir -p /dungeon_map_randomizer/data +RUN touch /dungeon_map_randomizer/data/base2current.json +RUN chown $APP_UID:$APP_UID /dungeon_map_randomizer/data/base2current.json + USER $APP_UID RUN python3 -m ensurepip --upgrade @@ -43,6 +47,10 @@ COPY BaseRandomizer/ . WORKDIR /apr2025_randomizer COPY Apr2025Randomizer/ . +WORKDIR /dungeon_map_randomizer + +COPY DungeonMapRandomizer/ . + WORKDIR /app COPY --from=build /app/publish . COPY ALttPRandomizer/appsettings.Docker.json appsettings.json diff --git a/DungeonMapRandomizer b/DungeonMapRandomizer new file mode 160000 index 0000000..507f417 --- /dev/null +++ b/DungeonMapRandomizer @@ -0,0 +1 @@ +Subproject commit 507f4170c85ae69f0f8b4a59a06dfb3fe83665d6