public Requirement GetRequirement(string name, string requirement) { this.logger.LogInformation($"Processing requirement {name} : {requirement}"); var requirementText = requirement; if (requirement.Contains(">") || requirement.Contains("<")) { return(GetValueBasedRequirement(name, requirement)); } if (requirement.Contains("npcID:")) { return(CreateNpcRequirement(requirement)); } if (requirement.Contains("BagItem:")) { return(CreateBagItemRequirement(requirement)); } if (requirement.Contains("SpellInRange:")) { return(CreateSpellInRangeRequirement(requirement)); } if (BuffDictionary.Count == 0) { BuffDictionary = new Dictionary <string, Func <bool> > { // Range { "InMeleeRange", () => playerReader.IsInMeleeRange }, { "InDeadZoneRange", () => playerReader.IsInDeadZone }, { "OutOfCombatRange", () => !playerReader.WithInCombatRange }, { "InCombatRange", () => playerReader.WithInCombatRange }, { "InFireblastRange", () => playerReader.SpellInRange.Mage_Fireblast }, // Pet { "Has Pet", () => playerReader.PlayerBitValues.HasPet }, { "Pet Happy", () => playerReader.PlayerBitValues.PetHappy }, // Auto Spell { "AutoAttacking", () => playerReader.IsAutoAttacking }, { "Shooting", () => playerReader.IsShooting }, // Temporary Enchants { "HasMainHandEnchant", () => playerReader.PlayerBitValues.MainHandEnchant_Active }, { "HasOffHandEnchant", () => playerReader.PlayerBitValues.OffHandEnchant_Active }, // Equipment - Bag { "Items Broken", () => playerReader.PlayerBitValues.ItemsAreBroken }, { "BagFull", () => bagReader.BagsFull }, { "HasRangedWeapon", () => equipmentReader.HasRanged() }, { "HasAmmo", () => playerReader.PlayerBitValues.HasAmmo }, // General Buff Condition { "Eating", () => playerReader.Buffs.Eating }, { "Drinking", () => playerReader.Buffs.Drinking }, { "Mana Regeneration", () => playerReader.Buffs.ManaRegeneration }, { "Well Fed", () => playerReader.Buffs.WellFed }, //Priest { "Fortitude", () => playerReader.Buffs.Fortitude }, { "InnerFire", () => playerReader.Buffs.InnerFire }, { "Divine Spirit", () => playerReader.Buffs.DivineSpirit }, { "Renew", () => playerReader.Buffs.Renew }, { "Shield", () => playerReader.Buffs.Shield }, // Druid { "Mark of the Wild", () => playerReader.Buffs.MarkOfTheWild }, { "Thorns", () => playerReader.Buffs.Thorns }, { "TigersFury", () => playerReader.Buffs.TigersFury }, // Paladin { "Seal", () => playerReader.Buffs.Seal }, { "Aura", () => playerReader.Buffs.Aura }, { "Devotion Aura", () => playerReader.Buffs.Aura }, { "Blessing", () => playerReader.Buffs.Blessing }, { "Blessing of Might", () => playerReader.Buffs.Blessing }, // Mage { "Frost Armor", () => playerReader.Buffs.FrostArmor }, { "Arcane Intellect", () => playerReader.Buffs.ArcaneIntellect }, { "Ice Barrier", () => playerReader.Buffs.IceBarrier }, { "Ward", () => playerReader.Buffs.Ward }, { "Fire Power", () => playerReader.Buffs.FirePower }, { "Slice And Dice", () => playerReader.Buffs.SliceAndDice }, { "Battle Shout", () => playerReader.Buffs.BattleShout }, // Warlock { "Demon Skin", () => playerReader.Buffs.Demon }, { "Demon Armor", () => playerReader.Buffs.Demon }, { "Soul Link", () => playerReader.Buffs.SoulLink }, { "Soulstone Resurrection", () => playerReader.Buffs.SoulstoneResurrection }, { "Shadow Trance", () => playerReader.Buffs.ShadowTrance }, // Shaman { "Lightning Shield", () => playerReader.Buffs.LightningShield }, //Hunter { "Aspect of the Cheetah", () => playerReader.Buffs.Aspect }, { "Aspect of the Pack", () => playerReader.Buffs.Aspect }, { "Aspect of the Beast", () => playerReader.Buffs.Aspect }, { "Aspect of the Hawk", () => playerReader.Buffs.Aspect }, { "Aspect of the Wild", () => playerReader.Buffs.Aspect }, { "Aspect of the Monkey", () => playerReader.Buffs.Aspect }, // Debuff Section // Druid Debuff { "Demoralizing Roar", () => playerReader.Debuffs.Roar }, { "Faerie Fire", () => playerReader.Debuffs.FaerieFire }, { "Rip", () => playerReader.Debuffs.Rip }, // Warrior Debuff { "Rend", () => playerReader.Debuffs.Rend }, // Priest Debuff { "Shadow Word: Pain", () => playerReader.Debuffs.ShadowWordPain }, // Mage Debuff { "Frostbite", () => playerReader.Debuffs.Frostbite }, // Warlock Debuff { "Curse of Weakness", () => playerReader.Debuffs.Curseof }, { "Curse of Elements", () => playerReader.Debuffs.Curseof }, { "Curse of Recklessness", () => playerReader.Debuffs.Curseof }, { "Curse of Shadow", () => playerReader.Debuffs.Curseof }, { "Curse of Agony", () => playerReader.Debuffs.Curseof }, { "Curse of", () => playerReader.Debuffs.Curseof }, { "Corruption", () => playerReader.Debuffs.Corruption }, { "Immolate", () => playerReader.Debuffs.Immolate }, { "Siphon Life", () => playerReader.Debuffs.SiphonLife }, // Hunter Debuff { "Serpent Sting", () => playerReader.Debuffs.SerpentSting }, }; } if (BuffDictionary.Keys.Contains(requirement)) { return(new Requirement { HasRequirement = BuffDictionary[requirement], LogMessage = () => $"{requirementText}" }); } if (requirement.StartsWith("not ")) { requirement = requirement.Substring(4); } if (requirement.StartsWith("!")) { requirement = requirement.Substring(1); } if (BuffDictionary.Keys.Contains(requirement)) { return(new Requirement { HasRequirement = () => !BuffDictionary[requirement](), LogMessage = () => $"{requirementText}" }); } logger.LogInformation($"UNKNOWN REQUIREMENT! {name} - {requirement}: try one of: {string.Join(", ", BuffDictionary.Keys)}"); return(new Requirement { HasRequirement = () => false, LogMessage = () => $"UNKNOWN REQUIREMENT! {requirementText}" }); }
public RequirementFactory(ILogger logger, AddonReader addonReader) { this.logger = logger; this.addonReader = addonReader; this.playerReader = addonReader.PlayerReader; this.bagReader = addonReader.BagReader; this.equipmentReader = addonReader.EquipmentReader; this.spellBookReader = addonReader.SpellBookReader; this.talentReader = addonReader.TalentReader; this.creatureDb = addonReader.CreatureDb; this.itemDb = addonReader.ItemDb; keywordDictionary = new Dictionary <string, Func <string, Requirement> >() { { ">=", GetInclusiveValueBasedRequirement }, { "<=", GetInclusiveValueBasedRequirement }, { ">", GetExcusiveValueBasedRequirement }, { "<", GetExcusiveValueBasedRequirement }, { "==", GetEqualsValueBasedRequirement }, { "npcID:", CreateNpcRequirement }, { "BagItem:", CreateBagItemRequirement }, { "SpellInRange:", CreateSpellInRangeRequirement }, { "TargetCastingSpell", CreateTargetCastingSpellRequirement }, { "Form", CreateFormRequirement }, { "Race", CreateRaceRequirement }, { "Spell", CreateSpellRequirement }, { "Talent", CreateTalentRequirement }, { "Trigger:", CreateTriggerRequirement } }; booleanDictionary = new Dictionary <string, Func <bool> > { // Target Based { "TargetYieldXP", () => playerReader.TargetYieldXP }, // Range { "InMeleeRange", () => playerReader.IsInMeleeRange }, { "InDeadZoneRange", () => playerReader.IsInDeadZone }, { "OutOfCombatRange", () => !playerReader.WithInCombatRange }, { "InCombatRange", () => playerReader.WithInCombatRange }, // Pet { "Has Pet", () => playerReader.Bits.HasPet }, { "Pet Happy", () => playerReader.Bits.PetHappy }, // Auto Spell { "AutoAttacking", () => playerReader.Bits.IsAutoRepeatSpellOn_AutoAttack }, { "Shooting", () => playerReader.Bits.IsAutoRepeatSpellOn_Shoot }, { "AutoShot", () => playerReader.Bits.IsAutoRepeatSpellOn_AutoShot }, // Temporary Enchants { "HasMainHandEnchant", () => playerReader.Bits.MainHandEnchant_Active }, { "HasOffHandEnchant", () => playerReader.Bits.OffHandEnchant_Active }, // Equipment - Bag { "Items Broken", () => playerReader.Bits.ItemsAreBroken }, { "BagFull", () => bagReader.BagsFull }, { "HasRangedWeapon", () => equipmentReader.HasRanged() }, { "HasAmmo", () => playerReader.Bits.HasAmmo }, // General Buff Condition { "Eating", () => playerReader.Buffs.Eating }, { "Drinking", () => playerReader.Buffs.Drinking }, { "Mana Regeneration", () => playerReader.Buffs.ManaRegeneration }, { "Well Fed", () => playerReader.Buffs.WellFed }, { "Clearcasting", () => playerReader.Buffs.Clearcasting }, // Player Affected { "Swimming", () => playerReader.Bits.IsSwimming }, { "Falling", () => playerReader.Bits.IsFalling }, //Priest { "Fortitude", () => playerReader.Buffs.Fortitude }, { "InnerFire", () => playerReader.Buffs.InnerFire }, { "Divine Spirit", () => playerReader.Buffs.DivineSpirit }, { "Renew", () => playerReader.Buffs.Renew }, { "Shield", () => playerReader.Buffs.Shield }, // Druid { "Mark of the Wild", () => playerReader.Buffs.MarkOfTheWild }, { "Thorns", () => playerReader.Buffs.Thorns }, { "TigersFury", () => playerReader.Buffs.TigersFury }, { "Prowl", () => playerReader.Buffs.Prowl }, { "Rejuvenation", () => playerReader.Buffs.Rejuvenation }, { "Regrowth", () => playerReader.Buffs.Regrowth }, // Paladin { "Seal", () => playerReader.Buffs.Seal }, { "Aura", () => playerReader.Buffs.Aura }, { "Devotion Aura", () => playerReader.Buffs.Aura }, { "Blessing", () => playerReader.Buffs.Blessing }, { "Blessing of Might", () => playerReader.Buffs.Blessing }, // Mage { "Frost Armor", () => playerReader.Buffs.FrostArmor }, { "Ice Armor", () => playerReader.Buffs.FrostArmor }, { "Arcane Intellect", () => playerReader.Buffs.ArcaneIntellect }, { "Ice Barrier", () => playerReader.Buffs.IceBarrier }, { "Ward", () => playerReader.Buffs.Ward }, { "Fire Power", () => playerReader.Buffs.FirePower }, { "Mana Shield", () => playerReader.Buffs.ManaShield }, { "Presence of Mind", () => playerReader.Buffs.PresenceOfMind }, { "Arcane Power", () => playerReader.Buffs.ArcanePower }, // Rogue { "Slice and Dice", () => playerReader.Buffs.SliceAndDice }, { "Stealth", () => playerReader.Buffs.Stealth }, // Warrior { "Battle Shout", () => playerReader.Buffs.BattleShout }, // Warlock { "Demon Skin", () => playerReader.Buffs.Demon }, { "Demon Armor", () => playerReader.Buffs.Demon }, { "Soul Link", () => playerReader.Buffs.SoulLink }, { "Soulstone Resurrection", () => playerReader.Buffs.SoulstoneResurrection }, { "Shadow Trance", () => playerReader.Buffs.ShadowTrance }, // Shaman { "Lightning Shield", () => playerReader.Buffs.LightningShield }, { "Water Shield", () => playerReader.Buffs.WaterShield }, { "Shamanistic Focus", () => playerReader.Buffs.ShamanisticFocus }, { "Focused", () => playerReader.Buffs.ShamanisticFocus }, { "Stoneskin", () => playerReader.Buffs.Stoneskin }, //Hunter { "Aspect of the Cheetah", () => playerReader.Buffs.Aspect }, { "Aspect of the Pack", () => playerReader.Buffs.Aspect }, { "Aspect of the Beast", () => playerReader.Buffs.Aspect }, { "Aspect of the Hawk", () => playerReader.Buffs.Aspect }, { "Aspect of the Wild", () => playerReader.Buffs.Aspect }, { "Aspect of the Monkey", () => playerReader.Buffs.Aspect }, { "Rapid Fire", () => playerReader.Buffs.RapidFire }, { "Quick Shots", () => playerReader.Buffs.QuickShots }, // Debuff Section // Druid Debuff { "Demoralizing Roar", () => playerReader.TargetDebuffs.Roar }, { "Faerie Fire", () => playerReader.TargetDebuffs.FaerieFire }, { "Rip", () => playerReader.TargetDebuffs.Rip }, { "Moonfire", () => playerReader.TargetDebuffs.Moonfire }, { "Entangling Roots", () => playerReader.TargetDebuffs.EntanglingRoots }, { "Rake", () => playerReader.TargetDebuffs.Rake }, // Warrior Debuff { "Rend", () => playerReader.TargetDebuffs.Rend }, // Priest Debuff { "Shadow Word: Pain", () => playerReader.TargetDebuffs.ShadowWordPain }, // Mage Debuff { "Frostbite", () => playerReader.TargetDebuffs.Frostbite }, { "Slow", () => playerReader.TargetDebuffs.Slow }, // Warlock Debuff { "Curse of Weakness", () => playerReader.TargetDebuffs.Curseof }, { "Curse of Elements", () => playerReader.TargetDebuffs.Curseof }, { "Curse of Recklessness", () => playerReader.TargetDebuffs.Curseof }, { "Curse of Shadow", () => playerReader.TargetDebuffs.Curseof }, { "Curse of Agony", () => playerReader.TargetDebuffs.Curseof }, { "Curse of", () => playerReader.TargetDebuffs.Curseof }, { "Corruption", () => playerReader.TargetDebuffs.Corruption }, { "Immolate", () => playerReader.TargetDebuffs.Immolate }, { "Siphon Life", () => playerReader.TargetDebuffs.SiphonLife }, // Hunter Debuff { "Serpent Sting", () => playerReader.TargetDebuffs.SerpentSting }, }; valueDictionary = new Dictionary <string, Func <int> > { { "Health%", () => playerReader.HealthPercent }, { "TargetHealth%", () => playerReader.TargetHealthPercentage }, { "PetHealth%", () => playerReader.PetHealthPercentage }, { "Mana%", () => playerReader.ManaPercentage }, { "BagCount", () => bagReader.BagItems.Count }, { "MobCount", () => addonReader.CombatCreatureCount }, { "MinRange", () => playerReader.MinRange }, { "MaxRange", () => playerReader.MaxRange }, { "LastAutoShotMs", () => playerReader.AutoShot.ElapsedMs }, { "LastMainHandMs", () => playerReader.MainHandSwing.ElapsedMs } }; }