Switch selftest to using mounts instead of teleporting

This commit is contained in:
RedworkDE 2026-01-03 23:11:50 +01:00
parent 8b0f0fb44e
commit 9b55b020ca

View file

@ -1,10 +1,13 @@
using Dalamud.Bindings.ImGui; using Dalamud.Bindings.ImGui;
using Dalamud.Data;
using Dalamud.Game.Chat; using Dalamud.Game.Chat;
using Dalamud.Game.Gui; using Dalamud.Game.Gui;
using Dalamud.Game.Text; using Dalamud.Game.Text;
using Dalamud.Game.Text.SeStringHandling; using Dalamud.Game.Text.SeStringHandling;
using Dalamud.Plugin.SelfTest; using Dalamud.Plugin.SelfTest;
using Lumina.Excel.Sheets;
namespace Dalamud.Interface.Internal.Windows.SelfTest.Steps; namespace Dalamud.Interface.Internal.Windows.SelfTest.Steps;
/// <summary> /// <summary>
@ -15,10 +18,10 @@ internal class ChatSelfTestStep : ISelfTestStep
private int step = 0; private int step = 0;
private bool subscribedChatMessage = false; private bool subscribedChatMessage = false;
private bool subscribedLogMessage = false; private bool subscribedLogMessage = false;
private bool hasPassed = false; private bool hasSeenEchoMessage = false;
private bool hasTeleportGil = false; private bool hasSeenMountMessage = false;
private bool hasTeleportTicket = false; private string mountName = "";
private int teleportCount = 0; private string mountUser = "";
/// <inheritdoc/> /// <inheritdoc/>
public string Name => "Test Chat"; public string Name => "Test Chat";
@ -45,7 +48,7 @@ internal class ChatSelfTestStep : ISelfTestStep
chatGui.ChatMessage += this.ChatOnOnChatMessage; chatGui.ChatMessage += this.ChatOnOnChatMessage;
} }
if (this.hasPassed) if (this.hasSeenEchoMessage)
{ {
chatGui.ChatMessage -= this.ChatOnOnChatMessage; chatGui.ChatMessage -= this.ChatOnOnChatMessage;
this.subscribedChatMessage = false; this.subscribedChatMessage = false;
@ -55,7 +58,7 @@ internal class ChatSelfTestStep : ISelfTestStep
break; break;
case 2: case 2:
ImGui.Text("Teleport somewhere..."); ImGui.Text("Use any mount...");
if (!this.subscribedLogMessage) if (!this.subscribedLogMessage)
{ {
@ -63,18 +66,11 @@ internal class ChatSelfTestStep : ISelfTestStep
chatGui.LogMessage += this.ChatOnLogMessage; chatGui.LogMessage += this.ChatOnLogMessage;
} }
if (this.hasTeleportGil) if (this.hasSeenMountMessage)
{ {
ImGui.Text($"You spent {this.teleportCount} gil to teleport."); ImGui.Text($"{this.mountUser} mounted {this.mountName}.");
}
if (this.hasTeleportTicket) ImGui.Text("Is this correct? It is correct if this triggers on other players around you.");
{
ImGui.Text($"You used a ticket to teleport and have {this.teleportCount} remaining.");
}
if (this.hasTeleportGil || this.hasTeleportTicket)
{
ImGui.Text("Is this correct?");
if (ImGui.Button("Yes")) if (ImGui.Button("Yes"))
{ {
@ -117,23 +113,25 @@ internal class ChatSelfTestStep : ISelfTestStep
{ {
if (type == XivChatType.Echo && message.TextValue == "DALAMUD") if (type == XivChatType.Echo && message.TextValue == "DALAMUD")
{ {
this.hasPassed = true; this.hasSeenEchoMessage = true;
} }
} }
private void ChatOnLogMessage(ILogMessage message) private void ChatOnLogMessage(ILogMessage message)
{ {
if (message.LogMessageId == 4590 && message.TryGetIntParameter(0, out var value)) if (message.LogMessageId == 646 && message.TryGetIntParameter(0, out var value))
{ {
this.hasTeleportGil = true; this.hasSeenMountMessage = true;
this.hasTeleportTicket = false; this.mountUser = message.SourceEntity?.Name.ExtractText() ?? "<incorrect>";
this.teleportCount = value; try
} {
if (message.LogMessageId == 4591 && message.TryGetIntParameter(0, out var item) && item == 7569 && message.TryGetIntParameter(1, out var remaining)) this.mountName = Service<DataManager>.Get().GetExcelSheet<Mount>().GetRow((uint)value).Singular.ExtractText();
{ }
this.hasTeleportGil = false; catch
this.hasTeleportTicket = true; {
this.teleportCount = remaining; // ignore any errors with retrieving the mount name, they are probably not related to this test
this.mountName = $"Mount ID: {value} (failed to retrieve mount name)";
}
} }
} }
} }