Пример #1
0
 /// <summary>
 /// 将Card对象复制到另一个对象的实例方法,在Deck.Shuffle()方法中调用。
 /// 这个实现假定源集合和目标集合是同一大小
 /// </summary>
 /// <param name="targetCards"></param>
 public void CopyTo(Cards targetCards)
 {
     for (int index = 0; index < this.Count; index++)
     {
         targetCards[index] = this[index];
     }
 }
Пример #2
0
 public Game()
 {
     currentCard = 0;
     playDeck = new Deck(true);
     playDeck.LastCardDrawn += new Deck.LastCardDrawnHandler(Reshuffle);
     playDeck.Shuffle();
     discardedCards = new Cards();
 }
Пример #3
0
 public object Clone()
 {
     Cards newCards = new Cards();
     foreach (Card sourceCard in List)
     {
         newCards.Add(sourceCard.Clone() as Card);
     }
     return newCards;
 }
Пример #4
0
 public object Clone()
 {
     Cards cloneTarget = new Cards();
     foreach (Card cloneCard in this)
     {
         cloneTarget.Add((Card)cloneCard.Clone());
     }
     return cloneTarget;
 }
Пример #5
0
 public void Shuffle()
 {
     Random rnd = new Random();
     Cards newDeck = new Cards();
     bool[] assigned = new bool[52];
     for (int i = 0; i < 52; i++)
     {
         int sourceCard = 0;
         bool foundCard = false;
         while (foundCard == false)
         {
             sourceCard = rnd.Next(52);
             if (assigned[sourceCard] == false)
                 foundCard = true;
         }
         assigned[sourceCard] = true;
         newDeck.Add(cards[sourceCard]);
     }
     newDeck.CopyTo(cards);
 }
Пример #6
0
 //Shuffle cards in deck
 public void Shuffle()
 {
     Cards tempDeck = new Cards();
     Random position = new Random();
     bool[] isSelect = new bool[52];
     for (int countPos = 0; countPos <= 51; countPos++)
     {
         bool isAssigned = false;
         do
         {
             int posCard = position.Next(52);
             if (isSelect[posCard])
                 continue;
             else
             {
                 isSelect[posCard] = true;
                 isAssigned = true;
                 tempDeck.Add(this.deck[posCard]);
             }
             tempDeck.CopyTo(this.deck);
         } while (!isAssigned);
     }
 }
Пример #7
0
 private Deck(Cards newCards)
 {
     cards = newCards;
 }
Пример #8
0
 public void Shuffle()
 {
     Cards newDeck = new Cards();
       bool[] assigned = new bool[cards.Count ];
       Random sourceGen = new Random();
       for (int i = 0; i < cards.Count ; i++)
       {
     int sourceCard = 0;
     bool foundCard = false;
     while (foundCard == false)
     {
       sourceCard = sourceGen.Next(cards.Count );
       if (assigned[sourceCard] == false)
     foundCard = true;
     }
     assigned[sourceCard] = true;
     newDeck.Add(cards[sourceCard]);
       }
       newDeck.CopyTo(cards);
 }
Пример #9
0
 public CardOutOfRangeException(Cards sourceDeckContents)
     : base("There are only 54 cards in the deck.")
 {
     deckContents = sourceDeckContents;
 }
Пример #10
0
 private void InitializeGame(int LandlordIndex)
 {
     AssignCurrentPlayer(LandlordIndex);
     CurrentAvailableCard = new Cards();
 }
Пример #11
0
 public void CopyTo(Cards targetCards)
 {
     for (int i = 0; i < this.Count; i++)
         targetCards[i] = this[i];
 }
Пример #12
0
 public Deck(Cards newCards)
 {
     this.cards = newCards;
 }
Пример #13
0
 private Deck(Cards newCards)
 {
     cards = newCards;
 }
Пример #14
0
 public CardOutOfRangeException(Cards sourceDeckContents) :
     base("There are only 54 cards in the deck.")
 {
     deckContents = sourceDeckContents;
 }
Пример #15
0
 public void DrawNewHand(Deck deck)
 {
     Hand = new Cards();
       Chosen = new Cards();
       for (int i = 0; i < 17; i++)
     Hand.Add(deck.Draw());
       if (Landlord)
       {
       for (int i = 0; i < 3; i++)
       Hand.Add(deck.Draw());
       }
       Hand.Sort();
 }
Пример #16
0
 private void player_OnCardPlayed(object sender, CardEventArgs e)
 {
     var nextIndex = CurrentPlayer.Index + 1 >= 3 ? 0 : CurrentPlayer.Index + 1;
     CurrentAvailableCard = new Cards();
     var cardsInPlay = new List<Card>();
     for (int i = 0; i < e.Cards.Count; i++)
         CurrentAvailableCard.Add(e.Cards[i]);
     if (e.Cards.Count > 0)
     {
         CurrentAvailableCardPlayer = e.index;
         Combination = e.CurrentCombination;
     }
     AssignCurrentPlayer(nextIndex);
 }
Пример #17
0
 public void DrawNewHand(Deck deck)
 {
     Hand = new Cards();
       for (int i = 0; i < 7; i++)
     Hand.Add(deck.Draw());
 }
Пример #18
0
 public Player(string newName)
 {
     name = newName;
     hand = new Cards();
 }