Exemplo n.º 1
0
        /// <summary>
        /// Returns all possible combinations of runs which can be found in the given list of runs
        /// </summary>
        private static List <CardCombo> GetPossibleRunCombos(List <Run> runs, CardCombo currentRunCombo)
        {
            var possibleRunCombos = new List <CardCombo>();

            for (int i = 0; i < runs.Count; i++)
            {
                var currentCombo = new CardCombo(currentRunCombo);
                currentCombo.AddRun(runs[i]);

                // This fixed run alone is also a possibility
                possibleRunCombos.Add(currentCombo);

                List <Run> otherRuns = runs.Skip(i + 1).Where(run => !run.Intersects(runs[i])).ToList();
                if (otherRuns.Count > 0)
                {
                    possibleRunCombos.AddRange(GetPossibleRunCombos(otherRuns, currentCombo));
                }
            }
            return(possibleRunCombos);
        }