using System;
using System.Collections.Generic;
using TheGameExtreme.model.card;
using TheGameExtreme.model.deck;
using TheGameExtreme.model.gameActions.classic;
using TheGameExtreme.model.piles;

namespace TheGameExtreme.model.gameActions.decimals
{
    public class GameModeDecimal : GameMode
    {
        public GameModeDecimal(Piles piles, Deck deck) : base(piles, deck)
        {
        }

        new public void load(int nbPlayer, List<Player> players)
        {
            base.load(nbPlayer, players);
            gameActions.RemoveAt(1);
            gameActions.RemoveAt(2);
            gameActions.Add(new JouerUneCarteDecimal(Piles));
            gameActions.Add(new TerminerSonTourDecimal(Piles));
        }

        new public bool playCard(decimal valueCard, List<Card> currentHand, int orderedStackSelected, Player player, List<Card> CurrentCardPlayed)
        {
            Message = null;
            if (((JouerUneCarteDecimal)gameActions[1]).play(valueCard, currentHand, orderedStackSelected, player, CurrentCardPlayed))
            {
                return true;
            }
            else
            {
                Message = ((JouerUneCarte)gameActions[1]).ErrorMessage;
                return false;
            }
        }

        new public bool endTurn(List<Card> currentHand, List<Card> CurrentCardPlayed, Player player)
        {
            Message = null;
            if (((TerminerSonTourDecimal)gameActions[2]).end(currentHand, CurrentCardPlayed))
            {
                pioche(currentHand, player);
                CurrentCardPlayed.Clear();
                OnPlayerChanged(null);
                return end;
            }
            else
            {
                Message = ((TerminerSonTour)gameActions[2]).ErrorMessage;
                return false;
            }
        }

        new public void TestEndGame(List<Card> currentHand)
        {
            if (((TerminerSonTourDecimal)gameActions[2]).Test(currentHand))
            {
                end = false;
            }
            else
            {
                OnEndGame(new EventArgs());
                end = true;
            }
        }
    }
}
