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

namespace TheGameExtreme.model.gameActions.decimals
{
    public class JouerUneCarteDecimal : JouerUneCarte
    {
        public JouerUneCarteDecimal(Piles ListOrderedStacks) : base(ListOrderedStacks)
        {
        }

        new protected bool Rule(Card card, Stack<Card> stack, bool bottomUp, Player player, List<Card> CurrentCardPlayed)
        {
            if ((bottomUp && card.Value > stack.Peek().Value) || (!bottomUp && card.Value < stack.Peek().Value))
            {
                OldCard = stack.Peek();
                player.joue(card);
                CurrentCardPlayed.Add(card);
                stack.Push(card);
                return true;
            }
            else if (card.Value.CompareTo(stack.Peek().Value - 0.1m) == 0 || card.Value.CompareTo(stack.Peek().Value + 0.1m) == 0 || card.Value.CompareTo(stack.Peek().Value - 0.01m) == 0 || card.Value.CompareTo(stack.Peek().Value + 0.01m) == 0 || card.Value.CompareTo(stack.Peek().Value - 0.001m) == 0 || card.Value.CompareTo(stack.Peek().Value + 0.001m) == 0)
            {
                OldCard = stack.Peek();
                player.joue(card);
                CurrentCardPlayed.Add(card);
                stack.Push(card);
                return true;
            }
            else
            {
                ErrorMessage = AppRessource.StrWrongStack;
                return false;
            }
        }
    }
}
