private void RefreshResultPane() { IEnumerable <SkillCard> effectiveContributions; var crisisResults = SkillCheck.EvalSkillCheck(CrisisContributions.Select(x => x.Item1), _crisis, Rules, out effectiveContributions); var toDisplay = new StringBuilder(); var totalPower = 0; var index = 0; foreach (var contribution in effectiveContributions) { toDisplay.AppendLine(string.Format(ResultFormat, contribution.CardPower, contribution.Heading, CrisisContributions[index].Item2)); totalPower += contribution.CardPower; index++; } toDisplay.AppendLine(@"\b--------------------\b0"); toDisplay.AppendLine(_crisis.ToString()); toDisplay.AppendLine(@"\b--------------------\b0"); foreach (var consequence in crisisResults) { toDisplay.AppendLine(string.Format(ResultFormat, consequence.ConditionText, consequence.Threshold, totalPower)); } toDisplay.Replace(Environment.NewLine, @" \line "); toDisplay.Insert(0, @"{\rtf1\ansi "); toDisplay.Append(@"}"); ResultTextBox.Rtf = toDisplay.ToString(); }
private void SubmitButtonClick(object sender, EventArgs e) { IEnumerable <SkillCard> effectiveContributions; var crisisResults = SkillCheck.EvalSkillCheck(CrisisContributions.Select(x => x.Item1), _crisis, Rules, out effectiveContributions); var resultOutput = new StringBuilder(); var totalPower = 0; foreach (var contribution in effectiveContributions.OrderBy(x => x.CardColor)) { resultOutput.AppendLine(string.Format(FinalFormat, contribution.CardPower, contribution.Heading)); totalPower += contribution.CardPower; } resultOutput.AppendLine(@"\b--------------------\b0"); foreach (var consequence in crisisResults) { resultOutput.AppendLine(string.Format(OutputResultFormat, totalPower, consequence.Threshold, consequence.ConditionText)); } resultOutput.Replace(Environment.NewLine, @" \line "); resultOutput.Insert(0, @"{\rtf1\ansi "); resultOutput.Append(@"}"); Result = resultOutput.ToString(); if (PlayerTakeCardsCheckBox.Checked) { PlayerTakingCards = (Player)PlayerTakeCardsDropdown.SelectedItem; } DialogResult = DialogResult.OK; Close(); }
private void CommitButtonClick(object sender, EventArgs e) { var selectedPlayer = (Player)PlayerDropDown.SelectedItem; CrisisContributions = CrisisContributions.Where(x => x.Item2 != selectedPlayer.PlayerName).ToList(); foreach (SkillCard card in PlayerCardListBox.SelectedItems) { CrisisContributions.Add(new Tuple <SkillCard, string>(card, selectedPlayer.PlayerName)); } RefreshResultPane(); }
private void PlayerDropDownSelectedIndexChanged(object sender, EventArgs e) { var selectedPlayer = (Player)PlayerDropDown.SelectedItem; PlayerCardListBox.DataSource = selectedPlayer.Cards; PlayerCardListBox.SelectedIndex = -1; var playerCards = PlayerCardListBox.Items.Cast <SkillCard>().ToList(); var contributedCards = CrisisContributions.Select(x => x.Item1); foreach (var card in playerCards.Where(contributedCards.Contains)) { PlayerCardListBox.SelectedItems.Add(card); } }