namespace SoulstormReplayReader.Core.Domain.Action;

public sealed class GameActionModel : IGameAction
{
    public int Tick { get; set; }

    public int PlayerId { get; set; }
    public int PlayerActionCount { get; set; }

    public int Cmd { get; set; }
    public byte Arg { get; set; }
    public short SubCmd { get; set; }
    public byte SomeByte { get; set; }
    public bool ShiftPressed { get; set; }

    public string Name => GetName(Cmd);

    public override string ToString() => $"{Cmd,3} {Arg,3} {SubCmd:x} {SomeByte:x} {ShiftPressed,5}";

    private static string GetName(int playerCommand) => playerCommand switch
    {
        0 => "Moved unit",
        2 => "Destroyed building",
        3 => "Train unit",
        4 => "Canceled research",
        6 => "Research started",
        7 => "Building is upgrading",
        10 => "UI building attack",
        14 => "Point of gathering",
        18 => "Changed building behavior",
        20 => "Building abils?? (laud hailer)",
        24 => "Auto train",
        26 => "Get from building",
        28 => "[eldar] Teleport building",
        56 => "UI move",
        57 => "UI stop",
        58 => "Delete unit",
        62 => "Clicked to reinforce",
        63 => "Training squad leader",
        64 => "Weapon upgrade row:1 col:$Arg",
        65 => "Weapon reinforce (->64)",
        66 => "UI attack ground",
        67 => "UI attack melee",
        68 => "Changed troops behavior",
        69 => "UI melee/range",
        70 => "UI attack move", // 0x09EB1DB8=attackmove_modal
        71 => "Jump/Teleport",
        73 => "Turn on ability",
        74 => "Connect leader",
        75 => "Disconnect leader",
        77 => "Squad leader auto reinforce",
        78 => "Auto reinforce",
        79 => "Auto reinforce weapon (->64)",
        80 => "Building repair",
        82 => "Land troops",
        84 => "[ork] Skwiggott stomps",
        85 => "Cargo unit button",
        89 => "[necr] Start collecting bodies",
        90 => "[necr] Stop collecting bodies",
        91 => "[necr] Summon nw from spider",
        94 => "[necr] Summon attack scarabs",
        97 => "[necr] Possess the tech",
        107 => "[eld] Dance of death",
        100 => "[necr] Summon lie monolith",
        103 => "[necr] Cast stasis field",
        110 => "[necr] Deceived",
        112 => "[necr] Turn in nightbringer",
        113 => "[necr] Turn in deceiver",
        117 => "Building started",
        126 => "All overwatch",
        127 => "Cancel all overwatch",
        _ => "UNKNOWN"
    };
}

/*
auto reinforce flames
auto reinforce
cancel auto reinforce 
cancel auto reinforce flames
auto reinforce flames
auto reinforce
cancel auto reinforce 
click reinforce 
auto reinforce
*/