Esempio n. 1
0
        public void BindCards(Panel parent, List <Card> cards)
        {
            parent.Children.Clear();

            Image[] cardImages = new Image[cards.Count];
            for (int i = 0; i < cards.Count; i++)
            {
                Card c = cards[i];
                cardImages[i] = CardImageCreator.VisualizeCard(c, parent);
            }
        }
Esempio n. 2
0
 public void VisualizePlayer(Player player, Label name, Label score, Panel hold)
 {
     hold.Children.Clear();
     name.Content  = player.name;
     score.Content = player.Pairs.cards.Count / 2 + " pairs";
     foreach (Card card in player.Hand.cards)
     {
         card.IsFlipped = true;
         Image image = CardImageCreator.VisualizeCard(card, hold);
         image.Margin     = new Thickness(-20, 0, 0, 0);
         image.MouseDown += CardAsk;
     }
 }
Esempio n. 3
0
        public void VisualizeActivePlayer(bool cardsFlipped = false)
        {
            page.ActiveHand.Children.Clear();
            page.lblActivePlayerName.Content  = players[currPlayer].name;
            page.lblActivePlayerScore.Content = players[currPlayer].Pairs.cards.Count / 2 + " pairs";
            Deck hand = players[currPlayer].Hand;

            foreach (Card card in hand.cards)
            {
                card.IsFlipped = cardsFlipped;
                Image image = CardImageCreator.VisualizeCard(card, page.ActiveHand);
                image.Margin     = new Thickness(-hand.cards.Count * 4, 0, 0, 0);
                image.MouseDown += IndicateCardSelection;
            }
        }
Esempio n. 4
0
        public void Initialize()
        {
            game = new BlackjackGame();
            game.InitializePlayers(playerAmo, playerNames, null);
            game.Start();

            // Display Cards
            // Buttons
            // Hit Btn

            // Center Card / Deck
            {
                Card c = new Card(1, 0);
                c.IsFlipped = true;
                var image = CardImageCreator.VisualizeCard(c, centerPanel);
                Grid.SetColumn(image, 0);
                Grid.SetRow(image, 0);
                Grid.SetColumnSpan(image, 2);
                Grid.SetRowSpan(image, 2);
            }

            HideBlackJack();
            SetupAnte();
        }
Esempio n. 5
0
        public WarGamePage()
        {
            InitializeComponent();
            Card back = new Card(0, 0)
            {
                IsFlipped = true
            };
            Image     card;
            Thickness faceDownThick = new Thickness(0, 100, 0, 0);
            Thickness faceUpThick   = new Thickness(0, 0, 0, 100);

            card = CardImageCreator.VisualizeCard(back, grdParent);
            Grid.SetColumn(card, 0);
            card = CardImageCreator.VisualizeCard(back, grdParent);
            Grid.SetColumn(card, 4);

            imgP1FaceDown            = CardImageCreator.VisualizeCard(back, grdParent);
            imgP1FaceDown.Margin     = faceDownThick;
            imgP1FaceDown.Visibility = Visibility.Hidden;
            Grid.SetColumn(imgP1FaceDown, 1);
            imgP2FaceDown            = CardImageCreator.VisualizeCard(back, grdParent);
            imgP2FaceDown.Margin     = faceDownThick;
            imgP2FaceDown.Visibility = Visibility.Hidden;
            Grid.SetColumn(imgP2FaceDown, 3);

            imgP1FaceUp            = CardImageCreator.VisualizeCard(back, grdParent);
            imgP1FaceUp.Margin     = faceUpThick;
            imgP1FaceUp.Visibility = Visibility.Hidden;
            Grid.SetColumn(imgP1FaceUp, 1);
            imgP2FaceUp            = CardImageCreator.VisualizeCard(back, grdParent);
            imgP2FaceUp.Margin     = faceUpThick;
            imgP2FaceUp.Visibility = Visibility.Hidden;
            Grid.SetColumn(imgP2FaceUp, 3);

            UpdateUI();
        }
Esempio n. 6
0
 public void UpdateUI()
 {
     if (game.p1.isComputer)
     {
         btnP1Play.IsEnabled = false;
     }
     if (game.p2.isComputer)
     {
         btnP2Play.IsEnabled = false;
     }
     lblAnnounce.Text = game.GetAnnounceText();
     if (lblAnnounce.Text.Length > 5 && lblAnnounce.Text.Substring(lblAnnounce.Text.Length - 5).Equals("game!"))
     {
         btnP1Play.IsEnabled = false;
         btnP2Play.IsEnabled = false;
     }
     lblP1CardCount.Content = game.p1.cards.Count;
     lblP2CardCount.Content = game.p2.cards.Count;
     if (game.p1.faceUp.Count > 0)
     {
         imgP1FaceUp.Visibility      = Visibility.Visible;
         imgP1FaceUp.Source          = CardImageCreator.Convert(game.p1.faceUp.Last());
         lblP1FaceUpCount.Visibility = Visibility.Visible;
         lblP1FaceUpCount.Content    = game.p1.faceUp.Count;
     }
     else
     {
         imgP1FaceUp.Visibility      = Visibility.Hidden;
         lblP1FaceUpCount.Visibility = Visibility.Hidden;
     }
     if (game.p2.faceUp.Count > 0)
     {
         imgP2FaceUp.Visibility      = Visibility.Visible;
         imgP2FaceUp.Source          = CardImageCreator.Convert(game.p2.faceUp.Last());
         lblP2FaceUpCount.Visibility = Visibility.Visible;
         lblP2FaceUpCount.Content    = game.p2.faceUp.Count;
     }
     else
     {
         imgP2FaceUp.Visibility      = Visibility.Hidden;
         lblP2FaceUpCount.Visibility = Visibility.Hidden;
     }
     if (game.p1.faceDown.Count > 0)
     {
         imgP1FaceDown.Visibility      = Visibility.Visible;
         lblP1FaceDownCount.Visibility = Visibility.Visible;
         lblP1FaceDownCount.Content    = game.p1.faceDown.Count;
     }
     else
     {
         imgP1FaceDown.Visibility      = Visibility.Hidden;
         lblP1FaceDownCount.Visibility = Visibility.Hidden;
     }
     if (game.p2.faceDown.Count > 0)
     {
         imgP2FaceDown.Visibility      = Visibility.Visible;
         lblP2FaceDownCount.Visibility = Visibility.Visible;
         lblP2FaceDownCount.Content    = game.p2.faceDown.Count;
     }
     else
     {
         imgP2FaceDown.Visibility      = Visibility.Hidden;
         lblP2FaceDownCount.Visibility = Visibility.Hidden;
     }
 }