コード例 #1
0
        public void UpdateTabs()
        {
            Player       currentPlayer = game.CurrentPlayer;
            AbstractCase currentCase   = game.Cases[game.CurrentPlayer.CurrentCaseIndex];

            tabs.TabPages.Clear();

            if (!game.HasPlayed && currentPlayer.NbDoubles <= 0) // @TODO : Player hasn't played ( firt throw )
            {
                btnLancerDes.Enabled = true;

                tabs.TabPages.Add(tabCaseDes);
            }
            else
            {
                if (currentPlayer.NbDoubles > 0)
                {
                    btnLancerDes.Enabled = true;

                    tabs.TabPages.Add(tabCaseDes);
                }
                if (currentCase is StartCase || currentCase is FreeParkingCase || currentCase is GoToJailCase || currentCase is JailCase)
                {
                    string title = currentCase.ToString();

                    if (currentCase is StartCase)
                    {
                        title += Environment.NewLine + "Vous gagnez 200F";
                    }
                    else if (currentCase is JailCase)
                    {
                        if (currentPlayer.IsInJail == true)
                        {
                            title += Environment.NewLine + "En prison !";
                        }
                        else
                        {
                            title += Environment.NewLine + "Visite simple";
                        }
                    }
                    else if (currentCase is GoToJailCase)
                    {
                        title += Environment.NewLine + "Allez en prison !";
                    }

                    lblCaseCoin.Text = title;

                    pbxCaseCoin.BackgroundImage       = currentCase.GetBoardCaseImage(game);
                    pbxCaseCoin.BackgroundImageLayout = ImageLayout.Zoom;

                    tabs.TabPages.Add(tabCaseCoin);
                }
                else if (currentCase is TaxCase)
                {
                    TaxCase taxe = currentCase as TaxCase;
                    pbxCaseTaxeCarte.BackgroundImage = taxe.GetBoardCaseImage(game);
                    tabs.TabPages.Add(tabCaseTaxe);
                }
                else if (currentCase is CardCase)
                {
                    CardCase specialCard = currentCase as CardCase;

                    lblChanceChancellerie.Text         = game.LastSpecialCard.ToString();
                    pbxCaseChanceImage.BackgroundImage = specialCard.TypeImage;
                    lblCaseChanceChancelTitre.Text     = specialCard.ToString();


                    tabs.TabPages.Add(tabCaseChanceChancel);
                }
                else if (currentCase is PropertyCase)
                {
                    PropertyCase property = currentCase as PropertyCase;

                    if (property.Owner == currentPlayer || property.Owner != null)
                    {
                        if (property.Owner == currentPlayer)
                        {
                            lblCasePropAchetee.Text = $"Bienvenue chez vous, {currentPlayer.Name} !";
                        }
                        else
                        {
                            if (!property.IsMortgaged)
                            {
                                lblCasePropAchetee.Text = $"Vous êtes chez {property.Owner.Name}.{Environment.NewLine}Vous payez {property.GetRent(game)}F de loyer";
                            }
                            else
                            {
                                lblCasePropAchetee.Text = $"Propriété hypothéquée {Environment.NewLine} Vous ne payez rien";
                            }
                        }

                        pbxCasePropAchetee.BackgroundImage = property.GetPropertyCardImage(2);

                        tabs.TabPages.Add(tabCasePropAchetee);
                    }
                    else
                    {
                        if (currentPlayer.Wealth >= property.Price)
                        {
                            btnAcheterPropriete.Enabled       = true;
                            pbxCasePropSimple.BackgroundImage = property.GetPropertyCardImage(2);
                            lblCasePropSimplePrixAchat.Text   = "Prix d'achat :" + Environment.NewLine + $"{property.Price}F";
                            tabs.TabPages.Add(tabCasePropSimple);
                        }
                        else
                        {
                            pbxCasePropSimple.BackgroundImage = property.GetPropertyCardImage(2);
                            lblCasePropSimplePrixAchat.Text   = "Vous n'avez pas assez de Flouzz.";
                            btnAcheterPropriete.Enabled       = false;
                            tabs.TabPages.Add(tabCasePropSimple);
                        }
                    }
                }
            }

            // Load the properties
            flpProperties.Controls.Clear();
            var cases = game.CurrentPlayer.GetProperties(game);

            foreach (PropertyCase c in cases)
            {
                PropertyManager pm = new PropertyManager()
                {
                    Property = c,
                    Game     = game,
                    FrmGame  = this,
                };

                flpProperties.Controls.Add(pm);

                pm.UpdateBuildings();
            }
            tabs.TabPages.Add(tabProperties);
        }