Compare commits
8 Commits
38754f7417
...
9a40c9dc0f
| Author | SHA1 | Date | |
|---|---|---|---|
| 9a40c9dc0f | |||
| 28948fdc80 | |||
| adaeb9f377 | |||
| 101a60415c | |||
| 720cc469d4 | |||
| 96cebd2289 | |||
| e5fd52376e | |||
| f5f8e6a9d0 |
@@ -1,4 +1,5 @@
|
|||||||
scripts/
|
Dockerfile
|
||||||
|
justfile
|
||||||
|
|
||||||
ALttPRandomizer/appsettings.json
|
ALttPRandomizer/appsettings.json
|
||||||
ALttPRandomizer/appsettings.Development.json
|
ALttPRandomizer/appsettings.Development.json
|
||||||
@@ -10,4 +11,10 @@ ALttPRandomizer/[Bb]in
|
|||||||
*/DR_*
|
*/DR_*
|
||||||
*/ER_*
|
*/ER_*
|
||||||
*/OR_*
|
*/OR_*
|
||||||
*/data/base2current.json
|
*/GK_*
|
||||||
|
*.sfc
|
||||||
|
*_Spoiler.txt
|
||||||
|
|
||||||
|
!alttp.sfc
|
||||||
|
|
||||||
|
# */data/base2current.json
|
||||||
|
|||||||
10
.editorconfig
Normal file
10
.editorconfig
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
[*.cs]
|
||||||
|
|
||||||
|
# CA1822: Mark members as static
|
||||||
|
dotnet_diagnostic.CA1822.severity = none
|
||||||
|
|
||||||
|
# IDE0305: Simplify collection initialization
|
||||||
|
dotnet_style_prefer_collection_expression = never
|
||||||
|
|
||||||
|
# IDE0290: Use primary constructor
|
||||||
|
csharp_style_prefer_primary_constructors = false
|
||||||
1
.gitattributes
vendored
Normal file
1
.gitattributes
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
* text=auto
|
||||||
20
.gitmodules
vendored
20
.gitmodules
vendored
@@ -1,12 +1,16 @@
|
|||||||
[submodule "ALttPDoorRandomizer"]
|
|
||||||
path = ALttPDoorRandomizer
|
|
||||||
url = https://github.com/ardnaxelarak/ALttPDoorRandomizer
|
|
||||||
[submodule "BaseRandomizer"]
|
[submodule "BaseRandomizer"]
|
||||||
path = BaseRandomizer
|
path = BaseRandomizer
|
||||||
url = https://github.com/ardnaxelarak/ALttPDoorRandomizer
|
url = https://git.gwaa.kiwi/alttpr-gwaa-kiwi/alttpr-python
|
||||||
|
branch = main
|
||||||
[submodule "Apr2025Randomizer"]
|
[submodule "Apr2025Randomizer"]
|
||||||
path = Apr2025Randomizer
|
path = Apr2025Randomizer
|
||||||
url = https://github.com/ardnaxelarak/ALttPDoorRandomizer
|
url = https://git.gwaa.kiwi/alttpr-gwaa-kiwi/alttpr-python
|
||||||
[submodule "DungeonMapRandomizer"]
|
branch = apr_2025
|
||||||
path = DungeonMapRandomizer
|
[submodule "BetaRandomizer"]
|
||||||
url = git@github.com:ardnaxelarak/ALttPDoorRandomizer
|
path = BetaRandomizer
|
||||||
|
url = https://git.gwaa.kiwi/alttpr-gwaa-kiwi/alttpr-python
|
||||||
|
branch = beta
|
||||||
|
[submodule "PikitRandomizer"]
|
||||||
|
path = PikitRandomizer
|
||||||
|
url = https://git.gwaa.kiwi/alttpr-gwaa-kiwi/alttpr-python.git
|
||||||
|
branch = pikit
|
||||||
|
|||||||
@@ -1,10 +1,15 @@
|
|||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
# Visual Studio Version 17
|
# Visual Studio Version 17
|
||||||
VisualStudioVersion = 17.12.35521.163 d17.12
|
VisualStudioVersion = 17.12.35521.163
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ALttPRandomizer", "ALttPRandomizer\ALttPRandomizer.csproj", "{8F6F2C3C-ACE4-4944-9722-21E71222195A}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ALttPRandomizer", "ALttPRandomizer\ALttPRandomizer.csproj", "{8F6F2C3C-ACE4-4944-9722-21E71222195A}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{02EA681E-C7D8-13C7-8484-4AC65E1B71E8}"
|
||||||
|
ProjectSection(SolutionItems) = preProject
|
||||||
|
.editorconfig = .editorconfig
|
||||||
|
EndProjectSection
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
|||||||
@@ -2,6 +2,6 @@
|
|||||||
using System;
|
using System;
|
||||||
|
|
||||||
public class GenerationFailedException : Exception {
|
public class GenerationFailedException : Exception {
|
||||||
public GenerationFailedException(string message) : base(message) { }
|
public GenerationFailedException(string message, params string[] args) : base(string.Format(message, args)) { }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
public static class JsonOptions {
|
public static class JsonOptions {
|
||||||
public static JsonSerializerOptions Default = new JsonSerializerOptions(JsonSerializerDefaults.Web) {
|
public static readonly JsonSerializerOptions Default = new JsonSerializerOptions(JsonSerializerDefaults.Web) {
|
||||||
PropertyNamingPolicy = JsonNamingPolicy.SnakeCaseLower,
|
PropertyNamingPolicy = JsonNamingPolicy.SnakeCaseLower,
|
||||||
NumberHandling = JsonNumberHandling.Strict,
|
NumberHandling = JsonNumberHandling.Strict,
|
||||||
}.WithStringEnum();
|
}.WithStringEnum();
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
public RaceMode Race { get; set; } = RaceMode.Normal;
|
public RaceMode Race { get; set; } = RaceMode.Normal;
|
||||||
|
|
||||||
[ForbiddenSetting([Apr2025], Mode.Inverted)]
|
[ForbiddenSetting([Apr2025], Mode.Inverted)]
|
||||||
|
[RequiredSetting([Pikit], Mode.Open)]
|
||||||
public Mode Mode { get; set; } = Mode.Open;
|
public Mode Mode { get; set; } = Mode.Open;
|
||||||
|
|
||||||
[SettingName("swords")]
|
[SettingName("swords")]
|
||||||
@@ -26,52 +27,57 @@
|
|||||||
public Goal Goal { get; set; } = Goal.Ganon;
|
public Goal Goal { get; set; } = Goal.Ganon;
|
||||||
|
|
||||||
[SettingName("crystals_ganon")]
|
[SettingName("crystals_ganon")]
|
||||||
|
[IgnoreSetting(Apr2025)]
|
||||||
public EntryRequirement CrystalsGanon { get; set; } = EntryRequirement.Crystals7;
|
public EntryRequirement CrystalsGanon { get; set; } = EntryRequirement.Crystals7;
|
||||||
|
|
||||||
[SettingName("bosses_ganon")]
|
[SettingName("bosses_ganon")]
|
||||||
|
[IgnoreSetting(Apr2025)]
|
||||||
public BossRequirement BossesGanon { get; set; } = BossRequirement.Bosses8of10;
|
public BossRequirement BossesGanon { get; set; } = BossRequirement.Bosses8of10;
|
||||||
|
|
||||||
|
[NoSettingName]
|
||||||
|
[IgnoreSetting(Apr2025)]
|
||||||
|
public TriforceRequirement TriforcePieces { get; set; } = TriforceRequirement.Triforce20of30;
|
||||||
|
|
||||||
[SettingName("crystals_gt")]
|
[SettingName("crystals_gt")]
|
||||||
[JsonPropertyName("crystals_gt")]
|
[JsonPropertyName("crystals_gt")]
|
||||||
[NoSettingName([Apr2025])]
|
[IgnoreSetting(Apr2025)]
|
||||||
public EntryRequirement CrystalsGT { get; set; } = EntryRequirement.Crystals7;
|
public EntryRequirement CrystalsGT { get; set; } = EntryRequirement.Crystals7;
|
||||||
|
|
||||||
[SettingName("ganon_item")]
|
[SettingName("ganon_item")]
|
||||||
[RequiredSetting([Apr2025], GanonItem.Silver)]
|
[IgnoreSetting(Apr2025)]
|
||||||
[NoSettingName([Apr2025])]
|
|
||||||
public GanonItem GanonItem { get; set; } = GanonItem.Silver;
|
public GanonItem GanonItem { get; set; } = GanonItem.Silver;
|
||||||
|
|
||||||
[SettingName("shuffle")]
|
[SettingName("shuffle")]
|
||||||
[ForbiddenSetting([Apr2025], EntranceShuffle.Swapped)]
|
[ForbiddenSetting([Apr2025], EntranceShuffle.Swapped)]
|
||||||
public EntranceShuffle EntranceShuffle { get; set; } = EntranceShuffle.Vanilla;
|
public EntranceShuffle EntranceShuffle { get; set; } = EntranceShuffle.Vanilla;
|
||||||
|
|
||||||
|
[SettingName("overworld_map")]
|
||||||
|
[IgnoreSetting(Apr2025)]
|
||||||
|
public OverworldMapDungeons OverworldMapDungeons { get; set; } = OverworldMapDungeons.Vanilla;
|
||||||
|
|
||||||
[NoSettingName]
|
[NoSettingName]
|
||||||
[RequiredSetting([Apr2025], LinksHouse.Vanilla)]
|
[IgnoreSetting(Apr2025)]
|
||||||
public LinksHouse LinksHouse { get; set; } = LinksHouse.Vanilla;
|
public LinksHouse LinksHouse { get; set; } = LinksHouse.Vanilla;
|
||||||
|
|
||||||
[SettingName("skullwoods")]
|
[SettingName("skullwoods")]
|
||||||
[RequiredSetting([Apr2025], SkullWoodsShuffle.Original)]
|
[IgnoreSetting(Apr2025)]
|
||||||
[NoSettingName([Apr2025])]
|
public SkullWoodsShuffle SkullWoods { get; set; } = SkullWoodsShuffle.Default;
|
||||||
public SkullWoodsShuffle SkullWoods { get; set; } = SkullWoodsShuffle.Original;
|
|
||||||
|
|
||||||
[SettingName("linked_drops")]
|
[SettingName("linked_drops")]
|
||||||
[RequiredSetting([Apr2025], LinkedDrops.Unset)]
|
[IgnoreSetting(Apr2025)]
|
||||||
[NoSettingName([Apr2025])]
|
public LinkedDrops LinkedDrops { get; set; } = LinkedDrops.Default;
|
||||||
public LinkedDrops LinkedDrops { get; set; } = LinkedDrops.Unset;
|
|
||||||
|
|
||||||
[SettingName("shufflebosses")]
|
[SettingName("shufflebosses")]
|
||||||
[RequiredSetting([Apr2025], BossShuffle.Vanilla)]
|
[IgnoreSetting(Apr2025)]
|
||||||
[NoSettingName([Apr2025])]
|
|
||||||
public BossShuffle BossShuffle { get; set; } = BossShuffle.Vanilla;
|
public BossShuffle BossShuffle { get; set; } = BossShuffle.Vanilla;
|
||||||
|
|
||||||
[SettingName("shuffleenemies")]
|
[SettingName("shuffleenemies")]
|
||||||
[RequiredSetting([Apr2025], EnemyShuffle.Vanilla)]
|
[IgnoreSetting(Apr2025)]
|
||||||
[NoSettingName([Apr2025])]
|
[RequiredSetting([Pikit], EnemyShuffle.Vanilla)]
|
||||||
public EnemyShuffle EnemyShuffle { get; set; } = EnemyShuffle.Vanilla;
|
public EnemyShuffle EnemyShuffle { get; set; } = EnemyShuffle.Vanilla;
|
||||||
|
|
||||||
[SettingName("shuffle_damage_table")]
|
[SettingName("shuffle_damage_table")]
|
||||||
[RequiredSetting([Apr2025], DamageTableShuffle.Vanilla)]
|
[IgnoreSetting(Apr2025)]
|
||||||
[NoSettingName([Apr2025])]
|
|
||||||
public DamageTableShuffle DamageTableShuffle { get; set; } = DamageTableShuffle.Vanilla;
|
public DamageTableShuffle DamageTableShuffle { get; set; } = DamageTableShuffle.Vanilla;
|
||||||
|
|
||||||
[SettingName("keyshuffle")]
|
[SettingName("keyshuffle")]
|
||||||
@@ -80,44 +86,38 @@
|
|||||||
public KeyLocations SmallKeys { get; set; } = KeyLocations.Dungeon;
|
public KeyLocations SmallKeys { get; set; } = KeyLocations.Dungeon;
|
||||||
|
|
||||||
[SettingName("bigkeyshuffle")]
|
[SettingName("bigkeyshuffle")]
|
||||||
[RequiredSetting([Apr2025], DungeonItemLocations.Dungeon)]
|
[IgnoreSetting(Apr2025)]
|
||||||
[NoSettingName([Apr2025])]
|
|
||||||
public DungeonItemLocations BigKeys { get; set; } = DungeonItemLocations.Dungeon;
|
public DungeonItemLocations BigKeys { get; set; } = DungeonItemLocations.Dungeon;
|
||||||
|
|
||||||
[SettingName("mapshuffle")]
|
[SettingName("mapshuffle")]
|
||||||
[RequiredSetting([Apr2025], DungeonItemLocations.Dungeon)]
|
[IgnoreSetting(Apr2025)]
|
||||||
[NoSettingName([Apr2025])]
|
|
||||||
public DungeonItemLocations Maps { get; set; } = DungeonItemLocations.Dungeon;
|
public DungeonItemLocations Maps { get; set; } = DungeonItemLocations.Dungeon;
|
||||||
|
|
||||||
[SettingName("compassshuffle")]
|
[SettingName("compassshuffle")]
|
||||||
[RequiredSetting([Apr2025], DungeonItemLocations.Dungeon)]
|
[IgnoreSetting(Apr2025)]
|
||||||
[NoSettingName([Apr2025])]
|
|
||||||
public DungeonItemLocations Compasses { get; set; } = DungeonItemLocations.Dungeon;
|
public DungeonItemLocations Compasses { get; set; } = DungeonItemLocations.Dungeon;
|
||||||
|
|
||||||
[SettingName("showloot")]
|
[SettingName("showloot")]
|
||||||
[RequiredSetting([Apr2025, Base], ShowLoot.Never)]
|
[IgnoreSetting(Apr2025)]
|
||||||
[NoSettingName([Apr2025, Base])]
|
|
||||||
public ShowLoot ShowLoot { get; set; } = ShowLoot.Never;
|
public ShowLoot ShowLoot { get; set; } = ShowLoot.Never;
|
||||||
|
|
||||||
[SettingName("showmap")]
|
[SettingName("showmap")]
|
||||||
[RequiredSetting([Apr2025, Base], ShowMap.Map)]
|
[IgnoreSetting(Apr2025)]
|
||||||
[NoSettingName([Apr2025, Base])]
|
|
||||||
public ShowMap ShowMap { get; set; } = ShowMap.Map;
|
public ShowMap ShowMap { get; set; } = ShowMap.Map;
|
||||||
|
|
||||||
[NoSettingName]
|
[NoSettingName]
|
||||||
[RequiredSetting([Apr2025], ShopShuffle.Vanilla)]
|
[IgnoreSetting(Apr2025)]
|
||||||
public ShopShuffle ShopShuffle { get; set; } = ShopShuffle.Vanilla;
|
public ShopShuffle ShopShuffle { get; set; } = ShopShuffle.Vanilla;
|
||||||
|
|
||||||
[RequiredSetting([Apr2025], DropShuffle.Vanilla)]
|
[IgnoreSetting(Apr2025)]
|
||||||
[NoSettingName([Apr2025])]
|
|
||||||
public DropShuffle DropShuffle { get; set; } = DropShuffle.Vanilla;
|
public DropShuffle DropShuffle { get; set; } = DropShuffle.Vanilla;
|
||||||
|
|
||||||
[RequiredSetting([Apr2025], Pottery.Vanilla)]
|
[SettingName("pottery")]
|
||||||
[NoSettingName([Apr2025])]
|
[IgnoreSetting(Apr2025)]
|
||||||
public Pottery Pottery { get; set; } = Pottery.Vanilla;
|
public PotShuffle PotShuffle { get; set; } = PotShuffle.Vanilla;
|
||||||
|
|
||||||
[RequiredSetting([Apr2025], PrizeShuffle.Vanilla)]
|
[IgnoreSetting(Apr2025)]
|
||||||
[NoSettingName([Apr2025])]
|
[RequiredSetting([Pikit], PrizeShuffle.Vanilla)]
|
||||||
public PrizeShuffle PrizeShuffle { get; set; } = PrizeShuffle.Vanilla;
|
public PrizeShuffle PrizeShuffle { get; set; } = PrizeShuffle.Vanilla;
|
||||||
|
|
||||||
[NoSettingName]
|
[NoSettingName]
|
||||||
@@ -125,68 +125,86 @@
|
|||||||
public BootsSettings Boots { get; set; } = BootsSettings.Normal;
|
public BootsSettings Boots { get; set; } = BootsSettings.Normal;
|
||||||
|
|
||||||
[NoSettingName]
|
[NoSettingName]
|
||||||
[RequiredSetting([Apr2025], FluteSettings.Normal)]
|
[IgnoreSetting(Apr2025)]
|
||||||
public FluteSettings Flute { get; set; } = FluteSettings.Normal;
|
public FluteSettings Flute { get; set; } = FluteSettings.Normal;
|
||||||
|
|
||||||
[SettingName("dark_rooms")]
|
[SettingName("dark_rooms")]
|
||||||
[RequiredSetting([Apr2025], DarkRoomSettings.RequireLamp)]
|
[IgnoreSetting(Apr2025)]
|
||||||
[NoSettingName([Apr2025])]
|
|
||||||
public DarkRoomSettings DarkRooms { get; set; } = DarkRoomSettings.RequireLamp;
|
public DarkRoomSettings DarkRooms { get; set; } = DarkRoomSettings.RequireLamp;
|
||||||
|
|
||||||
[NoSettingName]
|
[NoSettingName]
|
||||||
[RequiredSetting([Apr2025], BombSettings.Normal)]
|
[IgnoreSetting(Apr2025)]
|
||||||
public BombSettings Bombs { get; set; } = BombSettings.Normal;
|
public BombSettings Bombs { get; set; } = BombSettings.Normal;
|
||||||
|
|
||||||
[NoSettingName]
|
[NoSettingName]
|
||||||
[RequiredSetting([Apr2025], BookSettings.Normal)]
|
[IgnoreSetting(Apr2025)]
|
||||||
public BookSettings Book { get; set; } = BookSettings.Normal;
|
public BookSettings Book { get; set; } = BookSettings.Normal;
|
||||||
|
|
||||||
[NoSettingName]
|
[NoSettingName]
|
||||||
[RequiredSetting([Apr2025], MirrorSettings.Normal)]
|
[IgnoreSetting(Apr2025)]
|
||||||
public MirrorSettings Mirror { get; set; } = MirrorSettings.Normal;
|
public MirrorSettings Mirror { get; set; } = MirrorSettings.Normal;
|
||||||
|
|
||||||
[SettingName("door_shuffle")]
|
[SettingName("door_shuffle")]
|
||||||
[RequiredSetting([Apr2025], DoorShuffle.Vanilla)]
|
[IgnoreSetting(Apr2025)]
|
||||||
[NoSettingName([Apr2025])]
|
|
||||||
public DoorShuffle DoorShuffle { get; set; } = DoorShuffle.Vanilla;
|
public DoorShuffle DoorShuffle { get; set; } = DoorShuffle.Vanilla;
|
||||||
|
|
||||||
[SettingName("intensity")]
|
[SettingName("intensity")]
|
||||||
[NoSettingName([Apr2025])]
|
[IgnoreSetting(Apr2025)]
|
||||||
public DoorLobbies Lobbies { get; set; } = DoorLobbies.Vanilla;
|
public DoorLobbies Lobbies { get; set; } = DoorLobbies.Vanilla;
|
||||||
|
|
||||||
[SettingName("door_type_mode")]
|
[SettingName("door_type_mode")]
|
||||||
[NoSettingName([Apr2025])]
|
[IgnoreSetting(Apr2025)]
|
||||||
public DoorTypeMode DoorTypeMode { get; set; } = DoorTypeMode.Big;
|
public DoorTypeMode DoorTypeMode { get; set; } = DoorTypeMode.Big;
|
||||||
|
|
||||||
[SettingName("trap_door_mode")]
|
[SettingName("trap_door_mode")]
|
||||||
[NoSettingName([Apr2025])]
|
[IgnoreSetting(Apr2025)]
|
||||||
public TrapDoorMode TrapDoorMode { get; set; } = TrapDoorMode.Optional;
|
public TrapDoorMode TrapDoorMode { get; set; } = TrapDoorMode.Some;
|
||||||
|
|
||||||
[NoSettingName]
|
[NoSettingName]
|
||||||
[RequiredSetting([Apr2025], FollowerShuffle.Vanilla)]
|
[IgnoreSetting(Apr2025)]
|
||||||
public FollowerShuffle FollowerShuffle { get; set; } = FollowerShuffle.Vanilla;
|
public FollowerShuffle FollowerShuffle { get; set; } = FollowerShuffle.Vanilla;
|
||||||
|
|
||||||
[SettingName("ow_fluteshuffle")]
|
[SettingName("ow_fluteshuffle")]
|
||||||
[NoSettingName([Apr2025])]
|
[IgnoreSetting(Apr2025)]
|
||||||
public FluteShuffle FluteShuffle { get; set; } = FluteShuffle.Vanilla;
|
public FluteShuffle FluteShuffle { get; set; } = FluteShuffle.Vanilla;
|
||||||
|
|
||||||
|
[SettingName("ow_layout")]
|
||||||
|
[IgnoreSetting(Apr2025, Base)]
|
||||||
|
public OverworldLayout OverworldLayout { get; set; } = OverworldLayout.Vanilla;
|
||||||
|
|
||||||
[NoSettingName]
|
[NoSettingName]
|
||||||
[RequiredSetting([Apr2025], TileSwap.Vanilla)]
|
[IgnoreSetting(Apr2025, Base)]
|
||||||
|
public OverworldWorldLayouts OverworldWorldLayouts { get; set; } = OverworldWorldLayouts.Parallel;
|
||||||
|
|
||||||
|
[NoSettingName]
|
||||||
|
[IgnoreSetting(Apr2025, Base)]
|
||||||
|
public OverworldLayoutTerrain OverworldLayoutTerrain { get; set; } = OverworldLayoutTerrain.SameOnly;
|
||||||
|
|
||||||
|
[NoSettingName]
|
||||||
|
[IgnoreSetting(Apr2025, Base)]
|
||||||
|
public OverworldLayoutEdges OverworldLayoutEdges { get; set; } = OverworldLayoutEdges.Unrestricted;
|
||||||
|
|
||||||
|
[NoSettingName]
|
||||||
|
[IgnoreSetting(Apr2025, Base)]
|
||||||
|
public OverworldMapFog OverworldMapFog { get; set; } = OverworldMapFog.Fog;
|
||||||
|
|
||||||
|
[NoSettingName]
|
||||||
|
[IgnoreSetting(Apr2025, Pikit)]
|
||||||
public TileSwap TileSwap { get; set; } = TileSwap.Vanilla;
|
public TileSwap TileSwap { get; set; } = TileSwap.Vanilla;
|
||||||
|
|
||||||
[SettingName("damage_challenge")]
|
[SettingName("damage_challenge")]
|
||||||
[NoSettingName([Apr2025])]
|
[IgnoreSetting(Apr2025)]
|
||||||
public DamageChallengeMode DamageChallenge { get; set; } = DamageChallengeMode.Normal;
|
public DamageChallengeMode DamageChallenge { get; set; } = DamageChallengeMode.Normal;
|
||||||
|
|
||||||
[NoSettingName]
|
[NoSettingName]
|
||||||
public Hints Hints { get; set; } = Hints.Off;
|
public Hints Hints { get; set; } = Hints.Off;
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum RandomizerInstance
|
public enum RandomizerInstance {
|
||||||
{
|
[GeneratorSettings("base", "GK_", "--bps", "--spoiler=json")] Base,
|
||||||
[RandomizerName(BaseRandomizer.Name)] Base,
|
[GeneratorSettings("beta", "GK_", "--bps", "--spoiler=json")] Beta,
|
||||||
[RandomizerName(Apr2025Randomizer.Name)] Apr2025,
|
[GeneratorSettings("pikit", "GK_", "--bps", "--spoiler=json")] Pikit,
|
||||||
[RandomizerName(BaseRandomizer.DungeonMapName)] DungeonMap,
|
[GeneratorSettings("apr2025", "ER_", requireFlips: true, "--json_spoiler")] Apr2025,
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum RaceMode {
|
public enum RaceMode {
|
||||||
@@ -233,6 +251,14 @@
|
|||||||
Random,
|
Random,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public enum TriforceRequirement {
|
||||||
|
[JsonStringEnumMemberName("8of10")] [AdditionalSetting("--triforce_goal=8", "--triforce_pool=10")] Triforce8of10,
|
||||||
|
[JsonStringEnumMemberName("20of30")] [AdditionalSetting("--triforce_goal=20", "--triforce_pool=30")] Triforce20of30,
|
||||||
|
[JsonStringEnumMemberName("67of100")] [AdditionalSetting("--triforce_goal=67", "--triforce_pool=100")] Triforce67of100,
|
||||||
|
[JsonStringEnumMemberName("125of175")] [AdditionalSetting("--triforce_goal=125", "--triforce_pool=175")] Triforce125of175,
|
||||||
|
[JsonStringEnumMemberName("400of500")] [AdditionalSetting("--triforce_goal=400", "--triforce_pool=500")] Triforce400of500,
|
||||||
|
}
|
||||||
|
|
||||||
public enum BossRequirement {
|
public enum BossRequirement {
|
||||||
[JsonStringEnumMemberName("0of10")] [SettingName("0")] Bosses0of10,
|
[JsonStringEnumMemberName("0of10")] [SettingName("0")] Bosses0of10,
|
||||||
[JsonStringEnumMemberName("1of10")] [SettingName("1")] Bosses1of10,
|
[JsonStringEnumMemberName("1of10")] [SettingName("1")] Bosses1of10,
|
||||||
@@ -287,20 +313,26 @@
|
|||||||
[SettingName("insanity")] Decoupled,
|
[SettingName("insanity")] Decoupled,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public enum OverworldMapDungeons {
|
||||||
|
[SettingName("default")] Vanilla,
|
||||||
|
Compass,
|
||||||
|
Map,
|
||||||
|
}
|
||||||
|
|
||||||
public enum LinksHouse {
|
public enum LinksHouse {
|
||||||
Vanilla,
|
Vanilla,
|
||||||
[AdditionalSetting("--shufflelinks")] Shuffled,
|
[AdditionalSetting("--shufflelinks")] Shuffled,
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum SkullWoodsShuffle {
|
public enum SkullWoodsShuffle {
|
||||||
Original,
|
[SettingName("original")] Default,
|
||||||
Restricted,
|
[SettingName("restricted")] VanillaDrops,
|
||||||
Loose,
|
Loose,
|
||||||
FollowLinked,
|
[SettingName("followlinked")] Chaos,
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum LinkedDrops {
|
public enum LinkedDrops {
|
||||||
Unset,
|
[SettingName("unset")] Default,
|
||||||
Linked,
|
Linked,
|
||||||
Independent,
|
Independent,
|
||||||
}
|
}
|
||||||
@@ -348,7 +380,7 @@
|
|||||||
Underworld,
|
Underworld,
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum Pottery {
|
public enum PotShuffle {
|
||||||
[SettingName("none")] Vanilla,
|
[SettingName("none")] Vanilla,
|
||||||
[AdditionalSetting("--colorizepots")] Keys,
|
[AdditionalSetting("--colorizepots")] Keys,
|
||||||
[AdditionalSetting("--colorizepots")] Cave,
|
[AdditionalSetting("--colorizepots")] Cave,
|
||||||
@@ -357,7 +389,7 @@
|
|||||||
[AdditionalSetting("--colorizepots")] Clustered,
|
[AdditionalSetting("--colorizepots")] Clustered,
|
||||||
[AdditionalSetting("--colorizepots")] NonEmpty,
|
[AdditionalSetting("--colorizepots")] NonEmpty,
|
||||||
[AdditionalSetting("--colorizepots")] Dungeon,
|
[AdditionalSetting("--colorizepots")] Dungeon,
|
||||||
Lottery,
|
[SettingName("lottery")] All,
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum PrizeShuffle {
|
public enum PrizeShuffle {
|
||||||
@@ -404,7 +436,7 @@
|
|||||||
[SettingName("always_light_cone")] AlwaysLightCone,
|
[SettingName("always_light_cone")] AlwaysLightCone,
|
||||||
[SettingName("no_dark_rooms")] NoDarkRooms,
|
[SettingName("no_dark_rooms")] NoDarkRooms,
|
||||||
[SettingName("require_lamp")] [AddStartingItems("Lamp")] StartingLamp,
|
[SettingName("require_lamp")] [AddStartingItems("Lamp")] StartingLamp,
|
||||||
[SettingName("always_in_logic")] AlwaysInLogic,
|
[SettingName("always_in_logic")] DarkInLogic,
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum BombSettings {
|
public enum BombSettings {
|
||||||
@@ -439,7 +471,7 @@
|
|||||||
|
|
||||||
public enum TrapDoorMode {
|
public enum TrapDoorMode {
|
||||||
Vanilla,
|
Vanilla,
|
||||||
Optional,
|
[SettingName("optional")] Some,
|
||||||
Boss,
|
Boss,
|
||||||
[SettingName("oneway")] RemoveAll,
|
[SettingName("oneway")] RemoveAll,
|
||||||
}
|
}
|
||||||
@@ -460,6 +492,32 @@
|
|||||||
[AdditionalSetting("--ow_mixed")] TileSwap,
|
[AdditionalSetting("--ow_mixed")] TileSwap,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public enum OverworldLayout {
|
||||||
|
Vanilla,
|
||||||
|
[SettingName("grid")] ShuffledGrid,
|
||||||
|
[SettingName("wild")] Shuffled,
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum OverworldWorldLayouts {
|
||||||
|
Parallel,
|
||||||
|
[AdditionalSetting("--ow_unparallel")] Independent,
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum OverworldLayoutEdges {
|
||||||
|
Unrestricted,
|
||||||
|
[AdditionalSetting("--ow_keepsimilar")] Grouped,
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum OverworldLayoutTerrain {
|
||||||
|
SameOnly,
|
||||||
|
[AdditionalSetting("--ow_terrain")] AllowMixed,
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum OverworldMapFog {
|
||||||
|
Fog,
|
||||||
|
[AdditionalSetting("--ow_no_fog")] NoFog,
|
||||||
|
}
|
||||||
|
|
||||||
public enum DamageChallengeMode {
|
public enum DamageChallengeMode {
|
||||||
Normal,
|
Normal,
|
||||||
OHKO,
|
OHKO,
|
||||||
|
|||||||
@@ -4,11 +4,15 @@
|
|||||||
|
|
||||||
public class ServiceOptions {
|
public class ServiceOptions {
|
||||||
public string Baserom { get; set; } = null!;
|
public string Baserom { get; set; } = null!;
|
||||||
public string PythonPath { get; set; } = null!;
|
|
||||||
public string FlipsPath { get; set; } = null!;
|
public string FlipsPath { get; set; } = null!;
|
||||||
public IList<string> AllowedCors { get; set; } = new List<string>();
|
public List<string> AllowedCors { get; set; } = [];
|
||||||
public AzureSettings AzureSettings { get; set; } = new AzureSettings();
|
public AzureSettings AzureSettings { get; set; } = new();
|
||||||
public IDictionary<string, string> RandomizerPaths { get; set; } = new Dictionary<string, string>();
|
public Dictionary<string, GeneratorSettings> Generators { get; set; } = new();
|
||||||
|
}
|
||||||
|
|
||||||
|
public class GeneratorSettings {
|
||||||
|
public string WorkingDirectory { get; set; } = null!;
|
||||||
|
public List<string> RandomizerCommand { get; set; } = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
public class AzureSettings {
|
public class AzureSettings {
|
||||||
|
|||||||
@@ -12,7 +12,6 @@
|
|||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
using Serilog;
|
using Serilog;
|
||||||
using System.Linq;
|
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
@@ -69,13 +68,10 @@
|
|||||||
builder.Services.AddSingleton(sp => sp);
|
builder.Services.AddSingleton(sp => sp);
|
||||||
builder.Services.AddSingleton<AzureStorage>();
|
builder.Services.AddSingleton<AzureStorage>();
|
||||||
builder.Services.AddSingleton<CommonSettingsProcessor>();
|
builder.Services.AddSingleton<CommonSettingsProcessor>();
|
||||||
|
builder.Services.AddSingleton<ProcessService>();
|
||||||
builder.Services.AddSingleton<ShutdownHandler>();
|
builder.Services.AddSingleton<ShutdownHandler>();
|
||||||
|
|
||||||
builder.Services.AddKeyedScoped<IRandomizer, BaseRandomizer>(BaseRandomizer.Name);
|
|
||||||
builder.Services.AddKeyedScoped<IRandomizer, BaseRandomizer>(BaseRandomizer.DungeonMapName);
|
|
||||||
builder.Services.AddKeyedScoped<IRandomizer, Apr2025Randomizer>(Apr2025Randomizer.Name);
|
|
||||||
builder.Services.AddScoped<BaseRandomizer>();
|
builder.Services.AddScoped<BaseRandomizer>();
|
||||||
|
|
||||||
builder.Services.AddScoped<RandomizeService>();
|
builder.Services.AddScoped<RandomizeService>();
|
||||||
builder.Services.AddScoped<SeedService>();
|
builder.Services.AddScoped<SeedService>();
|
||||||
builder.Services.AddScoped<IdGenerator>();
|
builder.Services.AddScoped<IdGenerator>();
|
||||||
|
|||||||
@@ -1,161 +0,0 @@
|
|||||||
namespace ALttPRandomizer.Randomizers {
|
|
||||||
using ALttPRandomizer;
|
|
||||||
using ALttPRandomizer.Azure;
|
|
||||||
using ALttPRandomizer.Model;
|
|
||||||
using ALttPRandomizer.Options;
|
|
||||||
using ALttPRandomizer.Settings;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using Microsoft.Extensions.Options;
|
|
||||||
using System;
|
|
||||||
using System.Diagnostics;
|
|
||||||
using System.IO;
|
|
||||||
using System.Text.Json;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
public class Apr2025Randomizer : IRandomizer {
|
|
||||||
public const string Name = "apr2025";
|
|
||||||
public const RandomizerInstance Instance = RandomizerInstance.Apr2025;
|
|
||||||
|
|
||||||
public Apr2025Randomizer(
|
|
||||||
AzureStorage azureStorage,
|
|
||||||
CommonSettingsProcessor settingsProcessor,
|
|
||||||
IOptionsMonitor<ServiceOptions> optionsMonitor,
|
|
||||||
ILogger<BaseRandomizer> logger) {
|
|
||||||
AzureStorage = azureStorage;
|
|
||||||
SettingsProcessor = settingsProcessor;
|
|
||||||
OptionsMonitor = optionsMonitor;
|
|
||||||
Logger = logger;
|
|
||||||
}
|
|
||||||
|
|
||||||
private CommonSettingsProcessor SettingsProcessor { get; }
|
|
||||||
private AzureStorage AzureStorage { get; }
|
|
||||||
private IOptionsMonitor<ServiceOptions> OptionsMonitor { get; }
|
|
||||||
private ILogger<BaseRandomizer> Logger { get; }
|
|
||||||
private ServiceOptions Configuration => OptionsMonitor.CurrentValue;
|
|
||||||
|
|
||||||
public void Validate(SeedSettings settings) {
|
|
||||||
this.SettingsProcessor.ValidateSettings(Instance, settings);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task Randomize(string id, SeedSettings settings, bool uploadSettings = true) {
|
|
||||||
Logger.LogDebug("Recieved request for id {id} to randomize settings {@settings}", id, settings);
|
|
||||||
|
|
||||||
var start = new ProcessStartInfo() {
|
|
||||||
FileName = Configuration.PythonPath,
|
|
||||||
WorkingDirectory = Configuration.RandomizerPaths[Name],
|
|
||||||
RedirectStandardOutput = true,
|
|
||||||
RedirectStandardError = true,
|
|
||||||
};
|
|
||||||
|
|
||||||
var args = start.ArgumentList;
|
|
||||||
args.Add("EntranceRandomizer.py");
|
|
||||||
args.Add("--rom");
|
|
||||||
args.Add(Configuration.Baserom);
|
|
||||||
|
|
||||||
args.Add("--outputpath");
|
|
||||||
args.Add(Path.GetTempPath());
|
|
||||||
|
|
||||||
args.Add("--outputname");
|
|
||||||
args.Add(id);
|
|
||||||
|
|
||||||
args.Add("--json_spoiler");
|
|
||||||
|
|
||||||
args.Add("--quickswap");
|
|
||||||
|
|
||||||
foreach (var arg in SettingsProcessor.GetSettings(Instance, settings)) {
|
|
||||||
args.Add(arg);
|
|
||||||
}
|
|
||||||
|
|
||||||
Logger.LogInformation("Randomizing with args: {args}", string.Join(" ", args));
|
|
||||||
|
|
||||||
var generating = string.Format("{0}/generating", id);
|
|
||||||
await AzureStorage.UploadFile(generating, BinaryData.Empty);
|
|
||||||
|
|
||||||
var process = Process.Start(start) ?? throw new GenerationFailedException("Process failed to start.");
|
|
||||||
process.EnableRaisingEvents = true;
|
|
||||||
|
|
||||||
process.OutputDataReceived += (_, args) => Logger.LogInformation("Randomizer STDOUT: {output}", args.Data);
|
|
||||||
process.ErrorDataReceived += (_, args) => Logger.LogInformation("Randomizer STDERR: {output}", args.Data);
|
|
||||||
|
|
||||||
process.BeginOutputReadLine();
|
|
||||||
process.BeginErrorReadLine();
|
|
||||||
|
|
||||||
process.Exited += async (sender, args) => {
|
|
||||||
var exitcode = process.ExitCode;
|
|
||||||
|
|
||||||
if (exitcode != 0) {
|
|
||||||
await GenerationFailed(id, exitcode);
|
|
||||||
} else {
|
|
||||||
await GenerationSucceeded(id, settings);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
if (uploadSettings) {
|
|
||||||
var settingsJson = JsonSerializer.SerializeToDocument(settings, JsonOptions.Default);
|
|
||||||
var settingsOut = string.Format("{0}/settings.json", id);
|
|
||||||
await AzureStorage.UploadFile(settingsOut, new BinaryData(settingsJson));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task GenerationSucceeded(string id, SeedSettings settings) {
|
|
||||||
var rom = Path.Join(Path.GetTempPath(), string.Format("ER_{0}.sfc", id));
|
|
||||||
|
|
||||||
var spoilerIn = Path.Join(Path.GetTempPath(), string.Format("ER_{0}_Spoiler.json", id));
|
|
||||||
var spoilerOut = string.Format("{0}/spoiler.json", id);
|
|
||||||
var uploadSpoiler = AzureStorage.UploadFileAndDelete(spoilerOut, spoilerIn);
|
|
||||||
|
|
||||||
var metaIn = Path.Join(Path.GetTempPath(), string.Format("ER_{0}_Meta.json", id));
|
|
||||||
var metaOut = string.Format("{0}/meta.json", id);
|
|
||||||
var uploadMeta = AzureStorage.UploadFileAndDelete(metaOut, metaIn);
|
|
||||||
|
|
||||||
var bpsIn = Path.Join(Path.GetTempPath(), string.Format("ER_{0}.bps", id));
|
|
||||||
|
|
||||||
var flips = new ProcessStartInfo() {
|
|
||||||
FileName = Configuration.FlipsPath,
|
|
||||||
RedirectStandardOutput = true,
|
|
||||||
RedirectStandardError = true,
|
|
||||||
};
|
|
||||||
var args = flips.ArgumentList;
|
|
||||||
args.Add("--create");
|
|
||||||
args.Add(Configuration.Baserom);
|
|
||||||
args.Add(rom);
|
|
||||||
args.Add(bpsIn);
|
|
||||||
|
|
||||||
var process = Process.Start(flips) ?? throw new GenerationFailedException("Process failed to start.");
|
|
||||||
process.EnableRaisingEvents = true;
|
|
||||||
|
|
||||||
process.OutputDataReceived += (_, args) => Logger.LogInformation("flips STDOUT: {output}", args.Data);
|
|
||||||
process.ErrorDataReceived += (_, args) => Logger.LogInformation("flips STDERR: {output}", args.Data);
|
|
||||||
|
|
||||||
process.BeginOutputReadLine();
|
|
||||||
process.BeginErrorReadLine();
|
|
||||||
|
|
||||||
await process.WaitForExitAsync();
|
|
||||||
|
|
||||||
if (process.ExitCode != 0) {
|
|
||||||
await this.GenerationFailed(id, process.ExitCode);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var bpsOut = string.Format("{0}/patch.bps", id);
|
|
||||||
var uploadPatch = AzureStorage.UploadFileAndDelete(bpsOut, bpsIn);
|
|
||||||
|
|
||||||
var generating = string.Format("{0}/generating", id);
|
|
||||||
var deleteGenerating = AzureStorage.DeleteFile(generating);
|
|
||||||
|
|
||||||
await Task.WhenAll(uploadPatch, uploadSpoiler, uploadMeta, deleteGenerating);
|
|
||||||
|
|
||||||
Logger.LogDebug("Deleting file {filepath}", rom);
|
|
||||||
File.Delete(rom);
|
|
||||||
|
|
||||||
Logger.LogInformation("Finished uploading seed id {id}", id);
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task GenerationFailed(string id, int exitcode) {
|
|
||||||
var generating = string.Format("{0}/generating", id);
|
|
||||||
var deleteGenerating = AzureStorage.DeleteFile(generating);
|
|
||||||
|
|
||||||
await Task.WhenAll(deleteGenerating);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -3,33 +3,32 @@
|
|||||||
using ALttPRandomizer.Azure;
|
using ALttPRandomizer.Azure;
|
||||||
using ALttPRandomizer.Model;
|
using ALttPRandomizer.Model;
|
||||||
using ALttPRandomizer.Options;
|
using ALttPRandomizer.Options;
|
||||||
|
using ALttPRandomizer.Service;
|
||||||
using ALttPRandomizer.Settings;
|
using ALttPRandomizer.Settings;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
public class BaseRandomizer : IRandomizer {
|
public class BaseRandomizer : IRandomizer {
|
||||||
public const string Name = "base";
|
|
||||||
public const string DungeonMapName = "dungeon_map";
|
|
||||||
|
|
||||||
public const int MULTI_TRIES = 100;
|
public const int MULTI_TRIES = 100;
|
||||||
public const int SINGLE_TRIES = 5;
|
public const int SINGLE_TRIES = 5;
|
||||||
|
|
||||||
public BaseRandomizer(
|
public BaseRandomizer(
|
||||||
AzureStorage azureStorage,
|
AzureStorage azureStorage,
|
||||||
CommonSettingsProcessor settingsProcessor,
|
CommonSettingsProcessor settingsProcessor,
|
||||||
|
ProcessService processService,
|
||||||
IdGenerator idGenerator,
|
IdGenerator idGenerator,
|
||||||
ShutdownHandler shutdownHandler,
|
ShutdownHandler shutdownHandler,
|
||||||
IOptionsMonitor<ServiceOptions> optionsMonitor,
|
IOptionsMonitor<ServiceOptions> optionsMonitor,
|
||||||
ILogger<BaseRandomizer> logger) {
|
ILogger<BaseRandomizer> logger) {
|
||||||
this.AzureStorage = azureStorage;
|
this.AzureStorage = azureStorage;
|
||||||
this.SettingsProcessor = settingsProcessor;
|
this.SettingsProcessor = settingsProcessor;
|
||||||
|
this.ProcessService = processService;
|
||||||
this.IdGenerator = idGenerator;
|
this.IdGenerator = idGenerator;
|
||||||
this.ShutdownHandler = shutdownHandler;
|
this.ShutdownHandler = shutdownHandler;
|
||||||
this.OptionsMonitor = optionsMonitor;
|
this.OptionsMonitor = optionsMonitor;
|
||||||
@@ -38,6 +37,7 @@
|
|||||||
|
|
||||||
private CommonSettingsProcessor SettingsProcessor { get; }
|
private CommonSettingsProcessor SettingsProcessor { get; }
|
||||||
private AzureStorage AzureStorage { get; }
|
private AzureStorage AzureStorage { get; }
|
||||||
|
private ProcessService ProcessService { get; }
|
||||||
private IdGenerator IdGenerator { get; }
|
private IdGenerator IdGenerator { get; }
|
||||||
private IOptionsMonitor<ServiceOptions> OptionsMonitor { get; }
|
private IOptionsMonitor<ServiceOptions> OptionsMonitor { get; }
|
||||||
private ILogger<BaseRandomizer> Logger { get; }
|
private ILogger<BaseRandomizer> Logger { get; }
|
||||||
@@ -57,12 +57,12 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private IList<string> GetArgs(SeedSettings settings) {
|
private List<string> GetArgs(SeedSettings settings) {
|
||||||
var args = new List<string>() {
|
var args = new List<string>();
|
||||||
"--reduce_flashing",
|
|
||||||
"--quickswap",
|
if (settings.Randomizer != RandomizerInstance.Apr2025) {
|
||||||
"--shuffletavern",
|
args.Add("--shuffletavern");
|
||||||
};
|
}
|
||||||
|
|
||||||
if (settings.DoorShuffle == DoorShuffle.Vanilla) {
|
if (settings.DoorShuffle == DoorShuffle.Vanilla) {
|
||||||
settings.DoorTypeMode = DoorTypeMode.Original;
|
settings.DoorTypeMode = DoorTypeMode.Original;
|
||||||
@@ -73,52 +73,32 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (settings.DoorShuffle != DoorShuffle.Vanilla || settings.DropShuffle != DropShuffle.Vanilla
|
if (settings.DoorShuffle != DoorShuffle.Vanilla || settings.DropShuffle != DropShuffle.Vanilla
|
||||||
|| (settings.Pottery != Pottery.Vanilla && settings.Pottery != Pottery.Cave)) {
|
|| (settings.PotShuffle != PotShuffle.Vanilla && settings.PotShuffle != PotShuffle.Cave)) {
|
||||||
args.Add("--dungeon_counters=on");
|
args.Add("--dungeon_counters=on");
|
||||||
}
|
}
|
||||||
|
|
||||||
return args;
|
return args;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task StartProcess(string randomizerName, string id, IEnumerable<string> settings, Func<int, Task> completed) {
|
private async Task StartProcess(GeneratorSettingsAttribute generatorSettings, string id, IEnumerable<string> settings, Func<int, Task> completed) {
|
||||||
var start = new ProcessStartInfo() {
|
var generatorConfigSettings = this.Configuration.Generators[generatorSettings.Name];
|
||||||
FileName = Configuration.PythonPath,
|
|
||||||
WorkingDirectory = Configuration.RandomizerPaths[randomizerName],
|
|
||||||
RedirectStandardOutput = true,
|
|
||||||
RedirectStandardError = true,
|
|
||||||
};
|
|
||||||
|
|
||||||
var args = start.ArgumentList;
|
string[] args = [
|
||||||
args.Add("DungeonRandomizer.py");
|
.. generatorConfigSettings.RandomizerCommand,
|
||||||
args.Add("--rom");
|
.. generatorSettings.Args,
|
||||||
args.Add(Configuration.Baserom);
|
"--rom",
|
||||||
args.Add("--bps");
|
Configuration.Baserom,
|
||||||
|
"--outputpath",
|
||||||
args.Add("--outputpath");
|
Path.GetTempPath(),
|
||||||
args.Add(Path.GetTempPath());
|
"--outputname",
|
||||||
|
id,
|
||||||
args.Add("--outputname");
|
.. settings,
|
||||||
args.Add(id);
|
];
|
||||||
|
|
||||||
args.Add("--spoiler=json");
|
|
||||||
|
|
||||||
foreach (var arg in settings) {
|
|
||||||
args.Add(arg);
|
|
||||||
}
|
|
||||||
|
|
||||||
Logger.LogInformation("Randomizing {id} with args: {args}", id, string.Join(" ", args.Select(arg => $"\"{arg}\"")));
|
|
||||||
|
|
||||||
var generating = string.Format("{0}/generating", id);
|
var generating = string.Format("{0}/generating", id);
|
||||||
await AzureStorage.UploadFile(generating, BinaryData.Empty);
|
await AzureStorage.UploadFile(generating, BinaryData.Empty);
|
||||||
|
|
||||||
var process = Process.Start(start) ?? throw new GenerationFailedException("Process failed to start.");
|
var process = this.ProcessService.StartProcess($"Generation {id}", generatorConfigSettings.WorkingDirectory, args);
|
||||||
process.EnableRaisingEvents = true;
|
|
||||||
|
|
||||||
process.OutputDataReceived += (_, args) => Logger.LogInformation("Randomizer {id} STDOUT: {output}", id, args.Data);
|
|
||||||
process.ErrorDataReceived += (_, args) => Logger.LogInformation("Randomizer {id} STDERR: {output}", id, args.Data);
|
|
||||||
|
|
||||||
process.BeginOutputReadLine();
|
|
||||||
process.BeginErrorReadLine();
|
|
||||||
|
|
||||||
this.ShutdownHandler.AddId(id);
|
this.ShutdownHandler.AddId(id);
|
||||||
|
|
||||||
@@ -136,13 +116,20 @@
|
|||||||
public async Task Randomize(string id, SeedSettings settings, bool uploadSettings = true) {
|
public async Task Randomize(string id, SeedSettings settings, bool uploadSettings = true) {
|
||||||
Logger.LogDebug("Recieved request for id {id} to randomize settings {@settings}", id, settings);
|
Logger.LogDebug("Recieved request for id {id} to randomize settings {@settings}", id, settings);
|
||||||
|
|
||||||
var args = this.GetArgs(settings).Append(string.Format("--tries={0}", SINGLE_TRIES));
|
var args = this.GetArgs(settings);
|
||||||
|
|
||||||
await StartProcess(this.SettingsProcessor.GetRandomizerName(settings.Randomizer), id, args, async exitcode => {
|
if (settings.Randomizer != RandomizerInstance.Apr2025) {
|
||||||
|
args.Add($"--tries={SINGLE_TRIES}");
|
||||||
|
args.Add($"--rom_header={id}");
|
||||||
|
}
|
||||||
|
|
||||||
|
var generatorSettings = this.SettingsProcessor.GetGeneratorSettings(settings.Randomizer);
|
||||||
|
|
||||||
|
await StartProcess(generatorSettings, id, args, async exitcode => {
|
||||||
if (exitcode != 0) {
|
if (exitcode != 0) {
|
||||||
await GenerationFailed(id, exitcode);
|
await GenerationFailed(id, exitcode);
|
||||||
} else {
|
} else {
|
||||||
await SingleSucceeded(id);
|
await SingleSucceeded(generatorSettings, id);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -154,7 +141,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async Task RandomizeMultiworld(string id, IList<SeedSettings> settings, bool uploadSettings = true) {
|
public async Task RandomizeMultiworld(string id, IList<SeedSettings> settings, bool uploadSettings = true) {
|
||||||
var randomizerName = this.SettingsProcessor.GetRandomizerName(settings[0].Randomizer);
|
var generatorSettings = this.SettingsProcessor.GetGeneratorSettings(settings[0].Randomizer);
|
||||||
|
|
||||||
Logger.LogDebug("Recieved request for id {id} to randomize multiworld settings {@settings}", id, settings);
|
Logger.LogDebug("Recieved request for id {id} to randomize multiworld settings {@settings}", id, settings);
|
||||||
|
|
||||||
var names = settings.Select(s => s.PlayerName.Replace(' ', '_')).ToList();
|
var names = settings.Select(s => s.PlayerName.Replace(' ', '_')).ToList();
|
||||||
@@ -162,13 +150,14 @@
|
|||||||
var args = settings.Select((s, idx) => string.Format("--p{0}={1}", idx + 1, string.Join(" ", this.GetArgs(s))))
|
var args = settings.Select((s, idx) => string.Format("--p{0}={1}", idx + 1, string.Join(" ", this.GetArgs(s))))
|
||||||
.Append(string.Format("--names={0}", string.Join(",", names)))
|
.Append(string.Format("--names={0}", string.Join(",", names)))
|
||||||
.Append(string.Format("--multi={0}", settings.Count))
|
.Append(string.Format("--multi={0}", settings.Count))
|
||||||
.Append(string.Format("--tries={0}", MULTI_TRIES));
|
.Append(string.Format("--tries={0}", MULTI_TRIES))
|
||||||
|
.Append(string.Format("--rom_header={0}", id));
|
||||||
|
|
||||||
await StartProcess(randomizerName, id, args, async exitcode => {
|
await StartProcess(generatorSettings, id, args, async exitcode => {
|
||||||
if (exitcode != 0) {
|
if (exitcode != 0) {
|
||||||
await GenerationFailed(id, exitcode);
|
await GenerationFailed(id, exitcode);
|
||||||
} else {
|
} else {
|
||||||
await MultiSucceeded(id, settings, names);
|
await MultiSucceeded(generatorSettings, id, settings, names);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -179,98 +168,122 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task SingleSucceeded(string id) {
|
private async Task<int> GeneratePatch(string id, string basename) {
|
||||||
try {
|
var tempPath = Path.GetTempPath();
|
||||||
var basename = string.Format("OR_{0}", id);
|
var bps = Path.Join(tempPath, string.Format("{0}.bps", basename));
|
||||||
await this.UploadFiles(id, basename, 1, null);
|
var sfc = Path.Join(tempPath, string.Format("{0}.sfc", basename));
|
||||||
|
|
||||||
var metaIn = Path.Join(Path.GetTempPath(), string.Format("OR_{0}_Meta.json", id));
|
var process = this.ProcessService.StartProcess($"Generation {id}", tempPath, this.Configuration.FlipsPath, "--create", this.Configuration.Baserom, sfc, bps);
|
||||||
|
|
||||||
|
await process.WaitForExitAsync();
|
||||||
|
|
||||||
|
return process.ExitCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task SingleSucceeded(GeneratorSettingsAttribute generatorSettings, string id) {
|
||||||
|
try {
|
||||||
|
var basename = $"{generatorSettings.Prefix}{id}";
|
||||||
|
if (generatorSettings.RequireFlips) {
|
||||||
|
var exitCode = await GeneratePatch(id, basename);
|
||||||
|
|
||||||
|
if (exitCode != 0) {
|
||||||
|
await this.GenerationFailed(id, exitCode);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
await this.UploadFiles(id, basename);
|
||||||
|
|
||||||
|
var metaIn = Path.Join(Path.GetTempPath(), string.Format("{0}_Meta.json", basename));
|
||||||
Logger.LogDebug("Deleting file {filepath}", metaIn);
|
Logger.LogDebug("Deleting file {filepath}", metaIn);
|
||||||
File.Delete(metaIn);
|
File.Delete(metaIn);
|
||||||
|
|
||||||
var spoilerIn = Path.Join(Path.GetTempPath(), string.Format("OR_{0}_Spoiler.json", id));
|
var spoilerIn = Path.Join(Path.GetTempPath(), string.Format("{0}_Spoiler.json", basename));
|
||||||
Logger.LogDebug("Deleting file {filepath}", spoilerIn);
|
Logger.LogDebug("Deleting file {filepath}", spoilerIn);
|
||||||
File.Delete(spoilerIn);
|
File.Delete(spoilerIn);
|
||||||
|
|
||||||
Logger.LogInformation("Finished uploading seed id {id}", id);
|
Logger.LogInformation("Finished uploading seed id {id}", id);
|
||||||
} finally {
|
} finally {
|
||||||
var generating = string.Format("{0}/generating", id);
|
await AzureStorage.DeleteFile($"{id}/generating");
|
||||||
await AzureStorage.DeleteFile(generating);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task UploadFiles(string id, string basename, int playerNum, string? parentId) {
|
private async Task UploadFiles(string id, string basename, int playerNum = 1, string playerSuffix = "") {
|
||||||
var tasks = new List<Task>();
|
var tasks = new List<Task>();
|
||||||
|
|
||||||
var rom = Path.Join(Path.GetTempPath(), string.Format("{0}.sfc", basename));
|
var rom = Path.Join(Path.GetTempPath(), string.Format("{0}{1}.sfc", basename, playerSuffix));
|
||||||
Logger.LogDebug("Deleting file {filepath}", rom);
|
Logger.LogDebug("Deleting file {filepath}", rom);
|
||||||
File.Delete(rom);
|
File.Delete(rom);
|
||||||
|
|
||||||
var bpsIn = Path.Join(Path.GetTempPath(), string.Format("{0}.bps", basename));
|
var bpsIn = Path.Join(Path.GetTempPath(), string.Format("{0}{1}.bps", basename, playerSuffix));
|
||||||
var bpsOut = string.Format("{0}/patch.bps", id);
|
tasks.Add(this.AzureStorage.UploadFileAndDelete($"{id}/patch.bps", bpsIn));
|
||||||
tasks.Add(this.AzureStorage.UploadFileAndDelete(bpsOut, bpsIn));
|
|
||||||
|
|
||||||
var spoilerIn = Path.Join(Path.GetTempPath(), string.Format("OR_{0}_Spoiler.json", parentId ?? id));
|
var spoilerIn = Path.Join(Path.GetTempPath(), string.Format("{0}_Spoiler.json", basename));
|
||||||
var spoilerOut = string.Format("{0}/spoiler.json", id);
|
tasks.Add(this.AzureStorage.UploadFileFromSource($"{id}/spoiler.json", spoilerIn));
|
||||||
tasks.Add(this.AzureStorage.UploadFileFromSource(spoilerOut, spoilerIn));
|
|
||||||
|
|
||||||
var metaIn = Path.Join(Path.GetTempPath(), string.Format("OR_{0}_Meta.json", parentId ?? id));
|
var metaIn = Path.Join(Path.GetTempPath(), string.Format("{0}_Meta.json", basename));
|
||||||
var metaOut = string.Format("{0}/meta.json", id);
|
|
||||||
var meta = ProcessMetadata(metaIn, playerNum);
|
var meta = ProcessMetadata(metaIn, playerNum);
|
||||||
tasks.Add(this.AzureStorage.UploadFile(metaOut, new BinaryData(meta)));
|
tasks.Add(this.AzureStorage.UploadFile($"{id}/meta.json", new BinaryData(meta)));
|
||||||
|
|
||||||
if (parentId != null) {
|
|
||||||
var parentOut = string.Format("{0}/parent", id);
|
|
||||||
tasks.Add(this.AzureStorage.UploadFile(parentOut, new BinaryData(parentId)));
|
|
||||||
}
|
|
||||||
|
|
||||||
await Task.WhenAll(tasks);
|
await Task.WhenAll(tasks);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task MultiSucceeded(string id, IList<SeedSettings> settings, IList<string> names) {
|
private async Task MultiSucceeded(GeneratorSettingsAttribute generatorSettings, string id, IList<SeedSettings> settings, List<string> names) {
|
||||||
var tasks = new List<Task>();
|
var tasks = new List<Task>();
|
||||||
var subIds = new List<string>();
|
var subIds = new List<string>();
|
||||||
var worlds = new List<object>();
|
var worlds = new List<object>();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
var basename = $"{generatorSettings.Prefix}{id}";
|
||||||
|
|
||||||
for (var i = 0; i < settings.Count; i++) {
|
for (var i = 0; i < settings.Count; i++) {
|
||||||
var basename = string.Format("OR_{0}_P{1}_{2}", id, i + 1, names[i]);
|
var playerSuffix = $"_P{i + 1}_{names[i]}";
|
||||||
var randomId = this.IdGenerator.GenerateId();
|
var randomId = this.IdGenerator.GenerateId();
|
||||||
subIds.Add(randomId);
|
subIds.Add(randomId);
|
||||||
tasks.Add(this.UploadFiles(randomId, basename, i + 1, id));
|
|
||||||
|
Task<int> flipsTask;
|
||||||
|
if (generatorSettings.RequireFlips) {
|
||||||
|
flipsTask = this.GeneratePatch(id, $"{basename}{playerSuffix}");
|
||||||
|
} else {
|
||||||
|
flipsTask = Task.FromResult(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.Add(flipsTask.ContinueWith(exitCode => {
|
||||||
|
if (exitCode.Result != 0) {
|
||||||
|
this.Logger.LogWarning("Generation {id} - flips failed with exit code {exitCode}", id, exitCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.UploadFiles(randomId, basename, i + 1, playerSuffix);
|
||||||
|
}));
|
||||||
|
|
||||||
|
tasks.Add(this.AzureStorage.UploadFile($"{randomId}/parent", new BinaryData(id)));
|
||||||
|
|
||||||
worlds.Add(new { Name = settings[i].PlayerName, Id = randomId });
|
worlds.Add(new { Name = settings[i].PlayerName, Id = randomId });
|
||||||
|
|
||||||
var settingsJson = JsonSerializer.SerializeToDocument(settings[i], JsonOptions.Default);
|
var settingsJson = JsonSerializer.SerializeToDocument(settings[i], JsonOptions.Default);
|
||||||
var settingsOut = string.Format("{0}/settings.json", randomId);
|
tasks.Add(this.AzureStorage.UploadFile($"{randomId}/settings.json", new BinaryData(settingsJson)));
|
||||||
tasks.Add(this.AzureStorage.UploadFile(settingsOut, new BinaryData(settingsJson)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var worldsJson = JsonSerializer.SerializeToDocument(worlds, JsonOptions.Default);
|
var worldsJson = JsonSerializer.SerializeToDocument(worlds, JsonOptions.Default);
|
||||||
var worldsOut = string.Format("{0}/worlds.json", id);
|
tasks.Add(this.AzureStorage.UploadFile($"{id}/worlds.json", new BinaryData(worldsJson)));
|
||||||
|
|
||||||
tasks.Add(this.AzureStorage.UploadFile(worldsOut, new BinaryData(worldsJson)));
|
|
||||||
|
|
||||||
await Task.WhenAll(tasks);
|
await Task.WhenAll(tasks);
|
||||||
|
|
||||||
var metaIn = Path.Join(Path.GetTempPath(), string.Format("OR_{0}_Meta.json", id));
|
var metaIn = Path.Join(Path.GetTempPath(), string.Format("{0}_Meta.json", basename));
|
||||||
var metaOut = string.Format("{0}/meta.json", id);
|
var uploadMeta = AzureStorage.UploadFileAndDelete($"{id}/meta.json", metaIn);
|
||||||
var uploadMeta = AzureStorage.UploadFileAndDelete(metaOut, metaIn);
|
|
||||||
|
|
||||||
var spoilerIn = Path.Join(Path.GetTempPath(), string.Format("OR_{0}_Spoiler.json", id));
|
var spoilerIn = Path.Join(Path.GetTempPath(), string.Format("{0}_Spoiler.json", basename));
|
||||||
var spoilerOut = string.Format("{0}/spoiler.json", id);
|
var uploadSpoiler = AzureStorage.UploadFileAndDelete($"{id}/spoiler.json", spoilerIn);
|
||||||
var uploadSpoiler = AzureStorage.UploadFileAndDelete(spoilerOut, spoilerIn);
|
|
||||||
|
|
||||||
var multidataIn = Path.Join(Path.GetTempPath(), string.Format("OR_{0}_multidata", id));
|
var multidataIn = Path.Join(Path.GetTempPath(), string.Format("{0}_multidata", basename));
|
||||||
var multidataOut = string.Format("{0}/multidata", id);
|
var uploadMultidata = AzureStorage.UploadFileAndDelete($"{id}/multidata", multidataIn);
|
||||||
var uploadMultidata = AzureStorage.UploadFileAndDelete(multidataOut, multidataIn);
|
|
||||||
|
|
||||||
await Task.WhenAll(uploadMeta, uploadSpoiler, uploadMultidata);
|
await Task.WhenAll(uploadMeta, uploadSpoiler, uploadMultidata);
|
||||||
|
|
||||||
Logger.LogInformation("Finished uploading multiworld id {id}", id);
|
Logger.LogInformation("Finished uploading multiworld id {id}", id);
|
||||||
} finally {
|
} finally {
|
||||||
var generating = string.Format("{0}/generating", id);
|
var generating = string.Format("{0}/generating", id);
|
||||||
var deleteGenerating = AzureStorage.DeleteFile(generating);
|
await AzureStorage.DeleteFile(generating);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -293,11 +306,9 @@
|
|||||||
return JsonSerializer.SerializeToDocument(processed, JsonOptions.Default);
|
return JsonSerializer.SerializeToDocument(processed, JsonOptions.Default);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task GenerationFailed(string id, int exitcode) {
|
private async Task GenerationFailed(string id, int _) {
|
||||||
var generating = string.Format("{0}/generating", id);
|
var generating = string.Format("{0}/generating", id);
|
||||||
var deleteGenerating = AzureStorage.DeleteFile(generating);
|
await AzureStorage.DeleteFile(generating);
|
||||||
|
|
||||||
await Task.WhenAll(deleteGenerating);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
41
ALttPRandomizer/Service/ProcessService.cs
Normal file
41
ALttPRandomizer/Service/ProcessService.cs
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
namespace ALttPRandomizer.Service {
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Linq;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
|
public class ProcessService {
|
||||||
|
public ProcessService(ILogger<ProcessService> logger) {
|
||||||
|
this.Logger = logger;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ILogger<ProcessService> Logger { get; }
|
||||||
|
|
||||||
|
public Process StartProcess(string logPrefix, string workingDirectory, params string[] args) {
|
||||||
|
var start = new ProcessStartInfo(args[0], args.Skip(1)) {
|
||||||
|
WorkingDirectory = workingDirectory,
|
||||||
|
RedirectStandardOutput = true,
|
||||||
|
RedirectStandardError = true,
|
||||||
|
};
|
||||||
|
|
||||||
|
this.Logger.LogInformation("{prefix} - executing command: {command}", logPrefix, string.Join(" ", args.Select(arg => arg.Contains(' ') ? $"\"{arg}\"" : arg)));
|
||||||
|
|
||||||
|
var process = Process.Start(start) ?? throw new GenerationFailedException("{0} - Process failed to start.", logPrefix);
|
||||||
|
process.EnableRaisingEvents = true;
|
||||||
|
|
||||||
|
process.OutputDataReceived += (_, args) => {
|
||||||
|
if (args.Data != null) {
|
||||||
|
Logger.LogInformation("{prefix} - STDOUT: {output}", logPrefix, args.Data);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
process.ErrorDataReceived += (_, args) => {
|
||||||
|
if (args.Data != null) {
|
||||||
|
Logger.LogInformation("{prefix} - STDERR: {output}", logPrefix, args.Data);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
process.BeginOutputReadLine();
|
||||||
|
process.BeginErrorReadLine();
|
||||||
|
return process;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,24 +2,18 @@
|
|||||||
using ALttPRandomizer.Azure;
|
using ALttPRandomizer.Azure;
|
||||||
using ALttPRandomizer.Model;
|
using ALttPRandomizer.Model;
|
||||||
using ALttPRandomizer.Randomizers;
|
using ALttPRandomizer.Randomizers;
|
||||||
using ALttPRandomizer.Settings;
|
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Reflection;
|
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
public class RandomizeService {
|
public class RandomizeService {
|
||||||
public RandomizeService(
|
public RandomizeService(
|
||||||
IdGenerator idGenerator,
|
IdGenerator idGenerator,
|
||||||
IServiceProvider serviceProvider,
|
|
||||||
BaseRandomizer baseRandomizer,
|
BaseRandomizer baseRandomizer,
|
||||||
AzureStorage azureStorage,
|
AzureStorage azureStorage,
|
||||||
ILogger<RandomizeService> logger) {
|
ILogger<RandomizeService> logger) {
|
||||||
this.IdGenerator = idGenerator;
|
this.IdGenerator = idGenerator;
|
||||||
this.ServiceProvider = serviceProvider;
|
|
||||||
this.BaseRandomizer = baseRandomizer;
|
this.BaseRandomizer = baseRandomizer;
|
||||||
this.AzureStorage = azureStorage;
|
this.AzureStorage = azureStorage;
|
||||||
this.Logger = logger;
|
this.Logger = logger;
|
||||||
@@ -29,25 +23,15 @@
|
|||||||
|
|
||||||
private IdGenerator IdGenerator { get; }
|
private IdGenerator IdGenerator { get; }
|
||||||
private BaseRandomizer BaseRandomizer { get; }
|
private BaseRandomizer BaseRandomizer { get; }
|
||||||
private IServiceProvider ServiceProvider { get; }
|
|
||||||
private AzureStorage AzureStorage { get; }
|
private AzureStorage AzureStorage { get; }
|
||||||
|
|
||||||
public async Task<string> RandomizeSeed(SeedSettings settings, string? seedId = null) {
|
public async Task<string> RandomizeSeed(SeedSettings settings, string? seedId = null) {
|
||||||
var id = seedId ?? this.IdGenerator.GenerateId();
|
var id = seedId ?? this.IdGenerator.GenerateId();
|
||||||
this.Logger.LogInformation("Generating seed {seedId} with settings {@settings}", id, settings);
|
this.Logger.LogInformation("Generating seed {seedId} with settings {@settings}", id, settings);
|
||||||
|
|
||||||
var fi = typeof(RandomizerInstance).GetField(settings.Randomizer.ToString(), BindingFlags.Static | BindingFlags.Public);
|
this.BaseRandomizer.Validate(settings);
|
||||||
|
|
||||||
var randomizerKey = fi?.GetCustomAttribute<RandomizerNameAttribute>()?.Name;
|
await this.BaseRandomizer.Randomize(id, settings, seedId == null);
|
||||||
|
|
||||||
if (randomizerKey == null) {
|
|
||||||
throw new InvalidSettingsException("Invalid randomizer: {0}", settings.Randomizer);
|
|
||||||
}
|
|
||||||
|
|
||||||
var randomizer = this.ServiceProvider.GetRequiredKeyedService<IRandomizer>(randomizerKey);
|
|
||||||
randomizer.Validate(settings);
|
|
||||||
|
|
||||||
await randomizer.Randomize(id, settings, seedId == null);
|
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,12 +3,25 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
internal class RandomizerNameAttribute : Attribute {
|
[AttributeUsage(AttributeTargets.Field)]
|
||||||
public RandomizerNameAttribute(string name) {
|
internal class GeneratorSettingsAttribute : Attribute {
|
||||||
|
public GeneratorSettingsAttribute(string name, string prefix, params string[] args) {
|
||||||
this.Name = name;
|
this.Name = name;
|
||||||
|
this.Prefix = prefix;
|
||||||
|
this.Args = args;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GeneratorSettingsAttribute(string name, string prefix, bool requireFlips, params string[] args) {
|
||||||
|
this.Name = name;
|
||||||
|
this.Prefix = prefix;
|
||||||
|
this.Args = args;
|
||||||
|
this.RequireFlips = requireFlips;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Name { get; }
|
public string Name { get; }
|
||||||
|
public string Prefix { get; }
|
||||||
|
public string[] Args { get; }
|
||||||
|
public bool RequireFlips { get; } = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal abstract class RandomizerSpecificAttribute : Attribute {
|
internal abstract class RandomizerSpecificAttribute : Attribute {
|
||||||
@@ -42,21 +55,27 @@
|
|||||||
internal class NoSettingNameAttribute : RandomizerSpecificAttribute {
|
internal class NoSettingNameAttribute : RandomizerSpecificAttribute {
|
||||||
public NoSettingNameAttribute() : base(null) { }
|
public NoSettingNameAttribute() : base(null) { }
|
||||||
|
|
||||||
public NoSettingNameAttribute(RandomizerInstance[] randomizers) : base(randomizers) { }
|
public NoSettingNameAttribute(params RandomizerInstance[] randomizers) : base(randomizers) { }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal class IgnoreSettingAttribute : RandomizerSpecificAttribute {
|
||||||
|
public IgnoreSettingAttribute(params RandomizerInstance[] randomizers) : base(randomizers) { }
|
||||||
|
}
|
||||||
|
|
||||||
|
[AttributeUsage(AttributeTargets.Field, AllowMultiple=true)]
|
||||||
internal class AdditionalSettingAttribute : RandomizerSpecificAttribute {
|
internal class AdditionalSettingAttribute : RandomizerSpecificAttribute {
|
||||||
public AdditionalSettingAttribute(string setting) : base(null) {
|
public AdditionalSettingAttribute(params string[] settings) : base(null) {
|
||||||
this.Setting = setting;
|
this.Settings = settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AdditionalSettingAttribute(RandomizerInstance[] randomizers, string setting) : base(randomizers) {
|
public AdditionalSettingAttribute(RandomizerInstance[] randomizers, params string[] settings) : base(randomizers) {
|
||||||
this.Setting = setting;
|
this.Settings = settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Setting { get; }
|
public string[] Settings { get; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[AttributeUsage(AttributeTargets.Field, AllowMultiple=true)]
|
||||||
internal class AddStartingItemsAttribute : RandomizerSpecificAttribute {
|
internal class AddStartingItemsAttribute : RandomizerSpecificAttribute {
|
||||||
public AddStartingItemsAttribute(params string[] items) : base(null) {
|
public AddStartingItemsAttribute(params string[] items) : base(null) {
|
||||||
this.Items = items;
|
this.Items = items;
|
||||||
@@ -69,6 +88,7 @@
|
|||||||
public string[] Items { get; }
|
public string[] Items { get; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[AttributeUsage(AttributeTargets.Property, AllowMultiple=true)]
|
||||||
internal class RequiredSettingAttribute : RandomizerSpecificAttribute {
|
internal class RequiredSettingAttribute : RandomizerSpecificAttribute {
|
||||||
public RequiredSettingAttribute(params object[] values) : base(null) {
|
public RequiredSettingAttribute(params object[] values) : base(null) {
|
||||||
this.Values = values;
|
this.Values = values;
|
||||||
@@ -81,6 +101,7 @@
|
|||||||
public object[] Values { get; }
|
public object[] Values { get; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[AttributeUsage(AttributeTargets.Property, AllowMultiple=true)]
|
||||||
internal class ForbiddenSettingAttribute : RandomizerSpecificAttribute {
|
internal class ForbiddenSettingAttribute : RandomizerSpecificAttribute {
|
||||||
public ForbiddenSettingAttribute(params object[] values) : base(null) {
|
public ForbiddenSettingAttribute(params object[] values) : base(null) {
|
||||||
this.Values = values;
|
this.Values = values;
|
||||||
|
|||||||
@@ -13,11 +13,16 @@
|
|||||||
if (prop.Name == nameof(SeedSettings.PlayerName)) {
|
if (prop.Name == nameof(SeedSettings.PlayerName)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
var value = prop.GetValue(settings) ?? throw new SettingsLookupException("settings.{0} not found", prop.Name);
|
var value = prop.GetValue(settings) ?? throw new SettingsLookupException("settings.{0} not found", prop.Name);
|
||||||
var valueFieldName = value.ToString() ?? throw new SettingsLookupException("settings.{0}.ToString() returned null", prop.Name);
|
var valueFieldName = value.ToString() ?? throw new SettingsLookupException("settings.{0}.ToString() returned null", prop.Name);
|
||||||
var fi = prop.PropertyType.GetField(valueFieldName, BindingFlags.Static | BindingFlags.Public)
|
var fi = prop.PropertyType.GetField(valueFieldName, BindingFlags.Static | BindingFlags.Public)
|
||||||
?? throw new SettingsLookupException("Could not get field info for value {0}.{1}", prop.PropertyType, valueFieldName);
|
?? throw new SettingsLookupException("Could not get field info for value {0}.{1}", prop.PropertyType, valueFieldName);
|
||||||
|
|
||||||
|
if (prop.GetCustomAttributes<IgnoreSettingAttribute>().Any(att => att.HasRandomizer(randomizer))) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (!prop.GetCustomAttributes<NoSettingNameAttribute>().Any(att => att.HasRandomizer(randomizer))) {
|
if (!prop.GetCustomAttributes<NoSettingNameAttribute>().Any(att => att.HasRandomizer(randomizer))) {
|
||||||
var settingName =
|
var settingName =
|
||||||
prop.GetCustomAttributes<SettingNameAttribute>()
|
prop.GetCustomAttributes<SettingNameAttribute>()
|
||||||
@@ -30,7 +35,9 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
foreach (var att in fi.GetCustomAttributes<AdditionalSettingAttribute>().Where(att => att.HasRandomizer(randomizer))) {
|
foreach (var att in fi.GetCustomAttributes<AdditionalSettingAttribute>().Where(att => att.HasRandomizer(randomizer))) {
|
||||||
yield return att.Setting;
|
foreach (var setting in att.Settings) {
|
||||||
|
yield return setting;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var att in fi.GetCustomAttributes<AddStartingItemsAttribute>().Where(att => att.HasRandomizer(randomizer))) {
|
foreach (var att in fi.GetCustomAttributes<AddStartingItemsAttribute>().Where(att => att.HasRandomizer(randomizer))) {
|
||||||
@@ -65,25 +72,21 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetRandomizerName(RandomizerInstance randomizer)
|
internal GeneratorSettingsAttribute GetGeneratorSettings(RandomizerInstance randomizer)
|
||||||
{
|
{
|
||||||
var fi = typeof(RandomizerInstance).GetField(randomizer.ToString(), BindingFlags.Static | BindingFlags.Public);
|
var fi = typeof(RandomizerInstance).GetField(randomizer.ToString(), BindingFlags.Static | BindingFlags.Public);
|
||||||
|
|
||||||
var randomizerKey = fi?.GetCustomAttribute<RandomizerNameAttribute>()?.Name;
|
var settings = fi?.GetCustomAttribute<GeneratorSettingsAttribute>();
|
||||||
|
|
||||||
if (randomizerKey == null) {
|
if (settings == null) {
|
||||||
throw new InvalidSettingsException("Invalid randomizer: {0}", randomizerKey);
|
throw new InvalidSettingsException("Invalid randomizer: {0}", randomizer);
|
||||||
}
|
}
|
||||||
|
|
||||||
return randomizerKey;
|
return settings;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class SettingsLookupException : Exception {
|
public class SettingsLookupException(string message, params object?[] args) : Exception(string.Format(message, args)) { }
|
||||||
public SettingsLookupException(string message, params object?[] args) : base(string.Format(message, args)) { }
|
|
||||||
}
|
|
||||||
|
|
||||||
public class InvalidSettingsException : Exception {
|
public class InvalidSettingsException(string message, params object?[] args) : Exception(string.Format(message, args)) { }
|
||||||
public InvalidSettingsException(string message, params object?[] args) : base(string.Format(message, args)) { }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
{
|
{
|
||||||
"ALttPRandomizer": {
|
"ALttPRandomizer": {
|
||||||
"baserom": "/randomizer/alttp.sfc",
|
"baserom": "/baserom/alttp.sfc",
|
||||||
"pythonPath": "/usr/bin/python3",
|
|
||||||
"flipsPath": "/flips/flips",
|
"flipsPath": "/flips/flips",
|
||||||
"allowedCors": [
|
"allowedCors": [
|
||||||
"https://new.alttpr.gwaa.kiwi",
|
"https://new.alttpr.gwaa.kiwi",
|
||||||
@@ -12,10 +11,19 @@
|
|||||||
"clientId": "a48d5ae1-fa0a-4e33-9586-18c0eca0a28c",
|
"clientId": "a48d5ae1-fa0a-4e33-9586-18c0eca0a28c",
|
||||||
"blobstoreEndpoint": "https://alttprstorage.blob.core.windows.net/seeds"
|
"blobstoreEndpoint": "https://alttprstorage.blob.core.windows.net/seeds"
|
||||||
},
|
},
|
||||||
"randomizerPaths": {
|
"generators": {
|
||||||
"base": "/randomizer",
|
"base": {
|
||||||
"apr2025": "/apr2025_randomizer",
|
"workingDirectory": "/randomizer",
|
||||||
"dungeon_map": "/dungeon_map_randomizer"
|
"randomizerCommand": [ "uv", "run", "DungeonRandomizer.py" ],
|
||||||
|
},
|
||||||
|
"apr2025": {
|
||||||
|
"workingDirectory": "/apr2025_randomizer",
|
||||||
|
"randomizerCommand": [ "uv", "run", "EntranceRandomizer.py" ],
|
||||||
|
},
|
||||||
|
"beta": {
|
||||||
|
"workingDirectory": "/beta_randomizer",
|
||||||
|
"randomizerCommand": [ "uv", "run", "DungeonRandomizer.py" ],
|
||||||
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"Serilog": {
|
"Serilog": {
|
||||||
|
|||||||
Submodule Apr2025Randomizer updated: 84adf1dd89...029e8de852
Submodule BaseRandomizer updated: ea8498f402...61d7940183
1
BetaRandomizer
Submodule
1
BetaRandomizer
Submodule
Submodule BetaRandomizer added at b1a71ef9b1
34
Dockerfile
34
Dockerfile
@@ -20,37 +20,39 @@ EXPOSE 8080
|
|||||||
EXPOSE 8081
|
EXPOSE 8081
|
||||||
|
|
||||||
RUN tdnf install -y python3
|
RUN tdnf install -y python3
|
||||||
|
RUN python3 -m ensurepip --default-pip --upgrade
|
||||||
|
RUN pip install uv
|
||||||
|
|
||||||
RUN mkdir -p /flips
|
RUN mkdir -p /flips
|
||||||
COPY --from=build /flips/Flips-198/flips /flips/flips
|
COPY --from=build /flips/Flips-198/flips /flips/flips
|
||||||
|
|
||||||
RUN mkdir -p /randomizer/data
|
COPY alttp.sfc /baserom/alttp.sfc
|
||||||
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
|
|
||||||
|
|
||||||
|
# base generator
|
||||||
WORKDIR /randomizer
|
WORKDIR /randomizer
|
||||||
COPY alttp.sfc .
|
|
||||||
|
|
||||||
COPY BaseRandomizer/resources/app/meta/manifests/pip_requirements.txt requirements.txt
|
COPY BaseRandomizer/pyproject.toml .
|
||||||
RUN python3 -m pip install -r requirements.txt
|
RUN uv sync
|
||||||
|
|
||||||
COPY BaseRandomizer/ .
|
COPY BaseRandomizer/ .
|
||||||
|
|
||||||
|
# apr2025 generator
|
||||||
WORKDIR /apr2025_randomizer
|
WORKDIR /apr2025_randomizer
|
||||||
|
|
||||||
|
COPY Apr2025Randomizer/pyproject.toml .
|
||||||
|
RUN uv sync
|
||||||
|
|
||||||
COPY Apr2025Randomizer/ .
|
COPY Apr2025Randomizer/ .
|
||||||
|
|
||||||
WORKDIR /dungeon_map_randomizer
|
# beta generator
|
||||||
|
WORKDIR /beta_randomizer
|
||||||
|
|
||||||
COPY DungeonMapRandomizer/ .
|
COPY BetaRandomizer/pyproject.toml .
|
||||||
|
RUN uv sync
|
||||||
|
|
||||||
|
COPY BetaRandomizer/ .
|
||||||
|
|
||||||
|
# web server
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY --from=build /app/publish .
|
COPY --from=build /app/publish .
|
||||||
COPY ALttPRandomizer/appsettings.Docker.json appsettings.json
|
COPY ALttPRandomizer/appsettings.Docker.json appsettings.json
|
||||||
|
|||||||
Submodule DungeonMapRandomizer deleted from 67307a872c
1
PikitRandomizer
Submodule
1
PikitRandomizer
Submodule
Submodule PikitRandomizer added at 2738f61c0d
Reference in New Issue
Block a user