private void UpdateDecision() { panelDecision.Controls.Clear(); labelError.Text = null; int x = 0; int y = 0; List<String> s = new List<String>(DLLInterface.GetString("decision").Split('@')); decision.type = s[0]; if (decision.type == "none") labelDecision.Text = "No decision?"; else if (decision.type == "gameover") { labelActiveCard.Text = ""; labelActiveCardName.Visible = false; labelDecision.Text = "Game Over!"; } else if (decision.type == "selectCard") { String playerName = s[2]; labelDecision.Text = "(" + playerName + ") " + s[3]; decision.minimumCount = Convert.ToInt32(s[4]); decision.maximumCount = Convert.ToInt32(s[5]); String activeCardName = s[6]; if (activeCardName.StartsWith("phase")) { labelActiveCard.Text = Utility.PhaseName(Convert.ToInt32(activeCardName.Split('|')[1])) + " Phase"; labelActiveCardName.Visible = false; } else { Card activeCard = database.GetCard(activeCardName); labelActiveCard.Text = "Active Card:"; labelActiveCardName.Text = activeCard.PrettyName(); labelActiveCardName.BackColor = activeCard.BackColor(); labelActiveCardName.Visible = true; } var sortedList = new List<String>(s[7].Split('|')); var cards = sortedList.Select(z => database.GetCard(z)); cards = cards.OrderByDescending(a => a.cost).ThenBy(a => a.name).ToList(); foreach (Card c in cards) { ButtonBase button; if (decision.maximumCount == 1) { button = new CardRadioButton(c); button.Click += delegate { ProcessDecision(); }; } else { button = new CardCheckBox(c); } button.Left = x * 150 + 3; button.Top = y * 25 + 3; button.MaximumSize = new Size(145, 23); button.Text = c.PrettyName(); button.BackColor = c.BackColor(); button.Font = panelDecision.Font; button.AutoSize = true; button.MouseMove += delegate { pictureBoxCardImage.BackgroundImage = c.fullImage; }; button.Padding = new Padding(3, 1, 1, 1); panelDecision.Controls.Add(button); y++; if (y == 5) { x++; y = 0; } } } else if (decision.type == "choice") { String playerName = s[2]; String[] parts = s[3].Split('|'); labelDecision.Text = "(" + playerName + ") " + parts[0]; for (int choiceIndex = 1; choiceIndex < parts.Length; choiceIndex++) { ButtonBase button = new ChoiceRadioButton(choiceIndex - 1); button.Click += delegate { ProcessDecision(); }; button.Left = x * 190 + 3; button.Top = y * 25 + 3; button.MaximumSize = new Size(185, 23); button.Text = parts[choiceIndex]; button.Font = panelDecision.Font; button.AutoSize = true; button.Padding = new Padding(3, 1, 1, 1); panelDecision.Controls.Add(button); y++; if (y == 5) { x++; y = 0; } } } }
private void UpdateDecision() { panelDecision.Controls.Clear(); labelError.Text = null; int x = 0; int y = 0; List <String> s = new List <String>(DLLInterface.GetString("decision").Split('@')); decision.type = s[0]; if (decision.type == "none") { labelDecision.Text = "No decision?"; } else if (decision.type == "gameover") { labelActiveCard.Text = ""; labelActiveCardName.Visible = false; labelDecision.Text = "Game Over!"; } else if (decision.type == "selectCard") { String playerName = s[2]; labelDecision.Text = "(" + playerName + ") " + s[3]; decision.minimumCount = Convert.ToInt32(s[4]); decision.maximumCount = Convert.ToInt32(s[5]); String activeCardName = s[6]; if (activeCardName.StartsWith("phase")) { labelActiveCard.Text = Utility.PhaseName(Convert.ToInt32(activeCardName.Split('|')[1])) + " Phase"; labelActiveCardName.Visible = false; } else { Card activeCard = database.GetCard(activeCardName); labelActiveCard.Text = "Active Card:"; labelActiveCardName.Text = activeCard.PrettyName(); labelActiveCardName.BackColor = activeCard.BackColor(); labelActiveCardName.Visible = true; } var sortedList = new List <String>(s[7].Split('|')); var cards = sortedList.Select(z => database.GetCard(z)); cards = cards.OrderByDescending(a => a.cost).ThenBy(a => a.name).ToList(); foreach (Card c in cards) { ButtonBase button; if (decision.maximumCount == 1) { button = new CardRadioButton(c); button.Click += delegate { ProcessDecision(); }; } else { button = new CardCheckBox(c); } button.Left = x * 150 + 3; button.Top = y * 25 + 3; button.MaximumSize = new Size(145, 23); button.Text = c.PrettyName(); button.BackColor = c.BackColor(); button.Font = panelDecision.Font; button.AutoSize = true; button.MouseMove += delegate { pictureBoxCardImage.BackgroundImage = c.fullImage; }; button.Padding = new Padding(3, 1, 1, 1); panelDecision.Controls.Add(button); y++; if (y == 5) { x++; y = 0; } } } else if (decision.type == "choice") { String playerName = s[2]; String[] parts = s[3].Split('|'); labelDecision.Text = "(" + playerName + ") " + parts[0]; for (int choiceIndex = 1; choiceIndex < parts.Length; choiceIndex++) { ButtonBase button = new ChoiceRadioButton(choiceIndex - 1); button.Click += delegate { ProcessDecision(); }; button.Left = x * 190 + 3; button.Top = y * 25 + 3; button.MaximumSize = new Size(185, 23); button.Text = parts[choiceIndex]; button.Font = panelDecision.Font; button.AutoSize = true; button.Padding = new Padding(3, 1, 1, 1); panelDecision.Controls.Add(button); y++; if (y == 5) { x++; y = 0; } } } }