public void Battle_ReturnLogsBattleOne_ReturnsString()
        {
            //Arrange
            FireElve    c1 = new FireElve();
            Dragon      c2 = new Dragon();
            Orc         c3 = new Orc();
            Wizzard     c4 = new Wizzard();
            FireSpell   c5 = new FireSpell();
            WaterSpell  c6 = new WaterSpell();
            Goblin      c7 = new Goblin();
            NormalSpell c8 = new NormalSpell();

            List <Card> deckOne = new List <Card>();
            List <Card> deckTwo = new List <Card>();

            deckOne.Add(c7); deckOne.Add(c3); deckOne.Add(c8); deckOne.Add(c5); deckOne.Add(c6);
            deckTwo.Add(c1); deckTwo.Add(c2); deckTwo.Add(c3); deckTwo.Add(c4); deckTwo.Add(c5);


            BattleHandler game   = new BattleHandler(deckOne, deckTwo);
            int           winner = game.Battle(); // Player One wins here!

            // Act
            List <String> logEntrys = game.ReturnLogs();
            String        lastLog   = logEntrys.Last();

            // Assert
            Assert.IsNotNull(lastLog);
        }
        public void Battle_DeterminesWinnerOne_ReturnsInt()
        {
            //Arrange
            FireElve    c1 = new FireElve();
            Dragon      c2 = new Dragon();
            Orc         c3 = new Orc();
            Wizzard     c4 = new Wizzard();
            FireSpell   c5 = new FireSpell();
            WaterSpell  c6 = new WaterSpell();
            Goblin      c7 = new Goblin();
            NormalSpell c8 = new NormalSpell();

            List <Card> deckOne = new List <Card>();
            List <Card> deckTwo = new List <Card>();

            deckOne.Add(c7); deckOne.Add(c3); deckOne.Add(c8); deckOne.Add(c5); deckOne.Add(c6);
            deckTwo.Add(c1); deckTwo.Add(c2); deckTwo.Add(c3); deckTwo.Add(c4); deckTwo.Add(c5);


            BattleHandler game = new BattleHandler(deckOne, deckTwo);

            // Act
            int winner = game.Battle();

            // Assert
            Assert.AreEqual(1, winner);
        }
Exemple #3
0
 public void Setup()
 {
     _normalSpell = new NormalSpell(CardType.Spell, ElementType.Normal, 20, "Normal Spell", 0, 1);
     _kraken      = new Kraken(CardType.Monster, ElementType.Water, 170, "Krakie dakie do whatcha gonna do", CardProperty.Kraken, 1);
     _goblinFire  = new Goblin(CardType.Monster, ElementType.Fire, 100, "Gobster the Robster", CardProperty.Goblin, 1);
     _goblinWater = new Goblin(CardType.Monster, ElementType.Water, 100, "Gobster the Robster", CardProperty.Goblin, 1);
 }
Exemple #4
0
        public void Constructor_WithParameters_ReturnsTrue()
        {
            //Arrange
            NormalSpell norm = new NormalSpell("Norm", 200, element.FIRE, 60);

            //Assert
            Assert.AreEqual(norm.Name, "Norm");
        }
Exemple #5
0
        public void Constructor_Base_ReturnsTrue()
        {
            //Arrange
            NormalSpell norm = new NormalSpell();

            // Assert
            Assert.IsTrue(norm.Name == "Magician`s Fist");
        }
Exemple #6
0
        [Test] // Orc against NORMAL Spell -> expect Dmg stays the same
        public void CalcDamage_AgainstNormalSpell_ReturnsInt()
        {
            //Arrange
            Orc         justOrc    = new Orc();
            NormalSpell enemySpell = new NormalSpell();
            //Act
            int justOrcDamage  = justOrc.CalcDamage(enemySpell);
            int expectedDamage = 8;

            //Assert
            Assert.AreEqual(expectedDamage, justOrcDamage);
        }
