Exemple #1
0
        //obtains the premade game object, begin the game
        public frmGameWindow(Player[] players, int deckSize)
        {
            InitializeComponent();
            //create the deck
            game = new Durak(deckSize);
            //shuffling the deck, setting the players and AIs

            Players.InitializeGame(players, true);
            game.SetPlayers(players);

            //  Get reference to the game table (Card container)

            game.Table.InPlay.CardsChanged += hand_CardChanged;
            //lblTrump.Text = game.TrumpSuit();
            cbTrump.Card = game.TrumpCard;

            player = Players.GetHumanPlayer();
            player.PlayHand.CardsChanged += hand_CardChanged;
            //Dealing the hands
            game.DealHands();
            attacker = Players.GetCurrentPlayer();   //  Determine attacker
            defender = Players.PeakNextPlayer();     //  Determine defender

            lblDeckSize.Text = game.GetCardsRemaining().ToString();
        }
Exemple #2
0
        /// <summary>
        /// Ends the Current turn, checks for winners
        /// </summary>
        private void EndTurn()
        {
            //Determine if the Player has lost
            int hasPlayerLost = 0;

            for (int i = 0; i < Players.PlayerCount; i++)
            {
                if (Players.GetPlayer(i).WinStatus == true)
                {
                    hasPlayerLost++;
                }
            }
            //If there is only one player remaining, the player has lost
            if (hasPlayerLost == Players.PlayerCount - 1)
            {
                MessageBox.Show("Too bad, you are the Durak!");
                this.Close();
            }
            game.Table.InPlay.Clear();
            pnlTable.Controls.Clear();
            //Begin the next Turn by advancing the turn
            attacker = Players.GetNextPlayer();
            defender = Players.PeakNextPlayer();
            //Drawing to the max number of cards possilbe
            game.DrawToMax();

            //Set the deck size
            lblDeckSize.Text = game.GetCardsRemaining().ToString();
            //If the next player is an AI, post which one
            if (attacker.IsAi == true)
            {
                //txtCardPlayed.Text += "\nIt is now "+Players.GetCurrentPlayer().Name +" Turn";
                DisplayOutput("It is now " + Players.GetCurrentPlayer().Name + " Turn");
                //Advance the turn
                AiTurn('A');
            }
            else
            {
                //Advance the turn ater setting the playState
                //btnAccept.Enabled = true;

                DisplayOutput("It is now your turn");

                //lblTempOutput.Text = game.ShowHand(attacker);
                playState = 'A';
            }
        }