예제 #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
파일: Game.cs 프로젝트: Hobdell/CardLib
 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
파일: Deck.cs 프로젝트: qsLampard/CardLib
 private Deck(Cards newCards)
 {
     cards = newCards;
 }
예제 #8
0
파일: Deck.cs 프로젝트: qsLampard/CardLib
 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
파일: Deck.cs 프로젝트: praused/CardLib
 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
파일: Player.cs 프로젝트: qsLampard/CardLib
 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
파일: Player.cs 프로젝트: ktjones/BVCS2012
 public void DrawNewHand(Deck deck)
 {
     Hand = new Cards();
       for (int i = 0; i < 7; i++)
     Hand.Add(deck.Draw());
 }
예제 #18
0
파일: Player.cs 프로젝트: Hobdell/CardLib
 public Player(string newName)
 {
     name = newName;
     hand = new Cards();
 }