Esempio n. 1
0
        public void Give(Seats seat, Suits suit, Ranks rank)
        {
            if (this.deal == null)
            {
                this.InitCardDealing();
            }

            if (Owned(suit, rank) && !this.Owns(seat, suit, rank))
            {
                throw new FatalBridgeException("Distribution.Give: card is already owned");
            }

            if (!this.Owns(seat, suit, rank))
            {
                lastCard++;
                if (this.deal[this.lastCard] == null)
                {
                    this.deal[this.lastCard] = new DistributionCard();
                }
                for (int i = lastCard; i <= 51; i++)
                {
                    if (deal[i].Suit == suit && deal[i].Rank == rank)
                    {
                        DistributionCard swap = Deal[i];
                        deal[i]        = deal[lastCard];
                        deal[lastCard] = swap;
                        break;
                    }
                }
                deal[lastCard].Seat   = seat;
                deal[lastCard].played = false;
            }
        }
Esempio n. 2
0
 public void Remove(Suits suit, Ranks rank)
 {
     for (int i = 0; i <= lastCard; i++)
     {
         if (deal[i].Suit == suit && deal[i].Rank == rank)
         {
             DistributionCard swap = deal[i];
             deal[i]        = deal[lastCard];
             deal[lastCard] = swap;
             lastCard--;
             break;
         }
     }
 }
Esempio n. 3
0
        public Distribution Clone()
        {
            Distribution copy = new Distribution();

            if (this.deal != null)
            {
                copy.deal = new Collection <DistributionCard>();
                foreach (var item in this.deal)
                {
                    var c = new DistributionCard();
                    c.Seat = item.Seat;
                    c.Suit = item.Suit;
                    c.Rank = item.Rank;
                    copy.deal.Add(c);
                }
            }

            copy.lastCard = this.lastCard;
            return(copy);
        }