Merge branch 'reconstruction_model' - Version Semi-Stable (encore légèrement brouillon par manque de temps)
commit
ff5e2ad7b2
Binary file not shown.
@ -1,177 +1,175 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using TheGameExtreme.model.card;
|
||||
using TheGameExtreme.model.card.rapidCard;
|
||||
using TheGameExtreme.model.@event;
|
||||
using TheGameExtreme.model.gameActions.classic;
|
||||
|
||||
namespace TheGameExtreme.model.manager
|
||||
{
|
||||
public class SoloGameManager : GameManager
|
||||
{
|
||||
|
||||
public SoloGameManager(int nbPlayer, List<String> players)
|
||||
: base(nbPlayer, players)
|
||||
public SoloGameManager(Parametreur parametreur)
|
||||
: base(parametreur)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override bool endTurn()
|
||||
{
|
||||
|
||||
if (gameMode.checkBeforeEndTurnRule(CurrentCardPlayed, nbCardAtBeginOfTurn, CurrentHand))
|
||||
{
|
||||
//verifyNbCardPlay();
|
||||
pioche();
|
||||
currentIndexPlayer += 1;
|
||||
if (currentIndexPlayer == playerList.Count)
|
||||
{
|
||||
currentIndexPlayer = 0;
|
||||
}
|
||||
CurrentHand = playerList[currentIndexPlayer].getCardList();
|
||||
OnPlayerChanged(new PlayerChangedEventArgs(CurrentHand, playerList[currentIndexPlayer].Pseudo));
|
||||
nbCardAtBeginOfTurn = CurrentHand.Count;
|
||||
CurrentCardPlayed.Clear();
|
||||
if (gameMode.checkEndTurnRule(CurrentCardPlayed, nbCardAtBeginOfTurn, CurrentHand))
|
||||
{
|
||||
//if (isEndGame()) // Ajouter le score en calculant les cartes restantes dans la pile et dans les mains des joueurs
|
||||
//{
|
||||
// displayWinner();
|
||||
// return true;
|
||||
//}
|
||||
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
protected void verifyNbCardPlay()
|
||||
{
|
||||
foreach (Card cardPlayed in CurrentCardPlayed)
|
||||
{
|
||||
if (Equals(cardPlayed.GetType(), ThreeCard.CARD_THREE))
|
||||
{
|
||||
if ((nbCardAtBeginOfTurn - CurrentHand.Count) < 3) // Penser à vérifier s'il a joué une ThreeCard pour regarder s'il a bien joué 3 cartes
|
||||
{
|
||||
testIsEndGame();
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
if ((nbCardAtBeginOfTurn - CurrentHand.Count) < 2) // Penser à vérifier s'il a joué une ThreeCard pour regarder s'il a bien joué 3 cartes
|
||||
{
|
||||
testIsEndGame();
|
||||
}
|
||||
}
|
||||
|
||||
protected void testIsEndGame()
|
||||
{
|
||||
if (isEndGame())
|
||||
{
|
||||
displayWinner();
|
||||
}
|
||||
else
|
||||
{
|
||||
//throw new Exception("Vous n'avez pas joué assez de carte!");
|
||||
throw new Exception(AppRessources_br.StrCardPlayedLessThanTwo);
|
||||
}
|
||||
}
|
||||
|
||||
protected void displayWinner()
|
||||
{
|
||||
if (win)
|
||||
{
|
||||
EndMessage = "Le jeu est terminé!\n Bravo vous avez gagné!";
|
||||
EndMessage = AppRessource.StrWin;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void pioche()
|
||||
{
|
||||
int nbPickedCard = nbMaxCard - CurrentHand.Count;
|
||||
for (int i = 0; i < nbPickedCard; i++)
|
||||
{
|
||||
if (deck.size() == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
int random = new Random().Next(0, deck.size() - 1);
|
||||
playerList[currentIndexPlayer].pioche(deck.getCard(random));
|
||||
deck.removeAt(random);
|
||||
}
|
||||
}
|
||||
|
||||
protected override bool isEndGame()
|
||||
{
|
||||
if (CurrentHand.Count != 0)
|
||||
{
|
||||
List<Card> playableCard = new List<Card>();
|
||||
tryToFindSoluce(playableCard);
|
||||
return testEndGame(playableCard);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected override void tryToFindSoluce(List<Card> playableCard)
|
||||
{
|
||||
CurrentHand.ForEach(card =>
|
||||
{
|
||||
if (card.Value > ListOrderedStacks[0].Peek().Value || card.Value > ListOrderedStacks[1].Peek().Value || card.Value < ListOrderedStacks[2].Peek().Value || card.Value < ListOrderedStacks[3].Peek().Value)
|
||||
{
|
||||
playableCard.Add(card);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected override bool testEndGame(List<Card> playableCard)
|
||||
{
|
||||
if (playableCard.Count == 2)
|
||||
{
|
||||
foreach (Card c in playableCard)
|
||||
{
|
||||
if (Equals(c.getName(), ThreeCard.CARD_THREE))
|
||||
{
|
||||
win = false;
|
||||
EndMessage = "Le jeu est terminé!\n Désolé, vous avez perdu... Vous deviez jouer trois cartes à cause de l'effet \"Trois cartes joué\" hors votre jeu ne permet pas d'en jouer autant! Essayez encore!";
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (playableCard.Count < 2)
|
||||
{
|
||||
win = false;
|
||||
EndMessage = "Le jeu est terminé!\n Désolé, vous avez perdu... Essayez encore!";
|
||||
return true;
|
||||
}
|
||||
else if (effectLose())
|
||||
{
|
||||
win = false;
|
||||
EndMessage = "Désolé, vous n'avez pas recouvert la tête de mort... Réessayez ;)";
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
protected override bool effectLose()
|
||||
{
|
||||
foreach (Stack<Card> orderedStack in ListOrderedStacks)
|
||||
{
|
||||
if (Equals(orderedStack.Peek().getName(), EndGameCard.CARD_ENDGAME))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
//public override bool endTurn()
|
||||
//{
|
||||
|
||||
// //if (gameMode.checkBeforeEndTurnRule(CurrentCardPlayed, nbCardAtBeginOfTurn, CurrentHand))
|
||||
// //{
|
||||
// // //verifyNbCardPlay();
|
||||
// // pioche();
|
||||
// // currentIndexPlayer += 1;
|
||||
// // if (currentIndexPlayer == playerList.Count)
|
||||
// // {
|
||||
// // currentIndexPlayer = 0;
|
||||
// // }
|
||||
// // CurrentHand = playerList[currentIndexPlayer].getCardList();
|
||||
// // OnPlayerChanged(new PlayerChangedEventArgs(CurrentHand, playerList[currentIndexPlayer].Pseudo));
|
||||
// // nbCardAtBeginOfTurn = CurrentHand.Count;
|
||||
// // CurrentCardPlayed.Clear();
|
||||
// // if (gameMode.checkEndTurnRule(CurrentCardPlayed, nbCardAtBeginOfTurn, CurrentHand))
|
||||
// // {
|
||||
// // //if (isEndGame()) // Ajouter le score en calculant les cartes restantes dans la pile et dans les mains des joueurs
|
||||
// // //{
|
||||
// // // displayWinner();
|
||||
// // // return true;
|
||||
// // //}
|
||||
|
||||
// // return false;
|
||||
// // }
|
||||
// // else
|
||||
// // {
|
||||
// // return true;
|
||||
// // }
|
||||
// //}
|
||||
// //else
|
||||
// //{
|
||||
// // return false;
|
||||
// //}
|
||||
|
||||
|
||||
//}
|
||||
|
||||
//protected void verifyNbCardPlay()
|
||||
//{
|
||||
// foreach (Card cardPlayed in CurrentCardPlayed)
|
||||
// {
|
||||
// if (Equals(cardPlayed.GetType(), ThreeCard.CARD_THREE))
|
||||
// {
|
||||
// if ((nbCardAtBeginOfTurn - CurrentHand.Count) < 3) // Penser à vérifier s'il a joué une ThreeCard pour regarder s'il a bien joué 3 cartes
|
||||
// {
|
||||
// testIsEndGame();
|
||||
// }
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
// if ((nbCardAtBeginOfTurn - CurrentHand.Count) < 2) // Penser à vérifier s'il a joué une ThreeCard pour regarder s'il a bien joué 3 cartes
|
||||
// {
|
||||
// testIsEndGame();
|
||||
// }
|
||||
//}
|
||||
|
||||
//protected void testIsEndGame()
|
||||
//{
|
||||
// if (isEndGame())
|
||||
// {
|
||||
// displayWinner();
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// //throw new Exception("Vous n'avez pas joué assez de carte!");
|
||||
// throw new Exception(AppRessources_br.StrCardPlayedLessThanTwo);
|
||||
// }
|
||||
//}
|
||||
|
||||
//protected void displayWinner()
|
||||
//{
|
||||
// if (win)
|
||||
// {
|
||||
// EndMessage = "Le jeu est terminé!\n Bravo vous avez gagné!";
|
||||
// EndMessage = AppRessource.StrWin;
|
||||
// }
|
||||
//}
|
||||
|
||||
//protected void pioche()
|
||||
//{
|
||||
// int nbPickedCard = nbMaxCard - CurrentHand.Count;
|
||||
// for (int i = 0; i < nbPickedCard; i++)
|
||||
// {
|
||||
// if (deck.size() == 0)
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
// int random = new Random().Next(0, deck.size() - 1);
|
||||
// playerList[currentIndexPlayer].pioche(deck.getCard(random));
|
||||
// deck.removeAt(random);
|
||||
// }
|
||||
//}
|
||||
|
||||
//protected override bool isEndGame()
|
||||
//{
|
||||
// if (CurrentHand.Count != 0)
|
||||
// {
|
||||
// List<Card> playableCard = new List<Card>();
|
||||
// tryToFindSoluce(playableCard);
|
||||
// return testEndGame(playableCard);
|
||||
// }
|
||||
// return false;
|
||||
//}
|
||||
|
||||
//protected override void tryToFindSoluce(List<Card> playableCard)
|
||||
//{
|
||||
// CurrentHand.ForEach(card =>
|
||||
// {
|
||||
// if (card.Value > ListOrderedStacks[0].Peek().Value || card.Value > ListOrderedStacks[1].Peek().Value || card.Value < ListOrderedStacks[2].Peek().Value || card.Value < ListOrderedStacks[3].Peek().Value)
|
||||
// {
|
||||
// playableCard.Add(card);
|
||||
// }
|
||||
// });
|
||||
//}
|
||||
|
||||
//protected override bool testEndGame(List<Card> playableCard)
|
||||
//{
|
||||
// if (playableCard.Count == 2)
|
||||
// {
|
||||
// foreach (Card c in playableCard)
|
||||
// {
|
||||
// if (Equals(c.getName(), ThreeCard.CARD_THREE))
|
||||
// {
|
||||
// win = false;
|
||||
// EndMessage = "Le jeu est terminé!\n Désolé, vous avez perdu... Vous deviez jouer trois cartes à cause de l'effet \"Trois cartes joué\" hors votre jeu ne permet pas d'en jouer autant! Essayez encore!";
|
||||
// return true;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// else if (playableCard.Count < 2)
|
||||
// {
|
||||
// win = false;
|
||||
// EndMessage = "Le jeu est terminé!\n Désolé, vous avez perdu... Essayez encore!";
|
||||
// return true;
|
||||
// }
|
||||
// else if (effectLose())
|
||||
// {
|
||||
// win = false;
|
||||
// EndMessage = "Désolé, vous n'avez pas recouvert la tête de mort... Réessayez ;)";
|
||||
// return true;
|
||||
// }
|
||||
|
||||
// return false;
|
||||
//}
|
||||
|
||||
//protected override bool effectLose()
|
||||
//{
|
||||
// foreach (Stack<Card> orderedStack in ListOrderedStacks)
|
||||
// {
|
||||
// if (Equals(orderedStack.Peek().getName(), EndGameCard.CARD_ENDGAME))
|
||||
// {
|
||||
// return true;
|
||||
// }
|
||||
// }
|
||||
// return false;
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in new issue