//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 void BattleEncounterWithArmorAndWeaponsTest() { Scenario scenario = new Scenario(); Dwarf gimli = new Dwarf(); Orc orc = new Orc(); BasicSword sword = new BasicSword(); ChainMail armor = new ChainMail(); GoldenCoat coat = new GoldenCoat(); orc.AddItem(sword); orc.AddItem(armor); orc.AddItem(coat); List <CharacterClass> heroes = new List <CharacterClass>() { gimli }; List <CharacterClass> villains = new List <CharacterClass>() { orc }; BattleEncounter battle = new BattleEncounter(heroes, villains); List <List <CharacterClass> > everything = battle.PlayEncounter(); Assert.AreEqual(0, everything[0][0].HealthActual); }
public void PuttingDefenseItemInTest() { Dwarf gimli = new Dwarf(); Dragon dummy = new Dragon(); gimli.ReceiveDamage(dummy.Attack()); int checkPoint1 = gimli.HealthMax - gimli.HealthActual; gimli.Healing(1000); ChainMail armor = new ChainMail(); gimli.AddItem(armor); gimli.ReceiveDamage(dummy.Attack()); int checkPoint2 = gimli.HealthMax - gimli.HealthActual; Assert.AreEqual(checkPoint1 - checkPoint2, armor.DefensePower); }
public void TestEquipToBody_EquippingArmourThatAThiefCannotUse() { 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); ChainMail chainArmour = new ChainMail(); bool valArmourEquipped = thief.EquipToBody(chainArmour); Assert.IsFalse(valArmourEquipped, "TEST1: It is expected that the Armour Cannot be equipped"); Assert.IsNull(thief.equippedToBody, "TEST2: It was expected that the armour is NOT equipped"); }
public void TestEquipToBody_EnsureArmourClassIsCorrectWithChainMailButNoShieldOrBonus() { int expectedArmourClass = 5; 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); ChainMail chainMail = new ChainMail(); bool valEquipped = cleric.EquipToBody(chainMail); Assert.IsTrue(valEquipped, "TEST1: It was expected that equipping Chain Mail returns true"); Assert.AreEqual(expectedArmourClass, cleric.armourClass, "The Cleric's expected AC was 5"); }
public Item GetItem(int id) { Item nextItem; switch (id) { case 100: nextItem = new Mace(); return(nextItem); case 101: nextItem = new Dagger(); return(nextItem); case 102: nextItem = new Spear(); return(nextItem); case 103: nextItem = new Longsword(); return(nextItem); case 150: nextItem = new LeatherA(); return(nextItem); case 151: nextItem = new ChainMail(); return(nextItem); case 152: nextItem = new ScaleMail(); return(nextItem); case 153: nextItem = new BandedMail(); return(nextItem); case 154: nextItem = new PlateMail(); return(nextItem); case 200: nextItem = new Health_Potion(); return(nextItem); case 201: nextItem = new STR_Potion(); return(nextItem); case 202: nextItem = new DEF_Potion(); return(nextItem); case 250: nextItem = new Food(); return(nextItem); case 251: nextItem = new Scroll_Ident(); return(nextItem); case 252: nextItem = new Diamond(); return(nextItem); default: nextItem = new Mace(); return(nextItem); } }
public static void Armor() { int _slot = random.Next(0, 8); string[] gearSlot = new string[8]; gearSlot[0] = "Head"; //helmet gearSlot[1] = "Shoulders"; gearSlot[2] = "Chest"; gearSlot[3] = "Waist"; // belt gearSlot[4] = "Arms"; // bracer gearSlot[5] = "Hands"; // gloves gearSlot[6] = "Legs"; // pants gearSlot[7] = "Feet"; // boots string prefixName; int prefixValue; string prefixStat; (prefixName, prefixStat, prefixValue) = Prefix.Generate("Armor"); string suffixName; string suffixStat; int suffixValue; (suffixName, suffixStat, suffixValue) = Suffix.Generate("Armor"); int _armorType = random.Next(1, 11); switch (_armorType) { case 1: Rags rags = new Rags(gearSlot[_slot], prefixName, prefixStat, prefixValue, suffixName, suffixStat, suffixValue); rags.ArmorAddToInventory(); break; case 2: Quilted cloak = new Quilted(gearSlot[_slot], prefixName, prefixStat, prefixValue, suffixName, suffixStat, suffixValue); cloak.ArmorAddToInventory(); break; case 3: Leather leather = new Leather(gearSlot[_slot], prefixName, prefixStat, prefixValue, suffixName, suffixStat, suffixValue); leather.ArmorAddToInventory(); break; case 4: HardLeather hardLeather = new HardLeather(gearSlot[_slot], prefixName, prefixStat, prefixValue, suffixName, suffixStat, suffixValue); hardLeather.ArmorAddToInventory(); break; case 5: StuddedLeather studdedLeather = new StuddedLeather(gearSlot[_slot], prefixName, prefixStat, prefixValue, suffixName, suffixStat, suffixValue); studdedLeather.ArmorAddToInventory(); break; case 6: RingMail ringMail = new RingMail(gearSlot[_slot], prefixName, prefixStat, prefixValue, suffixName, suffixStat, suffixValue); ringMail.ArmorAddToInventory(); break; case 7: ChainMail chainMail = new ChainMail(gearSlot[_slot], prefixName, prefixStat, prefixValue, suffixName, suffixStat, suffixValue); chainMail.ArmorAddToInventory(); break; case 8: ScaleMail scaleMail = new ScaleMail(gearSlot[_slot], prefixName, prefixStat, prefixValue, suffixName, suffixStat, suffixValue); scaleMail.ArmorAddToInventory(); break; case 9: FieldPlate fieldPlate = new FieldPlate(gearSlot[_slot], prefixName, prefixStat, prefixValue, suffixName, suffixStat, suffixValue); fieldPlate.ArmorAddToInventory(); break; case 10: GothicPlate gothicPlate = new GothicPlate(gearSlot[_slot], prefixName, prefixStat, prefixValue, suffixName, suffixStat, suffixValue); gothicPlate.ArmorAddToInventory(); break; } }