Example #1
0
        private void Hit(Game.Table.Player Player, Label lblCount, Button btnHit, Button btnStay)
        {
            //Called for the player hit buttons to draw a card
            //int X = 20;
            Game.Table.Player.Hand h;
            byte hit = (byte)'h';

            BJinterface.DLLplayerTurn(ref Game.TableStruct, ref Game.DeckStruct, hit);

            h = this.BJgame.gameTable.players[Player.pos - 1].playerHand;


            lblCount.Text = h.score.ToString();
            if (h.bust)
            {
                lblCount.Text += " Busted";
            }
            if (h.hasEnded)
            {
                btnHit.Enabled  = false;
                btnStay.Enabled = false;
            }
            lblCardCount.Text = this.BJgame.gameDeck.cards_left.ToString();
            this.Invalidate();
        }
Example #2
0
        private void btnDeal_Click(object sender, EventArgs e)
        {
            //This resets all player hands to their starting (not dealt a hand yet) state
            BJinterface.DLLsetAllHands(ref Game.TableStruct);


            //this gets the bet amount from the GUI, makes the applicable update to the player's hand class
            //moved this here from DisplayHand_Load(), it's more appropriate here.
            GetBetsALL(true);

            //This deals out the starting hands to all players and dealer
            BJinterface.DLLdealStartingHands(ref Game.TableStruct, ref Game.DeckStruct);


            lblDealerCount.Text = "";
            for (int i = 0; i < this.BJgame.gameTable.NO_OF_PLAYERS; i++)
            {
                //Display the cards for all players
                switch (i)
                {
                case 0:
                    PlayerChairs[i].Count.Text     = this.BJgame.gameTable.players[i].playerHand.score.ToString();
                    PlayerChairs[i].Hit.Enabled    = true;
                    PlayerChairs[i].Stay.Enabled   = true;
                    PlayerChairs[i].BetInc.Enabled = false;
                    PlayerChairs[i].BetDec.Enabled = false;
                    break;

                case 1:
                    PlayerChairs[i].Count.Text = this.BJgame.gameTable.players[i].playerHand.score.ToString();
                    //PlayerChairs[i].Hit.Enabled = true;
                    //PlayerChairs[i].Stay.Enabled = true;
                    PlayerChairs[i].BetInc.Enabled = false;
                    PlayerChairs[i].BetDec.Enabled = false;
                    break;

                case 2:
                    PlayerChairs[i].Count.Text = this.BJgame.gameTable.players[i].playerHand.score.ToString();
                    //PlayerChairs[i].Hit.Enabled = true;
                    //PlayerChairs[i].Stay.Enabled = true;
                    PlayerChairs[i].BetInc.Enabled = false;
                    PlayerChairs[i].BetDec.Enabled = false;
                    break;
                }
            }
            btnDeal.Enabled   = false;
            lblCardCount.Text = this.BJgame.gameDeck.cards_left.ToString();
            this.Invalidate();
        }//End btnDeal_Click
        //Game class constructor
        public Game(int NO_OF_PLAYERS, int NO_OF_COMPS, string[] players)
        {
            //Deck Struct constructor
            IntPtr dPtr = BJinterface.DLLcreateDeck();

            DeckStruct = (deck)Marshal.PtrToStructure(dPtr, typeof(deck));
            gameDeck   = new Deck(ref DeckStruct);

            //Table Struct constructor
            IntPtr tPtr = BJinterface.DLLSetTable(NO_OF_PLAYERS, NO_OF_COMPS, players);

            TableStruct = (table)Marshal.PtrToStructure(tPtr, typeof(table));

            BJinterface.DLLshuffle(ref DeckStruct);
        }
Example #4
0
        private void btnStay3_Click(object sender, EventArgs e)
        {
            BJinterface.DLLplayerTurn(ref Game.TableStruct, ref Game.DeckStruct, (byte)'s');

            Chair3.Hit.Enabled  = false;
            Chair3.Stay.Enabled = false;

            if (Chair3.Player.pos < (this.BJgame.gameTable.NO_OF_PLAYERS))
            {
                btnHit4.Enabled  = true;
                btnStay4.Enabled = true;
            }
            else
            {
                //If there is not another player go to DealerHand
                DealerHand();
            }
            this.Invalidate();
        }
Example #5
0
        private void btnClear_Click(object sender, EventArgs e)
        {
            //Clears the table and allows players to set bets for next hand

            lblDealerCount.Text = "";
            //lblCount3.Text = "";

            BJinterface.DLLclearTable(ref Game.TableStruct);

            GetBetsALL(false);

            btnDeal.Enabled  = true;
            btnClear.Enabled = false;
            for (int i = 0; i < PlayerChairs.Count; i++)
            {
                PlayerChairs[i].BetInc.Enabled = true;
                PlayerChairs[i].BetDec.Enabled = true;
                PlayerChairs[i].Count.Text     = "";
            }

            this.Invalidate();
        }
Example #6
0
        private void DealerHand()
        {
            //After the last player's hand is done, DealerHand is called to show and complete the dealers hand
            //int X = 20;
            Game.Table.Player Dealer = this.BJgame.gameTable.dealer;

            BJinterface.DLLdealerTurn(ref Game.TableStruct, ref Game.DeckStruct);
            Dealer = this.BJgame.gameTable.dealer;


            lblDealerCount.Text = Dealer.playerHand.score.ToString();
            btnClear.Enabled    = true;

            BJinterface.DLLtakeScores(ref Game.TableStruct);

            for (int i = 0; i < this.BJgame.gameTable.NO_OF_PLAYERS; i++)
            {
                //reset buttons and text
                switch (i)
                {
                case 0:
                    lblChips3.Text     = this.BJgame.gameTable.players[i].chips.ToString();
                    btnBetInc3.Enabled = false;
                    btnBetDec3.Enabled = false;
                    break;

                case 1:
                    lblChips4.Text     = this.BJgame.gameTable.players[i].chips.ToString();
                    btnBetInc4.Enabled = false;
                    btnBetDec4.Enabled = false;
                    break;
                }
            }

            lblCardCount.Text = this.BJgame.gameDeck.cards_left.ToString();
        }
Example #7
0
 private void DisplayHand_FormClosed(object sender, FormClosedEventArgs e)
 {
     BJinterface.DLLcleanUp(ref Game.TableStruct, ref Game.DeckStruct);
     Application.Exit();
 }