Ejemplo n.º 1
0
        /*
         *  Es necesario probar que la implementación del método ChangeArmor
         *  efectivamente cambie la armadura por una nueva, ya que esta es la finalidad
         *  del mismo. Si se cambiara la implementación y este test fallara, entonces
         *  estaría mal implementado el método.
         */
        public void ChangeArmor()
        {
            LeatherArmor newArmor = new LeatherArmor(300, 0);

            this.elf.Armor = newArmor;
            Assert.AreEqual(this.elf.Armor, newArmor);
        }
Ejemplo n.º 2
0
        private static Armor GenerateArmor()
        {
            Armor armor;
            int   roll = Dice.RollMultipleDice(6);

            if (roll >= 24)
            {
                armor = new ChainMailArmor();
            }
            else
            {
                armor = new LeatherArmor();
            }

            Tuple <string, int> extraDefense = RollExtraDefense();

            armor.ExtraDefense = extraDefense.Item2;

            Tuple <string, int> health = RollHealth();

            armor.Health = health.Item2;

            string prefix  = extraDefense.Item1;
            string postfix = health.Item1;

            armor.Name = prefix + armor.Name + postfix;

            return(armor);
        }
Ejemplo n.º 3
0
        public void Setup()
        {
            this.elf = new Elf("Legolas");
            Bow bow = new Bow(150, 0);

            this.elf.Bow = bow;
            LeatherArmor armor = new LeatherArmor(0, 50);

            this.elf.Armor = armor;
        }
        public void DefaultMaterial_Medium_Masterwork()
        {
            // Arrange
            var armor = new LeatherArmor(SizeCategory.Medium)
            {
                IsMasterwork = true
            };

            // Assert
            Assert.AreEqual(0, armor.ArmorCheckPenalty());
            Assert.AreEqual(160, armor.MundaneMarketPrice());
            Assert.AreEqual("Masterwork Leather Armor", armor.ToString());
        }
        public void DefaultMaterial_Large()
        {
            // Arrange
            var armor = new LeatherArmor(SizeCategory.Large);

            // Assert
            Assert.IsFalse(armor.IsMasterwork);
            Assert.AreEqual(0, armor.ArmorCheckPenalty());
            Assert.AreEqual(6, armor.MaximumDexterityBonus());
            Assert.AreEqual(0, armor.SpeedPenalty);
            Assert.AreEqual(30, armor.GetWeight());
            Assert.AreEqual(20, armor.MundaneMarketPrice());
            Assert.AreEqual(Leather.Hardness, armor.Hardness.MaterialHardness);
            Assert.AreEqual("Leather Armor", armor.ToString());
        }
        public void Dragonhide_Small()
        {
            // Arrange
            var armor = new LeatherArmor(SizeCategory.Small, DragonhideColor.Red);

            // Assert
            Assert.IsTrue(armor.IsMasterwork);
            Assert.IsFalse(armor.MasterworkIsToggleable);
            Assert.AreEqual(0, armor.ArmorCheckPenalty());
            Assert.AreEqual(6, armor.MaximumDexterityBonus());
            Assert.AreEqual(0, armor.SpeedPenalty);
            Assert.AreEqual(7.5, armor.GetWeight());
            Assert.AreEqual(320, armor.MundaneMarketPrice());
            Assert.AreEqual(Dragonhide.Hardness, armor.Hardness.MaterialHardness);
            Assert.AreEqual("Red Dragonhide Leather Armor", armor.ToString());
        }
        /// <summary>
        /// Read item from byte stream.
        /// </summary>
        /// <param name="byteStream">Byte stream to read items from.</param>
        /// <param name="map">Map to write data to.</param>
        /// <returns>Items</returns>
        private AbstractItem ReadItem(Stream byteStream, Map map)
        {
            AbstractItem item;
            int          uid   = ReadInt(byteStream);
            string       name  = ReadName(byteStream);
            int          x     = ReadInt(byteStream);
            int          y     = ReadInt(byteStream);
            int          param = ReadInt(byteStream);
            byte         type  = ReadByte(byteStream);

            switch (type)
            {
            case 0:
                item = new Axe(map.Grid[x, y])
                {
                    UniqueId = uid, Name = name, Damage = param
                };
                break;

            case 1:
                item = new LeatherArmor(map.Grid[x, y])
                {
                    UniqueId = uid, Name = name, Defense = param
                };
                break;

            case 2:
                item = new BasicItem(name, map.Grid[x, y], param)
                {
                    UniqueId = uid
                };
                break;

            default:
                throw new Exception($"Neznámý typ předmětu: {type}!");
            }

            map.AddItem(item);

            return(item);
        }
Ejemplo n.º 8
0
    // Use this for initialization
    public Alexis()
    {
        this.playerName    = "Alexis";
        this.playerClass   = "Soldier";
        this.playerProfile = "Images/Cloud";
        this.playerLevel   = 1;
        this.strength      = 35;
        this.intelligence  = 15;
        this.speed         = 15;
        this.spirit        = 10;
        this.defense       = 35;
        this.hitPoints     = 150;
        this.currentHP     = this.hitPoints;
        this.magicPoints   = 50;
        this.currentMP     = this.magicPoints;

        weapon    = new IronSword();
        armor     = new LeatherArmor();
        accessory = new HPRing();

        UpdatePlayer();
    }
