コード例 #1
0
ファイル: GameForm.cs プロジェクト: GalTzemach/BlackJack
        // Set up the UI for when the game is in play after the player has press deal game
        public void UpdateButtonsToPlay()
        {
            Btn_deal.Enabled  = false;
            Btn_clear.Enabled = false;

            Btn_10.Enabled  = false;
            Btn_25.Enabled  = false;
            Btn_50.Enabled  = false;
            Btn_100.Enabled = false;

            Btn_stand.Enabled = true;
            Btn_hit.Enabled   = true;
            if (refPlayer.IsFirstTurn)
            {
                Btn_double.Enabled = true;
            }

            Tb_status.Hide();
            Lbl_dealer_cardsSum.Show();

            if (game.Players[0] != null)
            {
                Lbl_p1_cardsSum.Show();
            }
            else
            {
                Lbl_p1_cardsSum.Hide();
            }

            if (game.Players[1] != null)
            {
                Lbl_p2_cardsSum.Show();
            }
            else
            {
                Lbl_p2_cardsSum.Hide();
            }

            if (game.Players[2] != null)
            {
                Lbl_p3_cardsSum.Show();
            }
            else
            {
                Lbl_p3_cardsSum.Hide();
            }
        }
コード例 #2
0
ファイル: GameForm.cs プロジェクト: GalTzemach/BlackJack
        // Refresh the UI to show appropriate cards
        public void UpdateUICards()
        {
            // Reset all cards on table.
            ClearCardsOnTable();

            // Reset and hide textBox status
            Tb_status.Hide();
            Tb_status.ResetText();

            // Update the value of the dealer hand
            Lbl_dealer_cardsSum.Show();
            Lbl_dealer_cardsSum.Text = game.Dealer.Hand.GetSumOfHand().ToString();

            List <Card> dcards = game.Dealer.Hand.Cards;

            for (int i = 0; i < dcards.Count; i++)
            {
                LoadCard(dealerCards[i], dcards[i]);
                dealerCards[i].Visible = true;
                dealerCards[i].BringToFront();
            }

            // Update the value of the player_1 hand
            if (game.Players[0] != null)
            {
                Lbl_p1_cardsSum.Show();
                Lbl_p1_cardsSum.Text = game.Players[0].Hand.GetSumOfHand().ToString();

                List <Card> p_1Cards = game.Players[0].Hand.Cards;
                for (int i = 0; i < p_1Cards.Count; i++)
                {
                    // Load each card from file
                    LoadCard(player_1Cards[i], p_1Cards[i]);
                    player_1Cards[i].Visible = true;
                    player_1Cards[i].BringToFront();
                }
            }
            else
            {
                Lbl_p1_cardsSum.Hide();
            }

            // Update the value of the player_2 hand
            if (game.Players[1] != null)
            {
                Lbl_p2_cardsSum.Show();
                Lbl_p2_cardsSum.Text = game.Players[1].Hand.GetSumOfHand().ToString();

                List <Card> p_2Cards = game.Players[1].Hand.Cards;
                for (int i = 0; i < p_2Cards.Count; i++)
                {
                    // Load each card from file
                    LoadCard(player_2Cards[i], p_2Cards[i]);
                    player_2Cards[i].Visible = true;
                    player_2Cards[i].BringToFront();
                }
            }
            else
            {
                Lbl_p2_cardsSum.Hide();
            }

            // Update the value of the player_3 hand
            if (game.Players[2] != null)
            {
                Lbl_p3_cardsSum.Show();
                Lbl_p3_cardsSum.Text = game.Players[2].Hand.GetSumOfHand().ToString();

                List <Card> p_3Cards = game.Players[2].Hand.Cards;
                for (int i = 0; i < p_3Cards.Count; i++)
                {
                    // Load each card from file
                    LoadCard(player_3Cards[i], p_3Cards[i]);
                    player_3Cards[i].Visible = true;
                    player_3Cards[i].BringToFront();
                }
            }
            else
            {
                Lbl_p3_cardsSum.Hide();
            }
        }