Descent.Model.Player.Figure.HeroStuff.Equipment.EquipToHero C# (CSharp) Method

EquipToHero() public method

The equipment will pass abilities on, so the hero is able to use them.
public EquipToHero ( Hero hero ) : void
hero Hero /// The hero that equips the equipment ///
return void
        public void EquipToHero(Hero hero)
        {
            Contract.Requires(hero != null);
            Contract.Requires(!Equipped);
            Contract.Ensures(Equipped);
            /*
            Contract.Ensures(
                this.type == EquipmentType.Weapon ?
                hero.Inventory.Weapon.Equals(this) :
                    this.type == EquipmentType.Armor ?
                    hero.Inventory.Armor.Equals(this) :
                        this.type == EquipmentType.Other ?
                        hero.Inventory.OtherItems.Contains(this) :
                            this.type == EquipmentType.Potion && hero.Inventory.Potions.Contains(this));
             * */
            foreach (Ability ability in abilities)
            {
                ability.Apply(hero);
            }

            hero.DiceContribution += this.DiceContribution;
            hero.SurgeAbilityContribution += this.SurgeAbilitiesContribution;
            equipped = true;
        }

Usage Example

Exemplo n.º 1
0
        /// <summary>
        /// Equip a weapon
        /// </summary>
        /// <param name="weapon">
        /// The weapon to be equipped
        /// </param>
        public void EquipWeapon(Equipment weapon)
        {
            Contract.Requires(weapon != null);
            Contract.Requires(weapon.Type == EquipmentType.Weapon);
            Contract.Requires(weapon.Hands <= FreeHands);
            Contract.Ensures(inventory[(int)EquipmentSlot.Weapon] == weapon);
            Contract.Ensures(FreeHands == Contract.OldValue(FreeHands) - weapon.Hands);

            inventory[(int)EquipmentSlot.Weapon] = weapon;
            weapon.EquipToHero(hero);
        }
All Usage Examples Of Descent.Model.Player.Figure.HeroStuff.Equipment::EquipToHero