Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Archipelago tracking #614

Merged
merged 4 commits into from
Dec 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,29 @@ public class ResponseConfig : IMergeable<ResponseConfig>, IConfigFile<ResponseCo
/// </summary> = new()
public SchrodingersString? ClearedMultipleItems { get; init; }

/// <summary>
/// Get the phrases to respond with when playing a parsed AP/Mainline multiworld game and the player picked up an
/// item for another player that is known by SMZ3 (another SMZ3, Z3, or SM item).
/// <c>{0}</c> is a placeholder for the name of the item.
/// <c>{1}</c> is a placeholder for the name of the item prefixed with the article.
/// <c>{2}</c> is a placeholder for the parsed name of the player this item is for.
/// </summary>
public SchrodingersString? TrackedParsedOtherGameKnownItem { get; init; }

/// <summary>
/// Gets the phrases to respond with when playing a parsed AP/Mainline multiworld game and the player picked up an
/// item for another player that is unknown by SMZ3 but was labeled as progression.
/// <c>{0}</c> is a placeholder for the parsed name of the player this item is for.
/// </summary>
public SchrodingersString? TrackedParsedOtherGameUnknownProgressionItem { get; init; }

/// <summary>
/// Gets the phrases to respond with when playing a parsed AP/Mainline multiworld game and the player picked up an
/// item for another player that is unknown by SMZ3 but was labeled as not progression.
/// <c>{0}</c> is a placeholder for the parsed name of the player this item is for.
/// </summary>
public SchrodingersString? TrackedParsedOtherGameUnknownRegularItem { get; init; }

/// <summary>
/// Gets the phrases to respond with when tracking or clearing multiple
/// items in an area at once, but there no items left.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,30 @@ public static RewardConfig Default()
Article = null,
RewardType = RewardType.Agahnim,
},
new()
{
Reward = "Kraid Boss Token",
Article = "the",
RewardType = RewardType.KraidToken,
},
new()
{
Reward = "Phantoon Boss Token",
Article = "the",
RewardType = RewardType.PhantoonToken,
},
new()
{
Reward = "Draygon Boss Token",
Article = "the",
RewardType = RewardType.DraygonToken,
},
new()
{
Reward = "Ridley Boss Token",
Article = "the",
RewardType = RewardType.RidleyToken,
},
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ public class AutoTrackerConfig : IMergeable<AutoTrackerConfig>
/// </summary>
public SchrodingersString? GameStartedMultiplayer { get; init; }

/// <summary>
/// Gets the phrases to respond with when a parsed non-Cas rando seed has been started
/// </summary>
public SchrodingersString? GameStartedNonCas { get; init; }

