/// <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]; } }
public Game() { currentCard = 0; playDeck = new Deck(true); playDeck.LastCardDrawn += new Deck.LastCardDrawnHandler(Reshuffle); playDeck.Shuffle(); discardedCards = new Cards(); }
public object Clone() { Cards newCards = new Cards(); foreach (Card sourceCard in List) { newCards.Add(sourceCard.Clone() as Card); } return newCards; }
public object Clone() { Cards cloneTarget = new Cards(); foreach (Card cloneCard in this) { cloneTarget.Add((Card)cloneCard.Clone()); } return cloneTarget; }
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); }
//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); } }
private Deck(Cards newCards) { cards = newCards; }
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); }
public CardOutOfRangeException(Cards sourceDeckContents) : base("There are only 54 cards in the deck.") { deckContents = sourceDeckContents; }
private void InitializeGame(int LandlordIndex) { AssignCurrentPlayer(LandlordIndex); CurrentAvailableCard = new Cards(); }
public void CopyTo(Cards targetCards) { for (int i = 0; i < this.Count; i++) targetCards[i] = this[i]; }
public Deck(Cards newCards) { this.cards = newCards; }
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(); }
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); }
public void DrawNewHand(Deck deck) { Hand = new Cards(); for (int i = 0; i < 7; i++) Hand.Add(deck.Draw()); }
public Player(string newName) { name = newName; hand = new Cards(); }