//Returns the total armour stat of the entity based on base armour + armour internal int GetArmour() { int ar = Stats[BaseArmour]; if (!Equiptory.ContainsKey("Armour")) { return(ar); } if (Equiptory["Armour"].ToList().Exists(x => x != null)) { foreach (Armour arm in Equiptory["Armour"].ToList().FindAll(x => x != null)) { ar += arm.Get("armourModifier"); } } return(ar); }
//Returns the total defence stat of the entity based on armour internal int GetDefence() { int def = 0; if (!Equiptory.ContainsKey("Armour")) { return(def); } if (Equiptory["Armour"].ToList().Exists(x => x != null)) { foreach (Armour arm in Equiptory["Armour"].ToList().FindAll(x => x != null)) { def += arm.Get("defenceModifier"); } } return(def); }
//Gets a list of all equipped weapons, defaulting to fists if there are none. internal List <Weapon> GetEquippedWeapons() { var tempList = new List <Weapon>() { Fist }; if (!Equiptory.ContainsKey("Weapon")) { return(tempList); } foreach (Weapon currWeapon in Equiptory["Weapon"]) { if (currWeapon != null) { tempList.Add(currWeapon); } } return(tempList); }
//Returns the damager of all weapons (Misleading as you cannot always use them all in combat) internal int GetDamage() { List <Weapon> alreadyCounted = new List <Weapon>(); //This list stores items as they are read, to stop multi-slot-filling items from being included more than once int dam = 1; if (!Equiptory.ContainsKey("Weapon")) { return(dam); } if (Equiptory["Weapon"].ToList().Exists(x => x != null)) { foreach (Weapon weap in Equiptory["Weapon"].ToList().FindAll(x => x != null)) { if (!alreadyCounted.Contains(weap)) { dam += weap.Get("damageModifier"); alreadyCounted.Add(weap); } } } return(dam); }
//Gets the minimum range of all items equipped by the entity. If this is larger than 1, an entity defaults to fists at range 1 internal int GetMinRange() { int temp = 1; if (!Equiptory.ContainsKey("Weapon")) { return(1); } foreach (Item weapon in Equiptory["Weapon"]) { if (weapon == null) { continue; } int range = int.Parse(weapon.itemData["minRange"]); if (range > temp) { temp = range; } } return(temp); }
//Unequip an item by the item itself public bool UnequipByItem(Item item) { #region Escape conditions if (!Inventory.inventData.Exists(x => x == item)) { WriteLine("Item not found!"); return(false); } if (item.Equipped == false) { WriteLine("That item is not currently equipped!"); return(false); } string itemType = item.GetType().Name; if (!Equiptory.ContainsKey(itemType)) { WriteLine("That shouldn't be equippable! Naughty."); item.Equipped = false; return(true); } #endregion int slotsRequired = 1; if (itemType == "Weapon") { slotsRequired = (item as Weapon).slotsRequired; //Note that only weapons can currently require multiple slots } if (Equiptory[itemType].ToList().FindAll(x => x == item).Count < slotsRequired) //If the item is somehow equipped despite lacking the slots for it { WriteLine("That shouldn't be equippable! Naughty."); //Remove the item from the slots and mark it as unequipped. for (int j = 0; j < slotsRequired; j++) { for (int i = 0; i < Equiptory[itemType].Length; i++) { if (Equiptory[item.GetType().Name][i] == item) { Equiptory[item.GetType().Name][i] = null; break; // } } } item.Equipped = false; return(true); //Returns the unequip as successful } item.Equipped = false; //Mark the item as unequipped for (int j = 0; j < slotsRequired; j++) //Remove the item from the slots { for (int i = 0; i < Equiptory[item.GetType().Name].Length; i++) { if (Equiptory[item.GetType().Name][i] == item) { Equiptory[item.GetType().Name][i] = null; break; // } } } return(true); //Return the unequip as successful }