Esempio n. 1
0
        public void RightDefense()
        {
            var hand = new List <Card>()
            {
                new Card(Suit.Clubs, Nominal.Ten)
            };
            var attack         = new Card(Suit.Clubs, Nominal.Eight);
            var defense        = new Card(Suit.Clubs, Nominal.Ten);
            var desirableTable = new Table();
            var prevTable      = new Table();

            Program.trumpCard = new Card(Suit.Diamonds, Nominal.Ace);
            desirableTable.AddOffCard(attack);
            desirableTable.AddDefCard(defense, 0);
            Assert.AreEqual(Arbiter.TryToDefense(hand, desirableTable, desirableTable), true);
        }
Esempio n. 2
0
        static public Dictionary <string, Card> defaultPack = FormDict(); //словарь со всеми картами.
        static void Main(string[] args)
        {
            Console.WriteLine("Let's play!");
            pack      = Arbiter.FormInitialPack();
            trumpCard = pack.First();
            players   = new Player[countOfPlayer];
            for (int i = 0; i < countOfPlayer; i++)
            {
                players[i] = new Player();
                Arbiter.GiveCardsToPlayer(players[i], pack);
            }
            foreach (Nominal nominal in (Nominal[])Enum.GetValues(typeof(Nominal)))
            {
                Card card = new Card(trumpCard.suit, nominal);
                for (int i = 0; i < countOfPlayer; i++)
                {
                    if (players[i].hand.Contains(card))
                    {
                        turn = (i + 1) % countOfPlayer;
                        break;
                    }
                }
            }
            bool t = false;

            while (true)
            {
                if (t)
                {
                    break;
                }
                AttackResponse firstAttack = players[(turn - 1 + countOfPlayer) % countOfPlayer].FirstMove(
                    new MoveInfo()
                {
                    CurrentTable = table, PlayerHand = players[(turn - 1 + countOfPlayer) % countOfPlayer].hand, Suit = trumpCard.suit
                });
                Arbiter.TryToAttack(firstAttack, (turn - 1 + countOfPlayer) % countOfPlayer);
                while (true)//Пока что понятия не имею, когда это закончить. нужна помощь
                {
                    DefendInfo defend = players[turn].Defend(
                        new MoveInfo()
                    {
                        CurrentTable = table, PlayerHand = players[(turn - 1 + countOfPlayer) % countOfPlayer].hand, Suit = trumpCard.suit
                    });
                    if (defend.Move == WhatMove.Translate)
                    {
                        turn += 1;
                        continue;
                    }
                    if (defend.Move == WhatMove.Take)
                    {
                        turn = (turn + 2) % countOfPlayer;
                        break;
                    }
                    AttackResponse addAttack = players[(turn + 1) % countOfPlayer].AdditionalMove(
                        new MoveInfo()
                    {
                        CurrentTable = table, PlayerHand = players[(turn - 1 + countOfPlayer) % countOfPlayer].hand, Suit = trumpCard.suit
                    });
                    Arbiter.TryToAttack(addAttack, (turn + 1) % countOfPlayer);
                    addAttack = players[(turn - 1 + countOfPlayer) % countOfPlayer].AdditionalMove(
                        new MoveInfo()
                    {
                        CurrentTable = table, PlayerHand = players[(turn - 1 + countOfPlayer) % countOfPlayer].hand, Suit = trumpCard.suit
                    });
                    Arbiter.TryToAttack(addAttack, (turn - 1 + countOfPlayer) % countOfPlayer);
                }
            }
        }