|
|
|
@ -15,6 +15,7 @@ namespace TheGameExtreme.model.gameActions.classic
|
|
|
|
|
protected int nbCardAtBeginOfTurn = 7;
|
|
|
|
|
protected Deck deck;
|
|
|
|
|
private int nbMaxCard;
|
|
|
|
|
public String Message { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region
|
|
|
|
@ -96,19 +97,26 @@ namespace TheGameExtreme.model.gameActions.classic
|
|
|
|
|
|
|
|
|
|
public void pioche(List<Card> currentHand, Player player)
|
|
|
|
|
{
|
|
|
|
|
Message = null;
|
|
|
|
|
((Piocher)gameActions[0]).pioche(currentHand, deck, player);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void playCard(int valueCard, List<Card> currentHand, int orderedStackSelected, Player player, List<Card> CurrentCardPlayed)
|
|
|
|
|
{
|
|
|
|
|
Message = null;
|
|
|
|
|
if (((JouerUneCarte)gameActions[1]).play(valueCard, currentHand, orderedStackSelected, player, CurrentCardPlayed))
|
|
|
|
|
{
|
|
|
|
|
OnTopRangeChanged(new TopRangeChangedEventArgs(piles.getStack(orderedStackSelected).Peek(), ((JouerUneCarte)gameActions[1]).OldCard, orderedStackSelected));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Message = ((JouerUneCarte)gameActions[1]).ErrorMessage;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool endTurn(List<Card> currentHand, List<Card> CurrentCardPlayed, Player player)
|
|
|
|
|
{
|
|
|
|
|
Message = null;
|
|
|
|
|
if (((TerminerSonTour)gameActions[2]).end(currentHand, nbCardAtBeginOfTurn, CurrentCardPlayed))
|
|
|
|
|
{
|
|
|
|
|
pioche(currentHand, player);
|
|
|
|
@ -120,118 +128,46 @@ namespace TheGameExtreme.model.gameActions.classic
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Message = ((TerminerSonTour)gameActions[2]).ErrorMessage;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//if (isEndGame()) // Ajouter le score en calculant les cartes restantes dans la pile et dans les mains des joueurs
|
|
|
|
|
//{
|
|
|
|
|
// displayWinner();
|
|
|
|
|
// return true;
|
|
|
|
|
//}
|
|
|
|
|
//else
|
|
|
|
|
//{
|
|
|
|
|
// return true;
|
|
|
|
|
//}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//protected void displayWinner()
|
|
|
|
|
//{
|
|
|
|
|
// if (win)
|
|
|
|
|
// {
|
|
|
|
|
// EndMessage = "Le jeu est terminé!\n Bravo vous avez gagné!";
|
|
|
|
|
// EndMessage = AppRessource.StrWin;
|
|
|
|
|
// }
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// private List<Rule> playRule = new List<Rule>();
|
|
|
|
|
// private List<Rule> beforeEndTurnRule = new List<Rule>();
|
|
|
|
|
// private List<Rule> endTurnRule = new List<Rule>();
|
|
|
|
|
// private List<Rule> commonRule = new List<Rule>();
|
|
|
|
|
|
|
|
|
|
// public GameMode()
|
|
|
|
|
// {
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// public void addPlayRule(PlayRule rule)
|
|
|
|
|
// {
|
|
|
|
|
// playRule?.Add(rule);
|
|
|
|
|
// }
|
|
|
|
|
#region Decaler dans un GameAction
|
|
|
|
|
|
|
|
|
|
// public void addEndTurnRule(EndTurnRule rule)
|
|
|
|
|
// {
|
|
|
|
|
// endTurnRule?.Add(rule);
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// public void addBeforeEndTurnRule(BeforeEndTurnRule rule)
|
|
|
|
|
// {
|
|
|
|
|
// beforeEndTurnRule?.Add(rule);
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// public void addCommonRule(Rule rule)
|
|
|
|
|
// {
|
|
|
|
|
// // Vérifier que se ne soit ni une PlayRule, ni une EndTurnRule ?
|
|
|
|
|
// commonRule?.Add(rule);
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// public bool checkPlayRule(Card card, Stack<Card> orderedStack, bool bottomUp, List<Card> CurrentHand)
|
|
|
|
|
// {
|
|
|
|
|
// foreach(PlayRule rule in playRule)
|
|
|
|
|
// {
|
|
|
|
|
// if (rule.Test(card, orderedStack, bottomUp, CurrentHand)) // Gestion des messages pour savoir qu'elle règle n'est pas respecter.
|
|
|
|
|
// {
|
|
|
|
|
// return true;
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// foreach (Rule rule in commonRule)
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
// return false;
|
|
|
|
|
// }
|
|
|
|
|
public bool isEndGame(List<Card> currentHand)
|
|
|
|
|
{
|
|
|
|
|
if (currentHand.Count != 0)
|
|
|
|
|
{
|
|
|
|
|
List<Card> playableCard = new List<Card>();
|
|
|
|
|
tryToFindSoluce(playableCard, currentHand);
|
|
|
|
|
return testEndGame(playableCard);
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// public bool checkBeforeEndTurnRule(List<Card> CurrentCardPlayed, int nbCardAtBeginOfTurn, List<Card> CurrentHand)
|
|
|
|
|
// {
|
|
|
|
|
// foreach (BeforeEndTurnRule rule in beforeEndTurnRule)
|
|
|
|
|
// {
|
|
|
|
|
// if (!rule.Test(CurrentCardPlayed, nbCardAtBeginOfTurn, CurrentHand)) // Gestion des messages pour savoir qu'elle règle n'est pas respecter.
|
|
|
|
|
// {
|
|
|
|
|
// return false;
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// foreach (Rule rule in commonRule)
|
|
|
|
|
// {
|
|
|
|
|
protected void tryToFindSoluce(List<Card> playableCard, List<Card> currentHand)
|
|
|
|
|
{
|
|
|
|
|
currentHand.ForEach(card =>
|
|
|
|
|
{
|
|
|
|
|
if (card.Value > piles.getStack(0).Peek().Value || card.Value > piles.getStack(1).Peek().Value || card.Value < piles.getStack(2).Peek().Value || card.Value < piles.getStack(3).Peek().Value)
|
|
|
|
|
{
|
|
|
|
|
playableCard.Add(card);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
// return true;
|
|
|
|
|
// }
|
|
|
|
|
protected bool testEndGame(List<Card> playableCard)
|
|
|
|
|
{
|
|
|
|
|
if (playableCard.Count < 2)
|
|
|
|
|
{
|
|
|
|
|
Message = "Le jeu est terminé!\n Désolé, vous avez perdu... Essayez encore!";
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// public bool checkEndTurnRule(List<Card> CurrentCardPlayed, int nbCardAtBeginOfTurn, List<Card> CurrentHand)
|
|
|
|
|
// {
|
|
|
|
|
// foreach (EndTurnRule rule in endTurnRule)
|
|
|
|
|
// {
|
|
|
|
|
// if (!rule.Test(CurrentCardPlayed, nbCardAtBeginOfTurn, CurrentHand)) // Gestion des messages pour savoir qu'elle règle n'est pas respecter.
|
|
|
|
|
// {
|
|
|
|
|
// return false;
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// foreach (Rule rule in commonRule)
|
|
|
|
|
// {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
// return true;
|
|
|
|
|
// }
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|