diff --git a/TheGameExtreme/AppRessource.Designer.cs b/TheGameExtreme/AppRessource.Designer.cs index 919096b..284b84d 100644 --- a/TheGameExtreme/AppRessource.Designer.cs +++ b/TheGameExtreme/AppRessource.Designer.cs @@ -1,57 +1,44 @@ //------------------------------------------------------------------------------ // -// Ce code a été généré par un outil. -// Version du runtime :4.0.30319.42000 +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 // -// Les modifications apportées à ce fichier peuvent provoquer un comportement incorrect et seront perdues si -// le code est régénéré. +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. // //------------------------------------------------------------------------------ namespace TheGameExtreme { using System; + using System.Reflection; - /// - /// Une classe de ressource fortement typée destinée, entre autres, à la consultation des chaînes localisées. - /// - // Cette classe a été générée automatiquement par la classe StronglyTypedResourceBuilder - // à l'aide d'un outil, tel que ResGen ou Visual Studio. - // Pour ajouter ou supprimer un membre, modifiez votre fichier .ResX, puis réexécutez ResGen - // avec l'option /str ou régénérez votre projet VS. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [System.Diagnostics.DebuggerNonUserCodeAttribute()] + [System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class AppRessource { - private static global::System.Resources.ResourceManager resourceMan; + private static System.Resources.ResourceManager resourceMan; - private static global::System.Globalization.CultureInfo resourceCulture; + private static System.Globalization.CultureInfo resourceCulture; - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] internal AppRessource() { } - /// - /// Retourne l'instance ResourceManager mise en cache utilisée par cette classe. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)] + internal static System.Resources.ResourceManager ResourceManager { get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("TheGameExtreme.AppRessource", typeof(AppRessource).Assembly); + if (object.Equals(null, resourceMan)) { + System.Resources.ResourceManager temp = new System.Resources.ResourceManager("TheGameExtreme.AppRessource", typeof(AppRessource).Assembly); resourceMan = temp; } return resourceMan; } } - /// - /// Remplace la propriété CurrentUICulture du thread actuel pour toutes - /// les recherches de ressources à l'aide de cette classe de ressource fortement typée. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)] + internal static System.Globalization.CultureInfo Culture { get { return resourceCulture; } @@ -60,169 +47,112 @@ namespace TheGameExtreme { } } - /// - /// Recherche une chaîne localisée semblable à Pile ascendante. - /// internal static string StrAcendingStack { get { return ResourceManager.GetString("StrAcendingStack", resourceCulture); } } - /// - /// Recherche une chaîne localisée semblable à La pile choisie n'existe pas!. - /// internal static string StrCantGetStack { get { return ResourceManager.GetString("StrCantGetStack", resourceCulture); } } - /// - /// Recherche une chaîne localisée semblable à Vous n'avez pas joué assez de carte! essaye encore. - /// internal static string StrCardPlayedLessThanTwo { get { return ResourceManager.GetString("StrCardPlayedLessThanTwo", resourceCulture); } } - /// - /// Recherche une chaîne localisée semblable à Veuillez selectionner une carte à placer sur une pile. - /// internal static string StrChooseCardToPlay { get { return ResourceManager.GetString("StrChooseCardToPlay", resourceCulture); } } - /// - /// Recherche une chaîne localisée semblable à Selectionner la pile sur laquelle vous souhaitez poser la carte. - /// internal static string StrChooseStack { get { return ResourceManager.GetString("StrChooseStack", resourceCulture); } } - /// - /// Recherche une chaîne localisée semblable à Pile Descendante. - /// internal static string StrDownStack { get { return ResourceManager.GetString("StrDownStack", resourceCulture); } } - /// - /// Recherche une chaîne localisée semblable à Le jeu est fini! Veuillez lancer une nouvelle partie!. - /// internal static string StrEndOfGame { get { return ResourceManager.GetString("StrEndOfGame", resourceCulture); } } - /// - /// Recherche une chaîne localisée semblable à Fin de tour. - /// internal static string StrEndTurn { get { return ResourceManager.GetString("StrEndTurn", resourceCulture); } } - /// - /// Recherche une chaîne localisée semblable à Veuillez saisir votre pseudo. - /// - internal static string StrEnterPseudo { - get { - return ResourceManager.GetString("StrEnterPseudo", resourceCulture); - } - } - - /// - /// Recherche une chaîne localisée semblable à Le jeu est terminé! Désolé, vous avez perdu... Essayez encore!. - /// internal static string StrLose { get { return ResourceManager.GetString("StrLose", resourceCulture); } } - /// - /// Recherche une chaîne localisée semblable à Le jeu est terminé! 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!. - /// internal static string StrLose3CardEffect { get { return ResourceManager.GetString("StrLose3CardEffect", resourceCulture); } } - /// - /// Recherche une chaîne localisée semblable à Le joueur n'a plus de carte dans sa main. - /// internal static string StrNoMoreCardOnHand { get { return ResourceManager.GetString("StrNoMoreCardOnHand", resourceCulture); } } - /// - /// Recherche une chaîne localisée semblable à Veuillez choisir un nombre de joueur et leur(s) nom(s). - /// - internal static string StrPlayerSelection { - get { - return ResourceManager.GetString("StrPlayerSelection", resourceCulture); - } - } - - /// - /// Recherche une chaîne localisée semblable à -L'objectif est de battre le jeu ! Seul ou à plusieurs ! - /// - ///-98 cartes numérotés de 2 à 99. - /// - ///-4 piles sont à votre disposition, deux ascendantes et deux descendantes. - /// - ///-L'objectif est de pourvoir poser toute les cartes de la pioches sur les différentes piles à votre disposition. - /// - ///-Si vous arrivez à vider toute la pioche et de poser tout les cartes sur les piles, vous gagnez, sinon vous perdez. - /// - ///-Chaque joueur doit jouer au minimum deux cartes par tour. - /// - ///-Sur une pile ascendante, il est possible de [le reste de la chaîne a été tronqué]";. - /// internal static string StrRules { get { return ResourceManager.GetString("StrRules", resourceCulture); } } - /// - /// Recherche une chaîne localisée semblable à Désolé, vous n'avez pas recouvert la tête de mort... Réessayez ;). - /// internal static string StrSkullEffect { get { return ResourceManager.GetString("StrSkullEffect", resourceCulture); } } - /// - /// Recherche une chaîne localisée semblable à Le jeu est terminé!\n Bravo vous avez gagné!. - /// internal static string StrWin { get { return ResourceManager.GetString("StrWin", resourceCulture); } } - /// - /// Recherche une chaîne localisée semblable à La carte ne rentre pas dans la pile sectionnée!. - /// internal static string StrWrongStack { get { return ResourceManager.GetString("StrWrongStack", resourceCulture); } } + + internal static string StrPlayerSelection { + get { + return ResourceManager.GetString("StrPlayerSelection", resourceCulture); + } + } + + internal static string StrEnterPseudo { + get { + return ResourceManager.GetString("StrEnterPseudo", resourceCulture); + } + } + + internal static string StrCardDoesntExist { + get { + return ResourceManager.GetString("StrCardDoesntExist", resourceCulture); + } + } } } diff --git a/TheGameExtreme/AppRessource.resx b/TheGameExtreme/AppRessource.resx index e9103c3..5b68b5b 100644 --- a/TheGameExtreme/AppRessource.resx +++ b/TheGameExtreme/AppRessource.resx @@ -189,4 +189,7 @@ Veuillez saisir votre pseudo + + Carte inexistante + \ No newline at end of file diff --git a/TheGameExtreme/TheGameExtreme.csproj b/TheGameExtreme/TheGameExtreme.csproj index 031f45a..5e389d5 100644 --- a/TheGameExtreme/TheGameExtreme.csproj +++ b/TheGameExtreme/TheGameExtreme.csproj @@ -22,6 +22,8 @@ + + diff --git a/TheGameExtreme/model/Card/Card.cs b/TheGameExtreme/model/Card/Card.cs index c257e10..f4e4f3f 100644 --- a/TheGameExtreme/model/Card/Card.cs +++ b/TheGameExtreme/model/Card/Card.cs @@ -7,8 +7,8 @@ namespace TheGameExtreme.model.card { //public event PropertyChangedEventHandler PropertyChanged; - private int value; - public int Value + private decimal value; + public decimal Value { get { return value; } set @@ -23,7 +23,7 @@ namespace TheGameExtreme.model.card //} - public Card(int value) + public Card(decimal value) { Value = value; } diff --git a/TheGameExtreme/model/Card/ClassicCard.cs b/TheGameExtreme/model/Card/cardType/ClassicCard.cs similarity index 80% rename from TheGameExtreme/model/Card/ClassicCard.cs rename to TheGameExtreme/model/Card/cardType/ClassicCard.cs index 559ad26..790d9e0 100644 --- a/TheGameExtreme/model/Card/ClassicCard.cs +++ b/TheGameExtreme/model/Card/cardType/ClassicCard.cs @@ -1,13 +1,13 @@ using System; -namespace TheGameExtreme.model.card +namespace TheGameExtreme.model.card.cardType { public class ClassicCard : Card { public static readonly String CARD_CLASSIC = "ClassicCard"; - public ClassicCard(int value) + public ClassicCard(decimal value) : base(value) { } diff --git a/TheGameExtreme/model/Parametreur.cs b/TheGameExtreme/model/Parametreur.cs index ac4b603..9b63a37 100644 --- a/TheGameExtreme/model/Parametreur.cs +++ b/TheGameExtreme/model/Parametreur.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using TheGameExtreme.model.gameActions.classic; +using TheGameExtreme.model.piles; namespace TheGameExtreme.model { diff --git a/TheGameExtreme/model/deck/ClassicDeck.cs b/TheGameExtreme/model/deck/ClassicDeck.cs index 72f53a1..199369d 100644 --- a/TheGameExtreme/model/deck/ClassicDeck.cs +++ b/TheGameExtreme/model/deck/ClassicDeck.cs @@ -1,5 +1,6 @@ using System; using TheGameExtreme.model.card; +using TheGameExtreme.model.card.cardType; namespace TheGameExtreme.model.deck { diff --git a/TheGameExtreme/model/deck/DecimalDeck.cs b/TheGameExtreme/model/deck/DecimalDeck.cs new file mode 100644 index 0000000..4904879 --- /dev/null +++ b/TheGameExtreme/model/deck/DecimalDeck.cs @@ -0,0 +1,19 @@ +using System; +using TheGameExtreme.model.card; +using TheGameExtreme.model.card.cardType; + +namespace TheGameExtreme.model.deck +{ + public class DecimalDeck : Deck + { + public DecimalDeck() + { + Card card; + for (decimal i = 0.02m; i <= 0.99m; i += 0.01m) + { + card = new ClassicCard(i); + deck.Add(card); + } + } + } +} diff --git a/TheGameExtreme/model/deck/Deck.cs b/TheGameExtreme/model/deck/Deck.cs index 60a2369..b54a510 100644 --- a/TheGameExtreme/model/deck/Deck.cs +++ b/TheGameExtreme/model/deck/Deck.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using TheGameExtreme.model.card; -namespace TheGameExtreme.model +namespace TheGameExtreme.model.deck { public abstract class Deck { diff --git a/TheGameExtreme/model/deck/ExtremeDeck.cs b/TheGameExtreme/model/deck/ExtremeDeck.cs index bf191f4..9216f13 100644 --- a/TheGameExtreme/model/deck/ExtremeDeck.cs +++ b/TheGameExtreme/model/deck/ExtremeDeck.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using TheGameExtreme.model.card; +using TheGameExtreme.model.card.cardType; using TheGameExtreme.model.card.rapidCard; namespace TheGameExtreme.model.deck diff --git a/TheGameExtreme/model/deck/_50Range100Deck.cs b/TheGameExtreme/model/deck/_50Range100Deck.cs new file mode 100644 index 0000000..708d539 --- /dev/null +++ b/TheGameExtreme/model/deck/_50Range100Deck.cs @@ -0,0 +1,19 @@ +using System; +using TheGameExtreme.model.card; +using TheGameExtreme.model.card.cardType; + +namespace TheGameExtreme.model.deck +{ + public class _50Range100Deck : Deck + { + public _50Range100Deck() + { + Card card; + for (int i = -49; i <= 49; i++) + { + card = new ClassicCard(i); + deck.Add(card); + } + } + } +} diff --git a/TheGameExtreme/model/gameActions/GameAction.cs b/TheGameExtreme/model/gameActions/GameAction.cs index 26af12d..adcd739 100644 --- a/TheGameExtreme/model/gameActions/GameAction.cs +++ b/TheGameExtreme/model/gameActions/GameAction.cs @@ -1,6 +1,5 @@ using System; -using System.Collections.Generic; -using TheGameExtreme.model.card; +using TheGameExtreme.model.piles; namespace TheGameExtreme.model.gameActions { diff --git a/TheGameExtreme/model/gameActions/Piles.cs b/TheGameExtreme/model/gameActions/Piles.cs deleted file mode 100644 index 911006e..0000000 --- a/TheGameExtreme/model/gameActions/Piles.cs +++ /dev/null @@ -1,39 +0,0 @@ -using System; -using System.Collections.Generic; -using TheGameExtreme.model.card; - -namespace TheGameExtreme.model.gameActions -{ - public class Piles - { - - private List> ListOrderedStacks { get; set; } - - public Piles() - { - ListOrderedStacks = new List>(); - - ListOrderedStacks.Add(new Stack()); - ListOrderedStacks.Add(new Stack()); - ListOrderedStacks.Add(new Stack()); - ListOrderedStacks.Add(new Stack()); - - for (int i = 0; i < 4; i++) - { - if (i < 2) - { - ListOrderedStacks[i].Push(new ClassicCard(1)); - } - else - { - ListOrderedStacks[i].Push(new ClassicCard(100)); - } - } - } - - public Stack getStack(int i) - { - return ListOrderedStacks[i]; - } - } -} diff --git a/TheGameExtreme/model/gameActions/classic/GameMode.cs b/TheGameExtreme/model/gameActions/classic/GameMode.cs index bb974d7..d2eda38 100644 --- a/TheGameExtreme/model/gameActions/classic/GameMode.cs +++ b/TheGameExtreme/model/gameActions/classic/GameMode.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using TheGameExtreme.model.card; using TheGameExtreme.model.deck; using TheGameExtreme.model.@event; +using TheGameExtreme.model.piles; namespace TheGameExtreme.model.gameActions.classic { @@ -33,20 +34,19 @@ namespace TheGameExtreme.model.gameActions.classic #endregion - public GameMode() + public GameMode(Piles piles, Deck deck) { gameActions = new List(); + Piles = piles; + this.deck = deck; } public void load(int nbPlayer, List players) { - Piles = new Piles(); - gameActions.Add(new Piocher(Piles)); gameActions.Add(new JouerUneCarte(Piles)); gameActions.Add(new TerminerSonTour(Piles)); - deck = new ClassicDeck(); defineNbMaxCard(nbPlayer); distribueCard(players); } @@ -74,9 +74,9 @@ namespace TheGameExtreme.model.gameActions.classic { if (start < end) { - int pivot = ar[end].Value; + decimal pivot = ar[end].Value; int pIndex = start; - int swap; + decimal swap; for (int i = start; i < end; i++) { @@ -119,7 +119,7 @@ namespace TheGameExtreme.model.gameActions.classic quickSort(currentHand, 0, currentHand.Count - 1); } - public bool playCard(int valueCard, List currentHand, int orderedStackSelected, Player player, List CurrentCardPlayed) + public bool playCard(decimal valueCard, List currentHand, int orderedStackSelected, Player player, List CurrentCardPlayed) { Message = null; if (((JouerUneCarte)gameActions[1]).play(valueCard, currentHand, orderedStackSelected, player, CurrentCardPlayed)) @@ -141,15 +141,28 @@ namespace TheGameExtreme.model.gameActions.classic pioche(currentHand, player); CurrentCardPlayed.Clear(); OnPlayerChanged(null); - return ((TerminerSonTour)gameActions[2]).Test(currentHand); + if (((TerminerSonTour)gameActions[2]).Test(currentHand)) + { + return false; + } + else + { + OnEndGame(new EventArgs()); + return true; + } } else { Message = ((TerminerSonTour)gameActions[2]).ErrorMessage; - return true; + return false; } } + public string getScore() + { + return deck.size().ToString(); + } + #region Decaler dans un GameAction public bool isEndGame(List currentHand) diff --git a/TheGameExtreme/model/gameActions/classic/JouerUneCarte.cs b/TheGameExtreme/model/gameActions/classic/JouerUneCarte.cs index fff9626..92a16cf 100644 --- a/TheGameExtreme/model/gameActions/classic/JouerUneCarte.cs +++ b/TheGameExtreme/model/gameActions/classic/JouerUneCarte.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using TheGameExtreme.model.card; +using TheGameExtreme.model.piles; namespace TheGameExtreme.model.gameActions.classic { @@ -14,11 +15,11 @@ namespace TheGameExtreme.model.gameActions.classic { } - public bool play(int valueCard, List CurrentHand, int orderedStackSelected, Player player, List CurrentCardPlayed) + public bool play(decimal valueCard, List CurrentHand, int orderedStackSelected, Player player, List CurrentCardPlayed) { foreach (Card card in CurrentHand) { - if (valueCard == card.Value) + if (valueCard.CompareTo(card.Value) == 0) { if (orderedStackSelected >= 0 && orderedStackSelected < 4) { @@ -39,12 +40,13 @@ namespace TheGameExtreme.model.gameActions.classic } } } + ErrorMessage = AppRessource.StrCardDoesntExist; return false; } private bool rule(Card card, Stack stack, bool bottomUp, Player player, List CurrentCardPlayed) { - if ((bottomUp && card.Value > stack.Peek().Value) || (!bottomUp && card.Value < stack.Peek().Value) || card.Value == stack.Peek().Value - 10 || card.Value == stack.Peek().Value + 10) + if ((bottomUp && card.Value > stack.Peek().Value) || (!bottomUp && card.Value < stack.Peek().Value) || card.Value.CompareTo(stack.Peek().Value - 10) == 0 || card.Value.CompareTo(stack.Peek().Value + 10) == 0) { OldCard = stack.Peek(); player.joue(card); diff --git a/TheGameExtreme/model/gameActions/classic/Piocher.cs b/TheGameExtreme/model/gameActions/classic/Piocher.cs index 68b792e..d0a913c 100644 --- a/TheGameExtreme/model/gameActions/classic/Piocher.cs +++ b/TheGameExtreme/model/gameActions/classic/Piocher.cs @@ -1,6 +1,8 @@ using System; using System.Collections.Generic; using TheGameExtreme.model.card; +using TheGameExtreme.model.deck; +using TheGameExtreme.model.piles; namespace TheGameExtreme.model.gameActions.classic { diff --git a/TheGameExtreme/model/gameActions/classic/TerminerSonTour.cs b/TheGameExtreme/model/gameActions/classic/TerminerSonTour.cs index ba84c39..8c2d250 100644 --- a/TheGameExtreme/model/gameActions/classic/TerminerSonTour.cs +++ b/TheGameExtreme/model/gameActions/classic/TerminerSonTour.cs @@ -2,13 +2,13 @@ using System.Collections.Generic; using TheGameExtreme.model.card; using TheGameExtreme.model.card.rapidCard; +using TheGameExtreme.model.piles; namespace TheGameExtreme.model.gameActions.classic { public class TerminerSonTour : GameAction { - public TerminerSonTour(Piles ListOrderedStacks) : base(ListOrderedStacks) { } diff --git a/TheGameExtreme/model/gameActions/extreme/ExtremeJouerUneCarte.cs b/TheGameExtreme/model/gameActions/extreme/ExtremeJouerUneCarte.cs index 9877c84..389a57c 100644 --- a/TheGameExtreme/model/gameActions/extreme/ExtremeJouerUneCarte.cs +++ b/TheGameExtreme/model/gameActions/extreme/ExtremeJouerUneCarte.cs @@ -1,5 +1,6 @@ using System; using TheGameExtreme.model.gameActions.classic; +using TheGameExtreme.model.piles; namespace TheGameExtreme.model.gameActions.extreme { diff --git a/TheGameExtreme/model/gameActions/extreme/ExtremeMode.cs b/TheGameExtreme/model/gameActions/extreme/ExtremeMode.cs index bc16cb9..02ccb86 100644 --- a/TheGameExtreme/model/gameActions/extreme/ExtremeMode.cs +++ b/TheGameExtreme/model/gameActions/extreme/ExtremeMode.cs @@ -1,11 +1,13 @@ using System; +using TheGameExtreme.model.deck; using TheGameExtreme.model.gameActions.classic; +using TheGameExtreme.model.piles; namespace TheGameExtreme.model.gameActions.extreme { public class ExtremeMode : GameMode { - public ExtremeMode() + public ExtremeMode(Piles piles, Deck deck) : base(piles, deck) { gameActions.Add(new ExtremePiocher(Piles)); gameActions.Add(new ExtremeJouerUneCarte(Piles)); diff --git a/TheGameExtreme/model/gameActions/extreme/ExtremePiocher.cs b/TheGameExtreme/model/gameActions/extreme/ExtremePiocher.cs index e0ff5df..9440010 100644 --- a/TheGameExtreme/model/gameActions/extreme/ExtremePiocher.cs +++ b/TheGameExtreme/model/gameActions/extreme/ExtremePiocher.cs @@ -1,5 +1,6 @@ using System; using TheGameExtreme.model.gameActions.classic; +using TheGameExtreme.model.piles; namespace TheGameExtreme.model.gameActions.extreme { diff --git a/TheGameExtreme/model/gameActions/extreme/ExtremeTerminerSonTour.cs b/TheGameExtreme/model/gameActions/extreme/ExtremeTerminerSonTour.cs index 501e352..4880007 100644 --- a/TheGameExtreme/model/gameActions/extreme/ExtremeTerminerSonTour.cs +++ b/TheGameExtreme/model/gameActions/extreme/ExtremeTerminerSonTour.cs @@ -1,5 +1,6 @@ using System; using TheGameExtreme.model.gameActions.classic; +using TheGameExtreme.model.piles; namespace TheGameExtreme.model.gameActions.extreme { diff --git a/TheGameExtreme/model/manager/GameManager.cs b/TheGameExtreme/model/manager/GameManager.cs index 307e6ee..0184fc4 100644 --- a/TheGameExtreme/model/manager/GameManager.cs +++ b/TheGameExtreme/model/manager/GameManager.cs @@ -4,6 +4,7 @@ using System.ComponentModel; using TheGameExtreme.model.card; using TheGameExtreme.model.@event; using TheGameExtreme.model.gameActions; +using TheGameExtreme.model.piles; namespace TheGameExtreme.model.manager { @@ -48,6 +49,17 @@ namespace TheGameExtreme.model.manager currentIndexPlayer = 0; } CurrentHand = parametreur.players[currentIndexPlayer].getCardList(); + int i = 0; + while (CurrentHand.Count == 0 && i != 5) + { + currentIndexPlayer += 1; + if (currentIndexPlayer == parametreur.players.Count) + { + currentIndexPlayer = 0; + } + CurrentHand = parametreur.players[currentIndexPlayer].getCardList(); + i++; // Garde fou + } PlayerChanged?.Invoke(source, new PlayerChangedEventArgs(CurrentHand, parametreur.players[currentIndexPlayer].Pseudo)); parametreur.GameMode.NbCardAtBeginOfTurn = CurrentHand.Count; } @@ -71,7 +83,7 @@ namespace TheGameExtreme.model.manager - public bool joue(int valueCard, int orderedStackSelected) + public bool joue(int orderedStackSelected, decimal valueCard) { bool isPlayed = parametreur.GameMode.playCard(valueCard, currentHand, orderedStackSelected, parametreur.players[currentIndexPlayer], CurrentCardPlayed); // Mettre le joueur actif EndMessage = parametreur.GameMode.Message; @@ -82,215 +94,19 @@ namespace TheGameExtreme.model.manager { if(parametreur.GameMode.endTurn(currentHand, CurrentCardPlayed, parametreur.players[currentIndexPlayer])) { - EndMessage = parametreur.GameMode.Message; - if (isEndGame()) - { - EndMessage = parametreur.GameMode.Message; - return true; - } - else - { - return false; - } + EndMessage = parametreur.GameMode.Message + "Il vous restait " + parametreur.GameMode.getScore() + " cartes à jouer!"; + return true; } else { + EndMessage = parametreur.GameMode.Message; return false; } } - private bool isEndGame() - { - return parametreur.GameMode.isEndGame(currentHand); - } - public Piles getPiles() { return parametreur.GameMode.Piles; } - - - - - - - - - - - - - - - - - - - - - //public readonly int nbPlayer; - //protected int nbMaxCard; - //protected int currentIndexPlayer; - //protected List playerList = new List(); - //public List> ListOrderedStacks { get; set; } - //protected Deck deck; - //protected bool win = true; - //public String EndMessage { get; set; } - //public List CurrentHand { get; set; } - //protected int nbCardAtBeginOfTurn; - //protected List CurrentCardPlayed = new List(); - //protected string langue; - //public event EventHandler TopRangeChanged; - //public event EventHandler PlayerChanged; - - - //protected GameManager(int nbPlayer, List players) - //{ - // ListOrderedStacks = new List>(); - // CurrentHand = new List(); - - // this.nbPlayer = nbPlayer; - // players.ForEach(player => playerList.Add(new Player(player))); - - - // initStacks(); - - // initRule(); - - // createDeck(); - // defineNbMaxCard(); - // distribueCard(); - - // CurrentHand = playerList[currentIndexPlayer].getCardList(); - // nbCardAtBeginOfTurn = CurrentHand.Count; - //} - - //protected void initStacks() - //{ - // ListOrderedStacks = new List>(); - - // ListOrderedStacks.Add(new Stack()); - // ListOrderedStacks.Add(new Stack()); - // ListOrderedStacks.Add(new Stack()); - // ListOrderedStacks.Add(new Stack()); - - // for (int i = 0; i < 4; i++) - // { - // if (i < 2) - // { - // ListOrderedStacks[i].Push(new ClassicCard(1)); - // } - // else - // { - // ListOrderedStacks[i].Push(new ClassicCard(100)); - // } - // } - //} - - //protected void createDeck() - //{ - // switch (true) - // { - // case false: - // deck = new ClassicDeck(); - // break; - - // default: - // deck = new ExtremeDeck(); - // break; - // } - //} - - //protected void defineNbMaxCard() - //{ - // switch (nbPlayer) - // { - // case 1: - // nbMaxCard = 8; - // break; - // case 2: - // nbMaxCard = 7; - // break; - // default: - // nbMaxCard = 6; - // break; - // } - //} - - //protected void distribueCard() - //{ - // for (int i = 0; i < nbMaxCard; i++) - // { - // players.ForEach(player => - // { - // int r = new Random().Next(0, deck.size() - 1); - // player.pioche(deck.getCard(r)); - // deck.removeAt(r); - // }); - // } - //} - - //public void joue(int valueCard, int orderedStackSelected) - //{ - // gameMode.playCard(valueCard, CurrentHand, orderedStackSelected, players[0], CurrentCardPlayed); // Mettre le joueur actif - //} - - //protected void testPossibility(Card card, Stack orderedStack, bool bottomUp) - //{ - // //if (gameMode.checkPlayRule(card, orderedStack, bottomUp, CurrentHand)) - // //{ - // // Card oldCard = orderedStack.Peek(); - // // playerList[currentIndexPlayer].joue(card); - // // CurrentCardPlayed.Add(card); - // // orderedStack.Push(card); - // // OnTopRangeChanged(new TopRangeChangedEventArgs(card, oldCard, ListOrderedStacks.IndexOf(orderedStack))); - // // //if (CurrentHand.Count == 0) - // // //{ - // // // endTurn(); // Presque bon, oublie juste d'afficher les nouvelles cartes - // // //} - // //} - // //else - // //{ - // // throw new Exception(AppRessource.StrWrongStack); - // //} - //} - - //protected internal void OnTopRangeChanged(TopRangeChangedEventArgs args) - //{ - // TopRangeChanged?.Invoke(this, args); - //} - - //protected internal void OnPlayerChanged(PlayerChangedEventArgs args) - //{ - // PlayerChanged?.Invoke(this, args); - //} - - //public bool isCanPlay() - //{ - // if (CurrentHand.Count > 0) - // { - // return true; - // } - // else - // { - // return false; - // } - //} - - //abstract public bool endTurn(); - - //abstract protected bool isEndGame(); - - //abstract protected void tryToFindSoluce(List playableCard); - - //abstract protected bool testEndGame(List playableCard); - - //abstract protected bool effectLose(); - - //public int getCurentIndexPlayer() - //{ - // return currentIndexPlayer; - //} - } } diff --git a/TheGameExtreme/model/manager/SoloGameManager.cs b/TheGameExtreme/model/manager/SoloGameManager.cs index d3e7204..7ced415 100644 --- a/TheGameExtreme/model/manager/SoloGameManager.cs +++ b/TheGameExtreme/model/manager/SoloGameManager.cs @@ -12,164 +12,5 @@ namespace TheGameExtreme.model.manager { } - - //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 playableCard = new List(); - // tryToFindSoluce(playableCard); - // return testEndGame(playableCard); - // } - // return false; - //} - - //protected override void tryToFindSoluce(List 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 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 orderedStack in ListOrderedStacks) - // { - // if (Equals(orderedStack.Peek().getName(), EndGameCard.CARD_ENDGAME)) - // { - // return true; - // } - // } - // return false; - //} } } diff --git a/TheGameExtreme/model/piles/ClassicPiles.cs b/TheGameExtreme/model/piles/ClassicPiles.cs new file mode 100644 index 0000000..7fdfbe1 --- /dev/null +++ b/TheGameExtreme/model/piles/ClassicPiles.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using TheGameExtreme.model.card; +using TheGameExtreme.model.card.cardType; +using TheGameExtreme.model.deck; + +namespace TheGameExtreme.model.piles +{ + public class ClassicPiles : Piles + { + + public ClassicPiles(int nbPile) : base(nbPile) + { + for (int i = 0; i < nbPile; i++) + { + if (i < (nbPile * 0.5)) + { + ListOrderedStacks[i].Push(new ClassicCard(1)); + } + else + { + ListOrderedStacks[i].Push(new ClassicCard(100)); + } + } + } + } +} diff --git a/TheGameExtreme/model/piles/DecimalPiles.cs b/TheGameExtreme/model/piles/DecimalPiles.cs new file mode 100644 index 0000000..4824423 --- /dev/null +++ b/TheGameExtreme/model/piles/DecimalPiles.cs @@ -0,0 +1,24 @@ +using System; +using TheGameExtreme.model.card.cardType; + +namespace TheGameExtreme.model.piles +{ + public class DecimalPiles : Piles + { + + public DecimalPiles(int nbPile) : base(nbPile) + { + for (int i = 0; i < nbPile; i++) + { + if (i < (nbPile * 0.5)) + { + ListOrderedStacks[i].Push(new ClassicCard(0.01m)); + } + else + { + ListOrderedStacks[i].Push(new ClassicCard(1m)); + } + } + } + } +} diff --git a/TheGameExtreme/model/piles/Piles.cs b/TheGameExtreme/model/piles/Piles.cs new file mode 100644 index 0000000..66d360b --- /dev/null +++ b/TheGameExtreme/model/piles/Piles.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using TheGameExtreme.model.card; + +namespace TheGameExtreme.model.piles +{ + public abstract class Piles + { + + protected List> ListOrderedStacks { get; set; } = new List>(); + + public Piles(int nbPile) + { + for (int i = 0; i < nbPile; i++) + { + ListOrderedStacks.Add(new Stack()); + } + } + + public Stack getStack(int i) + { + return ListOrderedStacks[i]; + } + } +} diff --git a/TheGameExtreme/model/piles/_50Range100Piles.cs b/TheGameExtreme/model/piles/_50Range100Piles.cs new file mode 100644 index 0000000..ccdacc9 --- /dev/null +++ b/TheGameExtreme/model/piles/_50Range100Piles.cs @@ -0,0 +1,23 @@ +using System; +using TheGameExtreme.model.card.cardType; + +namespace TheGameExtreme.model.piles +{ + public class _50Range100Piles : Piles + { + public _50Range100Piles(int nbPile) : base(nbPile) + { + for (int i = 0; i < nbPile; i++) + { + if (i < (nbPile * 0.5)) + { + ListOrderedStacks[i].Push(new ClassicCard(-50)); + } + else + { + ListOrderedStacks[i].Push(new ClassicCard(50)); + } + } + } + } +} diff --git a/TheGameExtreme/view/MainPage.xaml.cs b/TheGameExtreme/view/MainPage.xaml.cs index eba7899..ed8a3fe 100644 --- a/TheGameExtreme/view/MainPage.xaml.cs +++ b/TheGameExtreme/view/MainPage.xaml.cs @@ -65,14 +65,21 @@ namespace TheGameExtreme.view canvas = args.Surface.Canvas; canvas.Clear(); - foreach (TouchManipulationBitmap textPaint in stackCollection) + for (int i = 0; i < stackCollection.Count; i++) { - textPaint.Paint(canvas); + if (i < (stackCollection.Count * 0.5)) + { + stackCollection[i].Paint(canvas, SKColors.Green); + } + else + { + stackCollection[i].Paint(canvas, SKColors.Red); + } } foreach (TouchManipulationBitmap textPaint in textCollection) { - textPaint.Paint(canvas); + textPaint.Paint(canvas, SKColors.SkyBlue); } } @@ -127,7 +134,7 @@ namespace TheGameExtreme.view if (stack.HitTest(point)) { int indexPile = stackCollection.IndexOf(stack); - if (played(indexPile, int.Parse(bitmap.Value))) + if (played(indexPile, decimal.Parse(bitmap.Value))) { point = stack.InitialPoint; bitmap.ProcessTouchEvent(args.Id, TouchActionType.Moved, point); @@ -169,7 +176,7 @@ namespace TheGameExtreme.view stackCollection.Clear(); SKPaint textPaint = new SKPaint(); - float textWidth = textPaint.MeasureText("01"); + float textWidth = textPaint.MeasureText("001"); float textSize = 0.05f * (float)DeviceDisplay.MainDisplayInfo.Width * textPaint.TextSize / textWidth; SKPoint position = new SKPoint((float)((DeviceDisplay.MainDisplayInfo.Width * 0.05) - (textWidth * 0.5)), (float)((DeviceDisplay.MainDisplayInfo.Height * 0.1) + (DeviceDisplay.MainDisplayInfo.Height * 0.9) * 0.01 + 2 * textSize)); @@ -184,14 +191,14 @@ namespace TheGameExtreme.view InitialPoint = position }); - position.X += (float)(DeviceDisplay.MainDisplayInfo.Width * 0.2); + position.X += (float)((DeviceDisplay.MainDisplayInfo.Width * 0.9) / viewmodel.getListOrderedStacks().Count); } } private void InflateHand() { SKPaint textPaint = new SKPaint(); - float textWidth = textPaint.MeasureText("01"); + float textWidth = textPaint.MeasureText("001"); float textSize = 0.05f * (float)DeviceDisplay.MainDisplayInfo.Width * textPaint.TextSize / textWidth; SKPoint position = new SKPoint((float)(DeviceDisplay.MainDisplayInfo.Width * 0.05), (float)((DeviceDisplay.MainDisplayInfo.Height * 0.9) - (DeviceDisplay.MainDisplayInfo.Height * 0.9) * 0.2 - textSize)); @@ -222,7 +229,7 @@ namespace TheGameExtreme.view gameOption.Children.Add(retryButton); } - private bool played(int numStack, int value) + private bool played(int numStack, decimal value) { if (!viewmodel.played(numStack, value)) { diff --git a/TheGameExtreme/view/TouchManipulationBitmap.cs b/TheGameExtreme/view/TouchManipulationBitmap.cs index 4b8402d..1030352 100644 --- a/TheGameExtreme/view/TouchManipulationBitmap.cs +++ b/TheGameExtreme/view/TouchManipulationBitmap.cs @@ -11,17 +11,18 @@ namespace TheGameExtreme.view Dictionary touchDictionary = new Dictionary(); public string Value; - public TouchManipulationBitmap(SKPaint textPaint, int value) + public TouchManipulationBitmap(SKPaint textPaint, decimal value) { this.textPaint = textPaint; - if (value > 0 && value < 10) - { - Value = "0" + value.ToString(); - } - else - { - Value = value.ToString(); - } + Value = value.ToString(); + //if (value > 0 && value < 10) + //{ + // Value = "0" + value.ToString(); + //} + //else + //{ + // Value = value.ToString(); + //} Matrix = SKMatrix.MakeIdentity(); @@ -35,14 +36,14 @@ namespace TheGameExtreme.view public SKMatrix Matrix { set; get; } - public void Paint(SKCanvas canvas) + public void Paint(SKCanvas canvas, SKColor color) { canvas.Save(); SKMatrix matrix = Matrix; canvas.Concat(ref matrix); - textPaint.Color = SKColors.SkyBlue; + textPaint.Color = color; textPaint.StrokeWidth = 5; textPaint.Style = SKPaintStyle.Stroke; @@ -51,12 +52,18 @@ namespace TheGameExtreme.view SKRoundRect card = new SKRoundRect(textBounds); card.Inflate(35, 55); - + canvas.DrawRoundRect(card, textPaint); canvas.DrawText(Value, 0, 0, textPaint); canvas.Restore(); + + } + + public void ChangeColor(SKColor color) + { + textPaint.Color = color; } public bool HitTest(SKPoint location) diff --git a/TheGameExtreme/viewmodel/CardVM.cs b/TheGameExtreme/viewmodel/CardVM.cs index 8743ec4..bfedae8 100644 --- a/TheGameExtreme/viewmodel/CardVM.cs +++ b/TheGameExtreme/viewmodel/CardVM.cs @@ -13,8 +13,8 @@ namespace TheGameExtreme.viewmodel public event PropertyChangedEventHandler PropertyChanged; public Card View { get; set; } - protected int value; - public int Value { + protected decimal value; + public decimal Value { get { return value; } set { diff --git a/TheGameExtreme/viewmodel/Main.cs b/TheGameExtreme/viewmodel/Main.cs index 7a22713..9e972ed 100644 --- a/TheGameExtreme/viewmodel/Main.cs +++ b/TheGameExtreme/viewmodel/Main.cs @@ -3,9 +3,11 @@ using System.Collections.Generic; using System.ComponentModel; using TheGameExtreme.model; using TheGameExtreme.model.card; +using TheGameExtreme.model.deck; using TheGameExtreme.model.@event; using TheGameExtreme.model.gameActions.classic; using TheGameExtreme.model.manager; +using TheGameExtreme.model.piles; namespace TheGameExtreme.viewmodel { @@ -51,10 +53,11 @@ namespace TheGameExtreme.viewmodel public Main(List playersNames) { + int nbPile = 4; playersNames.ForEach(name => players.Add(new PlayerVM(new Player(name)))); - Parametreur parametreur = new Parametreur(new GameMode()); + Parametreur parametreur = new Parametreur(new GameMode(new ClassicPiles(nbPile), new ClassicDeck())); players.ForEach(player => parametreur.AddPlayer(player.View)); - gameManager = new SoloGameManager(parametreur) ; // Donner le nom des joueurs + gameManager = new SoloGameManager(parametreur); gameManager.EndGame += OnEndGame; @@ -67,7 +70,7 @@ namespace TheGameExtreme.viewmodel Pseudo = players[0].Pseudo; - for (int i = 0; i < 4; i++) + for (int i = 0; i < nbPile; i++) { Stack pileView = gameManager.getPiles().getStack(i); Stack pile = new Stack(); @@ -106,9 +109,9 @@ namespace TheGameExtreme.viewmodel * * @return booléen de fin de jeu */ - public bool played(int numStack, int valueCard) + public bool played(int numStack, decimal valueCard) { - if (!gameManager.joue(valueCard, numStack)) + if (!gameManager.joue(numStack, valueCard)) { Alert = gameManager.EndMessage; return false; @@ -121,10 +124,6 @@ namespace TheGameExtreme.viewmodel { bool isEnd = gameManager.endTurn(); Alert = gameManager.EndMessage; - if (isEnd) - { - OnEndGame(this, new EventArgs()); - } return isEnd; }