public SpellSystem(Transform root, Rigidbody2D rb) { _root = root; _rb = rb; _fireSpell = new FireSpell(); _waterSpell = new WaterSpell(); _earthSpell = new EarthSpell(); _airSpell = new AirSpell(); _activeSpell = _fireSpell; }
[Test] // Dragon against WATER Spell -> expect Dmg halved public void CalcDamage_AgainstWaterSpell_ReturnsInt() { //Arrange Dragon smaug = new Dragon(); WaterSpell enemySpell = new WaterSpell(); //Act int smaugDamage = smaug.CalcDamage(enemySpell); int expectedDamage = 7; //Assert Assert.AreEqual(expectedDamage, smaugDamage); }
[Test] // Orc against WATER Spell -> expect Dmg doubled public void CalcDamage_AgainstWaterSpell_ReturnsInt() { //Arrange Orc justOrc = new Orc(); WaterSpell enemySpell = new WaterSpell(); //Act int justOrcDamage = justOrc.CalcDamage(enemySpell); int expectedDamage = 16; //Assert Assert.AreEqual(expectedDamage, justOrcDamage); }
[Test] // Knight against WATER Spell -> 0 damage public void CalcDamage_AgainstWaterSpell_ReturnsInt() { //Arrange Knight paladin = new Knight(); WaterSpell enemySpell = new WaterSpell(); //Act int paladinDamage = paladin.CalcDamage(enemySpell); int expectedDamage = 0; //Assert Assert.AreEqual(expectedDamage, paladinDamage); }
[Test] // Goblin against WATER Spell -> expect Dmg doubled public void CalcDamage_AgainstWaterSpell_ReturnsInt() { //Arrange Goblin gobo = new Goblin(); WaterSpell enemySpell = new WaterSpell(); //Act int goboDamage = gobo.CalcDamage(enemySpell); int expectedDamage = 10; //Assert Assert.AreEqual(expectedDamage, goboDamage); }
[Test] // Wizzard against WATER Spell -> expect Dmg halved public void CalcDamage_AgainstWaterSpell_ReturnsInt() { //Arrange Wizzard wiz = new Wizzard(); WaterSpell enemySpell = new WaterSpell(); //Act int wizDamage = wiz.CalcDamage(enemySpell); int expectedDamage = 6; //Assert Assert.AreEqual(expectedDamage, wizDamage); }
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); }
public void createAllSpellcards() { ICard card1 = new FireSpell(100); ICard card2 = new RegularSpell(100); ICard card3 = new WaterSpell(100); Cardname desiredName1 = Cardname.FireSpell; Cardname desiredName2 = Cardname.RegularSpell; Cardname desiredName3 = Cardname.WaterSpell; Assert.AreEqual(desiredName1, card1.name); Assert.AreEqual(desiredName2, card2.name); Assert.AreEqual(desiredName3, card3.name); }
public void Kraken_Waterspell() { ICard card1 = new Kraken(40); ICard card2 = new WaterSpell(40); float desiredCard1Damage = 40; float desiredCard2Damage = 0; float actualCard1Damage = card1.CombatBehavior(card2); float actualCard2Damage = card2.CombatBehavior(card1); Assert.AreEqual(desiredCard1Damage, actualCard1Damage); Assert.AreEqual(desiredCard2Damage, actualCard2Damage); }
public void Dragon_Waterspell() { ICard card1 = new Dragon(100); ICard card2 = new WaterSpell(40); float desiredCard1Damage = 50; float desiredCard2Damage = 80; float actualCard1Damage = card1.CombatBehavior(card2); float actualCard2Damage = card2.CombatBehavior(card1); Assert.AreEqual(desiredCard1Damage, actualCard1Damage); Assert.AreEqual(desiredCard2Damage, actualCard2Damage); }
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); }
public void TestFireVSWaterSpellCards() { var fire = new FireSpell() { Damage = 20 }; var water = new WaterSpell() { Damage = 20 }; int fireDamage = fire.CalculateDamage(water); int waterDamage = water.CalculateDamage(fire); // water > fire Assert.AreEqual(10, fireDamage); Assert.AreEqual(40, waterDamage); }
public void TestMixedFightKrakenWaterSpell() { var kraken = new Kraken() { Damage = 20 }; var water = new WaterSpell() { Damage = 20 }; int krakenDamage = kraken.CalculateDamage(water); int waterDamage = water.CalculateDamage(kraken); // no element type effectiveness applies // kraken not affected by spells Assert.AreEqual(20, krakenDamage); Assert.AreEqual(0, waterDamage); }
public void TestMixedFightKnightWaterSpell() { var knight = new Knight() { Damage = 20 }; var water = new WaterSpell() { Damage = 20 }; int knightDamage = knight.CalculateDamage(water); int waterDamage = water.CalculateDamage(knight); // normal > water // water spell drowns knights instantly Assert.AreEqual(20 * 2, knightDamage); Assert.AreEqual(9999 / 2, waterDamage); }
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); }
public void Setup() { _knight = new Knight(CardType.Monster, ElementType.Normal, 150, "Knight in the Night, just Right", CardProperty.Knight, 1); _waterSpell = new WaterSpell(CardType.Spell, ElementType.Water, 20, "Nasser Spell", 0, 1); }