Exemple #7
0
        [Test] // Wizzard against NORMAL Spell -> expect Dmg doubled
        public void CalcDamage_AgainstNormalSpell_ReturnsInt()
        {
            //Arrange
            Wizzard     wiz        = new Wizzard();
            NormalSpell enemySpell = new NormalSpell();
            //Act
            int wizDamage      = wiz.CalcDamage(enemySpell);
            int expectedDamage = 24;

            //Assert
            Assert.AreEqual(expectedDamage, wizDamage);
        }
        [Test] // Knight against NORMAL Spell -> expect Dmg stays the same
        public void CalcDamage_AgainstNormalSpell_ReturnsInt()
        {
            //Arrange
            Knight      paladin    = new Knight();
            NormalSpell enemySpell = new NormalSpell();
            //Act
            int paladinDamage  = paladin.CalcDamage(enemySpell);
            int expectedDamage = 10;

            //Assert
            Assert.AreEqual(expectedDamage, paladinDamage);
        }
        public void Test_KrakenShouldResistSpell()
        {
            //arrange
            Card kraken      = new Kraken("Tentakel", 50, ElementType.Normal);
            Card normalSpell = new NormalSpell("Mud Throw", 20);

            //act
            bool hasResisted = ((Kraken)kraken).TryResistSpell(normalSpell);

            //assert
            Assert.IsTrue(hasResisted);
        }
Exemple #10
0
        public void Test_KnightShouldNotDrownByNonWaterSpell()
        {
            //arrange
            Card knight        = new Knight("Sir Rudolf", 50, ElementType.Normal);
            Card nonWaterSpell = new NormalSpell("Mud Throw", 20);

            //act
            bool hasDrowned = ((Knight)knight).TryDrown(nonWaterSpell);

            //assert
            Assert.IsFalse(hasDrowned);
        }
Exemple #11
0
        [Test] // Goblin against NORMAL Spell -> expect Dmg stays the same
        public void CalcDamage_AgainstNormalSpell_ReturnsInt()
        {
            //Arrange
            Goblin      gobo       = new Goblin();
            NormalSpell enemySpell = new NormalSpell();
            //Act
            int goboDamage     = gobo.CalcDamage(enemySpell);
            int expectedDamage = 5;

            //Assert
            Assert.AreEqual(expectedDamage, goboDamage);
        }
        [Test] // Kraken against NORMAL Spell -> expect Dmg stays the same
        public void CalcDamage_AgainstNormalSpell_ReturnsInt()
        {
            //Arrange
            Kraken      leviathan  = new Kraken();
            NormalSpell enemySpell = new NormalSpell();
            //Act
            int leviathanDamage = leviathan.CalcDamage(enemySpell);
            int expectedDamage  = 30;

            //Assert
            Assert.AreEqual(expectedDamage, leviathanDamage);
        }
        [Test] // Enemy NORMAL Spell against Kraken -> expect 0 enemy Dmg
        public void CalcEnemyDamage_AgainstNORMALSpell_ReturnsInt()
        {
            //Arrange
            Kraken      leviathan  = new Kraken();
            NormalSpell enemySpell = new NormalSpell();
            //Act
            int enemyDamage    = enemySpell.CalcDamage(leviathan);
            int expectedDamage = 0;

            //Assert
            Assert.AreEqual(expectedDamage, enemyDamage);
        }
Exemple #14
0
        [Test] // NormalSpell against NORMAL Spell -> expect Dmg stays the same
        public void CalcDamage_AgainstNormalSpell_ReturnsInt()
        {
            //Arrange
            NormalSpell norm       = new NormalSpell();
            NormalSpell enemySpell = new NormalSpell();
            //Act
            int normDamage     = norm.CalcDamage(enemySpell);
            int expectedDamage = 40;

            //Assert
            Assert.AreEqual(expectedDamage, normDamage);
        }
Exemple #15
0
        [Test] // FireElve against NORMAL Spell -> expect Dmg doubled
        public void CalcDamage_AgainstNormalSpell_ReturnsInt()
        {
            //Arrange
            FireElve    elfi       = new FireElve();
            NormalSpell enemySpell = new NormalSpell();
            //Act
            int elfiDamage     = elfi.CalcDamage(enemySpell);
            int expectedDamage = 28;

            //Assert
            Assert.AreEqual(expectedDamage, elfiDamage);
        }
Exemple #16
0
        [Test] // Dragon against NORMAL Spell -> expect Dmg doubled
        public void CalcDamage_AgainstNormalSpell_ReturnsInt()
        {
            //Arrange
            Dragon      smaug      = new Dragon();
            NormalSpell enemySpell = new NormalSpell();
            //Act
            int smaugDamage    = smaug.CalcDamage(enemySpell);
            int expectedDamage = 30;

            //Assert
            Assert.AreEqual(expectedDamage, smaugDamage);
        }
