示例#1
0
        public ValueExplorer(WorldState w, IndexedValue v)
        {
            this.world        = w;
            this.indexedValue = v;
            this.Valeur       = v.Value;

            InitializeComponent();
            this.champValeur.Value = v.Value;
            this.nom.Text          = v.Name;
            this.Decription.Text   = v.CompletePresentation().Substring(v.CompletePresentation().IndexOf("\n") + 1);
            this.champValeur.Value = v.Value;
            this.reset.Text        = v.Value.ToString();

            foreach (KeyValuePair <IndexedValue, double> pair in v.OutputWeights)
            {
                listeValeursAffectées.Items.Add((pair.Value > 0 ? "Augmente " : "Diminue ") + pair.Key.Name);
            }

            int amount = Valeur;
            int mCost = 0, gCost = 0;

            indexedValue.PreviewPolicyChange(ref amount, out mCost, out gCost);

            this.financesValeur.Text = mCost.ToString();
            this.gloireValeur.Text   = gCost.ToString();
        }
示例#2
0
        protected override void OnMouseClick(MouseEventArgs e)
        {
            FindForm().Enabled = false;

            if (indexedValue.AvailableAt.GetValueOrDefault(0) <= theWorld.Turns && indexedValue.Type == IndexedValue.ValueType.Policy)
            {
                ValueExplorer infos = new ValueExplorer(theWorld, indexedValue);

                if (infos.ShowDialog() == DialogResult.OK)
                {
                    int amount = infos.Valeur;
                    int mCost = 0, gCost = 0;

                    if (amount == 0)
                    {
                        if (MessageBox.Show($"Vous êtes sur le point de désactiver la politique {indexedValue.Name}, continuer ?",
                                            "Désactivation", MessageBoxButtons.YesNo) == DialogResult.No)
                        {
                            return;
                        }

                        theWorld.DeactivatePolicy(indexedValue, out mCost, out gCost);
                    }
                    else
                    {
                        indexedValue.PreviewPolicyChange(ref amount, out mCost, out gCost);

                        if (MessageBox.Show($"Cette politique va désormais coûter {-mCost} de monnaie et {-gCost} de gloire par tour.",
                                            "Modifications",
                                            MessageBoxButtons.OKCancel) == DialogResult.Cancel)
                        {
                            return;
                        }

                        if (gCost < 0)
                        {
                            if (theWorld.CostGlory(gCost))
                            {
                                indexedValue.ChangeTo(amount, out mCost, out gCost);
                            }
                        }

                        indexedValue.ChangeTo(amount, out mCost, out gCost);
                    }

                    this.Refresh();
                }
            }
            else
            {
                MessageBox.Show("Description complète : " +
                                indexedValue.CompletePresentation().Substring(indexedValue.CompletePresentation().IndexOf("\n")),
                                indexedValue.Name, MessageBoxButtons.OK
                                );
            }

            FindForm().Enabled = true;
        }
示例#3
0
 public static void LoseDialog(IndexedValue indexedValue)
 {
     if (indexedValue == null)
     {
         MessageBox.Show("Partie perdue : dette insurmontable.", "Perdu");
     }
     else
     {
         MessageBox.Show("Partie perdue :" +
                         indexedValue.CompletePresentation());
     }
 }