//for more equipping armour tests see thief public void TestEquipToBody_EquippingArmourWhenArmourIsAlreadyWorn() { int expectedItemCountInInventory = 0; int expectedItemCountInInventoryAfterTheSwap = 1; Dictionary <Dungeons_and_Dragons.Attribute, int> dict = new Dictionary <Dungeons_and_Dragons.Attribute, int>(); dict.Add(Dungeons_and_Dragons.Attribute.Strength, 12); dict.Add(Dungeons_and_Dragons.Attribute.Dexterity, 15); dict.Add(Dungeons_and_Dragons.Attribute.Intelligence, 3); dict.Add(Dungeons_and_Dragons.Attribute.Wisdom, 18); dict.Add(Dungeons_and_Dragons.Attribute.Constitution, 17); dict.Add(Dungeons_and_Dragons.Attribute.Charisma, 9); int xp = 0; int hp = 3; Fighter fighter = new Fighter("Richard", Race.Human, dict, hp, xp); LeatherArmour leatherArmour = new LeatherArmour(); ChainMail chainMail = new ChainMail(); bool valLeatherArmourEquipped = fighter.EquipToBody(leatherArmour); Assert.IsTrue(valLeatherArmourEquipped, "TEST1: It was expected that equipping the leather armour should return true"); Assert.AreEqual(leatherArmour, fighter.equippedToBody, "TEST2: It was expected that the leather armour should be equipped to the body"); Assert.AreEqual(expectedItemCountInInventory, fighter.inventory.Count, "TEST3: It was expected that the fighter's inventory should be empty"); bool valChainArmourEquipped = fighter.EquipToBody(chainMail); Assert.IsTrue(valChainArmourEquipped, "TEST4: It was expected that equipping the chain armour should return true"); Assert.AreEqual(chainMail, fighter.equippedToBody, "TEST5: It was expected that the chain armour should be equipped to the body"); Assert.AreEqual(expectedItemCountInInventoryAfterTheSwap, fighter.inventory.Count, "TEST6: It was expected that the fighter's inventory should contain a single item"); Assert.AreEqual(leatherArmour, fighter.inventory[0], "TEST7: It was expected that the fighter's inventory should contain the leather armour"); }
public override void EquipItem(Unit unit) { LeatherArmour armour = unit.gameObject.AddComponent <LeatherArmour>(); armour.owner = unit.gameObject.GetComponent <TacticsMovement>(); armour.itemData = this; unit.unitInfo.currentArmour += 2; }
public void TestEquipToBody_EquippingArmourThatAThiefCanUse() { Dictionary <Dungeons_and_Dragons.Attribute, int> dict = new Dictionary <Dungeons_and_Dragons.Attribute, int>(); dict.Add(Dungeons_and_Dragons.Attribute.Strength, 15); dict.Add(Dungeons_and_Dragons.Attribute.Dexterity, 10); dict.Add(Dungeons_and_Dragons.Attribute.Intelligence, 3); dict.Add(Dungeons_and_Dragons.Attribute.Wisdom, 8); dict.Add(Dungeons_and_Dragons.Attribute.Constitution, 17); dict.Add(Dungeons_and_Dragons.Attribute.Charisma, 9); int xp = 0; int hp = 3; Thief thief = new Thief("Stickie", Race.Elf, dict, hp, xp); LeatherArmour leatherArmour = new LeatherArmour(); bool valArmourEquipped = thief.EquipToBody(leatherArmour); Assert.IsTrue(valArmourEquipped, "TEST1: It is expected that the Armour will be equipped"); Assert.AreEqual(leatherArmour, thief.equippedToBody, "TEST2: It was expected that the leather armour is now equipped"); }
public void TestTestEquipToHand_TryingToEquipAmrourToAHandThatShouldEquipToBody() { Dictionary <Dungeons_and_Dragons.Attribute, int> dict = new Dictionary <Dungeons_and_Dragons.Attribute, int>(); dict.Add(Dungeons_and_Dragons.Attribute.Strength, 15); dict.Add(Dungeons_and_Dragons.Attribute.Dexterity, 10); dict.Add(Dungeons_and_Dragons.Attribute.Intelligence, 3); dict.Add(Dungeons_and_Dragons.Attribute.Wisdom, 8); dict.Add(Dungeons_and_Dragons.Attribute.Constitution, 17); dict.Add(Dungeons_and_Dragons.Attribute.Charisma, 9); int xp = 0; int hp = 3; Thief thief = new Thief("Stickie", Race.Elf, dict, hp, xp); LeatherArmour leatherArmour = new LeatherArmour(); bool valArmourEquipped = thief.EquipToHand(leatherArmour, Hand.Right); Assert.IsFalse(valArmourEquipped, "TEST1: It is expected that the Armour will not be equipped"); Assert.IsNull(thief.equippedInRightHand, "TEST2: It was expected that the right hand should be empty"); Assert.IsNull(thief.equippedInLeftHand, "TEST3: It was expected that the left hand should be empty"); }
public void TestEquipToBody_EnsureArmourClassIsCorrectWithLeatherArmourButNoShieldOrBonus() { int expectedArmourClass = 7; Dictionary <Dungeons_and_Dragons.Attribute, int> dict = new Dictionary <Dungeons_and_Dragons.Attribute, int>(); dict.Add(Dungeons_and_Dragons.Attribute.Strength, 12); dict.Add(Dungeons_and_Dragons.Attribute.Dexterity, 10); dict.Add(Dungeons_and_Dragons.Attribute.Intelligence, 3); dict.Add(Dungeons_and_Dragons.Attribute.Wisdom, 12); dict.Add(Dungeons_and_Dragons.Attribute.Constitution, 1); dict.Add(Dungeons_and_Dragons.Attribute.Charisma, 9); int xp = 0; int hp = 1; Cleric cleric = new Cleric("Fryer Ben", Race.Halfling, dict, hp, xp); LeatherArmour leatherArmour = new LeatherArmour(); bool valEquipped = cleric.EquipToBody(leatherArmour); Assert.IsTrue(valEquipped, "TEST1: It was expected that equipping Leather Armour returns true"); Assert.AreEqual(expectedArmourClass, cleric.armourClass, "The Cleric's expected AC was 7"); }