/// <summary> /// Creates a new Deck to be used for the game /// </summary> public void CreateDeck() { foreach (Suit type in this.suit) { foreach (string Value in this.cardValue) { CardVM tempcard = new CardVM(Value, type); tempcard.SourceRect(); this.listOfCards.Add(tempcard); } } this.OnNotify(); }
/// <summary> /// Adds a card obtained from the deck to the players hand. /// </summary> /// <param name="deck"> The deck from which the card will be dealt</param> public void DealCard(DeckVM deck) { CardVM card = deck.AddCard(); card.CardOffset = new Thickness(((this.cardsInHand.Count - 1) * 5), (this.cardsInHand.Count - 1) * 7, (this.cardsInHand.Count - 1) * -45, 0); // Storyboard animation = new Storyboard(); card.CardTransform = new RotateTransform(this.cardsInHand.Count * 10, 0, 0); if (this.cardsInHand.Count < 1) { card.FaceUp = true; } else if (this.handIsVisible == true) { card.FaceUp = true; } else { card.FaceUp = false; } this.cardsInHand.Insert(0,card); if (this.cardsInHand.Count > 3) { for (int i = 0; i < this.cardsInHand.Count; i++) { cardsInHand[this.cardsInHand.Count - 1 - i].CardTransform = new RotateTransform((i - (this.cardsInHand.Count - 3)) * 10, 0, 0); } } if (this.CardsInHand.Count == 4) { for (int i = (this.cardsInHand.Count - 1); i > (this.cardsInHand.Count - 3); i--) { cardsInHand[i].CardOffset = new Thickness( ((((this.cardsInHand.Count - i) - 3) * -1) * -18), ((((this.cardsInHand.Count - i) - 1.5) * -1) * 23) * (this.cardsInHand.Count - i), (((this.cardsInHand.Count - i) - 1.5) * -18) * (this.cardsInHand.Count - i), (((this.cardsInHand.Count - i) - 1.25) * -18) * (this.cardsInHand.Count - i)); } } else if (this.cardsInHand.Count == 5) { for (int i = (this.cardsInHand.Count - 1); i > (this.cardsInHand.Count - 4); i--) { cardsInHand[i].CardOffset = new Thickness( (((this.cardsInHand.Count - i) - 4) * -1) * -20, (((this.cardsInHand.Count - i) - 4) * -1) * 7, ((this.cardsInHand.Count - i) - 1) * -33, ((this.cardsInHand.Count - i) - 1) * 0); } } else if (this.cardsInHand.Count == 6) { for (int i = (this.cardsInHand.Count - 1); i > (this.cardsInHand.Count - 5); i--) { cardsInHand[i].CardOffset = new Thickness( (Math.Abs((this.cardsInHand.Count - i) - 5)) * -20, (Math.Abs((this.cardsInHand.Count - i) - 5)) * 8, ((this.cardsInHand.Count - i) - 1) * -35, ((this.cardsInHand.Count - i) - 1) * 0); } } this.CurrentScore(); }