Add attribute for starting items
This commit is contained in:
@@ -89,7 +89,8 @@
|
|||||||
public PrizeShuffle PrizeShuffle { get; set; } = PrizeShuffle.Vanilla;
|
public PrizeShuffle PrizeShuffle { get; set; } = PrizeShuffle.Vanilla;
|
||||||
|
|
||||||
[NoSettingName]
|
[NoSettingName]
|
||||||
public BootsSettings StartingBoots { get; set; } = BootsSettings.None;
|
[ForbiddenSetting([Apr2025], BootsSettings.Starting)]
|
||||||
|
public BootsSettings Boots { get; set; } = BootsSettings.Normal;
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum RandomizerInstance {
|
public enum RandomizerInstance {
|
||||||
@@ -216,7 +217,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
public enum BootsSettings {
|
public enum BootsSettings {
|
||||||
None,
|
Normal,
|
||||||
[AdditionalSetting("--pseudoboots")] Pseudoboots,
|
[AdditionalSetting("--pseudoboots")] Pseudoboots,
|
||||||
|
[AddStartingItems("Pegasus_Boots")] Starting,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -74,6 +74,9 @@
|
|||||||
|
|
||||||
Logger.LogInformation("Randomizing with args: {args}", string.Join(" ", args));
|
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.");
|
var process = Process.Start(start) ?? throw new GenerationFailedException("Process failed to start.");
|
||||||
process.EnableRaisingEvents = true;
|
process.EnableRaisingEvents = true;
|
||||||
|
|
||||||
@@ -95,12 +98,7 @@
|
|||||||
|
|
||||||
var settingsJson = JsonSerializer.SerializeToDocument(settings, JsonOptions.Default);
|
var settingsJson = JsonSerializer.SerializeToDocument(settings, JsonOptions.Default);
|
||||||
var settingsOut = string.Format("{0}/settings.json", id);
|
var settingsOut = string.Format("{0}/settings.json", id);
|
||||||
var uploadSettings = AzureStorage.UploadFile(settingsOut, new BinaryData(settingsJson));
|
await AzureStorage.UploadFile(settingsOut, new BinaryData(settingsJson));
|
||||||
|
|
||||||
var generating = string.Format("{0}/generating", id);
|
|
||||||
var uploadGenerating = AzureStorage.UploadFile(generating, BinaryData.Empty);
|
|
||||||
|
|
||||||
await Task.WhenAll(uploadSettings, uploadGenerating);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task GenerationSucceeded(string id, SeedSettings settings) {
|
private async Task GenerationSucceeded(string id, SeedSettings settings) {
|
||||||
|
|||||||
@@ -57,6 +57,18 @@
|
|||||||
public string Setting { get; }
|
public string Setting { get; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal class AddStartingItemsAttribute : RandomizerSpecificAttribute {
|
||||||
|
public AddStartingItemsAttribute(params string[] items) : base(null) {
|
||||||
|
this.Items = items;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AddStartingItemsAttribute(RandomizerInstance[] randomizers, params string[] items) : base(randomizers) {
|
||||||
|
this.Items = items;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string[] Items { get; }
|
||||||
|
}
|
||||||
|
|
||||||
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;
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
public class CommonSettingsProcessor {
|
public class CommonSettingsProcessor {
|
||||||
public IEnumerable<string> GetSettings(RandomizerInstance randomizer, SeedSettings settings) {
|
public IEnumerable<string> GetSettings(RandomizerInstance randomizer, SeedSettings settings) {
|
||||||
var props = typeof(SeedSettings).GetProperties(BindingFlags.Instance | BindingFlags.Public);
|
var props = typeof(SeedSettings).GetProperties(BindingFlags.Instance | BindingFlags.Public);
|
||||||
|
var starting = new List<string>();
|
||||||
foreach (var prop in props) {
|
foreach (var prop in props) {
|
||||||
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);
|
||||||
@@ -28,6 +29,17 @@
|
|||||||
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;
|
yield return att.Setting;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach (var att in fi.GetCustomAttributes<AddStartingItemsAttribute>().Where(att => att.HasRandomizer(randomizer))) {
|
||||||
|
foreach (var item in att.Items) {
|
||||||
|
starting.Add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (starting.Count > 0) {
|
||||||
|
yield return "--usestartinventory=true";
|
||||||
|
yield return string.Format("--startinventory={0}", string.Join(",", starting));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Submodule BaseRandomizer updated: 283ece4020...82815d256d
Reference in New Issue
Block a user