public void assign(CardDeck source) { this.clear(); foreach (AbstractCard card in source.cardStack) { this.cardStack.Add(card); } }
public CardRow() { this.Deck = CardDeck.FromNewDeckOrder(); this.FromIndex = 0; this.ToIndex = Deck.Count - 1; this.Build(); }
public static CardDeck FromNewDeckOrder() { CardDeck result = new CardDeck(); for (CardValue v = CardValue.Ace; v <= CardValue.King; v++) { NormalCard card = new NormalCard(v, Suit.Clubs, AbstractCard.DEFAULT_BACK_COLOR); result.addCard(card); } for (CardValue v = CardValue.Ace; v <= CardValue.King; v++) { NormalCard card = new NormalCard(v, Suit.Hearts, AbstractCard.DEFAULT_BACK_COLOR); result.addCard(card); } for (CardValue v = CardValue.King; v >= CardValue.Ace; v--) { NormalCard card = new NormalCard(v, Suit.Diamonds, AbstractCard.DEFAULT_BACK_COLOR); result.addCard(card); } for (CardValue v = CardValue.King; v >= CardValue.Ace; v--) { NormalCard card = new NormalCard(v, Suit.Spades, AbstractCard.DEFAULT_BACK_COLOR); result.addCard(card); } return result; }
public void shuffle(CardDeck deck) { CardDeck tempDeck = new CardDeck(); tempDeck.assign(deck); deck.clear(); Random rnd = new Random(); int randomIndex; while (tempDeck.Count > 0) { randomIndex = rnd.Next(tempDeck.Count); AbstractCard card = tempDeck.getCardAt(randomIndex); deck.addCard(card); tempDeck.removeCardAt(randomIndex); } }
public void shuffle(CardDeck deck) { List<AbstractCard> help = new List<AbstractCard>(); for (int i = 0; i < deck.Count; i++) { help.Add(new NormalCard()); } for (int i = 0; i < deck.Count; i++) { if (this.OutFaro) { if (!this.AntiFaro) { if (2 * i < deck.Count) { help[2 * i].Assign(deck.getCardAt(i)); } else { help[(2 * i) - (deck.Count - 1)].Assign(deck.getCardAt(i)); } } else { if (2 * i < deck.Count) { help[i].Assign(deck.getCardAt(2 * i)); } else { help[i].Assign(deck.getCardAt(2 * i - (deck.Count - 1))); } } } else { if (!this.AntiFaro) { if (2 * i + 1 < deck.Count) { help[2 * i + 1].Assign(deck.getCardAt(i)); } else { help[2 * i - deck.Count].Assign(deck.getCardAt(i)); } } else { if (2 * i + 1 < deck.Count) { help[i].Assign(deck.getCardAt(2 * i + 1)); } else { help[i].Assign(deck.getCardAt(2 * i - deck.Count)); } } } } deck.clear(); foreach (AbstractCard card in help) { deck.addCard(card); } }
public void shuffle(CardDeck deck) { if (deck != null && deck.Count > 1) { if (this.reverseFrom > this.reverseTo) { int temp = this.reverseFrom; this.reverseFrom = this.reverseTo; this.reverseTo = temp; } if (this.reverseFrom < 0) { this.reverseFrom = 0; } if (this.reverseTo > deck.Count - 1) { this.reverseTo = deck.Count - 1; } if (this.reverseFrom != this.reverseTo) { CardDeck tempDeck = new CardDeck(); tempDeck.assign(deck); deck.clear(); for (int i = 0; i < this.reverseFrom; i++) { deck.addCard(tempDeck.getCardAt(i)); } for (int i = this.reverseTo; i >= this.reverseFrom; i--) { deck.addCard(tempDeck.getCardAt(i)); } for (int i = this.reverseTo + 1; i < tempDeck.Count; i++) { deck.addCard(tempDeck.getCardAt(i)); } } } }
public void SetDeck(CardDeck Deck) { this.Deck.assign(Deck); this.Invalidate(); }
public void shuffle(CardDeck deck) { for (int i = 0; i < deck.Count; i++) { AbstractCard card = deck.getCardAt(i); if (!((card.faceSide is CardSide) && (card.backSide is BackSide))) { return; } } CardDeck tempDeck = new CardDeck(); tempDeck.assign(deck); deck.clear(); for (CardValue v = CardValue.Ace; v <= CardValue.King; v++) { for (int i = 0; i < tempDeck.Count; i++) { AbstractCard card = tempDeck.getCardAt(i); AbstractSide cside = card.faceSide; if (cside is CardSide) { CardSide side = (CardSide) cside; if ((side.cardValue == v) && (side.suit == Suit.Hearts)) { deck.addCard(card); } } } } for (CardValue v = CardValue.Ace; v <= CardValue.King; v++) { for (int i = 0; i < tempDeck.Count; i++) { AbstractCard card = tempDeck.getCardAt(i); AbstractSide cside = card.faceSide; if (cside is CardSide) { CardSide side = (CardSide) cside; if ((side.cardValue == v) && (side.suit == Suit.Clubs)) { deck.addCard(card); } } } } for (CardValue v = CardValue.King; v >= CardValue.Ace; v--) { for (int i = 0; i < tempDeck.Count; i++) { AbstractCard card = tempDeck.getCardAt(i); AbstractSide cside = card.faceSide; if (cside is CardSide) { CardSide side = (CardSide) cside; if ((side.cardValue == v) && (side.suit == Suit.Diamonds)) { deck.addCard(card); } } } } for (CardValue v = CardValue.King; v >= CardValue.Ace; v--) { for (int i = 0; i < tempDeck.Count; i++) { AbstractCard card = tempDeck.getCardAt(i); AbstractSide cside = card.faceSide; if (cside is CardSide) { CardSide side = (CardSide) cside; if ((side.cardValue == v) && (side.suit == Suit.Spades)) { deck.addCard(card); } } } } }