Compare commits
8
Commits
e7f101ddee
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a1a614bc9a | ||
|
|
6adc007313 | ||
|
|
54f160e8d0 | ||
|
|
5965fd51c7 | ||
|
|
2eb946a042 | ||
|
|
81110a2852 | ||
|
|
3b0f2de5b2 | ||
|
|
e173ae8056 |
@@ -1,3 +1,7 @@
|
|||||||
|
.env
|
||||||
|
.env.just
|
||||||
|
local.just
|
||||||
|
|
||||||
*.sfc
|
*.sfc
|
||||||
appsettings.Development.json
|
appsettings.Development.json
|
||||||
kube/
|
kube/
|
||||||
|
|||||||
@@ -48,7 +48,7 @@
|
|||||||
|
|
||||||
public RandomizableWeights<DungeonItemLocations> Compasses { get; set; } = new();
|
public RandomizableWeights<DungeonItemLocations> Compasses { get; set; } = new();
|
||||||
|
|
||||||
public RandomizableWeights<ShowLoot> ShowLoot { get; set; } = new();
|
public RandomizableWeights<ShowLootMap> ShowLootMap { get; set; } = new();
|
||||||
|
|
||||||
public RandomizableWeights<ShowLootHud> ShowLootHud { get; set; } = new();
|
public RandomizableWeights<ShowLootHud> ShowLootHud { get; set; } = new();
|
||||||
|
|
||||||
|
|||||||
@@ -7,9 +7,12 @@
|
|||||||
[NoSettingName]
|
[NoSettingName]
|
||||||
public RandomizerInstance Randomizer { get; set; } = RandomizerInstance.Base;
|
public RandomizerInstance Randomizer { get; set; } = RandomizerInstance.Base;
|
||||||
|
|
||||||
[NoSettingName]
|
[IgnoreSetting]
|
||||||
public string PlayerName { get; set; } = string.Empty;
|
public string PlayerName { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
[IgnoreSetting]
|
||||||
|
public int PlayerSlot { get; set; } = 1;
|
||||||
|
|
||||||
[NoSettingName]
|
[NoSettingName]
|
||||||
public RaceMode Race { get; set; } = RaceMode.Normal;
|
public RaceMode Race { get; set; } = RaceMode.Normal;
|
||||||
|
|
||||||
@@ -48,6 +51,10 @@
|
|||||||
[IgnoreSetting(Apr2025)]
|
[IgnoreSetting(Apr2025)]
|
||||||
public GanonItem GanonItem { get; set; } = GanonItem.Silver;
|
public GanonItem GanonItem { get; set; } = GanonItem.Silver;
|
||||||
|
|
||||||
|
[NoSettingName]
|
||||||
|
[IgnoreSetting(Apr2025)]
|
||||||
|
public RequireGanonItem RequireGanonItem { get; set; } = RequireGanonItem.SilverlessAllowed;
|
||||||
|
|
||||||
[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;
|
||||||
@@ -99,10 +106,10 @@
|
|||||||
|
|
||||||
[SettingName("showloot")]
|
[SettingName("showloot")]
|
||||||
[IgnoreSetting(Apr2025)]
|
[IgnoreSetting(Apr2025)]
|
||||||
public ShowLoot ShowLoot { get; set; } = ShowLoot.Never;
|
public ShowLootMap ShowLootMap { get; set; } = ShowLootMap.Never;
|
||||||
|
|
||||||
[SettingName("loothud")]
|
[SettingName("loothud")]
|
||||||
[IgnoreSetting(Apr2025, Base)]
|
[IgnoreSetting(Apr2025)]
|
||||||
public ShowLootHud ShowLootHud { get; set; } = ShowLootHud.Never;
|
public ShowLootHud ShowLootHud { get; set; } = ShowLootHud.Never;
|
||||||
|
|
||||||
[SettingName("showmap")]
|
[SettingName("showmap")]
|
||||||
@@ -165,7 +172,7 @@
|
|||||||
public TrapDoorMode TrapDoorMode { get; set; } = TrapDoorMode.Some;
|
public TrapDoorMode TrapDoorMode { get; set; } = TrapDoorMode.Some;
|
||||||
|
|
||||||
[SettingName("extra_keys")]
|
[SettingName("extra_keys")]
|
||||||
[IgnoreSetting(Apr2025, Base)]
|
[IgnoreSetting(Apr2025)]
|
||||||
public ExtraKeysMode ExtraKeys { get; set; } = ExtraKeysMode.None;
|
public ExtraKeysMode ExtraKeys { get; set; } = ExtraKeysMode.None;
|
||||||
|
|
||||||
[NoSettingName]
|
[NoSettingName]
|
||||||
@@ -324,6 +331,11 @@
|
|||||||
None,
|
None,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public enum RequireGanonItem {
|
||||||
|
SilverlessAllowed,
|
||||||
|
[AdditionalSetting("--require_ganon_item")] SpecialItemRequired,
|
||||||
|
}
|
||||||
|
|
||||||
public enum EntranceShuffle {
|
public enum EntranceShuffle {
|
||||||
Vanilla,
|
Vanilla,
|
||||||
Full,
|
Full,
|
||||||
@@ -418,7 +430,7 @@
|
|||||||
Wild,
|
Wild,
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum ShowLoot {
|
public enum ShowLootMap {
|
||||||
Never,
|
Never,
|
||||||
Presence,
|
Presence,
|
||||||
Compass,
|
Compass,
|
||||||
@@ -430,6 +442,7 @@
|
|||||||
Presence,
|
Presence,
|
||||||
Value,
|
Value,
|
||||||
[SettingName("dungeon_value")] DungeonValue,
|
[SettingName("dungeon_value")] DungeonValue,
|
||||||
|
[SettingName("cave_value")] CaveValue,
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum ShowMap {
|
public enum ShowMap {
|
||||||
@@ -468,6 +481,7 @@
|
|||||||
public enum BombSettings {
|
public enum BombSettings {
|
||||||
Normal,
|
Normal,
|
||||||
[AdditionalSetting("--bombbag")] BombBagRequired,
|
[AdditionalSetting("--bombbag")] BombBagRequired,
|
||||||
|
[AddStartingItems("Bombs_(10)")] Starting,
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum BookSettings {
|
public enum BookSettings {
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
using ALttPRandomizer.Randomizers;
|
using ALttPRandomizer.Randomizers;
|
||||||
using ALttPRandomizer.Service;
|
using ALttPRandomizer.Service;
|
||||||
using ALttPRandomizer.Settings;
|
using ALttPRandomizer.Settings;
|
||||||
|
using global::Azure.Core;
|
||||||
using global::Azure.Identity;
|
using global::Azure.Identity;
|
||||||
using global::Azure.Storage.Blobs;
|
using global::Azure.Storage.Blobs;
|
||||||
using Microsoft.AspNetCore.Builder;
|
using Microsoft.AspNetCore.Builder;
|
||||||
@@ -14,12 +15,13 @@
|
|||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
using Serilog;
|
using Serilog;
|
||||||
|
using System;
|
||||||
|
using System.Linq;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using YamlDotNet.Serialization;
|
using YamlDotNet.Serialization;
|
||||||
using YamlDotNet.Serialization.NamingConventions;
|
using YamlDotNet.Serialization.NamingConventions;
|
||||||
|
|
||||||
internal class Program
|
internal class Program {
|
||||||
{
|
|
||||||
static void Main(string[] args)
|
static void Main(string[] args)
|
||||||
{
|
{
|
||||||
var builder = WebApplication.CreateBuilder(args);
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
@@ -44,9 +46,15 @@
|
|||||||
var settings = provider.GetRequiredService<IOptionsMonitor<ServiceOptions>>().CurrentValue!;
|
var settings = provider.GetRequiredService<IOptionsMonitor<ServiceOptions>>().CurrentValue!;
|
||||||
var logger = provider.GetRequiredService<ILogger<Program>>();
|
var logger = provider.GetRequiredService<ILogger<Program>>();
|
||||||
|
|
||||||
|
var allowedCors = settings.AllowedCors;
|
||||||
|
var envCors = Environment.GetEnvironmentVariable("ALLOWED_CORS");
|
||||||
|
if (envCors != null) {
|
||||||
|
allowedCors = allowedCors.Concat(envCors.Split()).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
builder.Services.AddCors(options => {
|
builder.Services.AddCors(options => {
|
||||||
options.AddPolicy("AllowDomains", policy => {
|
options.AddPolicy("AllowDomains", policy => {
|
||||||
policy.WithOrigins(settings.AllowedCors.ToArray()).AllowAnyMethod().AllowAnyHeader();
|
policy.WithOrigins(allowedCors.ToArray()).AllowAnyMethod().AllowAnyHeader();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -75,13 +83,22 @@
|
|||||||
options.OperationFilter<DefaultMysterySettingsFilter>();
|
options.OperationFilter<DefaultMysterySettingsFilter>();
|
||||||
});
|
});
|
||||||
|
|
||||||
var options = new DefaultAzureCredentialOptions();
|
TokenCredential? token = null;
|
||||||
|
|
||||||
if (settings.AzureSettings.ClientId != null) {
|
if (Environment.GetEnvironmentVariable("USE_SAMI") == "true") {
|
||||||
options.ManagedIdentityClientId = new(settings.AzureSettings.ClientId);
|
token = new ManagedIdentityCredential(ManagedIdentityId.SystemAssigned);
|
||||||
|
} else {
|
||||||
|
var options = new DefaultAzureCredentialOptions();
|
||||||
|
|
||||||
|
var clientId = Environment.GetEnvironmentVariable("CLIENT_ID");
|
||||||
|
|
||||||
|
if (clientId != null) {
|
||||||
|
options.ManagedIdentityClientId = new(clientId);
|
||||||
|
}
|
||||||
|
|
||||||
|
token = new DefaultAzureCredential(options);
|
||||||
}
|
}
|
||||||
|
|
||||||
var token = new DefaultAzureCredential(options);
|
|
||||||
var seedClient = new BlobContainerClient(settings.AzureSettings.BlobstoreEndpoint, token);
|
var seedClient = new BlobContainerClient(settings.AzureSettings.BlobstoreEndpoint, token);
|
||||||
|
|
||||||
builder.Services.AddSingleton(seedClient);
|
builder.Services.AddSingleton(seedClient);
|
||||||
|
|||||||
@@ -18,6 +18,8 @@
|
|||||||
public const int MULTI_TRIES = 100;
|
public const int MULTI_TRIES = 100;
|
||||||
public const int SINGLE_TRIES = 5;
|
public const int SINGLE_TRIES = 5;
|
||||||
|
|
||||||
|
private static readonly Random random = new();
|
||||||
|
|
||||||
public BaseRandomizer(
|
public BaseRandomizer(
|
||||||
AzureStorage azureStorage,
|
AzureStorage azureStorage,
|
||||||
CommonSettingsProcessor settingsProcessor,
|
CommonSettingsProcessor settingsProcessor,
|
||||||
@@ -64,10 +66,20 @@
|
|||||||
args.Add("--shuffletavern");
|
args.Add("--shuffletavern");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (settings.Randomizer == RandomizerInstance.Beta) {
|
||||||
|
if (random.NextDouble() < 0.25) {
|
||||||
|
args.Add("--orange_potion");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (settings.DoorShuffle == DoorShuffle.Vanilla) {
|
if (settings.DoorShuffle == DoorShuffle.Vanilla) {
|
||||||
settings.DoorTypeMode = DoorTypeMode.Original;
|
settings.DoorTypeMode = DoorTypeMode.Original;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (settings.GanonItem == GanonItem.None) {
|
||||||
|
settings.RequireGanonItem = RequireGanonItem.SilverlessAllowed;
|
||||||
|
}
|
||||||
|
|
||||||
foreach (var arg in SettingsProcessor.GetSettings(settings.Randomizer, settings)) {
|
foreach (var arg in SettingsProcessor.GetSettings(settings.Randomizer, settings)) {
|
||||||
args.Add(arg);
|
args.Add(arg);
|
||||||
}
|
}
|
||||||
@@ -149,6 +161,10 @@
|
|||||||
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 generatorSettings = this.SettingsProcessor.GetGeneratorSettings(settings[0].Randomizer);
|
var generatorSettings = this.SettingsProcessor.GetGeneratorSettings(settings[0].Randomizer);
|
||||||
|
|
||||||
|
for (var i = 0; i < settings.Count; i++) {
|
||||||
|
settings[i].PlayerSlot = i + 1;
|
||||||
|
}
|
||||||
|
|
||||||
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();
|
||||||
|
|||||||
@@ -111,6 +111,12 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Route("/healthcheck")]
|
||||||
|
[HttpGet]
|
||||||
|
public StatusCodeResult GetHealthCheck() {
|
||||||
|
return Ok();
|
||||||
|
}
|
||||||
|
|
||||||
private ObjectResult ResolveResult(IDictionary<string, object> result) {
|
private ObjectResult ResolveResult(IDictionary<string, object> result) {
|
||||||
if (result.TryGetValue("status", out var responseCode)) {
|
if (result.TryGetValue("status", out var responseCode)) {
|
||||||
if (responseCode is int code) {
|
if (responseCode is int code) {
|
||||||
|
|||||||
@@ -59,6 +59,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
internal class IgnoreSettingAttribute : RandomizerSpecificAttribute {
|
internal class IgnoreSettingAttribute : RandomizerSpecificAttribute {
|
||||||
|
public IgnoreSettingAttribute() : base(null) { }
|
||||||
public IgnoreSettingAttribute(params RandomizerInstance[] randomizers) : base(randomizers) { }
|
public IgnoreSettingAttribute(params RandomizerInstance[] randomizers) : base(randomizers) { }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
var props = typeof(SeedSettings).GetProperties(BindingFlags.Instance | BindingFlags.Public);
|
var props = typeof(SeedSettings).GetProperties(BindingFlags.Instance | BindingFlags.Public);
|
||||||
var starting = new List<string>();
|
var starting = new List<string>();
|
||||||
foreach (var prop in props) {
|
foreach (var prop in props) {
|
||||||
if (prop.Name == nameof(SeedSettings.PlayerName)) {
|
if (prop.GetCustomAttributes<IgnoreSettingAttribute>().Any(att => att.HasRandomizer(randomizer))) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -19,10 +19,6 @@
|
|||||||
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>()
|
||||||
|
|||||||
@@ -5,10 +5,9 @@
|
|||||||
"allowedCors": [
|
"allowedCors": [
|
||||||
"https://new.alttpr.gwaa.kiwi",
|
"https://new.alttpr.gwaa.kiwi",
|
||||||
"https://api.alttpr.gwaa.kiwi",
|
"https://api.alttpr.gwaa.kiwi",
|
||||||
"http://localhost:8082"
|
"http://localhost:8082",
|
||||||
],
|
],
|
||||||
"azureSettings": {
|
"azureSettings": {
|
||||||
"clientId": "a48d5ae1-fa0a-4e33-9586-18c0eca0a28c",
|
|
||||||
"blobstoreEndpoint": "https://alttprstorage.blob.core.windows.net/seeds"
|
"blobstoreEndpoint": "https://alttprstorage.blob.core.windows.net/seeds"
|
||||||
},
|
},
|
||||||
"generators": {
|
"generators": {
|
||||||
|
|||||||
+1
-1
Submodule BaseRandomizer updated: 7bab5b0434...c0c177dfed
+1
-1
Submodule BetaRandomizer updated: 5278f9f2c6...e77bb2980b
+1
-1
Submodule PikitRandomizer updated: be35ed4451...1d4a77b8e7
@@ -0,0 +1,25 @@
|
|||||||
|
set dotenv-filename := ".env.just"
|
||||||
|
|
||||||
|
import? "local.just"
|
||||||
|
|
||||||
|
[private]
|
||||||
|
@list:
|
||||||
|
just --list --list-submodules --unsorted
|
||||||
|
|
||||||
|
# Build docker image
|
||||||
|
[group("docker")]
|
||||||
|
[arg("TAG", long="tag", short="t")]
|
||||||
|
build VERSION="latest" TAG=env("DOCKER_TAG"):
|
||||||
|
DOCKER_BUILDKIT=1 docker build . --progress=plain -t {{TAG}}:{{VERSION}}
|
||||||
|
|
||||||
|
# Run docker image
|
||||||
|
[group("docker")]
|
||||||
|
[arg("TAG", long="tag", short="t")]
|
||||||
|
run VERSION="latest" TAG=env("DOCKER_TAG"): (build VERSION TAG)
|
||||||
|
docker run -p 5000:8080 {{TAG}}:{{VERSION}}
|
||||||
|
|
||||||
|
# Push docker image to registry
|
||||||
|
[group("docker")]
|
||||||
|
[arg("TAG", long="tag", short="t")]
|
||||||
|
push VERSION="latest" TAG=env("DOCKER_TAG"): (build VERSION TAG)
|
||||||
|
docker push {{TAG}}:{{VERSION}}
|
||||||
Reference in New Issue
Block a user