コード例 #1
0
 public SentientCreature(string name, int level, char gender, Race race, Caste caste, int team, int[] abilityScoreValues = null, MapPoint location = null) :
     base(name, level, gender, team, abilityScoreValues, null, location)
 {
     Race    = race;
     Caste   = caste;
     _hitDie = race.HitDie;
     AbilityScores.AddMods(AbilityScores.RacialMods, Race.AbilityMods);
 }
コード例 #2
0
        public override bool AddItem(Item newItem)
        {
            bool canAddItem = true;

            if (newItem is Armor)
            {
                var newArmor      = (Armor)newItem;
                var equippedArmor = from i in Items where i is Armor select(Armor) i;

                if (equippedArmor.Any(a => a.Slot == newArmor.Slot))
                {
                    canAddItem = false;
                    Console.WriteLine($"{Name} already has {newArmor.Slot} armor equipped.");
                }
                if (newArmor.Material != Caste.ArmorProficiency)
                {
                    canAddItem = false;
                    Console.WriteLine($"{Name} cannot wear {newArmor.Name} because it is {newArmor.Material}. A {Caste.Name} can only wear {Caste.ArmorProficiency} armor.");
                }
            }
            if (newItem is Weapon)
            {
                var newWeapon   = (Weapon)newItem;
                var heldWeapons = from i in Items where i is Weapon select(Weapon) i;

                if (heldWeapons.Any(w => w.TwoHanded) || heldWeapons.Where(w => !w.TwoHanded).Count() >= 2)
                {
                    canAddItem = false;
                    Console.WriteLine($"{Name} cannot hold any more weapons.");
                }
                if (!Caste.WeaponProficiency.Contains(newWeapon.Type))
                {
                    canAddItem = false;
                    Console.WriteLine($"{Name} cannot use {newWeapon.Name} because {Pronouns[0].ToLower()} is a {Caste.Name}.");
                }
            }
            if (_currentWeightCarried + newItem.Weight > _maxCarryWeight)
            {
                canAddItem = false;
                Console.WriteLine($"{newItem.Name} is too heavy for {Name} to carry.");
            }

            if (canAddItem)
            {
                Items.Add(newItem);
                AbilityScores.AddMods(AbilityScores.ItemMods, newItem.AbilityMods);
            }

            return(canAddItem);
        }