From 9662b4cd1bfe366888195e1da5312828fb7b6c42 Mon Sep 17 00:00:00 2001 From: cldupland Date: Thu, 12 Dec 2019 11:48:05 +0100 Subject: [PATCH] =?UTF-8?q?Re-impl=C3=A9mentation=20des=20decimaux=20avec?= =?UTF-8?q?=20visuel=20de=20nombre=20=C3=A0=20virgule?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TheGameExtreme/Resx/AppResources.Designer.cs | 74 ++------ TheGameExtreme/Resx/AppResources.resx | 18 +- TheGameExtreme/TheGameExtreme.csproj | 2 +- TheGameExtreme/model/deck/ClassicDeck.cs | 8 - TheGameExtreme/model/deck/Decimal1.cs | 18 ++ TheGameExtreme/model/deck/Decimal2.cs | 18 ++ .../view/GamePreparationPage.xaml.cs | 2 +- .../view/GamePreparationPage.xaml.cs.orig | 160 ------------------ TheGameExtreme/view/HomePage.xaml.orig | 156 ----------------- .../view/MultiPlayerMode.xaml.cs.orig | 27 --- TheGameExtreme/viewmodel/Main.cs | 6 + 11 files changed, 74 insertions(+), 415 deletions(-) create mode 100644 TheGameExtreme/model/deck/Decimal1.cs create mode 100644 TheGameExtreme/model/deck/Decimal2.cs delete mode 100644 TheGameExtreme/view/GamePreparationPage.xaml.cs.orig delete mode 100644 TheGameExtreme/view/HomePage.xaml.orig delete mode 100644 TheGameExtreme/view/MultiPlayerMode.xaml.cs.orig diff --git a/TheGameExtreme/Resx/AppResources.Designer.cs b/TheGameExtreme/Resx/AppResources.Designer.cs index c7c8c86..e455e5a 100644 --- a/TheGameExtreme/Resx/AppResources.Designer.cs +++ b/TheGameExtreme/Resx/AppResources.Designer.cs @@ -161,18 +161,12 @@ namespace TheGameExtreme.Resx { } } - /// - /// Recherche une chaîne localisée semblable à Suivant. - /// public static string StrNext { get { return ResourceManager.GetString("StrNext", resourceCulture); } } - /// - /// Recherche une chaîne localisée semblable à Veuillez choisir un nombre de joueur ainsi que leur(s) nom(s). - /// public static string StrPlayerSelections { get { return ResourceManager.GetString("StrPlayerSelections", resourceCulture); @@ -191,128 +185,84 @@ namespace TheGameExtreme.Resx { } } - /// - /// Recherche une chaîne localisée semblable à - L'objectif est de battre la machine seul et/ou en coopération.. - /// public static string StrTiret1 { get { return ResourceManager.GetString("StrTiret1", resourceCulture); } } - /// - /// Recherche une chaîne localisée semblable à - Une fois votre tour terminé, vous appuyez sur le boutton "Fin de tour" afin de passer au joueur suivant.. - /// public static string StrTiret10 { get { return ResourceManager.GetString("StrTiret10", resourceCulture); } } - /// - /// Recherche une chaîne localisée semblable à - La partie est finie quand toutes les cartes sont jouées ou quand le joueur dont c'est le tour ne peut plus jouer.. - /// public static string StrTiret11 { get { return ResourceManager.GetString("StrTiret11", resourceCulture); } } - /// - /// Recherche une chaîne localisée semblable à - Afin de préparer la partie, vous disposez d'un écran permettant de choisir le nombre de joueur et leur pseudo, le type de jeu auquels vous souhaitez jouer et enfin le nombre de piles pour jouer.. - /// public static string StrTiret12 { get { return ResourceManager.GetString("StrTiret12", resourceCulture); } } - /// - /// Recherche une chaîne localisée semblable à - Le type de jeu permet de définir les valeurs présentent sur les cartes. Vous pouvez jouer avec des valeurs entières, relatives, décimales (1 chiffre), décimales (2 chiffres), décimales (3 chiffres) et avec des fractions décimales. - /// public static string StrTiret13 { get { return ResourceManager.GetString("StrTiret13", resourceCulture); } } - /// - /// Recherche une chaîne localisée semblable à - Afin d'atteindre l'objectif, les joueurs disposent de 4 piles (par défaut): deux piles ascendantes vertes et deux piles descendantes rouges.. - /// public static string StrTiret2 { get { return ResourceManager.GetString("StrTiret2", resourceCulture); } } - /// - /// Recherche une chaîne localisée semblable à - Sur les piles ascendantes, le joueur doit poser des cartes plus grandes et inversement sur les piles descendantes.. - /// public static string StrTiret3 { get { return ResourceManager.GetString("StrTiret3", resourceCulture); } } - /// - /// Recherche une chaîne localisée semblable à - Le but est de poser les 98 cartes du jeu sur les différentes piles à votre disposition.. - /// public static string StrTiret4 { get { return ResourceManager.GetString("StrTiret4", resourceCulture); } } - /// - /// Recherche une chaîne localisée semblable à - Pour jouer, il suffit de faire glisser une carte sur la pile que vous avez décidé.. - /// public static string StrTiret5 { get { return ResourceManager.GetString("StrTiret5", resourceCulture); } } - /// - /// Recherche une chaîne localisée semblable à - Cette carte doit être plus grande que celle déjà présente s'il s'agit d'une pile ascendante et plus petite si c'est l'inverse.. - /// public static string StrTiret6 { get { return ResourceManager.GetString("StrTiret6", resourceCulture); } } - /// - /// Recherche une chaîne localisée semblable à - Il est possible de poser une carte plus petite sur une pile ascendante à condition que ce soit d''une dizaine inférieur. De la même manière, si la carte est plus grande d'une dizaine, il est possible de la poser sur une pile descendante.. - /// public static string StrTiret7 { get { return ResourceManager.GetString("StrTiret7", resourceCulture); } } - /// - /// Recherche une chaîne localisée semblable à - Ex : Sur une pile descendante, nous avons 22 => Nous pouvons alors poser 32. - /// Sur une pile ascendante, nous avons 16 => Nous pouvons poser 6.. - /// public static string StrTiret8 { get { return ResourceManager.GetString("StrTiret8", resourceCulture); } } - /// - /// Recherche une chaîne localisée semblable à - Chaque joueur doit jouer au minimum deux cartes par tour. - /// Il n'y a donc aucune limite maximale de carte à jouer par tour. Cependant, il est conseillé dans la plupart des cas de ne pas jouer toutes les cartes en sa possessions.. - /// public static string StrTiret9 { get { return ResourceManager.GetString("StrTiret9", resourceCulture); } } - /// - /// Recherche une chaîne localisée semblable à OrderStacks. - /// public static string StrTitle { get { return ResourceManager.GetString("StrTitle", resourceCulture); @@ -349,9 +299,9 @@ namespace TheGameExtreme.Resx { } } - public static string TypeValuehundredth { + public static string TypeValueHundredthFract { get { - return ResourceManager.GetString("TypeValuehundredth", resourceCulture); + return ResourceManager.GetString("TypeValueHundredthFract", resourceCulture); } } @@ -361,15 +311,15 @@ namespace TheGameExtreme.Resx { } } - public static string TypeValueTens { + public static string TypeValueTenthFract { get { - return ResourceManager.GetString("TypeValueTens", resourceCulture); + return ResourceManager.GetString("TypeValueTenthFract", resourceCulture); } } - public static string TypeValuethousandth { + public static string TypeValueThousandthFract { get { - return ResourceManager.GetString("TypeValuethousandth", resourceCulture); + return ResourceManager.GetString("TypeValueThousandthFract", resourceCulture); } } @@ -379,6 +329,18 @@ namespace TheGameExtreme.Resx { } } + public static string TypeValueTenth { + get { + return ResourceManager.GetString("TypeValueTenth", resourceCulture); + } + } + + public static string TypeValueHundredth { + get { + return ResourceManager.GetString("TypeValueHundredth", resourceCulture); + } + } + public static string WhiteTheme { get { return ResourceManager.GetString("WhiteTheme", resourceCulture); diff --git a/TheGameExtreme/Resx/AppResources.resx b/TheGameExtreme/Resx/AppResources.resx index 81da45d..bfa8e38 100644 --- a/TheGameExtreme/Resx/AppResources.resx +++ b/TheGameExtreme/Resx/AppResources.resx @@ -253,21 +253,27 @@ Une possibilité de changer le thème de l'application grâce aux images du sole Fractionnées - - Décimales (2 chiffres) + + 2 Décimales (Fraction) Relatives - - Décimales (1 chiffre) + + 1 Décimales (Fraction) - - Décimales (3 chiffres) + + 3 Décimales (Fraction) Entière + + 1 Décimales + + + 2 Décimales + Thème clair : diff --git a/TheGameExtreme/TheGameExtreme.csproj b/TheGameExtreme/TheGameExtreme.csproj index 19febeb..f7dd762 100644 --- a/TheGameExtreme/TheGameExtreme.csproj +++ b/TheGameExtreme/TheGameExtreme.csproj @@ -83,7 +83,7 @@ MSBuild:UpdateDesignTimeXaml - + MSBuild:UpdateDesignTimeXaml diff --git a/TheGameExtreme/model/deck/ClassicDeck.cs b/TheGameExtreme/model/deck/ClassicDeck.cs index b13e1ef..38c54ee 100644 --- a/TheGameExtreme/model/deck/ClassicDeck.cs +++ b/TheGameExtreme/model/deck/ClassicDeck.cs @@ -13,14 +13,6 @@ namespace TheGameExtreme.model.deck while (deck.Count < nbCard && deck.Count < (borneMax - borneMin)) { int value = random.Next(borneMin, borneMax); - //foreach (Card card in deck) - //{ - // if (card.Value.CompareTo(value) == 0) - // { - // Debug.WriteLine("Regarde!"); - // break; - // } - //} InsertionDichotomique(deck, 0, deck.Count-1, new ClassicCard(value)); } } diff --git a/TheGameExtreme/model/deck/Decimal1.cs b/TheGameExtreme/model/deck/Decimal1.cs new file mode 100644 index 0000000..bdc7374 --- /dev/null +++ b/TheGameExtreme/model/deck/Decimal1.cs @@ -0,0 +1,18 @@ +using System; +using TheGameExtreme.model.card.cardType; + +namespace TheGameExtreme.model.deck +{ + public class Decimal1Deck : Deck + { + public Decimal1Deck(int nbCard, int borneMin, int borneMax) : base(nbCard) + { + Random random = new Random(); + while (deck.Count < nbCard && deck.Count < (borneMax - borneMin)) + { + decimal value = random.Next(borneMin, borneMax) * 0.1m; + InsertionDichotomique(deck, 0, deck.Count - 1, new ClassicCard(value)); + } + } + } +} diff --git a/TheGameExtreme/model/deck/Decimal2.cs b/TheGameExtreme/model/deck/Decimal2.cs new file mode 100644 index 0000000..293be22 --- /dev/null +++ b/TheGameExtreme/model/deck/Decimal2.cs @@ -0,0 +1,18 @@ +using System; +using TheGameExtreme.model.card.cardType; + +namespace TheGameExtreme.model.deck +{ + public class Decimal2Deck : Deck + { + public Decimal2Deck(int nbCard, int borneMin, int borneMax) : base(nbCard) + { + Random random = new Random(); + while (deck.Count < nbCard && deck.Count < (borneMax - borneMin)) + { + decimal value = random.Next(borneMin, borneMax) * 0.01m; + InsertionDichotomique(deck, 0, deck.Count - 1, new ClassicCard(value)); + } + } + } +} diff --git a/TheGameExtreme/view/GamePreparationPage.xaml.cs b/TheGameExtreme/view/GamePreparationPage.xaml.cs index f408921..76532e2 100644 --- a/TheGameExtreme/view/GamePreparationPage.xaml.cs +++ b/TheGameExtreme/view/GamePreparationPage.xaml.cs @@ -9,7 +9,7 @@ namespace TheGameExtreme.view public partial class GamePreparationPage : ContentPage { public List listNbPlayer = new List { 1, 2, 3, 4, 5 }; - public List listGameMode = new List { AppResources.TypeValueWhole, AppResources.TypeValueRelative, AppResources.TypeValueTens, AppResources.TypeValuehundredth, AppResources.TypeValuethousandth, AppResources.TypeValuefractionated }; + public List listGameMode = new List { AppResources.TypeValueWhole, AppResources.TypeValueRelative, AppResources.TypeValueTenthFract, AppResources.TypeValueHundredthFract, AppResources.TypeValueThousandthFract, AppResources.TypeValuefractionated, AppResources.TypeValueTenth, AppResources.TypeValueHundredth }; public List listNbStack = new List { 4, 6, 8 }; public List listNbCard = new List { 100, 80, 60, 40 }; diff --git a/TheGameExtreme/view/GamePreparationPage.xaml.cs.orig b/TheGameExtreme/view/GamePreparationPage.xaml.cs.orig deleted file mode 100644 index 8c9f238..0000000 --- a/TheGameExtreme/view/GamePreparationPage.xaml.cs.orig +++ /dev/null @@ -1,160 +0,0 @@ -using System; -using System.Collections.Generic; -using TheGameExtreme.IO; -using TheGameExtreme.Resx; -using Xamarin.Forms; - -namespace TheGameExtreme.view -{ - public partial class GamePreparationPage : ContentPage - { - public List listNbPlayer = new List { 1, 2, 3, 4, 5 }; - public List listGameMode = new List { AppResources.TypeValueWhole, AppResources.TypeValueRelative, AppResources.TypeValueTens, AppResources.TypeValuehundredth, AppResources.TypeValuethousandth, AppResources.TypeValuefractionated }; - public List listNbStack = new List { 4, 6, 8 }; - public List listNbCard = new List { 100, 80, 60, 40 }; - - - public GamePreparationPage() - { - InitializeComponent(); - - NavigationPage.SetHasNavigationBar(this, false); - - LoadParameterName(); - - PlayerSelecter.ItemsSource = listNbPlayer; - LoadParameterNbPlayerGamePreparation(); - - SelectMode.ItemsSource = listGameMode; - LoadParameterGameModeValueGamePreparation(); - - SelectNbStack.ItemsSource = listNbStack; - LoadParameterNbStacksGamePreparation(); - - SelectNbCard.ItemsSource = listNbCard; - LoadParameterNbCardsGamePreparation(); - - - - } - - private async void Back(object sender, EventArgs e) - { - IOGamePreparation.SaveParamaterGamePreparationNbPlayers(PlayerSelecter.SelectedIndex); - IOGamePreparation.SaveParameterGamePreparationGameModeValue(SelectMode.SelectedIndex); - IOGamePreparation.SaveParameterGamePreparationNbStacks(SelectNbStack.SelectedIndex); - IOGamePreparation.SaveParameterGamePreparationNbCards(SelectNbCard.SelectedIndex); -<<<<<<< HEAD - IOGamePreparation.SaveParameterGamePreparationName(FirstEntry.Text); - await Navigation.PopToRootAsync(); -======= - if ((int)PlayerSelecter.SelectedItem == 1) - { - IOGamePreparation.SaveParameterGamePreparationName(FirstEntry.Text); - } - await Navigation.PopAsync(); ->>>>>>> 6006856012a9420076ac40947eee0560f1e65e3e - } - - protected override bool OnBackButtonPressed() - { - IOGamePreparation.SaveParamaterGamePreparationNbPlayers(PlayerSelecter.SelectedIndex); - IOGamePreparation.SaveParameterGamePreparationGameModeValue(SelectMode.SelectedIndex); - IOGamePreparation.SaveParameterGamePreparationNbStacks(SelectNbStack.SelectedIndex); - IOGamePreparation.SaveParameterGamePreparationNbCards(SelectNbCard.SelectedIndex); - if ((int)PlayerSelecter.SelectedItem == 1) - { - IOGamePreparation.SaveParameterGamePreparationName(FirstEntry.Text); - } - return base.OnBackButtonPressed(); - } - - private async void Play(object sender, EventArgs args) - { - List playersNames = new List(); - - - for (int i = 1; i < NameList.Children.Count; i++) - { - playersNames.Add(((Entry)NameList.Children[i]).Text); - if (string.IsNullOrWhiteSpace(playersNames[playersNames.Count - 1])) - { - await DisplayAlert(AppResources.WrongPseudo, AppResources.StrEnterPseudo, AppResources.StrCloseWind); - return; - } - } - IOGamePreparation.SaveParamaterGamePreparationNbPlayers(PlayerSelecter.SelectedIndex); - IOGamePreparation.SaveParameterGamePreparationGameModeValue(SelectMode.SelectedIndex); - IOGamePreparation.SaveParameterGamePreparationNbStacks(SelectNbStack.SelectedIndex); - IOGamePreparation.SaveParameterGamePreparationNbCards(SelectNbCard.SelectedIndex); - IOGamePreparation.SaveParameterGamePreparationName(FirstEntry.Text); - await Navigation.PushAsync(new MainPage(playersNames, (int)SelectNbStack.SelectedItem, (int)SelectMode.SelectedIndex, (int)SelectNbCard.SelectedItem)); - } - - private void ChangedPseudo(object sender, EventArgs args) - { - if ((int)PlayerSelecter.SelectedItem == 1) - { - LoadParameterName(); - } - else - { - FirstEntry.Text = ""; - } - while (NameList.Children.Count - 1 != (int)PlayerSelecter.SelectedItem) - { - if (NameList.Children.Count - 1 < (int)PlayerSelecter.SelectedItem) - { - - Entry e = new Entry - { - Placeholder = "Pseudo", - BackgroundColor = (Color)Application.Current.Resources["Gold"], - WidthRequest = 200, - MinimumWidthRequest = 50, - HorizontalOptions = LayoutOptions.Center, - MaxLength = 18, - IsTextPredictionEnabled = false - }; - - - NameList.Children.Add(e); - } - else - { - NameList.Children.RemoveAt(NameList.Children.Count - 1); - } - } - } - public void LoadParameterNbPlayerGamePreparation() - { - int nbJoueurs = IOGamePreparation.LoadParameterGamePreparationNbPlayers(); - PlayerSelecter.SelectedIndex = nbJoueurs; - } - - public void LoadParameterGameModeValueGamePreparation() - { - int gameModeValue = IOGamePreparation.LoadParameterGamePreparationGameModeValue(); - SelectMode.SelectedIndex = gameModeValue; - } - - public void LoadParameterNbStacksGamePreparation() - { - int nbStackSer = IOGamePreparation.LoadParamaterGamePreparationNbStacks(); - SelectNbStack.SelectedIndex = nbStackSer; - } - public void LoadParameterNbCardsGamePreparation() - { - int nbCards = IOGamePreparation.LoadParameterGamePreparationNbCards(); - SelectNbCard.SelectedIndex = nbCards; - } - public void LoadParameterName() - { - string pseudo = IOGamePreparation.LoadNameFromGamePrepararion(); - FirstEntry.Text = pseudo; - } - - - - } -} diff --git a/TheGameExtreme/view/HomePage.xaml.orig b/TheGameExtreme/view/HomePage.xaml.orig deleted file mode 100644 index 82da23b..0000000 --- a/TheGameExtreme/view/HomePage.xaml.orig +++ /dev/null @@ -1,156 +0,0 @@ - - - - - - - - - - - - - - - - - - - - -