Exemple #17
0
        public void TestKrakenImmuneToSpells()
        {
            Card kraken      = new Kraken("kragli", "Glindat", 140, ElementType.Water);
            Card waterSpell  = new WaterSpell("watsta", "Static Shower", 60);
            Card fireSpell   = new FireSpell("firfir", "Fire Storm", 80);
            Card normalSpell = new NormalSpell("norsco", "Scorch", 70);

            bool immuneWater  = ((Kraken)kraken).ImmuneTo(waterSpell);
            bool immuneFire   = ((Kraken)kraken).ImmuneTo(fireSpell);
            bool immuneNormal = ((Kraken)kraken).ImmuneTo(normalSpell);

            Assert.True(immuneWater && immuneFire && immuneNormal);
        }
Exemple #18
0
        public void TestCreateCard()
        {
            var card = new NormalSpell()
            {
                Id = DemoCard1Id, Damage = 24
            };

            try
            {
                _db.CreateCard(card).RunSynchronously();
            }
            catch (Npgsql.PostgresException)
            {
                // may happen when database has not been reset as card has already been inserted before
                Assert.Warn("Did not create demo card as ID already exists.");
            }
        }
Exemple #19
0
        public void TestFireVSNormalSpellCards()
        {
            var fire = new FireSpell()
            {
                Damage = 20
            };
            var normal = new NormalSpell()
            {
                Damage = 20
            };

            int fireDamage   = fire.CalculateDamage(normal);
            int normalDamage = normal.CalculateDamage(fire);

            // fire > normal
            Assert.AreEqual(40, fireDamage);
            Assert.AreEqual(10, normalDamage);
        }
Exemple #20
0
        public void TestNormalVSWaterSpellCards()
        {
            var normal = new NormalSpell()
            {
                Damage = 20
            };
            var water = new WaterSpell()
            {
                Damage = 20
            };

            int normalDamage = normal.CalculateDamage(water);
            int waterDamage  = water.CalculateDamage(normal);

            // normal > water
            Assert.AreEqual(40, normalDamage);
            Assert.AreEqual(10, waterDamage);
        }
Exemple #21
0
        public void TestMixedFightKrakenNormalSpell()
        {
            var kraken = new Kraken()
            {
                Damage = 20
            };
            var normal = new NormalSpell()
            {
                Damage = 20
            };

            int krakenDamage = kraken.CalculateDamage(normal);
            int normalDamage = normal.CalculateDamage(kraken);

            // normal > water
            // kraken not affected by spells
            Assert.AreEqual(10, krakenDamage);
            Assert.AreEqual(0, normalDamage);
        }
