Exemplo n.º 1
0
        /// <summary>
        /// Starts the next turns logic
        /// </summary>
        public void NextTurn()
        {
            //Check if it's the player's turn or the Ai's turn
            if (isPlayerTurn)
            {
                //Make it the AI player's turn
                isPlayerTurn = false;
                (boutDeckViewer as BoutViewer).AllowDrop = false;

                //Since nothing currently triggers the AiPlayer's turn, recursively call
                //this event handler in order to activate the AiPlayer's turn
                NextTurn();
            }
            else
            {
                //The AI chooses what card to play
                Card cardToPlay = enemyPlayer.ChooseAction(enemyDeckViewer, boutDeckViewer);

                //Confirm the AI actually chose a card, and not the default null card
                if (object.ReferenceEquals(cardToPlay, null))
                {
                    //The AI is unable to play any cards, so he loses the Bout
                    EndBout();
                }
                else
                {
                    //The AI plays a card
                    boutDeckViewer.AddCard((Card)cardToPlay.Clone(), false);
                    enemyDeckViewer.RemoveCard(cardToPlay);
                }

                //Make it the human player's turn
                isPlayerTurn = true;
                (boutDeckViewer as BoutViewer).AllowDrop = true;
            }
        }