Ejemplo n.º 9
0
    // Use this for initialization
    public Alexis()
    {
        this.playerName    = "Alexis";
        this.playerClass   = "Soldier";
        this.playerProfile = "Images/Cloud";
        this.playerLevel   = 1;
        this.strength      = 35;
        this.intelligence  = 15;
        this.speed         = 15;
        this.spirit        = 10;
        this.defense       = 35;
        this.hitPoints     = 150;
        this.currentHP     = this.hitPoints;
        this.magicPoints   = 50;
        this.currentMP     = this.magicPoints;

        weapon    = new IronSword ();
        armor     = new LeatherArmor ();
        accessory = new HPRing ();

        UpdatePlayer ();
    }
Ejemplo n.º 10
0
        public void TestPickUpArmor()
        {
            // prepare map block with one item, player and pick up action
            MapBlock     mapBlock = new MapBlock(0, 0);
            AbstractItem armor    = new LeatherArmor(mapBlock);

            mapBlock.Item = armor;
            AbstractPlayer testPlayer   = new EmptyAIPlayer("Test player", mapBlock);
            PickUp         pickUpAction = new PickUp()
            {
                Actor = testPlayer
            };

            // check that player has no armor
            Assert.IsNull(testPlayer.Armor, "No armor should be equipped!");

            // perform pick up action
            pickUpAction.Execute();

            // check that armor was equipped
            Assert.IsNotNull(testPlayer.Armor, "Armor should be equipped!");
            Assert.AreEqual(armor, testPlayer.Armor, "Wrong armor picked up");
            Assert.IsNull(mapBlock.Item, "Item was not picked up from map block");

            // add new sword to the map block and check that swapping works
            AbstractItem armor2 = new LeatherArmor(mapBlock);

            mapBlock.Item = armor2;
            pickUpAction.Execute();

            // check swap
            Assert.IsNotNull(testPlayer.Armor, "Amor should be equipped!");
            Assert.AreEqual(armor2, testPlayer.Armor, "Wrong armor picked up!");
            Assert.IsNotNull(mapBlock.Item, "First armor should be placed back to map block!");
            Assert.AreEqual(armor, mapBlock.Item, "Wrong armor placed in map block!");
        }
Ejemplo n.º 11
0
        static void Main(string[] args)
        {
            Console.WriteLine("----Demo: Generate some characters----");

            Mage magica = new Mage("Magica-Raspotina");

            magica.GainExperience(210);
            Console.WriteLine($"\nMage details: {magica}");

            Warrior war = new Warrior("M - The unshackled");

            war.GainExperience(2500);
            Console.WriteLine($"\nWarrior details: {war}");

            Ranger rag = new Ranger("Nico Rock");

            rag.GainExperience(1080);
            Console.WriteLine($"\nRanger details: {rag}");

            Console.WriteLine("\n----Demo: Generate some items----");

            MagicWeapon magicWeapon = new MagicWeapon("MagicWeapon");

            Console.WriteLine($"\nMagic Weapon details: {magicWeapon}");
            magicWeapon.LevelScale(2);
            Console.WriteLine($"\nMagic Weapon details on level 2: {magicWeapon}");

            MeleeWeapon meele = new MeleeWeapon("Infinity Edge");

            meele.LevelScale(11);
            Console.WriteLine($"\nMeele Weapon details on level 11: {meele}");

            RangedWeapon rangedWeapon = new RangedWeapon("Beyond distance");

            rangedWeapon.LevelScale(4);
            Console.WriteLine($"\nRanged Weapon details on level 4: {rangedWeapon}");

            ClothArmor armorMask = new ClothArmor("Abyssal Mask", Slots.Head);

            armorMask.ScaleStatsByLevelAndSlot(6);
            Console.WriteLine($"\nCloth armor: {armorMask}");

            PlateArmor armorPlate = new PlateArmor("Bramble Vest", Slots.Body);

            armorPlate.ScaleStatsByLevelAndSlot(3);
            Console.WriteLine($"\nPlate armor: {armorPlate}");

            LeatherArmor armorLeather = new LeatherArmor("Legwraps ", Slots.Legs);

            armorLeather.ScaleStatsByLevelAndSlot(8);
            Console.WriteLine($"\nLeather armor: {armorLeather}");

            ClothArmor clothPants = new ClothArmor("El Pj Pants", Slots.Legs);

            clothPants.ScaleStatsByLevelAndSlot(1);
            Console.WriteLine($"\nCloth armor: {clothPants}");

            Console.WriteLine("\n----Demo: Hero's eqiup some items----");

            HeroService warriorGame = new HeroService(war);

            warriorGame.EquipWeapon(meele);
            Console.WriteLine("\n----Warrior equips ClothAmor lvl 6:Head:----");
            warriorGame.EquipArmor(armorMask);
            warriorGame.NewStats();

            Console.WriteLine("\n----Warrior equips PlateArmor lvl 3: Body----");
            warriorGame.EquipArmor(armorPlate);
            Console.WriteLine("\n----Warrior equips LeatherArmor lvl 8: Legs----");
            warriorGame.EquipArmor(armorLeather);
            Console.WriteLine("\n----Warrior equips ClothArmor: Legs again----");
            warriorGame.EquipArmor(clothPants);
            warriorGame.NewStats();

            Console.WriteLine("\n----Demo: Hero's can't eqiup item with higher level----");
            HeroService magicaGame = new HeroService(magica);

            magicaGame.EquipWeapon(meele);

            Console.WriteLine("\n----Demo: Hero:Warrior attacking with weapon: meele----");
            warriorGame.Attack();
            Console.WriteLine("\n----Demo: Hero's attacking without weapon----");
            magicaGame.Attack();
        }
Ejemplo n.º 12
0
 public void Setup()
 {
     this.leatherArmor = new LeatherArmor(0, 50);
 }