﻿using AsmodeeDigital.PlayReal.Plugin.Domain.GameState;
using AsmodeeDigital.PlayReal.Plugin.Domain.Players;
using AsmodeeDigital.PlayReal.Plugin.Logic.Engine;
using System.Collections.Generic;

namespace AsmodeeDigital.PlayReal.Plugin.Logic.Gameplay
{
    /// <summary>
    /// Gameplay logic contract
    /// </summary>
    /// <typeparam name="T">Game state type</typeparam>
    public interface IGameplayLogic<T>
        where T : GameStateBase
    {
        /// <summary>
        /// Game state of the game (contains events for event sourcing)
        /// </summary>
        T GameState { get; set; }

        /// <summary>
        /// Game engine interpreting events of the game state
        /// </summary>
        IGameEngine GameEngine { get; set; }

        /// <summary>
        /// Current playing player
        /// </summary>
        IPlayerSeat CurrentPlayer { get; set; }

        /// <summary>
        /// List of all players in the current game
        /// </summary>
        List<IPlayerSeat> PlayersSeats { get; set; }

        /// <summary>
        /// Refresh game logic when it's the turn of the next player. Can be a local (human / bot) or distant player
        /// </summary>
        /// <param name="nextPlayers">Ordered list of next players (first in the list will play next)</param>
        void UpdateNextPlayer(List<int> nextPlayers, bool canPlayAI = false);

        /// <summary>
        /// Called when a game will finished
        /// </summary>
        ///<param name="saveGameLocally">Save the game state locally for replay</param>
        void SetGameOutcome(bool saveGameLocally);

        /// <summary>
        /// Return true if the current game over
        /// </summary>
        /// <returns></returns>
        bool IsGameOverOrGameOutcome();
    }
}
