using System.Collections.Generic;
using MessagePack;
#if GameClient
using GameFramework;
#endif

namespace GameMessage
{
    /// <summary>
    /// 俱乐部统计请求消息
    /// </summary>
    [Message(MessageCode.ClubStatisticsRequest)]
    [MessagePackObject]
    public class ClubStatisticsRequest : MessageData
    {
        /// <summary>
        /// 俱乐部ID
        /// </summary>
        [Key(0)] public int ClubId;

        [Key(1)] public long DayBegin;

        [Key(2)] public long DayEnd;

#if GameClient
        public static ClubStatisticsRequest Create(int cluId,long dayBegin,long dayEnd)
        {
            ClubStatisticsRequest request = ReferencePool.Acquire<ClubStatisticsRequest>();
            request.ClubId = cluId;
            request.DayBegin = dayBegin;
            request.DayEnd = dayEnd;
            return request;
        }
#endif
    }

    /// <summary>
    /// 俱乐部统计响应消息
    /// </summary>
    [Message(MessageCode.ClubStatisticsResponse)]
    [MessagePackObject]
    public class ClubStatisticsResponse : MessageData
    {
        /// <summary>
        /// 俱乐部ID
        /// </summary>
        [Key(0)] public int ClubId;

        /// <summary>
        /// 请求哪天的数据
        /// </summary>
        [Key(1)] public long DayBegin;

        /// <summary>
        /// 如果有该值就是请求一个时间段的数据
        /// </summary>
        [Key(2)] public long DayEnd;

        /// <summary>
        /// 统计数据
        /// </summary>
        [Key(3)] public ClubStatisticsData Data;
    }

    [Message(MessageCode.ClubPlayerFightStatisticsRequest)]
    [MessagePackObject]
    public class ClubPlayerFightStatisticsRequest : MessageData
    {
        /// <summary>
        /// 俱乐部ID
        /// </summary>
        [Key(0)] public int ClubId;

        /// <summary>
        /// 请求哪天的数据
        /// </summary>
        [Key(1)] public long DayBegin;

        /// <summary>
        /// 如果有该值就是请求一个时间段的数据
        /// </summary>
        [Key(2)] public long DayEnd;

        /// <summary>
        /// 1 场次统计  2 全场最佳  3 房主统计
        /// </summary>
        [Key(3)] public int Style;

#if GameClient
        public static ClubPlayerFightStatisticsRequest Create(int clubId,long dayBegin,long dayEnd,int style)
        {
            ClubPlayerFightStatisticsRequest request = ReferencePool.Acquire<ClubPlayerFightStatisticsRequest>();
            request.ClubId = clubId;
            request.DayBegin = dayBegin;
            request.DayEnd = dayEnd;
            request.Style = style;
            return request;
        }
#endif
    }

    [Message(MessageCode.ClubPlayerFightStatisticsResponse)]
    [MessagePackObject]
    public class ClubPlayerFightStatisticsResponse : MessageData
    {
        [Key(0)] public int ClubId;

        [Key(1)] public int Style;

        [Key(2)] public List<PlayerStatisticsInfo> PlayerStatisticsInfos;
    }

    [MessagePackObject]
    public class PlayerStatisticsInfo
    {
        /// <summary>
        /// 昵称
        /// </summary>
        [Key(0)] public string NickName;

        /// <summary>
        /// id
        /// </summary>
        [Key(1)] public int UserId;

        /// <summary>
        /// 性别
        /// </summary>
        [Key(2)] public int Sex;

        /// <summary>
        /// 把数
        /// </summary>
        [Key(3)] public int CountOfRound;

        /// <summary>
        /// 耗卡数
        /// </summary>
        [Key(4)] public double CountOfUsedCard;

        /// <summary>
        /// 最佳数
        /// </summary>
        [Key(5)] public int CountOfBest;

        /// <summary>
        /// 房主数
        /// </summary>
        [Key(6)] public int CountOfRoomOwner;
    }

    /// <summary>
    /// 俱乐部统计数据
    /// </summary>
    [MessagePackObject]
    public class ClubStatisticsData
    {
        /// <summary>
        /// 人次
        /// </summary>
        [Key(0)] public int CountOfRound;

        /// <summary>
        /// 耗卡数量
        /// </summary>
        [Key(1)] public int CountOfUsedCard;

        /// <summary>
        /// 今日打朋友房的人数
        /// </summary>
        [Key(2)] public int CountOfPlayer;

        /// <summary>
        /// 开房间数量
        /// </summary>
        [Key(3)] public int CountOfRoomOwner;
    }

    /// <summary>
    /// 联盟汇总积分数据结构
    /// </summary>
    [MessagePackObject]
    public class LeagueClubStatisticsData
    {
        /// <summary>
        /// 有效耗卡
        /// </summary>
        [Key(0)] public decimal CardScore;

        /// <summary>
        /// 活跃积分-群主赚的房费
        /// </summary>
        [Key(1)] public decimal DeskScore;

        /// <summary>
        /// 成员总积分
        /// </summary>
        [Key(2)] public decimal ClubUserSumScore;

        /// <summary>
        /// 联盟的活跃积分
        /// </summary>
        [Key(3)] public decimal LeagueScore;

        /// <summary>
        /// 参与房间数量
        /// </summary>
        [Key(4)] public int JoinRoom;

        public static LeagueClubStatisticsData operator +(LeagueClubStatisticsData left, LeagueClubStatisticsData right)
        {
            left.CardScore += right.CardScore;
            left.DeskScore += right.DeskScore;
            left.ClubUserSumScore += right.ClubUserSumScore;
            left.LeagueScore += right.LeagueScore;
            left.JoinRoom += right.JoinRoom;
            return left;
        }

        public LeagueClubStatisticsData Clone()
        {
            return new LeagueClubStatisticsData
            {
                CardScore = CardScore,
                DeskScore = DeskScore,
                ClubUserSumScore = ClubUserSumScore,
                LeagueScore = LeagueScore,
                JoinRoom = JoinRoom
            };
        }
    }
}