Exemple #1
0
        public void MoveRecursive()
        {
            var p1 = Player1Deck.Dequeue();
            var p2 = Player2Deck.Dequeue();

            if (p1 <= Player1Deck.Count && p2 <= Player2Deck.Count)
            {
                var subGame = new CombatGame(new Queue <int>(Player1Deck.Take(p1)), new Queue <int>(Player2Deck.Take(p2)));
                subGame.PlayRecursive();
                if (!subGame.Player2Deck.Any())
                {
                    Player1Deck.Enqueue(p1);
                    Player1Deck.Enqueue(p2);
                }
                else if (!subGame.Player1Deck.Any())
                {
                    Player2Deck.Enqueue(p2);
                    Player2Deck.Enqueue(p1);
                }
                else
                {
                    throw new NotImplementedException();
                }
            }
            else
            {
                if (p1 > p2)
                {
                    Player1Deck.Enqueue(p1);
                    Player1Deck.Enqueue(p2);
                }
                else if (p2 > p1)
                {
                    Player2Deck.Enqueue(p2);
                    Player2Deck.Enqueue(p1);
                }
                else
                {
                    throw new NotImplementedException();
                }
            }
        }
Exemple #2
0
        public void Move()
        {
            var p1 = Player1Deck.Dequeue();
            var p2 = Player2Deck.Dequeue();

            if (p1 > p2)
            {
                Player1Deck.Enqueue(p1);
                Player1Deck.Enqueue(p2);
            }
            else if (p2 > p1)
            {
                Player2Deck.Enqueue(p2);
                Player2Deck.Enqueue(p1);
            }
            else
            {
                throw new NotImplementedException();
            }
        }