using DbController;

namespace Tabletop.Core.Models
{
    public class Game : IDbModel<int?>
    {
        [CompareField("game_id")]
        public int GameId { get; set; }
        [CompareField("gamemode_id")]
        public int GamemodeId { get; set; }
        [CompareField("user_id")]
        public int UserId { get; set; }
        [CompareField("surface_id")]
        public int SurfaceId { get; set; }
        [CompareField("layout_id")]
        public int LayoutId { get; set; }
        [CompareField("name")]
        public string Name { get; set; } = string.Empty;
        [CompareField("number_of_rounds")]
        public int? NumberOfRounds { get; set; }
        [CompareField("force")]
        public int Force { get; set; }
        [CompareField("number_of_teams")]
        public int NumberOfTeams { get; set; }
        [CompareField("number_of_players")]
        public int NumberOfPlayers { get; set; }
        [CompareField("date")]
        public DateTime Date { get; set; } = DateTime.Now;

        public string Host { get; set; } = string.Empty;

        public List<Player> Players { get; set; } = [];
        public List<Move> Rounds { get; set; } = [];
        public List<Capture> Captures { get; set; } = [];
        public List<Elimination> Elimination { get; set; } = [];

        public string GUID { get; set; } = string.Empty;

        public int? GetIdentifier()
        {
            return GameId > 0 ? GameId : null;
        }

        public Dictionary<string, object?> GetParameters()
        {
            return new Dictionary<string, object?>
            {
                { "GAME_ID", GameId },
                { "GAMEMODE_ID", GamemodeId },
                { "USER_ID", UserId },
                { "SURFACE_ID", SurfaceId },
                { "LAYOUT_ID", LayoutId },
                { "NAME", Name },
                { "NUMBER_OF_ROUNDS", NumberOfRounds },
                { "FORCE", Force },
                { "NUMBER_OF_TEAMS", NumberOfTeams },
                { "NUMBER_OF_PLAYERS", NumberOfPlayers },
                { "DATE", Date }
            };
        }
    }
}