/// <summary> /// Fix case mistakes /// </summary> private static void FixCasing(Event evt, DiscretePayoffs payoffs) { HashSet <DiscreteOutcome> outcomes = new HashSet <DiscreteOutcome>(); for (int i = 0; i < payoffs.Count; i++) { var outcomeString = payoffs[i].Outcome.OutcomeString?.Trim(); if (outcomeString is null) { throw new CommandException("payoff", "The payoff can't be parsed"); } var knownOutcome = evt.Outcomes.Select(o => new DiscreteOutcome(o)) .FirstOrDefault(o => o.OutcomeString !.Equals(outcomeString, StringComparison.OrdinalIgnoreCase)); if (knownOutcome is null) { throw new CommandException("payoff", $"This outcome {outcomeString} is not part of the event"); } outcomes.Add(knownOutcome); payoffs[i] = new DiscretePayoff(knownOutcome, payoffs[i].Reward); } if (outcomes.Count != evt.Outcomes.Length) { throw new CommandException("payoff", $"You did not specified the reward of all outcomes of the event"); } }
private DiscretePayoffs CreatePayoffs(List <string> payoffs) { var result = new DiscretePayoffs(); foreach (var payoff in payoffs) { if (!DiscretePayoff.TryParse(payoff, out var o) || o is null) { throw new CommandException("payoff", "The payoff can't be parsed"); } result.Add(o); } return(result); }