using System.ComponentModel.DataAnnotations;

namespace iyixiGames.Domain.DTOs.Games
{
    // --- Request DTOs ---

    public class CreateGameRequest
    {
        [Required(ErrorMessage = "游戏名称是必填项。")]
        [StringLength(100, MinimumLength = 3, ErrorMessage = "游戏名称长度必须在3到100个字符之间。")]
        public string Name { get; set; } = string.Empty;

        [Required(ErrorMessage = "游戏路径是必填项。")]
        [StringLength(255, MinimumLength = 1, ErrorMessage = "游戏路径长度必须在1到255个字符之间。")]
        [RegularExpression(@"^[a-zA-Z0-9_-]+$", ErrorMessage = "游戏路径只能包含字母、数字、下划线和连字符。")]
        public string Path { get; set; } = string.Empty;

        [StringLength(1000, ErrorMessage = "游戏简介长度不能超过1000个字符。")] // New
        public string? Description { get; set; } // New: Make it nullable if not required on creation

        [Required(ErrorMessage = "游戏类别是必填项。")]
        public string Category { get; set; } = string.Empty;

        [Range(0, 100, ErrorMessage = "流行度必须在0到100之间。")]
        public int Popularity { get; set; } = 0;

        [Range(0.0, 5.0, ErrorMessage = "平均评分必须在0.0到5.0之间。")]
        public double AvgRating { get; set; } = 0.0;

        [DataType(DataType.Date, ErrorMessage = "发布日期格式不正确。")]
        public DateTime ReleaseDate { get; set; } = DateTime.UtcNow.Date;
    }

    public class UpdateGameRequest
    {
        [StringLength(100, MinimumLength = 3, ErrorMessage = "游戏名称长度必须在3到100个字符之间。")]
        public string? Name { get; set; }

        [StringLength(255, MinimumLength = 1, ErrorMessage = "游戏路径长度必须在1到255个字符之间。")]
        [RegularExpression(@"^[a-zA-Z0-9_-]+$", ErrorMessage = "游戏路径只能包含字母、数字、下划线和连字符。")]
        public string? Path { get; set; }

        [StringLength(1000, ErrorMessage = "游戏简介长度不能超过1000个字符。")] // New
        public string? Description { get; set; } // New

        public string? Category { get; set; }

        [Range(0, 100, ErrorMessage = "流行度必须在0到100之间。")]
        public int? Popularity { get; set; }

        [Range(0.0, 5.0, ErrorMessage = "平均评分必须在0.0到5.0之间。")]
        public double? AvgRating { get; set; }

        [DataType(DataType.Date, ErrorMessage = "发布日期格式不正确。")]
        public DateTime? ReleaseDate { get; set; }
    }

    public class BatchCreateGamesRequest
    {
        [Required(ErrorMessage = "请输入游戏文件夹名称。")]
        public string GamePathsText { get; set; } = string.Empty;
    }

    // --- Response DTOs ---

    public class GameResponse
    {
        public string Id { get; set; } = string.Empty;
        public string Name { get; set; } = string.Empty;
        public string Path { get; set; } = string.Empty;
        public string? Description { get; set; } // New: Make it nullable
        public List<string> Category { get; set; } = new List<string>();
        public int Popularity { get; set; }
        public double AvgRating { get; set; }
        public DateTime ReleaseDate { get; set; }
        public DateTime CreatedAt { get; set; }
        public DateTime UpdatedAt { get; set; }
    }
}