using RynthCore.Plugin.Shared;
namespace RynthCore.Plugin.RynthInventory;
internal enum InventoryVerb { Window, Scan, Keep, Reload, Status, Help, Search, Bank, Trade }
///
/// A parsed "/ginv ..." and the lines it answers with (2026-10-28: every command answers,
/// Plugins/Shared/CommandReply.cs). Anything that isn't a verb is a search. Pure, so
/// RynthInventory.Tests checks every word.
///
internal readonly record struct InventoryCommand(InventoryVerb Verb, string Text = "")
{
public static InventoryCommand Parse(string? arg)
{
string a = (arg ?? string.Empty).Trim();
return a.ToLowerInvariant() switch
{
"" => new(InventoryVerb.Window),
"scan" or "rescan" => new(InventoryVerb.Scan),
"keep" => new(InventoryVerb.Keep),
"reload" => new(InventoryVerb.Reload),
"status" => new(InventoryVerb.Status),
"help" or "?" => new(InventoryVerb.Help),
// The test branch's Banking tab (Infinite Leaftide) and trade list.
"bank" or "banking" => new(InventoryVerb.Bank),
"trade" => new(InventoryVerb.Trade),
_ => new(InventoryVerb.Search, a),
};
}
public const string Usage =
"/ginv (window), /ginv (search), /ginv trade (trade list), /ginv bank (every character's bank, Infinite Leaftide), /ginv scan (rescan and save now), /ginv keep (record the open container as storage), /ginv reload, /ginv status. "
+ "To find items like one you carry, right-click it in the Inventory panel: Find like this in Global Inventory (/ginv like clear removes that filter).";
public const string NoWindows =
"This RynthCore engine can't show plugin windows (it needs script windows, API v71, with ImGui on). Scanning and saving still work; /ginv status shows what was saved.";
/// /ginv alone: the window after the toggle.
public static string Window(bool shown) => CommandReply.Shown("Global Inventory", shown);
/// /ginv <text>: the search the window now shows.
public static string Searching(string text) => $"Global Inventory: searching for '{text.Trim()}'.";
}