You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
67 lines
2.2 KiB
67 lines
2.2 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using TheGameExtreme.model.card;
|
|
using TheGameExtreme.model.card.rapidCard;
|
|
|
|
namespace TheGameExtreme.model.gameActions.classic
|
|
{
|
|
public class TerminerSonTour : GameAction
|
|
{
|
|
public TerminerSonTour(Piles ListOrderedStacks) : base(ListOrderedStacks)
|
|
{
|
|
}
|
|
|
|
public bool end(List<Card> CurrentHand, int nbCardAtBeginOfTurn, List<Card> CurrentCardPlayed)
|
|
{
|
|
// Si carte qui fait piocher que d'un, vérifier la bonne pioche (penser si elle vient d'être recouverte)
|
|
// Sinon
|
|
if (nbCardAtBeginOfTurn == CurrentCardPlayed.Count || CurrentHand.Count == 0 || (nbCardAtBeginOfTurn - CurrentHand.Count) >= 2)
|
|
{ // Ne pas oublié de gérer les ThreeCard
|
|
return Test(CurrentHand);
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public bool Test(List<Card> CurrentHand)
|
|
{
|
|
if (CurrentHand.Count != 0)
|
|
{
|
|
List<Card> playableCard = new List<Card>();
|
|
tryToFindSoluce(playableCard, CurrentHand);
|
|
return testEndGame(playableCard);
|
|
}
|
|
return false;
|
|
}
|
|
|
|
protected void tryToFindSoluce(List<Card> playableCard, List<Card> CurrentHand)
|
|
{
|
|
CurrentHand.ForEach(card =>
|
|
{
|
|
if (card.Value > ListOrderedStacks.getStack(0).Peek().Value || card.Value > ListOrderedStacks.getStack(1).Peek().Value || card.Value < ListOrderedStacks.getStack(2).Peek().Value || card.Value < ListOrderedStacks.getStack(3).Peek().Value)
|
|
{
|
|
playableCard.Add(card);
|
|
}
|
|
});
|
|
}
|
|
|
|
protected bool testEndGame(List<Card> playableCard)
|
|
{
|
|
if (playableCard.Count == 2)
|
|
{
|
|
foreach (Card c in playableCard)
|
|
{
|
|
if (Equals(c.getName(), ThreeCard.CARD_THREE))
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
else if (playableCard.Count < 2)
|
|
{
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
}
|
|
}
|