Ejemplo n.º 1
0
 public bool Dehypothequer(CarreauAchetable prop)
 {
     if (prop != null)
     {
         if (this.PeutPayer(prop.PrixAchat))
         {
             if (prop.EstHypotheque)
             {
                 this.Argent       -= prop.PrixAchat;
                 prop.EstHypotheque = false;
                 MessageBox.Show("Propriete: " + prop.positionCarreau + "a ete rachetée!", "Avertissement", MessageBoxButton.OK, MessageBoxImage.Information);
                 return(true);
             }
             else
             {
                 MessageBox.Show("Propriete: " + prop.positionCarreau + "n'est pas hypothequée!", "Avertissement", MessageBoxButton.OK, MessageBoxImage.Information);
             }
         }
         else
         {
             MessageBox.Show("Joueur: " + prop.Proprietaire.Nom + "ne peut pas racheter la propriété.", "Avertissement", MessageBoxButton.OK, MessageBoxImage.Information);
             return(false);
         }
     }
     else
     {
         MessageBox.Show("Propriete: " + prop.positionCarreau + "n'appartient pas au joueur courant", "Avertissement", MessageBoxButton.OK, MessageBoxImage.Information);
     }
     return(false);
 }
Ejemplo n.º 2
0
        private bool AUneProprieteAHypothequer()
        {
            //A partir de ce moment, il va payer son droit de passage avec directement la premiere propriété qui n'est pas hypothequer parmis propriété, service et trains.
            //On pourrait ici demander a l'utilisateur laquel des propriété qui veut hypothequer. Je conseil d'utiliser un nouveau window (affiche propriété, service et trains + double-click)
            CarreauAchetable proprieteNonHypotheque = Plateau.Instance.JoueurCourant.Proprietes.Where(x => !x.EstHypotheque).First();
            CarreauAchetable serviceNonHypotheque   = Plateau.Instance.JoueurCourant.Services.Where(x => !x.EstHypotheque).First();
            CarreauAchetable trainsNonHypotheque    = Plateau.Instance.JoueurCourant.Proprietes.Where(x => !x.EstHypotheque).First();

            //int dep = int.Parse(Microsoft.VisualBasic.Interaction.InputBox("Quel propriete voulez-vous hypotheque?\n" + liste + "\n" + " $        Votre argent: " + Plateau.Instance.JoueurCourant.Argent + " $ ", "Hypotheque?"));
            //CarreauAchetable prop = Proprietes.FirstOrDefault(x => x.positionCarreau == dep);

            if (proprieteNonHypotheque != null)
            {
                Plateau.Instance.JoueurCourant.Hypothequer(proprieteNonHypotheque);
                return(true);
            }
            else if (serviceNonHypotheque != null)
            {
                Plateau.Instance.JoueurCourant.Hypothequer(serviceNonHypotheque);
                return(true);
            }
            else if (trainsNonHypotheque != null)
            {
                Plateau.Instance.JoueurCourant.Hypothequer(trainsNonHypotheque);
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Cette fonction sert a payer le droit de passage sur une propriété qui n'est pas la sienne
        /// Si le joueur n'a pas assez de tunes pour payer le propriétaire, il fait faillite
        /// </summary>
        public void payerDroitPassage(CarreauAchetable carreau)
        {
            Joueur joueurProprietaire = carreau.Proprietaire;
            long   droitPassage       = carreau.getPrixPassage();

            // Faire une fct qui valide si le joueur est propriétaire de la case sur laquel il est
            //enlever ce if de la fonction, ya pas d,affaire la
            if (Plateau.Instance.JoueurCourant != joueurProprietaire)
            {
                if (!joueurProprietaire.Proprietes.FirstOrDefault(x => x == carreau).EstHypotheque)
                {
                    if (Plateau.Instance.JoueurCourant.PeutPayer(droitPassage))
                    {
                        Plateau.Instance.JoueurCourant.Payer(droitPassage);
                        joueurProprietaire.Depot(droitPassage);
                    }
                    else
                    {
                        if (AUneProprieteAHypothequer())
                        {
                            payerDroitPassage(carreau);
                        }
                        else
                        {
                            Plateau.Instance.JoueurCourant.FaitFaillite();
                        }
                    }
                }
            }
        }
Ejemplo n.º 4
0
 public void execute(Carreau carreau)
 {
     if (carreau is CarreauAchetable)
     {
         CarreauAchetable carreauActuel = (CarreauAchetable)carreau;
         if (carreauActuel.estPossede())
         {
             payerDroitPassage(carreauActuel);
         }
     }
     else if (carreau is CarreauTaxe)
     {
         payerTaxe((CarreauPayant)carreau);
     }
 }
Ejemplo n.º 5
0
        internal bool Hypothequer(CarreauAchetable carreauAHypothequer)
        {
            if (carreauAHypothequer != null)
            {
                if (!carreauAHypothequer.EstHypotheque)
                {
                    Depot(carreauAHypothequer.PrixAchat / 2);
                    carreauAHypothequer.EstHypotheque = true;
                    MessageBox.Show("Propriete: " + carreauAHypothequer.positionCarreau + " a ete hypotheque!", "Avertissement", MessageBoxButton.OK, MessageBoxImage.Information);
                    return(true);
                }
                else
                {
                    MessageBox.Show("Propriete: " + carreauAHypothequer.positionCarreau + "N'EST PAS HYPOTHEQUE!!!!", "Avertissement", MessageBoxButton.OK, MessageBoxImage.Information);
                }
            }
            else
            {
                MessageBox.Show("La propriete selectionnée n'appartient pas au joueur courant", "Avertissement", MessageBoxButton.OK, MessageBoxImage.Information);
            }

            return(false);
        }
Ejemplo n.º 6
0
        public static string ShowDialog(string label1, string label2, string caption)
        {
            Form prompt = new Form()
            {
                Width           = 500,
                Height          = 300,
                FormBorderStyle = FormBorderStyle.FixedDialog,
                Text            = caption,
                StartPosition   = FormStartPosition.CenterScreen
            };
            // Propriétés du joueur
            Label textLabel = new Label()
            {
                Left = 50, Top = 20, Width = 400, Text = label1
            };
            ComboBox listePropJoueur = new ComboBox()
            {
                Left = 50, Top = 80, Width = 400
            };

            string[] listePropJoueurStr = new string[Plateau.Instance.JoueurCourant.Proprietes.Count];
            int      noProp             = 0;

            foreach (CarreauAchetable p in Plateau.Instance.JoueurCourant.Proprietes)
            {
                listePropJoueurStr[noProp] = p.ToString();
                noProp++;
            }
            listePropJoueur.DataSource = listePropJoueurStr;

            // Propriétés qui ont été achetées mais qui n'appartiennent pas au joueur
            Label textLabel2 = new Label()
            {
                Left = 50, Top = 120, Width = 400, Text = label2
            };
            ComboBox listePropTous = new ComboBox()
            {
                Left = 50, Top = 180, Width = 400
            };

            string[] listePropTousStr = new string[(CarreauAchetable.getTousLesCarreauxAchetablesPossedes().Count - Plateau.Instance.JoueurCourant.Proprietes.Count)];
            int      noPropTous       = 0;

            foreach (CarreauAchetable c in CarreauAchetable.getTousLesCarreauxAchetablesPossedes())
            {
                if (!Plateau.Instance.JoueurCourant.Proprietes.Contains(c))
                {
                    listePropTousStr[noPropTous] = c.ToString();
                    noPropTous++;
                }
            }
            listePropTous.DataSource = listePropTousStr;

            Button confirmation = new Button()
            {
                Text = "Ok", Left = 350, Width = 100, Top = 220, DialogResult = DialogResult.OK
            };

            confirmation.Click += (sender, e) => { prompt.Close(); };
            prompt.Controls.Add(textLabel);
            prompt.Controls.Add(listePropJoueur);
            prompt.Controls.Add(textLabel2);
            prompt.Controls.Add(listePropTous);
            prompt.Controls.Add(confirmation);
            prompt.AcceptButton = confirmation;

            return(prompt.ShowDialog() == DialogResult.OK ? listePropJoueurStr[listePropJoueur.SelectedIndex] + " contre " + listePropTousStr[listePropTous.SelectedIndex] : "");
        }