示例#1
0
        /// <summary>
        /// TurnAttack() - The attack phase. A Durak round begins here, and
        ///             after cards are either discarded or taken from the river,
        ///             this function is called to begin a new turn.
        /// </summary>
        public void TurnAttack()
        {
            // Verify that the GUI is synced
            if (gui is frmGameGUI)
            {
                gui.CheckSync();
            }

            CheckForWinner();
            IPlayer attacker = GetAttacker();
            IPlayer defender = GetDefender();

            if (Winner == null)
            {
                if (attacker.GetType() == typeof(ComputerPlayer))
                {
                    ComputerPlayer           ai     = attacker as ComputerPlayer;
                    Tuple <PlayingCard, int> attack = ai.Attack(River, deck);
                    PlayingCard attackCard          = attack.Item1;
                    int         attackCardIndex     = attack.Item2;
                    if (attackCardIndex == -1)
                    {
                        TakeRiver(ai);
                        gui.gameStats.defensesRepelled++;
                    }
                    else
                    {
                        Print(attacker.Name + " is attacking " + defender.Name + " with a " + attackCard.ToString() + "!");
                        River.Add(attackCard);
                        gui.PlayCardAt(attackCardIndex, Players.IndexOf(attacker));
                        gui.GetHumanResponse();
                    }
                }
                if (attacker.GetType() == typeof(Player))
                {
                    gui.GetHumanResponse();
                }
            }
        }