using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace Kalaha.Api.Database.Models
{
    
    public class Game
    {
        [Key]
        public Guid GameId { get; set; }

        public Guid Player1Id { get; set; }

        [ForeignKey(nameof(Player1Id))]
        public User Player1 { get; set; }

        public Guid? Player2Id { get; set; }

        [ForeignKey(nameof(Player2Id))]
        public User? Player2 { get; set; }

        public Guid? ActivePlayerId { get; set; }
        [ForeignKey(nameof(ActivePlayerId))]
        public User? ActivePlayer { get; set; }

        public Guid? WinnerId { get; set; }
        [ForeignKey(nameof(WinnerId))]
        public User? Winner { get; set; }

        [Required]
        public GameState State { get; set; } = GameState.Waiting;

        [Required]
        public int[] BoardState { get; set; } = new int[14];

        public DateTime? FinishedTime { get; set; }

        [Timestamp]
        public byte[] RowVersion { get; set; }

    }

    public enum GameState
    {
        Waiting = 0,
        Running = 1,
        Finished = 2,
    }
}