/// <summary>
/// Gets the phrases to respond with when nearing KAD
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public BossInfo(SchrodingersString name)
public BossInfo(string name)
{
Boss = name;
Name = new SchrodingersString(name);
Name = [name];
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,13 @@ public class HintsConfig : IMergeable<HintsConfig>
/// </summary>
public SchrodingersString? LocationHasUsefulItem { get; init; }

/// <summary>
/// Gets hints for a non Cas' seed where it could be mandatory, but we don't know
/// <c>{0}</c> is placeholder for the name of the location.
/// <c>{1}</c> is placeholder for the name of the character who the item is for.
/// </summary>
public SchrodingersString? LocationHasNonCasProgressionItem { get; init; }

/// <summary>
/// Gets the hints for locations that have an item from Super Metroid.
/// <c>{0}</c> is placeholder for the name of the location. <c>{1}</c>
Expand Down Expand Up @@ -269,6 +276,19 @@ public class HintsConfig : IMergeable<HintsConfig>
/// </summary>
public SchrodingersString? AreaHasJunkAndCrystal { get; init; }

/// <summary>
/// Gets the hint to give for an area in a non-Cas parsed rom that could
/// possibly be progression, but we're not positive
/// </summary>
public SchrodingersString? AreaHasNonCasPossibleProgression { get; init; }

/// <summary>
/// Gets the hint to give for an area in a non-Cas parsed rom that only has
/// junk items left, but also has a crystal or metroid boss as the reward
/// for beating the boss. <c>{0}</c> is a placeholder for the name of the area.
/// </summary>
public SchrodingersString? AreaHasNonCasJunkAndReward { get; init; }

/// <summary>
/// Gets the hint to give for an area whose worth is complicated, e.g.
/// when a dungeon has only junk and is not a crystal dungeon, but the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,19 @@ public class SpoilerConfig : IMergeable<SpoilerConfig>
/// <summary>
/// Gets the phrases that spoil the item that is at the requested
/// location, when the item does not exist in the item data.
/// <c>{0}</c> is a placeholder for the name of the location. <c>{1}</c>
/// is a placeholder for the name of the item, with "a", "an" or "the".
/// <c>{0}</c> is a placeholder for the name of the location.
/// </summary>
public SchrodingersString? LocationHasUnknownItem { get; init; }

/// <summary>
/// Gets the phrases that spoil the item that is at the requested
/// location, but the item is for another game.
/// <c>{0}</c> is a placeholder for the name of the location.
/// <c>{1}</c> is a placeholder for the name of the item. Note for this
/// we don't have knowledge of if it's singular or plural
/// </summary>
public SchrodingersString? LocationHasOtherGameItem { get; init; }

/// <summary>
/// Gets the phrases that spoil the location that has the requested
/// item.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,5 @@ public UIGridLocation() { }
/// <summary>
/// Map of identifier to images to use
/// </summary>
public Dictionary<string, string> ReplacementImages { get; set; } = new();
public Dictionary<string, string>? ReplacementImages { get; set; } = new();
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public interface IRomGenerationService
{
public SeedData GeneratePlandoSeed(RandomizerOptions options, PlandoConfig plandoConfig);
public Task<GeneratedRomResult> GenerateRandomRomAsync(RandomizerOptions options, int attempts = 5);
public byte[] GenerateRomBytes(RandomizerOptions options, SeedData? seed);
public byte[] GenerateRomBytes(RandomizerOptions options, SeedData? seed, ParsedRomDetails? parsedRomDetails);
public Task<GeneratedRomResult> GeneratePlandoRomAsync(RandomizerOptions options, PlandoConfig plandoConfig);
public Task<GeneratedRomResult> GenerateParsedRomAsync(RandomizerOptions options, ParsedRomDetails parsedRomDetails);
public Task<GeneratedRomResult> GeneratePreSeededRomAsync(RandomizerOptions options, SeedData seed,
Expand Down
4 changes: 2 additions & 2 deletions src/TrackerCouncil.Smz3.Data/Options/CasPatches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ public class CasPatches : ViewModelBase
[DynamicFormFieldComboBox(label: "Zelda item drops:", groupName: "Bottom")]
public ZeldaDrops ZeldaDrops { get; set; }

[DynamicFormFieldSlider(0, 15, label: "Hint tiles:", groupName: "Bottom", visibleWhenTrue: nameof(CanChangeGameSettings))]
[DynamicFormFieldSlider(0, 15, label: "Hint tiles:", groupName: "Bottom", visibleWhenTrue: nameof(CanSetHintTiles))]
public int HintTiles { get; set; } = 15;

[YamlIgnore] public bool CanChangeGameSettings { get; set; } = true;
[YamlIgnore] public bool CanSetHintTiles { get; set; } = true;

public CasPatches Clone()
{
Expand Down
3 changes: 2 additions & 1 deletion src/TrackerCouncil.Smz3.Data/Options/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -187,14 +187,15 @@ public class Config
public MenuSpeed MenuSpeed { get; set; } = MenuSpeed.Default;
public bool CasualSMPatches { get; set; } = false;
public ZeldaDrops? ZeldaDrops { get; set; }
public RomGenerator RomGenerator { get; set; } = RomGenerator.Cas;
public bool GenerateSeedOnly { get; private set; } = false;

public string LinkName { get; set; } = "Link";

public string SamusName { get; set; } = "Samus";

public bool SingleWorld => GameMode == GameMode.Normal;
public bool MultiWorld => GameMode == GameMode.Multiworld;
public bool MultiWorld => GameMode == GameMode.Multiworld && RomGenerator == RomGenerator.Cas;
public bool Keysanity => KeysanityMode != KeysanityMode.None;
public int Id { get; set; }
public string PlayerName { get; set; } = "";
Expand Down
34 changes: 24 additions & 10 deletions src/TrackerCouncil.Smz3.Data/Options/ItemSettingOptions.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using TrackerCouncil.Smz3.Shared;
using TrackerCouncil.Smz3.Shared.Enums;
using YamlDotNet.Serialization;
using YamlDotNet.Serialization.NamingConventions;
Expand Down Expand Up @@ -41,14 +41,28 @@ public class ItemSettingOptions
/// <returns>The item types that the user will start with</returns>
public static IEnumerable<ItemType> GetStartingItemTypes(Config config)
{
var itemOptions = config.ItemOptions;
var itemTypes = GetOptions()
.Where(x => itemOptions.ContainsKey(x.Item)
&& x.Options[itemOptions[x.Item]].MemoryValues != null
&& x.Options[itemOptions[x.Item]].MatchingItemTypes != null)
.SelectMany(x => x.Options[itemOptions[x.Item]].MatchingItemTypes!)
.ToList();
return itemTypes;
var selectedOptions = config.ItemOptions;
var options = GetOptions().ToList();

var toReturn = new List<ItemType>();

foreach (var option in selectedOptions)
{
if (option.Key.StartsWith("ItemType:") && Enum.TryParse(option.Key[9..], out ItemType itemType))
{
toReturn.AddRange(Enumerable.Repeat(itemType, option.Value));
}
else
{
var settings = options.FirstOrDefault(x => x.Item == option.Key && x.Options[option.Value].MemoryValues != null && x.Options[option.Value].MatchingItemTypes?.Count > 0);
if (settings != null)
{
toReturn.AddRange(settings.Options[option.Value].MatchingItemTypes!);
}
}
}

return toReturn;
}

/// <summary>
Expand Down
7 changes: 5 additions & 2 deletions src/TrackerCouncil.Smz3.Data/ParsedRom/ParsedRomDetails.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ namespace TrackerCouncil.Smz3.Data.ParsedRom;

public class ParsedRomDetails
{
public required string OriginalPath { get; set; }
public required string OriginalFilename { get; set; }
public required string RomTitle { get; set; }
public required int Seed { get; set; }
public required bool IsMultiworld { get; set; }
public required bool IsHardLogic { get; set; }
public required KeysanityMode KeysanityMode { get; set; }
public required bool IsArchipelago { get; set; }
public required bool IsCasRom { get; set; }
public required RomGenerator RomGenerator { get; set; }
public required int GanonsTowerCrystalCount { get; set; }
public required int GanonCrystalCount { get; set; }
public required int TourianBossCount { get; set; }
Expand All @@ -20,4 +21,6 @@ public class ParsedRomDetails
public required List<ParsedRomBossDetails> Bosses { get; set; }
public required List<ParsedRomRewardDetails> Rewards { get; set; }
public required List<ParsedRomPrerequisiteDetails> Prerequisites { get; set; }
public required Dictionary<ItemType, int> StartingItems { get; set; }
public required List<byte[]> ParsedText { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
using TrackerCouncil.Smz3.Data.Interfaces;
using TrackerCouncil.Smz3.Data.Options;
using TrackerCouncil.Smz3.Data.ViewModels;
using TrackerCouncil.Smz3.Shared;
using TrackerCouncil.Smz3.Shared.Enums;
using YamlDotNet.Serialization;
using YamlDotNet.Serialization.NamingConventions;

Expand Down Expand Up @@ -478,10 +480,46 @@ public Config GetConfig()
public void UpdateSummaryText()
{
var sb = new StringBuilder();
sb.AppendLine("Game Settings");
sb.AppendLine(GetObjectSummary(_model.GameSettings, " - ", Environment.NewLine));
sb.AppendLine("Logic");
sb.AppendLine(GetObjectSummary(_model.Logic.LogicConfig, " - ", Environment.NewLine));

if (_model.ImportDetails != null)
{
var details = _model.ImportDetails;
var ynResponses = new Dictionary<bool, string> { { true, "Yes" }, { false, "No" } };
var playerCount = details.RomGenerator == RomGenerator.Mainline
? details.Players.Count
: details.Players.Count - 1;

sb.AppendLine("Rom Import Details");
sb.AppendLine($" - File: {details.OriginalPath}");
sb.AppendLine($" - Seed: {details.Seed}");
sb.AppendLine($" - Original Generator: {details.RomGenerator.GetDescription()}");
sb.AppendLine($" - Player Name: {details.Players.First(x => x.IsLocalPlayer).PlayerName}");
sb.AppendLine($" - Player Count: {playerCount}");

sb.AppendLine($" - GT Crystal Count: {details.GanonsTowerCrystalCount}");
sb.AppendLine($" - Ganon Crystal Count: {details.GanonCrystalCount}");
sb.AppendLine($" - Tourian Boss Count: {details.TourianBossCount}");

sb.AppendLine($" - IsMultiworld: {ynResponses[details.IsMultiworld]}");
sb.AppendLine($" - IsHardLogic: {ynResponses[details.IsHardLogic]}");
sb.AppendLine($" - Keysanity: {details.KeysanityMode.GetDescription()}");

if (details.RomGenerator != RomGenerator.Archipelago)
{
var startingItems = string.Join(", ",
details.StartingItems.Select(x => $"{x.Key.GetDescription()}: {x.Value}"));
sb.AppendLine($" - Starting Items: {startingItems}");
}
}
else
{
sb.AppendLine("Game Settings");
sb.AppendLine(GetObjectSummary(_model.GameSettings, " - ", Environment.NewLine));

sb.AppendLine("Logic");
sb.AppendLine(GetObjectSummary(_model.Logic.LogicConfig, " - ", Environment.NewLine));
}

sb.AppendLine("Cas' Patches");
sb.AppendLine(GetObjectSummary(_model.Logic.CasPatches, " - ", Environment.NewLine));

Expand Down
Loading