Exemple #22
0
        private string Round(ref CardDeck deck1, ref CardDeck deck2, string username1, string username2)
        {
            Card card1Deck = deck1.GetRandomCard();
            Card card2Deck = deck2.GetRandomCard();

            // create new cards instead of references
            Card card1 = card1Deck switch
            {
                Dragon d => new Dragon(card1Deck.ID, card1Deck.Name, card1Deck.Damage, card1Deck.Type),
                Elve e => new Elve(card1Deck.ID, card1Deck.Name, card1Deck.Damage, card1Deck.Type),
                Goblin g => new Goblin(card1Deck.ID, card1Deck.Name, card1Deck.Damage, card1Deck.Type),
                Knight k => new Knight(card1Deck.ID, card1Deck.Name, card1Deck.Damage, card1Deck.Type),
                Kraken k => new Kraken(card1Deck.ID, card1Deck.Name, card1Deck.Damage, card1Deck.Type),
                Orc o => new Orc(card1Deck.ID, card1Deck.Name, card1Deck.Damage, card1Deck.Type),
                Wizard w => new Wizard(card1Deck.ID, card1Deck.Name, card1Deck.Damage, card1Deck.Type),
                FireSpell f => new FireSpell(card1Deck.ID, card1Deck.Name, card1Deck.Damage),
                NormalSpell n => new NormalSpell(card1Deck.ID, card1Deck.Name, card1Deck.Damage),
                WaterSpell w => new WaterSpell(card1Deck.ID, card1Deck.Name, card1Deck.Damage),
            };
            Card card2 = card2Deck switch
            {
                Dragon d => new Dragon(card2Deck.ID, card2Deck.Name, card2Deck.Damage, card2Deck.Type),
                Elve e => new Elve(card2Deck.ID, card2Deck.Name, card2Deck.Damage, card2Deck.Type),
                Goblin g => new Goblin(card2Deck.ID, card2Deck.Name, card2Deck.Damage, card2Deck.Type),
                Knight k => new Knight(card2Deck.ID, card2Deck.Name, card2Deck.Damage, card2Deck.Type),
                Kraken k => new Kraken(card2Deck.ID, card2Deck.Name, card2Deck.Damage, card2Deck.Type),
                Orc o => new Orc(card2Deck.ID, card2Deck.Name, card2Deck.Damage, card2Deck.Type),
                Wizard w => new Wizard(card2Deck.ID, card2Deck.Name, card2Deck.Damage, card2Deck.Type),
                FireSpell f => new FireSpell(card2Deck.ID, card2Deck.Name, card2Deck.Damage),
                NormalSpell n => new NormalSpell(card2Deck.ID, card2Deck.Name, card2Deck.Damage),
                WaterSpell w => new WaterSpell(card2Deck.ID, card2Deck.Name, card2Deck.Damage),
            };

            //card1.Damage = card1.Damage * _elementEffectivenessService.CompareElements(card1.Type, card2.Type);
            //card2.Damage = card2.Damage * _elementEffectivenessService.CompareElements(card2.Type, card1.Type);
            card1.EnhanceDamage(_elementEffectivenessService.CompareElements(card1.Type, card2.Type));
            card2.EnhanceDamage(_elementEffectivenessService.CompareElements(card2.Type, card1.Type));

            // without special abilities

            /*int card1wins = card1 switch
             * {
             *  IMonster monster => monster.CompareDamage(card2.Damage) ? 1 : -1,
             *  ISpell spell => spell.CompareDamage(card2.Damage) ? 1 : -1,
             *  _ => 0
             * };*/

            Random random       = new Random();
            bool   boosterCard1 = (random.Next(1, 21) == 20);

            if (boosterCard1)
            {
                //card1.Damage = card1.Damage * 10;
                card1.EnhanceDamage(10);
            }

            int card1wins = card1 switch
            {
                IMonster _ when card2 is IMonster => FightMonsterMonster(card1, card2),
                IMonster _ when card1 is ISpell => FightMonsterSpell(card1, card2),
                ISpell _ when card2 is IMonster => FightSpellMonster(card2, card1),
                _ => FightSpellSpell(card1, card2)
            };

            string roundLog;

            if (card1wins == 1)
            {
                deck1.AddCard(card2Deck, true);
                deck2.RemoveCard(card2Deck);
                if (boosterCard1)
                {
                    roundLog = (card1Deck.ToBattleString() + " (" + username1 + ") won with a booster against " + card2Deck.ToBattleString() + " (" + username2 + ")");
                }
                else
                {
                    roundLog = (card1Deck.ToBattleString() + " (" + username1 + ") won against " + card2Deck.ToBattleString() + " (" + username2 + ")");
                }
            }
            else if (card1wins == -1)
            {
                deck2.AddCard(card1Deck, true);
                deck1.RemoveCard(card1Deck);
                if (boosterCard1)
                {
                    roundLog = (card1Deck.ToBattleString() + " (" + username1 + ") lost although a booster to " + card2Deck.ToBattleString() + " (" + username2 + ")");
                }
                else
                {
                    roundLog = (card1Deck.ToBattleString() + " (" + username1 + ") lost to " + card2Deck.ToBattleString() + " (" + username2 + ")");
                }
            }
            else
            {
                if (boosterCard1)
                {
                    roundLog = (card1Deck.ToBattleString() + " (" + username1 + ") drew although a booster with " + card2Deck.ToBattleString() + " (" + username2 + ")");
                }
                else
                {
                    roundLog = (card1Deck.ToBattleString() + " (" + username1 + ") drew with " + card2Deck.ToBattleString() + " (" + username2 + ")");
                }
            }

            return(roundLog);
        }