Beispiel #1
0
        public static Technique[] Parse(IEnumerable <string> lines, long numCards)
        {
            var parsedInputs = new List <Technique>();

            foreach (var line in lines)
            {
                var split = line.Split(' ');

                Technique pi = null;
                if (split[0] == "cut")
                {
                    pi = new Cut(split[1], numCards);
                }
                else if (split[0] == "deal")
                {
                    if (split[3] == "stack")
                    {
                        pi = new Revert();
                    }
                    else
                    {
                        pi = new Deal(split[3], numCards);
                    }
                }
                else
                {
                    throw new Exception("unparseable line");
                }

                parsedInputs.Add(pi);
            }

            return(parsedInputs.ToArray());
        }
Beispiel #2
0
        public void TestBackTrackRevert()
        {
            var cards = new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };

            var reverted = new Revert().Apply(cards);

            for (int n = 0; n < cards.Length; n++)
            {
                var indexInReverted = n;
                var indexInCards    = new Revert().BackTrack(indexInReverted, 10);

                Assert.AreEqual(cards[indexInCards], reverted[indexInReverted]);
            }
        }