using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Text.Json.Serialization;
using iyixiGames.AI.Converters;

namespace iyixiGames.Domain.Entities
{
    /// <summary>
    /// Represents a core entity for a small game.
    /// </summary>
    public class Game
    {
        public string Id { get; set; } = Guid.NewGuid().ToString("N"); // Unique game identifier

        [Required]
        [StringLength(100, MinimumLength = 3)]
        public string Name { get; set; } = string.Empty; // Game name

        [Required]
        [StringLength(1024, MinimumLength = 1)]
        public string Path { get; set; } = string.Empty; // Game folder name, e.g., "space-adventure"

        // New: Game Description
        [StringLength(1000)] // Adjust max length as needed
        public string? Description { get; set; } // Short description generated by AI or manually entered

        public string Category { get; set; } = string.Empty;
        // 应用自定义转换器
        [JsonPropertyName("popularity")]
        [JsonConverter(typeof(IntConverter))]
        [Range(0, 100)]
        public int Popularity { get; set; } = 0;

        [Range(0.0, 5.0)]
        public double AvgRating { get; set; } = 0.0;

        public DateTime ReleaseDate { get; set; } = DateTime.UtcNow;

        public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
        public DateTime UpdatedAt { get; set; } = DateTime.UtcNow;
    }
}