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(); }
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; }
public static void ApplyPolicyChanges(string arg) { if (!arg.Contains(" ")) { Console.WriteLine("erreur texte application politique : " + arg); return; } string pol = arg.Split(' ')[0]; int amount = -1; int.TryParse(arg.Split(' ')[1], out amount); if (amount < 0) { Console.WriteLine("erreur nombre application politique : " + arg); return; } int mCost = 0, gCost = 0; IndexedValue val = null; val = theWorld.FindPolicyOrDefault(pol); if (val == null) { Console.WriteLine("erreur nom application politique : " + arg); return; } if (amount == 0) { theWorld.DeactivatePolicy(val, out mCost, out gCost); return; } val.PreviewPolicyChange(ref amount, out mCost, out gCost); Console.WriteLine("Estimation : " + mCost + " pieces (par tour) et " + gCost + " gloire."); if (!ConfirmDialog()) { mCost = 0; gCost = 0; return; } if (gCost < 0) { if (theWorld.CostGlory(gCost)) { Console.WriteLine("Changement effectue pour " + gCost + " gloire."); val.ChangeTo(amount, out mCost, out gCost); return; } else { Console.WriteLine("Gloire insuffisante : " + theWorld.Glory); return; } } Console.WriteLine("Changement effectue."); val.ChangeTo(amount, out mCost, out gCost); }
private void actualiserValeur() { champValeur.Value = Valeur; 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(); }