using SoulstormReplayReader.Core.Utils;

namespace SoulstormReplayReader.Core.Domain.ChatMessage;

public readonly struct ChatMessageModel
{
    public readonly int Ticks;
    public readonly string SenderName;
    public readonly int SenderId;
    public readonly string Text;
    public readonly SenderType From;
    public readonly ReceiverType To;

    public ChatMessageModel(
        int ticks,
        string senderName,
        int senderId,
        string text,
        SenderType from,
        ReceiverType to
    )
    {
        Ticks = ticks;
        SenderName = senderName;
        SenderId = senderId;
        Text = text;
        From = from;
        To = to;
    }

    public string FormattedTime => TicksFormatter.ShortFormat(Ticks);

    public string FromTo => From == SenderType.System ? "(All) System:" : $"({To}) {SenderName}:";

    public override string ToString() => $"[{FormattedTime}] {FromTo} {Text}";
}