Пример #1
0
        /// <summary>
        /// PutDown()
        ///         Allows the winner to put down more cards
        ///         before the river is taken and another round is started.
        /// </summary>
        public void PutDown()
        {
            IPlayer attacker = GetAttacker();
            IPlayer defender = GetDefender();

            if (OnPuttingDown != null)
            {
                OnPuttingDown(attacker, new EventArgs());
            }

            if (attacker.GetType() == typeof(ComputerPlayer))
            {
                if (attacker.PuttingDown)
                {
                    ComputerPlayer           ai     = attacker as ComputerPlayer;
                    Tuple <PlayingCard, int> attack = ai.Attack(River, deck);
                    PlayingCard attackCard          = attack.Item1;
                    int         attackCardIndex     = attack.Item2;
                    if (attackCardIndex == -1)
                    {
                        if (PuttingDownComplete != null)
                        {
                            PuttingDownComplete(attacker, new EventArgs());
                        }
                    }
                    else
                    {
                        Print(attacker.Name + " is attacking " + defender.Name + " with a " + attackCard.ToString() + "!");
                        River.Add(attackCard);
                        gui.PlayCardAt(attackCardIndex, Players.IndexOf(attacker));
                        PutDown();
                    }
                }
                else
                {
                    TakeRiver(defender);
                    if (defender.GetType() == typeof(Player))
                    {
                        gui.GetHumanResponse();
                    }
                }
            }
            else if (attacker.GetType() == typeof(Player))
            {
                if (attacker.PuttingDown)
                {
                    gui.GetHumanResponse();
                }
                else
                {
                    if (PuttingDownComplete != null)
                    {
                        PuttingDownComplete(attacker, new EventArgs());
                    }
                }
            }
        }
Пример #2
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();
                }
            }
        }