using System; using System.Collections.Generic; using UnityEngine; public static class RequirementHandler { // Container for player information, specifically stats and inventory information private static PlayerHandler playerHandlerInfo; private static Entity componentInfo; private static bool isOutOfCreation; /// <summary> /// Sets the private player info to the passed player object /// </summary> /// <param name="player">Player Information, also contains the inventory information</param> public static void SetPlayerInformation(PlayerHandler player, bool isFinalChoice = false) { playerHandlerInfo = player; if (isFinalChoice) isOutOfCreation = true; } public static void SetEntityInformaiton(Entity entity) => componentInfo = entity; /// <summary> /// Hub handler for checking what the object passed is before checking the /// respective object's requirements through a specific check handler /// </summary> /// <param name="aspectRef">The object to be checked</param> /// <returns>The object along with an indicator if the requirements were met or not</returns> /// <exception cref="NullReferenceException">If the object is null</exception> /// <exception cref="ArgumentException">If the object does not show to be one of the necessary Scriptable Objects</exception> public static (object, bool) DetermineObjectEligibility(object aspectRef) { if (aspectRef is null) throw new NullReferenceException("Object call in DetermineObjectEligibility shows null."); // Indicator output bool isEligible; // Checks for the necessary Scriptable Object before calling the necessary // requirement handler if (aspectRef is WeaponSO) isEligible = WeaponObjectReqCheck(aspectRef as WeaponSO); else if (aspectRef is ApparelSO) isEligible = ApparelObjectReqCheck(aspectRef as ApparelSO); else if (aspectRef is ItemSO) isEligible = ItemObjectReqCheck(aspectRef as ItemSO); else if (aspectRef is SpellSO) isEligible = SpellObjectReqCheck(aspectRef as SpellSO); else if (aspectRef is AbilitySO ability) { isEligible = AbilityObjectReqCheck(ability); // These switches indicate if the ability has a setting turned on to NOT be available // with the requirements searched if (ability.RequirementsEntityCantHave) isEligible = !isEligible; } else throw new ArgumentException("Object is unknown... stopping handling."); return (aspectRef, isEligible); } public static (object, bool) DetermineSpawnedAspectEligibility(object aspectRef) { if (aspectRef is null) throw new NullReferenceException("Object call in DetermineSpawnedAspectEligibility shows null."); bool isEligible; if (aspectRef is Weapon weapon) isEligible = WeaponAspectReqCheck(weapon); else if (aspectRef is Apparel apparel) isEligible = ApparelAspectReqCheck(apparel); else if (aspectRef is Item item) isEligible = ItemAspectReqCheck(item); else if (aspectRef is Spell spell) isEligible = SpellAspectReqCheck(spell); else if (aspectRef is Ability ability) { isEligible = AbilityAspectReqCheck(ability); if (ability.HasRequirementsInverted) isEligible = !isEligible; } else throw new ArgumentException("Object is unknown... stopping handling."); return (aspectRef, isEligible); } /// <summary> /// Checks requirements for an Weapon Scriptable Object and if they are met based /// on the player information within the handler /// </summary> /// <param name="weaponObjectRef">The Weapon Scriptable Object to be checked</param> /// <returns>True if all of the requirements are met, false if not</returns> private static bool WeaponObjectReqCheck(WeaponSO weaponObjectRef) { bool output = false; WeaponSO.Type weaponType = weaponObjectRef.Weapon_Type; Player.PlayerType playerClass = playerHandlerInfo.PlayersType; // Check for if the player's class is Gunslinger and the weapon type must be a firearm type to continue if (weaponType is not WeaponSO.Type.Firearm && playerClass is Player.PlayerType.Gunslinger) return output; // Check for if the player's class is Berserker and the weapon type must be a blunt or sharp type to continue else if (!(weaponType is WeaponSO.Type.Blunt || weaponType is WeaponSO.Type.Sharp) && playerClass is Player.PlayerType.Berserker) return output; // Simply returns true if no requirement is necessary if (!weaponObjectRef.Has_Requirement) output = true; // Otherwise, requirement conditions are filtered else { // Seconadry Trigger acts as a filter for if one of the requirements in a group are not met // simply breaks the rest of the loop to indicate that all of the requirements are not met bool secondaryTrigger = true; foreach (ItemSO.PossReqs requirement in weaponObjectRef.Requirements) { switch (requirement) { case ItemSO.PossReqs.Stats: // Primary Stats Requirements { secondaryTrigger = FilterStats(weaponObjectRef.Stats_List); break; } case ItemSO.PossReqs.Sec_Stats: // Secondary Stats Requirements { secondaryTrigger = FilterSecStats(weaponObjectRef.Sec_Stats_List); break; } case ItemSO.PossReqs.Item: // Item Requirements { secondaryTrigger = FilterSpecificItemReqs(weaponObjectRef.Item_List); break; } } if (!secondaryTrigger) break; } if (secondaryTrigger) output = true; } return output; } private static bool WeaponAspectReqCheck(Weapon weaponAspectRef) { bool output = false; WeaponSO.Type weaponType = weaponAspectRef.WeaponType; Player.PlayerType playerClass = componentInfo is Player player ? player.GetPlayerType() : Player.PlayerType.IsAlly; if (weaponType is not WeaponSO.Type.Firearm && playerClass is Player.PlayerType.Gunslinger) return output; else if (!(weaponType is WeaponSO.Type.Blunt || weaponType is WeaponSO.Type.Sharp) && playerClass is Player.PlayerType.Berserker) return output; if (!weaponAspectRef.HasRequirements) output = true; else { bool secondaryTrigger = true; foreach (ItemSO.PossReqs requirement in weaponAspectRef.Requirements) { switch (requirement) { case ItemSO.PossReqs.Stats: secondaryTrigger = FilterStats(weaponAspectRef.statListReqs); break; case ItemSO.PossReqs.Sec_Stats: secondaryTrigger = FilterSecStats(weaponAspectRef.secStatListReqs); break; case ItemSO.PossReqs.Item: secondaryTrigger = FilterSpecificItemReqs(weaponAspectRef.reqItemNames); break; } if (!secondaryTrigger) break; } if (secondaryTrigger) output = true; } return output; } /// <summary> /// Checks requirements for an Apparel Scriptable Object and if they are met based /// on the player information within the handler /// </summary> /// <param name="apparelObjectRef">The Apparel Scriptable Object to be checked</param> /// <returns>True if all of the requirements are met, false if not</returns> private static bool ApparelObjectReqCheck(ApparelSO apparelObjectRef) { bool output = false; // Simply returns true if no requirement is necessary if (!apparelObjectRef.Has_Requirement) output = true; // Otherwise, requirement conditions are filtered else { // Seconadry Trigger acts as a filter for if one of the requirements in a group are not met // simply breaks the rest of the loop to indicate that all of the requirements are not met bool secondaryTrigger = true; foreach (ItemSO.PossReqs requirement in apparelObjectRef.Requirements) { switch (requirement) { case ItemSO.PossReqs.Stats: // Primary Stats Requirements { secondaryTrigger = FilterStats(apparelObjectRef.Stats_List); break; } case ItemSO.PossReqs.Sec_Stats: // Secondary Stats Requirements { secondaryTrigger = FilterSecStats(apparelObjectRef.Sec_Stats_List); break; } case ItemSO.PossReqs.Item: // Item Requirements { secondaryTrigger = FilterSpecificItemReqs(apparelObjectRef.Item_List); break; } } if (!secondaryTrigger) break; } if (secondaryTrigger) output = true; } return output; } private static bool ApparelAspectReqCheck(Apparel apparelAspectRef) { bool output = false; if (!apparelAspectRef.HasRequirements) output = true; else { bool secondaryTrigger = true; foreach (ItemSO.PossReqs requirement in apparelAspectRef.Requirements) { switch (requirement) { case ItemSO.PossReqs.Stats: // Primary Stats Requirements { secondaryTrigger = FilterStats(apparelAspectRef.statListReqs); break; } case ItemSO.PossReqs.Sec_Stats: // Secondary Stats Requirements { secondaryTrigger = FilterSecStats(apparelAspectRef.secStatListReqs); break; } case ItemSO.PossReqs.Item: // Item Requirements { secondaryTrigger = FilterSpecificItemReqs(apparelAspectRef.reqItemNames); break; } } if (!secondaryTrigger) break; } if (secondaryTrigger) output = true; } return output; } /// <summary> /// Checks requirements for an Item Scriptable Object and if they are met based /// on the player information within the handler /// </summary> /// <param name="itemObjectRef">The Item Scriptable Object to be checked</param> /// <returns>True if all of the requirements are met, false if not</returns> private static bool ItemObjectReqCheck(ItemSO itemObjectRef) { bool output = false; // Simply returns true if no requirement is necessary if (!itemObjectRef.Has_Requirement) output = true; // Otherwise, requirement conditions are filtered else { // Seconadry Trigger acts as a filter for if one of the requirements in a group are not met // simply breaks the rest of the loop to indicate that all of the requirements are not met bool secondaryTrigger = true; foreach (ItemSO.PossReqs requirement in itemObjectRef.Requirements) { switch (requirement) { case ItemSO.PossReqs.Stats: // Primary Stats Requirements { secondaryTrigger = FilterStats(itemObjectRef.Stats_List); break; } case ItemSO.PossReqs.Sec_Stats: // Seconadry Stats Requirements { secondaryTrigger = FilterSecStats(itemObjectRef.Sec_Stats_List); break; } case ItemSO.PossReqs.Item: // Item Requirements { secondaryTrigger = FilterSpecificItemReqs(itemObjectRef.Item_List); break; } } if (!secondaryTrigger) break; } if (secondaryTrigger) output = true; } return output; } private static bool ItemAspectReqCheck(Item itemAspectRef) { bool output = false; if (!itemAspectRef.HasRequirements) output = true; else { bool secondaryTrigger = true; foreach (ItemSO.PossReqs requirement in itemAspectRef.Requirements) { switch (requirement) { case ItemSO.PossReqs.Stats: // Primary Stats Requirements { secondaryTrigger = FilterStats(itemAspectRef.statListReqs); break; } case ItemSO.PossReqs.Sec_Stats: // Seconadry Stats Requirements { secondaryTrigger = FilterSecStats(itemAspectRef.secStatListReqs); break; } case ItemSO.PossReqs.Item: // Item Requirements { secondaryTrigger = FilterSpecificItemReqs(itemAspectRef.reqItemNames); break; } } if (!secondaryTrigger) break; } if (secondaryTrigger) output = true; } return output; } /// <summary> /// Checks requirements for a Spell Scriptable Object and if they are met based /// on the player information within the handler /// </summary> /// <param name="spellObjectRef">The Spell Scriptable Object to be checked</param> /// <returns>True if all of the requirements are met, false if not</returns> private static bool SpellObjectReqCheck(SpellSO spellObjectRef) { bool output = false; // Simply returns true if no requirement is necessary if (!spellObjectRef.Has_Requirement) output = true; // Otherwise, requirement conditions are filtered else { // Seconadry Trigger acts as a filter for if one of the requirements in a group are not met // simply breaks the rest of the loop to indicate that all of the requirements are not met bool secondaryTrigger = true; foreach (SpellSO.PossReqs req in spellObjectRef.Requirements) { switch (req) { case SpellSO.PossReqs.Stats: // Primary Stats Requirements { secondaryTrigger = FilterStats(spellObjectRef.Stats_List); break; } case SpellSO.PossReqs.Sec_Stats: // Seconadry Stats Requirements { secondaryTrigger = FilterSecStats(spellObjectRef.Sec_Stats_List); break; } case SpellSO.PossReqs.Item: // Item Requirements { if (spellObjectRef.Requires_Specific) // Specific Item Requirements { secondaryTrigger = FilterSpecificItemReqs(spellObjectRef.Item_List); if (!secondaryTrigger) break; } if (spellObjectRef.Requires_WType) // Specific Weapon Type Requirement { secondaryTrigger = FilterWeaponItemTypeReqs(spellObjectRef.W_Type); if (!secondaryTrigger) break; } if (spellObjectRef.Requires_AType) // Specific Apparel Type Requirement { secondaryTrigger = FilterApparelItemTypeReqs(spellObjectRef.A_Type); if (!secondaryTrigger) break; } break; } case SpellSO.PossReqs.Ability: // Ability Requirements { secondaryTrigger = FilterAbilityReqs(spellObjectRef.Ability_List); break; } } if (!secondaryTrigger) break; } if (secondaryTrigger) output = true; } return output; } private static bool SpellAspectReqCheck(Spell spellAspectRef) { bool output = false; // Simply returns true if no requirement is necessary if (!spellAspectRef.HasRequirements) output = true; // Otherwise, requirement conditions are filtered else { // Seconadry Trigger acts as a filter for if one of the requirements in a group are not met // simply breaks the rest of the loop to indicate that all of the requirements are not met bool secondaryTrigger = true; foreach (SpellSO.PossReqs req in spellAspectRef.Requirements) { switch (req) { case SpellSO.PossReqs.Stats: // Primary Stats Requirements { secondaryTrigger = FilterStats(spellAspectRef.reqStatList); break; } case SpellSO.PossReqs.Sec_Stats: // Seconadry Stats Requirements { secondaryTrigger = FilterSecStats(spellAspectRef.reqSecStatList); break; } case SpellSO.PossReqs.Item: // Item Requirements { if (spellAspectRef.requiresSpecific) // Specific Item Requirements { secondaryTrigger = FilterSpecificItemReqs(spellAspectRef.reqItems); if (!secondaryTrigger) break; } if (spellAspectRef.requiresWeaponType) // Specific Weapon Type Requirement { secondaryTrigger = FilterWeaponItemTypeReqs(spellAspectRef.weaponType); if (!secondaryTrigger) break; } if (spellAspectRef.requiresApparelType) // Specific Apparel Type Requirement { secondaryTrigger = FilterApparelItemTypeReqs(spellAspectRef.apparelType); if (!secondaryTrigger) break; } break; } case SpellSO.PossReqs.Ability: // Ability Requirements { secondaryTrigger = FilterAbilityReqs(spellAspectRef.reqAbilities); break; } } if (!secondaryTrigger) break; } if (secondaryTrigger) output = true; } return output; } /// <summary> /// Checks requirements for an Ability Scriptable Object and if they are met based /// on the player information within the handler /// </summary> /// <param name="abilityObjectRef">The Ability Scriptable Object to be checked</param> /// <returns>True if all of the requirements are met, false if not</returns> private static bool AbilityObjectReqCheck(AbilitySO abilityObjectRef) { bool output = false; // Simply returns true if no requirement is necessary if (!abilityObjectRef.Has_Requirement) output = true; // Otherwise, requirement conditions are filtered else { // Seconadry Trigger acts as a filter for if one of the requirements in a group are not met // simply breaks the rest of the loop to indicate that all of the requirements are not met bool secondaryTrigger = true; foreach (AbilitySO.PossReqs req in abilityObjectRef.Requirements) { switch (req) { case AbilitySO.PossReqs.Stats: // Primary Stats Requirements { secondaryTrigger = FilterStats(abilityObjectRef.Stats_List); break; } case AbilitySO.PossReqs.Sec_Stats: // Seconadry Stats Requirements { secondaryTrigger = FilterSecStats(abilityObjectRef.Sec_Stats_List); break; } case AbilitySO.PossReqs.Item: // Item Requirements { if (abilityObjectRef.Requires_Specific) // Specific Item Requirements { secondaryTrigger = FilterSpecificItemReqs(abilityObjectRef.Item_List); if (!secondaryTrigger) break; } if (abilityObjectRef.Requires_WType) // Specific Weapon Type Requirement { secondaryTrigger = FilterWeaponItemTypeReqs(abilityObjectRef.W_Type); if (!secondaryTrigger) break; } if (abilityObjectRef.Requires_AType) // Specific Apparel Type Requirement { secondaryTrigger = FilterApparelItemTypeReqs(abilityObjectRef.A_Type); if (!secondaryTrigger) break; } break; } case AbilitySO.PossReqs.Ability: // Ability Requirements { secondaryTrigger = FilterAbilityReqs(abilityObjectRef.Ability_List); break; } } if (!secondaryTrigger) break; } if (secondaryTrigger) output = true; } return output; } private static bool AbilityAspectReqCheck(Ability abilityAspectRef) { bool output = false; // Simply returns true if no requirement is necessary if (!abilityAspectRef.HasRequirements) output = true; // Otherwise, requirement conditions are filtered else { // Seconadry Trigger acts as a filter for if one of the requirements in a group are not met // simply breaks the rest of the loop to indicate that all of the requirements are not met bool secondaryTrigger = true; foreach (AbilitySO.PossReqs req in abilityAspectRef.Requirements) { switch (req) { case AbilitySO.PossReqs.Stats: // Primary Stats Requirements { secondaryTrigger = FilterStats(abilityAspectRef.statReqs); break; } case AbilitySO.PossReqs.Sec_Stats: // Seconadry Stats Requirements { secondaryTrigger = FilterSecStats(abilityAspectRef.secStatReqs); break; } case AbilitySO.PossReqs.Item: // Item Requirements { if (abilityAspectRef.requiresSpecificItem) // Specific Item Requirements { secondaryTrigger = FilterSpecificItemReqs(abilityAspectRef.reqItems); if (!secondaryTrigger) break; } if (abilityAspectRef.requiresWeaponType) // Specific Weapon Type Requirement { secondaryTrigger = FilterWeaponItemTypeReqs(abilityAspectRef.weaponType); if (!secondaryTrigger) break; } if (abilityAspectRef.requiresApparelType) // Specific Apparel Type Requirement { secondaryTrigger = FilterApparelItemTypeReqs(abilityAspectRef.apparelType); if (!secondaryTrigger) break; } break; } case AbilitySO.PossReqs.Ability: // Ability Requirements { secondaryTrigger = FilterAbilityReqs(abilityAspectRef.reqAbilities); break; } } if (!secondaryTrigger) break; } if (secondaryTrigger) output = true; } return output; } /// <summary> /// Searches through all of the apparel in the player's inventory for the type that /// is required, i.e. passed through as parameter /// </summary> /// <param name="type">The apparel type required from the player's inventory</param> /// <returns>True if the type was found, false if not</returns> private static bool FilterApparelItemTypeReqs(ApparelSO.Type type) { bool output = false; // Checks if the player's inventory has the apparel type necessary foreach (var apparel in playerHandlerInfo.PlayerInven.Apparel) { if (apparel.Key.ApparelType == type) { output = true; break; } } return output; } /// <summary> /// Checks for the necessary weapon type within the player's inventory /// </summary> /// <param name="type">The weapon type required in the player's inventory</param> /// <returns>True if the type was found, false if not</returns> private static bool FilterWeaponItemTypeReqs(WeaponSO.Type type) { bool output = false; // Checks if the player's inventory has the weapon type necessary foreach (var weapon in playerHandlerInfo.PlayerInven.Weapons) { if (weapon.Key.WeaponType == type) { output = true; break; } } return output; } /// <summary> /// Searches for the specific item within player's inventory by name /// </summary> /// <param name="conRef">The list of item names that need to be found</param> /// <returns>True if all of the names were found, false if at least one was not found</returns> private static bool FilterSpecificItemReqs(List<string> conRef) { bool output = true; // Retrieves all of the items from the player's inventory Dictionary<Item, int> itemList = playerHandlerInfo.PlayerInven.GetAllItems(); foreach (string item_Name in conRef) { bool foundItem = false; // Filters through each of the items in the player's inventory until the name is found foreach (KeyValuePair<Item, int> item in itemList) { if (item.Key.ItemName == item_Name) { foundItem = true; break; } } // If the required name was not found then the output is set to false and the primary loop is broken if (!foundItem) { output = false; break; } } return output; } /// <summary> /// Checks an aspect's secondary stats, i.e. health, mana, etc. to see if the requirements /// are met for the aspect in question /// </summary> /// <param name="statReqList">The list from an aspect</param> /// <returns>True if all the requirements are met, false if not</returns> private static bool FilterSecStats(List<Vector3Int> statReqList) { bool output = true; foreach (Vector3Int statRequirement in statReqList) { // If the stat's requirement is lower than or equal to a value if (statRequirement.z < 0) { switch (statRequirement.x) { case 0: // HP { if (isOutOfCreation) { if (statRequirement.y < componentInfo.RetrieveMaxHealth()) output = false; } else { if (statRequirement.y < playerHandlerInfo.MaxHealth) output = false; } break; } case 1: // MP { if (isOutOfCreation) { if (statRequirement.y < componentInfo.RetrieveMaxMana()) output = false; } else { if (statRequirement.y < playerHandlerInfo.MaxMana) output = false; } break; } case 2: // ARMOR { if (isOutOfCreation) { if (statRequirement.y < componentInfo.RetrieveArmor()) output = false; } else { if (statRequirement.y < playerHandlerInfo.Armor) output = false; } break; } } // Breaks out of the loop to save time if one of the reqs shows false if (!output) break; } // If the stat's value is greater than or equal to a value else { switch (statRequirement.x) { case 0: // HP { if (isOutOfCreation) { if (statRequirement.y > componentInfo.RetrieveMaxHealth()) output = false; } else { if (statRequirement.y > playerHandlerInfo.MaxHealth) output = false; } break; } case 1: // MP { if (isOutOfCreation) { if (statRequirement.y > componentInfo.RetrieveMaxMana()) output = false; } else { if (statRequirement.y > playerHandlerInfo.MaxMana) output = false; } break; } case 2: // ARMOR { if (isOutOfCreation) { if (statRequirement.y > componentInfo.RetrieveArmor()) output = false; } else { if (statRequirement.y > playerHandlerInfo.Armor) output = false; } break; } } // Breaks out of the loop to save time if one of the reqs shows false if (!output) break; } } return output; } /// <summary> /// Checks an aspect's stat list to see if the current player info matches with the /// necessary requirements of the aspect in question /// </summary> /// <param name="statReqList">List from an aspect</param> /// <returns>True if all of the stat requirements are met, false if a stat requirement is not met</returns> private static bool FilterStats(List<Vector3Int> statReqList) { bool output = true; // Checks each of the stat requirements within the list if Stat reqs are shown to be necessary foreach (Vector3Int statReqirement in statReqList) { // Checks if the stat value necessary is above the value necessary for the object if (statReqirement.z < 0) { switch (statReqirement.x) { case 0: // STR { if (isOutOfCreation) { if (statReqirement.y < componentInfo.GatherStats().GetBaseStat(EntityStats.Stat.Strength)) output = false; } else { if (statReqirement.y < playerHandlerInfo.Strength) output = false; } break; } case 1: // INT { if (isOutOfCreation) { if (statReqirement.y < componentInfo.GatherStats().GetBaseStat(EntityStats.Stat.Intelligence)) output = false; } else { if (statReqirement.y < playerHandlerInfo.Intelligence) output = false; } break; } case 2: // CON { if (isOutOfCreation) { if (statReqirement.y < componentInfo.GatherStats().GetBaseStat(EntityStats.Stat.Constitution)) output = false; } else { if (statReqirement.y < playerHandlerInfo.Constitution) output = false; } break; } case 3: // DEX { if (isOutOfCreation) { if (statReqirement.y < componentInfo.GatherStats().GetBaseStat(EntityStats.Stat.Dexterity)) output = false; } else { if (statReqirement.y < playerHandlerInfo.Dexterity) output = false; } break; } case 4: // CHA { if (isOutOfCreation) { if (statReqirement.y < componentInfo.GatherStats().GetBaseStat(EntityStats.Stat.Charisma)) output = false; } else { if (statReqirement.y < playerHandlerInfo.Charisma) output = false; } break; } case 5: // WIS { if (isOutOfCreation) { if (statReqirement.y < componentInfo.GatherStats().GetBaseStat(EntityStats.Stat.Wisdom)) output = false; } else { if (statReqirement.y < playerHandlerInfo.Wisdom) output = false; } break; } case 6: // LCK { if (isOutOfCreation) { if (statReqirement.y < componentInfo.GatherStats().GetBaseStat(EntityStats.Stat.Luck)) output = false; } else { if (statReqirement.y < playerHandlerInfo.Luck) output = false; } break; } } // Breaks out of the loop to save time if one of the reqs shows false if (!output) break; } // Checks if the stat value necessary is below the necessary value for the object else { switch (statReqirement.x) { case 0: // STR { if (isOutOfCreation) { if (statReqirement.y > componentInfo.GatherStats().GetBaseStat(EntityStats.Stat.Strength)) output = false; } else { if (statReqirement.y > playerHandlerInfo.Strength) output = false; } break; } case 1: // INT { if (isOutOfCreation) { if (statReqirement.y > componentInfo.GatherStats().GetBaseStat(EntityStats.Stat.Intelligence)) output = false; } else { if (statReqirement.y > playerHandlerInfo.Intelligence) output = false; } break; } case 2: // CON { if (isOutOfCreation) { if (statReqirement.y > componentInfo.GatherStats().GetBaseStat(EntityStats.Stat.Constitution)) output = false; } else { if (statReqirement.y > playerHandlerInfo.Constitution) output = false; } break; } case 3: // DEX { if (isOutOfCreation) { if (statReqirement.y > componentInfo.GatherStats().GetBaseStat(EntityStats.Stat.Dexterity)) output = false; } else { if (statReqirement.y > playerHandlerInfo.Dexterity) output = false; } break; } case 4: // CHA { if (isOutOfCreation) { if (statReqirement.y > componentInfo.GatherStats().GetBaseStat(EntityStats.Stat.Charisma)) output = false; } else { if (statReqirement.y > playerHandlerInfo.Charisma) output = false; } break; } case 5: // WIS { if (isOutOfCreation) { if (statReqirement.y > componentInfo.GatherStats().GetBaseStat(EntityStats.Stat.Wisdom)) output = false; } else { if (statReqirement.y > playerHandlerInfo.Wisdom) output = false; } break; } case 6: // LCK { if (isOutOfCreation) { if (statReqirement.y > componentInfo.GatherStats().GetBaseStat(EntityStats.Stat.Luck)) output = false; } else { if (statReqirement.y > playerHandlerInfo.Luck) output = false; } break; } } // Breaks out of the loop to save time if one of the reqs shows false if (!output) break; } } return output; } /// <summary> /// Checks the user's inventory ability list to make sure that the ability requirements /// are met for the aspect that is indicated /// </summary> /// <param name="abilityList">List of ability names</param> /// <returns>True if all the abilities are in the player's inventory, false if otherwise</returns> private static bool FilterAbilityReqs(List<string> abilityList) { bool output = true; foreach (string ability in abilityList) { bool foundAbility = false; if (isOutOfCreation) { List<Ability> abList = new List<Ability>(componentInfo.GetInventory().Abilities); abList.AddRange(componentInfo.GetInventory().limitedAbilities); foreach (Ability aspect in abList) { if (aspect.AbilityName == ability) foundAbility = true; } } else { foreach (Ability aspect in playerHandlerInfo.PlayerInven.Abilities) { if (aspect.AbilityName == ability) foundAbility = true; } } if (!foundAbility) { output = false; break; } } return output; } }