using MessagePack;
using System.Text.Json.Serialization;
using SVSim.EmulatedEntrypoint.Models.Dtos.Common.Guild;

namespace SVSim.EmulatedEntrypoint.Models.Dtos.Guild;

/// <summary>
/// Response for POST /guild/friend_list.
/// NOTE: per guild-friend_list.md, `data` is an array at the root — BUT we return this
/// as a wrapper for now; the controller returns the List directly.
/// TODO(task-14): verify array-root shape via capture; may need a custom response wrapper.
/// </summary>
[MessagePackObject]
public class GuildFriendListResponse
{
    // Placeholder — see controller; actual wire shape is array-at-root per spec.
    // The controller returns List<GuildInviteCandidateDto> directly for now.
    [JsonPropertyName("friends"), Key("friends")]
    public List<GuildInviteCandidateDto> Friends { get; set; } = new();
}

/// <summary>InviteCandidate — UserInfoBase + is_join_guild flag.</summary>
[MessagePackObject]
public class GuildInviteCandidateDto
{
    [JsonPropertyName("viewer_id"), Key("viewer_id"), JsonConverter(typeof(SVSim.EmulatedEntrypoint.Models.Dtos.Common.StringifiedLongConverter))]
    public long ViewerId { get; set; }

    [JsonPropertyName("name"), Key("name")]
    public string Name { get; set; } = "";

    [JsonPropertyName("emblem_id"), Key("emblem_id"), JsonConverter(typeof(SVSim.EmulatedEntrypoint.Models.Dtos.Common.StringifiedLongConverter))]
    public long EmblemId { get; set; }

    [JsonPropertyName("country_code"), Key("country_code")]
    public string CountryCode { get; set; } = "";

    [JsonPropertyName("rank"), Key("rank"), JsonConverter(typeof(SVSim.EmulatedEntrypoint.Models.Dtos.Common.StringifiedIntConverter))]
    public int Rank { get; set; }

    [JsonPropertyName("degree_id"), Key("degree_id"), JsonConverter(typeof(SVSim.EmulatedEntrypoint.Models.Dtos.Common.StringifiedIntConverter))]
    public int DegreeId { get; set; }

    [JsonPropertyName("is_friend"), Key("is_friend")]
    public int? IsFriend { get; set; }

    [JsonPropertyName("is_friend_apply"), Key("is_friend_apply")]
    public int? IsFriendApply { get; set; }

    /// <summary>true => friend is already in a guild and can't be invited.</summary>
    [JsonPropertyName("is_join_guild"), Key("is_join_guild")]
    public bool IsJoinGuild { get; set; }
}
