コード例 #1
0
 private FinishStack(FinishStack parent, Card topCard)
 {
     Parent = parent;
     _top   = topCard;
     _count = parent.Count + 1;
     _hash  = 351 * parent.GetHashCode() + _top.GetHashCode();
 }
コード例 #2
0
 private static FinishStack Create(FinishStack parent, IEnumerable <Card> cards)
 {
     foreach (var card in cards)
     {
         parent = new FinishStack(parent, card);
     }
     return(parent);
 }
コード例 #3
0
        public static PatienceField FillWithRandomCards(Random random)
        {
            var cards = GetStock().ToList();
            Util.Shuffle(cards, random);
            IEnumerable<Card> stackless = cards;
            var playstacks = new List<PlayStack>();
            var finishstacks = new List<FinishStack>();
            for (int playstack = 1; playstack <= 7; playstack++)
            {
                var stack = PlayStack.Create(stackless.Take(playstack));
                stackless = stackless.Skip(playstack);
                playstacks.Add(stack);
            }
            for (int finishstack = 1; finishstack <= 4; finishstack++)
            {
                var stack = FinishStack.Create(Enumerable.Empty<Card>());
                finishstacks.Add(stack);
            }
            var stock = new Stock(stackless, false);

            return new PatienceField(stock, playstacks, finishstacks);
        }