Skip to content
Merged
Show file tree
Hide file tree
Changes from 11 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
4 changes: 2 additions & 2 deletions src/TrackerCouncil.Smz3.Data/RandomizerVersion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ public class RandomizerVersion
{
// Update this whenever we have breaking logic changes which might affect
// old seeds. Only use the major version number.
public static Version Version => new(7, 0);
public static Version Version => new(8, 0);

public static string VersionString => Version.ToString();

public static int MajorVersion => Version.Major;

public static Version PreReplaceDungeonStateVersion => new Version(6, 0);
public static Version PreReplaceDungeonStateVersion => new(7, 0);

public static bool IsVersionPreReplaceDungeonState(int version) => version <= PreReplaceDungeonStateVersion.Major;
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class GenerationWindowLogicViewModel : ViewModelBase
[DynamicFormObject(groupName: "All")]
public CasPatches CasPatches { get; set; } = new();

public bool CanChangeGameSettings { get; set; }
public bool CanChangeGameSettings { get; set; } = true;

public bool IsPlando
{
Expand Down
2 changes: 1 addition & 1 deletion src/TrackerCouncil.Smz3.Data/WorldData/Location.cs
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ public string RandomName
}


public IHasTreasure? GetTreasureRegion() => Region as IHasTreasure;
public IHasTreasure? GetTreasureRegion() => Type == LocationType.NotInDungeon ? null : Region as IHasTreasure;

public event EventHandler? ClearedUpdated;
public event EventHandler? MarkedItemUpdated;
Expand Down
6 changes: 6 additions & 0 deletions src/TrackerCouncil.Smz3.Data/WorldData/Regions/IHasBoss.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ public interface IHasBoss

LocationId? BossLocationId { get; }

/// <summary>
/// If the boss and location are tied where one can't be received without the other
/// (e.g. Zelda dungeons)
/// </summary>
public bool UnifiedBossAndItemLocation { get; }

Region Region => (Region)this;

public bool BossDefeated
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Collections.Generic;
using TrackerCouncil.Smz3.Shared;
using TrackerCouncil.Smz3.Data.Configuration.ConfigTypes;
using TrackerCouncil.Smz3.Data.Options;
using TrackerCouncil.Smz3.Data.Services;
Expand Down Expand Up @@ -35,6 +34,8 @@ public KraidsLair(World world, Config config, IMetadataService? metadata, Tracke

public LocationId? BossLocationId => LocationId.KraidsLairVariaSuit;

public bool UnifiedBossAndItemLocation => false;

public Reward Reward { get; set; } = null!;

public RewardType DefaultRewardType => RewardType.KraidToken;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ public InnerMaridia(World world, Config config, IMetadataService? metadata, Trac

public LocationId? BossLocationId => LocationId.InnerMaridiaSpaceJump;

public bool UnifiedBossAndItemLocation => false;

public Reward Reward { get; set; } = null!;

public RewardType DefaultRewardType => RewardType.DraygonToken;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ public LowerNorfairEast(World world, Config config, IMetadataService? metadata,

public LocationId? BossLocationId => LocationId.LowerNorfairRidleyTank;

public bool UnifiedBossAndItemLocation => false;

public Reward Reward { get; set; } = null!;

public RewardType DefaultRewardType => RewardType.RidleyToken;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ public WreckedShip(World world, Config config, IMetadataService? metadata, Track

public LocationId? BossLocationId => LocationId.WreckedShipWestSuper;

public bool UnifiedBossAndItemLocation => false;

public Reward Reward { get; set; } = null!;

public RewardType DefaultRewardType => RewardType.PhantoonToken;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ public CastleTower(World world, Config config, IMetadataService? metadata, Track

public LocationId? BossLocationId => null;

public bool UnifiedBossAndItemLocation => false;

public Reward Reward { get; set; } = null!;

public FoyerRoom Foyer { get; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ public DesertPalace(World world, Config config, IMetadataService? metadata, Trac

public bool IsShuffledReward => true;

public bool UnifiedBossAndItemLocation => true;

public override List<string> AlsoKnownAs { get; } = ["Dessert Palace"];

public LocationId? BossLocationId => LocationId.DesertPalaceLanmolas;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ public EasternPalace(World world, Config config, IMetadataService? metadata, Tra

public bool IsShuffledReward => true;

public bool UnifiedBossAndItemLocation => true;

public Reward Reward { get; set; } = null!;

public TrackerTreasureState TreasureState { get; set; } = null!;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ public GanonsTower(World world, Config config, IMetadataService? metadata, Track

public LocationId? BossLocationId => null;

public bool UnifiedBossAndItemLocation => true;

public BossType DefaultBossType => BossType.Ganon;

public TrackerTreasureState TreasureState { get; set; } = null!;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ public HyruleCastle(World world, Config config, IMetadataService? metadata, Trac

public LocationId? BossLocationId => null;

public bool UnifiedBossAndItemLocation => true;

public TrackerTreasureState TreasureState { get; set; } = null!;

public event EventHandler? UpdatedTreasure;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ public IcePalace(World world, Config config, IMetadataService? metadata, Tracker

public LocationId? BossLocationId => LocationId.IcePalaceKholdstare;

public bool UnifiedBossAndItemLocation => true;

public Reward Reward { get; set; } = null!;

public TrackerTreasureState TreasureState { get; set; } = null!;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ public MiseryMire(World world, Config config, IMetadataService? metadata, Tracke

public LocationId? BossLocationId => LocationId.MiseryMireVitreous;

public bool UnifiedBossAndItemLocation => true;

public Reward Reward { get; set; } = null!;

public TrackerRewardState RewardState { get; set; } = null!;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ public PalaceOfDarkness(World world, Config config, IMetadataService? metadata,

public LocationId? BossLocationId => LocationId.PalaceOfDarknessHelmasaurKing;

public bool UnifiedBossAndItemLocation => true;

public Reward Reward { get; set; } = null!;

public TrackerTreasureState TreasureState { get; set; } = null!;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ public SkullWoods(World world, Config config, IMetadataService? metadata, Tracke

public LocationId? BossLocationId => LocationId.SkullWoodsMothula;

public bool UnifiedBossAndItemLocation => true;

public Reward Reward { get; set; } = null!;

public TrackerTreasureState TreasureState { get; set; } = null!;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ public SwampPalace(World world, Config config, IMetadataService? metadata, Track

public LocationId? BossLocationId => LocationId.SwampPalaceArrghus;

public bool UnifiedBossAndItemLocation => true;

public Reward Reward { get; set; } = null!;

public TrackerTreasureState TreasureState { get; set; } = null!;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ public ThievesTown(World world, Config config, IMetadataService? metadata, Track

public LocationId? BossLocationId => LocationId.ThievesTownBlind;

public bool UnifiedBossAndItemLocation => true;

public Reward Reward { get; set; } = null!;

public TrackerTreasureState TreasureState { get; set; } = null!;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ public TowerOfHera(World world, Config config, IMetadataService? metadata, Track

public LocationId? BossLocationId => LocationId.TowerOfHeraMoldorm;

public bool UnifiedBossAndItemLocation => true;

public Reward Reward { get; set; } = null!;

public TrackerTreasureState TreasureState { get; set; } = null!;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ public TurtleRock(World world, Config config, IMetadataService? metadata, Tracke

public LocationId? BossLocationId => LocationId.TurtleRockTrinexx;

public bool UnifiedBossAndItemLocation => true;

public Reward Reward { get; set; } = null!;

public TrackerTreasureState TreasureState { get; set; } = null!;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ public void MarkBossAsNotDefeated(Boss boss, float? confidence = null, bool forc
/// </summary>
/// <param name="region">The dungeon that should be un-cleared.</param>
/// <param name="confidence">The speech recognition confidence.</param>
/// <param name="force">If the user requested to force the boss to be marked as not defeated</param>
public void MarkBossAsNotDefeated(IHasBoss region, float? confidence = null, bool force = false)
{
if (!region.BossDefeated)
Expand All @@ -201,7 +202,7 @@ public void MarkBossAsNotDefeated(IHasBoss region, float? confidence = null, boo
// Try to untrack the associated boss reward item
List<Action> undoActions = [];

if (region.BossLocationId != null)
if (region is { BossLocationId: not null, UnifiedBossAndItemLocation: true })
{
var bossLocation = World.LocationMap[region.BossLocationId.Value];
if (bossLocation.Cleared)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ public bool TrackItem(Item item, string? trackedAs = null, float? confidence = n
// Clear the location if it's for the local player's world
if (location != null && location.World == World && !location.Cleared)
{
Tracker.LocationTracker.Clear(location, confidence, autoTracked, !stateResponse, true);
Tracker.LocationTracker.Clear(location, confidence, autoTracked, stateResponse, true);
undoActions.Add(autoTracked ? null : PopUndo().Action);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ public void Clear(List<Location> locations, float? confidence = null)
if (locations.First().Region is IHasTreasure dungeon)
{
var treasureCount = locations.Count(x => x.Item.IsTreasure || World.Config.ZeldaKeysanity);
if (Tracker.TreasureTracker.TrackDungeonTreasure(dungeon, confidence, treasureCount))
if (treasureCount > 0 && Tracker.TreasureTracker.TrackDungeonTreasure(dungeon, confidence, treasureCount))
undoDungeonTreasure = PopUndo().Action;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,20 +53,19 @@ public void GiveAreaReward(IHasReward rewardRegion, bool isAutoTracked, bool sta
return;
}

// Skip Metroid region rewards unless it's a parsed AP/Mainline rom
if (rewardRegion is SMRegion && rewardRegion.World.Config.RomGenerator == RomGenerator.Cas)
{
return;
}

var previousMarkedReward = rewardRegion.MarkedReward;
rewardRegion.HasReceivedReward = true;

if (isAutoTracked && !rewardRegion.HasCorrectlyMarkedReward)
{
rewardRegion.MarkedReward = rewardRegion.RewardType;
var rewardObj = rewardRegion.Reward;
Tracker.Say(response: Responses.DungeonRewardMarked, args: [rewardRegion.Metadata.Name, rewardObj.Metadata.Name ?? rewardObj.Type.GetDescription()]);

if (rewardRegion is not SMRegion || rewardRegion.World.Config.RomGenerator != RomGenerator.Cas)
{
var rewardObj = rewardRegion.Reward;
Tracker.Say(response: Responses.DungeonRewardMarked, args: [rewardRegion.Metadata.Name, rewardObj.Metadata.Name ?? rewardObj.Type.GetDescription()]);
}

}

UpdateAllAccessibility(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public bool TrackDungeonTreasure(IHasTreasure region, float? confidence = null,
// Always add a response if there's treasure left, even when
// clearing a dungeon (because that means it was out of logic
// and could be relevant)
if (stateResponse && (confidence != null || region.RemainingTreasure >= 1 || autoTracked))
if (stateResponse && (confidence != null || region.RemainingTreasure >= 0 || autoTracked))
{
// Try to get the response based on the amount of items left
if (Responses.DungeonTreasureTracked?.TryGetValue(region.RemainingTreasure, out var response) == true)
Expand Down Expand Up @@ -112,7 +112,7 @@ public bool UntrackDungeonTreasure(IHasTreasure region, int amount = 1)

public Action? TryTrackDungeonTreasure(Location location, float? confidence, bool autoTracked = false, bool stateResponse = true)
{
if (!autoTracked && confidence < Options.MinimumSassConfidence)
if (!autoTracked && confidence < Options.MinimumSassConfidence || location.Type == LocationType.NotInDungeon)
{
// Tracker response could give away the location of an item if
// it is in a dungeon but tracker misheard.
Expand Down
10 changes: 9 additions & 1 deletion src/TrackerCouncil.Smz3.UI/Services/MultiRomListService.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
using System.Linq;
using System.Threading.Tasks;
using Avalonia.Controls;
using AvaloniaControls.Controls;
using AvaloniaControls.ControlServices;
using TrackerCouncil.Smz3.Data.Options;
using TrackerCouncil.Smz3.Data.Services;
using TrackerCouncil.Smz3.UI.ViewModels;
using TrackerCouncil.Smz3.UI.Views;

namespace TrackerCouncil.Smz3.UI.Services;

public class MultiRomListService(IGameDbService gameDbService, SharedCrossplatformService sharedCrossplatformService) : ControlService
public class MultiRomListService(IGameDbService gameDbService, SharedCrossplatformService sharedCrossplatformService, OptionsFactory options) : ControlService
{
private MultiRomListViewModel _model = new();
private MultiRomListPanel _panel = null!;
Expand Down Expand Up @@ -36,6 +38,12 @@ public void OpenStatusWindow(MultiplayerRomViewModel model)

public async Task OpenConnectWindow(bool isCreate)
{
if (!options.Create().GeneralOptions.Validate())
{
await MessageWindow.ShowErrorDialog("You must select the A Link to the Past and Super Metroid roms in the Options window before creating or joining multiplayer games.");
return;
}

var window = new MultiplayerConnectWindow(isCreate);
await window.ShowDialog(ParentWindow);
if (!window.DialogResult)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,15 +128,15 @@ public void OpenSpoilerLog()
sharedCrossplatformService.OpenSpoilerLog(_model.GeneratedRom);
}

public void LaunchTracker()
public async Task LaunchTracker()
{
_trackerWindow = sharedCrossplatformService.LaunchTracker(_model.GeneratedRom);
_trackerWindow = await sharedCrossplatformService.LaunchTrackerAsync(_model.GeneratedRom);
FinalizeLaunch();
}

public void LaunchRom()
public async Task LaunchRom()
{
_trackerWindow = sharedCrossplatformService.LaunchRom(_model.GeneratedRom);
_trackerWindow = await sharedCrossplatformService.LaunchRom(_model.GeneratedRom);
FinalizeLaunch();
}

Expand Down
21 changes: 19 additions & 2 deletions src/TrackerCouncil.Smz3.UI/Services/SetupWindowService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,26 @@ public async Task TestAutoTracking()
_model.AutoTrackerOpacity = 0.2f;
_model.AutoTrackerIconKind = MaterialIconKind.CircleOutline;
_model.AutoTrackerBrush = Brushes.White;
_model.AutoTrackerMessage = "Connecting...";

snesConnectorService.Connect(GetSnesConnectorSettings());
var connectorSettings = GetSnesConnectorSettings();

if (connectorSettings.ConnectorType is SnesConnectorType.Lua or SnesConnectorType.LuaEmoTracker)
{
_model.AutoTrackerMessage =
"Connecting. Make sure you have a game running in your emulator with the Lua script executing.";
}
else if (connectorSettings.ConnectorType == SnesConnectorType.Usb2Snes)
{
_model.AutoTrackerMessage =
"Connecting. Make sure you have a game running in your emulator with QUSB2SNES running and connected to it.";
}
else if (connectorSettings.ConnectorType == SnesConnectorType.Sni)
{
_model.AutoTrackerMessage =
"Connecting. Make sure you have a game running in your emulator with SNI running and conected to it.";
}

snesConnectorService.Connect(connectorSettings);

try
{
Expand Down
Loading