예제 #1
0
        public void TestAddElement_Error()
        {
            var card1 = new RPSCardsEngine.Cards.Card(CardType.Fire, Zone.Board, 0);

            Assert.ThrowsException <InvalidOperationException>(() => card1.AddElement(new RPSCardsEngine.Cards.Card(CardType.Water)));

            var card2 = new RPSCardsEngine.Cards.Card(CardType.Rock, Zone.Board, 0);

            Assert.ThrowsException <ArgumentException>(() => card2.AddElement(new RPSCardsEngine.Cards.Card(CardType.Rock)));

            card2.AddElement(new RPSCardsEngine.Cards.Card(CardType.Water));
            Assert.IsTrue(card2.IsDestroyed);
            Assert.ThrowsException <InvalidOperationException>(() => card2.AddElement(new RPSCardsEngine.Cards.Card(CardType.Water)));


            var card3 = new RPSCardsEngine.Cards.Card(CardType.Rock, Zone.Hand, 0);

            Assert.ThrowsException <InvalidOperationException>(() => card3.AddElement(new RPSCardsEngine.Cards.Card(CardType.Water)));

            var card4 = new RPSCardsEngine.Cards.Card(CardType.Rock, Zone.Deck, 0);

            Assert.ThrowsException <InvalidOperationException>(() => card4.AddElement(new RPSCardsEngine.Cards.Card(CardType.Water)));

            var card5 = new RPSCardsEngine.Cards.Card(CardType.Rock, Zone.Graveyard, 0);

            Assert.ThrowsException <InvalidOperationException>(() => card5.AddElement(new RPSCardsEngine.Cards.Card(CardType.Water)));
        }
예제 #2
0
        public void TestDestroyUnit()
        {
            var  testCard     = new RPSCardsEngine.Cards.Card(CardType.Rock);
            var  ownGraveyard = new Graveyard();
            Hand hand         = TestHelpers.GetFilledHand(
                new List <Card> {
                testCard,
                new RPSCardsEngine.Cards.Card(CardType.Water),
            },
                ownGraveyard);

            var enemyGraveyard = new Graveyard();
            var enemyBoard     = new Board(enemyGraveyard);


            hand.PlayCard(0, enemyBoard, 2);

            Assert.AreEqual(enemyBoard[2], testCard);
            Assert.AreEqual(enemyBoard.Count, 1);

            hand.PlayCard(1, enemyBoard, 2);

            Assert.AreEqual(enemyBoard[2], testCard);
            Assert.IsTrue(testCard.IsDestroyed);
            Assert.AreEqual(ownGraveyard.Count, 1);

            Assert.AreEqual(enemyBoard.Count, 1);
            enemyBoard.RemoveDestroyed();
            Assert.AreEqual(enemyBoard.Count, 0);

            Assert.AreEqual(enemyGraveyard.Count, 1);
        }
예제 #3
0
        public void AddElement_UpgradeHelper(CardType original, CardType element, CardType result)
        {
            var c = new RPSCardsEngine.Cards.Card(original, Zone.Board, 0);

            c.AddElement(new RPSCardsEngine.Cards.Card(element));

            Assert.AreEqual(c.Type, result);
            Assert.AreEqual(c.Zone, Zone.Board);
            Assert.AreEqual(c.Position, 0);
            Assert.IsFalse(c.IsDestroyed);
        }
예제 #4
0
        public void TestPlayUnit()
        {
            var  testCard = new RPSCardsEngine.Cards.Card(CardType.Rock);
            Hand hand     = TestHelpers.GetFilledHand(new List <Card> {
                testCard
            });
            var board = new Board();

            hand.PlayCard(0, board, 2);

            Assert.IsFalse(hand.HasCard(0));
            Assert.IsTrue(board.HasCard(2));
            Assert.AreEqual(board[2], testCard);
        }
예제 #5
0
        public static Card CardOfType(CardType type, Zone zone)
        {
            if (CardTypeHelpers.IsElement(type))
            {
                return(new RPSCardsEngine.Cards.Card(type, zone, 0));
            }

            var card = new RPSCardsEngine.Cards.Card(CardTypeHelpers.GetBaseUnit(type), zone, 0);

            if (CardTypeHelpers.IsBaseUnit(type) == false)
            {
                card.AddElement(new RPSCardsEngine.Cards.Card(CardTypeHelpers.GetUnitElement(type)));
            }
            return(card);
        }
예제 #6
0
        public void TestAddElement_DestroyHelper(CardType original, CardType element)
        {
            var c = new RPSCardsEngine.Cards.Card(CardTypeHelpers.GetBaseUnit(original), Zone.Board, 0);

            if (CardTypeHelpers.IsBaseUnit(original) == false)
            {
                c.AddElement(new RPSCardsEngine.Cards.Card(CardTypeHelpers.GetUnitElement(original)));
            }

            c.AddElement(new RPSCardsEngine.Cards.Card(element));

            Assert.AreEqual(c.Type, original);
            Assert.AreEqual(c.Zone, Zone.Board);
            Assert.AreEqual(c.Position, 0);
            Assert.IsTrue(c.IsDestroyed);
        }
예제 #7
0
        public void TestUpgradeUnit()
        {
            var  testCard = new RPSCardsEngine.Cards.Card(CardType.Rock);
            Hand hand     = TestHelpers.GetFilledHand(new List <Card> {
                testCard,
                new RPSCardsEngine.Cards.Card(CardType.Fire),
            }, new Graveyard());
            var board = new Board(new Graveyard());

            hand.PlayCard(0, board, 2);

            Assert.AreEqual(board[2], testCard);

            hand.PlayCard(1, board, 2);

            Assert.AreEqual(board[2], testCard);
            Assert.AreEqual(testCard.Type, CardType.Magma);
        }