コード例 #1
0
 private PlayStack(PlayStack parent, Card topCard)
 {
     Parent = parent;
     _top   = topCard;
     _count = parent.Count + 1;
     _hash  = 81 * parent.GetHashCode() + _top.GetHashCode();
 }
コード例 #2
0
 private static PlayStack Create(PlayStack parent, IEnumerable <Card> cards)
 {
     foreach (var card in cards)
     {
         parent = new PlayStack(parent, card);
     }
     return(parent.WithTopVisible());
 }
コード例 #3
0
 private bool Equals(PlayStack stack)
 {
     if (ReferenceEquals(this, stack))
     {
         return(true);
     }
     if (stack.Top != Top)
     {
         return(false);
     }
     if (Top == null)
     {
         return(true);
     }
     return(Parent.Equals(stack.Parent));
 }
コード例 #4
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);
        }