示例#1
0
        public void VipersChest_HasExpectedValues()
        {
            // Arrange
            var attributes = new List <ItemStatAttribute>
            {
                new ItemStatAttribute("Power", .3m),
                new ItemStatAttribute("ConditionDamage", .3m),
                new ItemStatAttribute("Precision", .165m),
                new ItemStatAttribute("Expertise", .165m)
            };

            // Act
            var actual = new ChestArmor(attributes);

            // Assert
            const int expectedPower           = 121;
            const int expectedConditionDamage = 121;
            const int expectedPrecision       = 67;
            const int expectedExpertise       = 67;

            Assert.AreEqual(expectedPower, actual.Power);
            Assert.AreEqual(expectedConditionDamage, actual.ConditionDamage);
            Assert.AreEqual(expectedPrecision, actual.Precision);
            Assert.AreEqual(expectedExpertise, actual.Expertise);
        }
示例#2
0
        public Item GenerateItem(ItemType itemType)
        {
            switch (itemType)
            {
            case ItemType.Weapon:
                Sword returnedSword = new Sword(30, "Short Sword", ItemType.Weapon, RndPos());
                TraceSource.TraceEvent(TraceEventType.Information, 50, $"Placed item {returnedSword.Name} in the world, at x{returnedSword.Position.PosX},y{returnedSword.Position.PosY}");
                TraceSource.Flush();
                _world.WorldObjects.Add(returnedSword);
                return(returnedSword);

            case ItemType.Armor:
                ChestArmor returnedArmor = new ChestArmor(50, "Low Quality Breastplate", ItemType.Armor, RndPos());
                TraceSource.TraceEvent(TraceEventType.Information, 50, $"Placed item {returnedArmor.Name} in the world, at x{returnedArmor.Position.PosX},y{returnedArmor.Position.PosY}");
                TraceSource.Flush();
                _world.WorldObjects.Add(returnedArmor);
                return(returnedArmor);

            default:
                return(null);
            }
        }
示例#3
0
        public void BerserkersChest_HasExpectedValues()
        {
            // Arrange
            var attributes = new List <ItemStatAttribute>
            {
                new ItemStatAttribute("Power", .35m),
                new ItemStatAttribute("Precision", .25m),
                new ItemStatAttribute("Ferocity", .25m)
            };

            // Act
            var actual = new ChestArmor(attributes);

            // Assert
            const int expectedPower     = 141;
            const int expectedPrecision = 101;
            const int expectedFerocity  = 101;

            Assert.AreEqual(expectedPower, actual.Power);
            Assert.AreEqual(expectedPrecision, actual.Precision);
            Assert.AreEqual(expectedFerocity, actual.Ferocity);
        }
示例#4
0
    public void unequip(String slot)
    {
        if (bag.Count == size)
        {
            log.Println("The inventory is full. Cannot unequip.");
            return;
        }

        EquippableItem item = null;

        switch (slot)
        {
        case "boots":
            item       = this.boots;
            this.boots = null;
            break;

        case "legs":
            item      = this.legs;
            this.legs = null;
            break;

        case "gloves":
            item        = this.gloves;
            this.gloves = null;
            break;


        case "chest":
            item       = this.chest;
            this.chest = null;
            break;

        case "cloak":
            item       = this.cloak;
            this.cloak = null;
            break;

        case "helm":
            item        = this.helmet;
            this.helmet = null;
            break;

        case "weapon":
            item        = this.weapon;
            this.weapon = null;
            break;

        default:
            //check if maybe the names match
            if (this.weapon != null && this.weapon.ToString().ToLower().Equals(slot.ToLower()))
            {
                item        = this.weapon;
                this.weapon = null;
            }
            else if (this.helmet != null && this.helmet.ToString().ToLower().Equals(slot.ToLower()))
            {
                item        = this.helmet;
                this.helmet = null;
            }
            else if (this.cloak != null && this.cloak.ToString().ToLower().Equals(slot.ToLower()))
            {
                item       = this.cloak;
                this.cloak = null;
            }
            else if (this.legs != null && this.legs.ToString().ToLower().Equals(slot.ToLower()))
            {
                item      = this.legs;
                this.legs = null;
            }
            else if (this.boots != null && this.boots.ToString().ToLower().Equals(slot.ToLower()))
            {
                item       = this.boots;
                this.boots = null;
            }
            else if (this.gloves != null && this.gloves.ToString().ToLower().Equals(slot.ToLower()))
            {
                item        = this.gloves;
                this.gloves = null;
            }
            else if (this.chest != null && this.chest.ToString().ToLower().Equals(slot.ToLower()))
            {
                item       = this.chest;
                this.chest = null;
            }
            else
            {
                return;
            }
            break;
        }

        Add(item, () => { }, () => { /*bag cannot be full here*/ });
    }
示例#5
0
    public void equip(EquippableItem item)
    {
        if (!bag.Contains(item))
        {
            return;
        }

        EquippableItem tmp = null;

        if (item is HelmArmor)
        {
            if (helmet != null)
            {
                tmp = helmet;
            }
            helmet = (HelmArmor)item;
        }

        if (item is CloakArmor)
        {
            if (cloak != null)
            {
                tmp = cloak;
            }
            cloak = (CloakArmor)item;
        }

        if (item is ChestArmor)
        {
            if (chest != null)
            {
                tmp = chest;
            }
            chest = (ChestArmor)item;
        }

        if (item is GlovesArmor)
        {
            if (gloves != null)
            {
                tmp = gloves;
            }
            gloves = (GlovesArmor)item;
        }

        if (item is LegArmor)
        {
            if (legs != null)
            {
                tmp = legs;
            }
            legs = (LegArmor)item;
        }

        if (item is BootsArmor)
        {
            if (boots != null)
            {
                tmp = boots;
            }
            boots = (BootsArmor)item;
        }

        if (item is Weapon)
        {
            if (weapon != null)
            {
                tmp = weapon;
            }
            weapon = (Weapon)item;
        }

        bag.Remove(item);
        if (tmp != null)
        {
            bag.Add(tmp);
        }

        log.Print("Equipped ");
        log.ItemPrintln(item);
    }
示例#6
0
 public ChestSlot(ChestArmor slotItem) : base(slotItem)
 {
 }