private string Replace(string prefix, string s, WoWUnit theunit) { string fnname = "FTWCore.Replace"; MyTimer.Start(fnname); if (theunit != null && theunit.Guid == StyxWoW.Me.Guid) { if (StyxWoW.Me.HasAura("Eclipse (Solar)")) { FTWProps._eclipsedirection = -1; } else if (StyxWoW.Me.HasAura("Eclipse (Lunar)")) { FTWProps._eclipsedirection = 1; } } // Replace aura checks with parenthese (Target.HasMyAura("Bad Aura") > 3) string findstring = string.Format(@"{0}\.(?<action>.*)\(""(?<aura>.*)""\)", prefix); Regex rg = new Regex(findstring); Match match = rg.Match(s); Dictionary <String, Object> d = new Dictionary <String, Object>(); while (match.Success) { if (!d.ContainsKey(match.Value)) { string action = match.Groups["action"].Value; string aura = match.Groups["aura"].Value; int value = 0; if (false) { } else if (action == "Weapon1HasAura") { value = (theunit != null && FTWCoreItems.WeaponEnchant(1) == aura) ? 1 : 0; } else if (action == "Weapon2HasAura") { value = (theunit != null && FTWCoreItems.WeaponEnchant(2) == aura) ? 1 : 0; } else if (action == "AuraExpiring") { value = (theunit != null) ? theunit.AuraExpiring(aura) : 0; } else if (action == "CanCast") { value = (theunit != null && SpellManager.CanCast(aura, theunit)) ? 1 : 0; } else if (action == "ClearBehindMe") { value = (theunit != null && StyxWoW.Me.ClearBehindMe(aura) ? 1 : 0); } else if (action == "HasAura") { value = (theunit != null && theunit.HasAura(aura)) ? 1 : 0; } else if (action == "HasItem") { value = StyxWoW.Me.HasItem(aura) ? 1 : 0; } else if (action == "HasMyAura") { value = (theunit != null && theunit.HasMyAura(aura)) ? 1 : 0; } else if (action == "HasSpell") { value = (StyxWoW.Me.HasSpell(aura)) ? 1 : 0; } else if (action == "HasTotem") { value = FTWCoreStatus.HasTotem(aura) ? 1 : 0; } else if (action == "IsCasting") { value = (theunit != null && theunit.CurrentSpellName() == aura) ? 1 : 0; } else if (action == "ItemOnCooldown") { value = FTWCoreItems.ItemOnCooldown(aura) ? 1 : 0; } else if (action == "MyAuraExpiring") { value = (theunit != null) ? theunit.MyAuraExpiring(aura) : 0; } else if (action == "MyStackCount") { value = (theunit != null) ? theunit.MyStackCount(aura) : 0; } else if (action == "OnCooldown") { value = FTWCoreStatus.OnCooldown(aura) ? 1 : 0; } else if (action == "PartyWithAura") { value = FTWCoreUnits.GetPartyWithAura(aura); } else if (action == "PartyWithHealth") { value = FTWCoreUnits.GetPartyWithHealth(aura); } else if (action == "StackCount") { value = (theunit != null) ? theunit.StackCount(aura) : 0; } else if (action == "NumItems") { value = (theunit != null) ? FTWCoreItems.NumItems(aura) : 0; } else { throw new Exception(string.Format("Unknown action {0}!", action)); } d.Add(match.Value, 0); s = s.Replace(match.Value, value.ToString()); } match = match.NextMatch(); } // Replace simple properties for (int i = 0; i < FTWProps.PropertyNames.Count(); i++) { string propname = FTWProps.PropertyNames[i].Trim(); if (propname.Length > 0) { string search = prefix + "." + propname; if (s.Contains(search)) { s = s.Replace(search, GetProperty(theunit, propname).ToString()); } } } // Stop the timer MyTimer.Stop(fnname); return(s); }
private string Replace(string prefix, string s, WoWUnit theunit) { string fnname = "FTWCore.Replace"; MyTimer.Start(fnname); if (theunit != null && theunit.Guid == StyxWoW.Me.Guid) { if (StyxWoW.Me.HasAura("Eclipse (Solar)")) FTWProps._eclipsedirection = -1; else if (StyxWoW.Me.HasAura("Eclipse (Lunar)")) FTWProps._eclipsedirection = 1; } // Replace aura checks with parenthese (Target.HasMyAura("Bad Aura") > 3) string findstring = string.Format(@"{0}\.(?<action>.*)\(""(?<aura>.*)""\)", prefix); Regex rg = new Regex(findstring); Match match = rg.Match(s); Dictionary<String, Object> d = new Dictionary<String, Object>(); while (match.Success) { if (!d.ContainsKey(match.Value)) { string action = match.Groups["action"].Value; string aura = match.Groups["aura"].Value; int value = 0; if (false) { } else if (action == "Weapon1HasAura") value = (theunit != null && FTWCoreItems.WeaponEnchant(1) == aura) ? 1 : 0; else if (action == "Weapon2HasAura") value = (theunit != null && FTWCoreItems.WeaponEnchant(2) == aura) ? 1 : 0; else if (action == "AuraExpiring") value = (theunit != null) ? theunit.AuraExpiring(aura) : 0; else if (action == "CanCast") value = (theunit != null && SpellManager.CanCast(aura, theunit)) ? 1 : 0; else if (action == "ClearBehindMe") value = (theunit != null && StyxWoW.Me.ClearBehindMe(aura) ? 1 : 0); else if (action == "HasAura") value = (theunit != null && theunit.HasAura(aura)) ? 1 : 0; else if (action == "HasItem") value = StyxWoW.Me.HasItem(aura) ? 1 : 0; else if (action == "HasMyAura") value = (theunit != null && theunit.HasMyAura(aura)) ? 1 : 0; else if (action == "HasSpell") value = (StyxWoW.Me.HasSpell(aura)) ? 1 : 0; else if (action == "HasTotem") value = FTWCoreStatus.HasTotem(aura) ? 1 : 0; else if (action == "IsCasting") value = (theunit != null && theunit.CurrentSpellName() == aura) ? 1 : 0; else if (action == "ItemOnCooldown") value = FTWCoreItems.ItemOnCooldown(aura) ? 1 : 0; else if (action == "MyAuraExpiring") value = (theunit != null) ? theunit.MyAuraExpiring(aura) : 0; else if (action == "MyStackCount") value = (theunit != null) ? theunit.MyStackCount(aura) : 0; else if (action == "OnCooldown") value = FTWCoreStatus.OnCooldown(aura) ? 1 : 0; else if (action == "PartyWithAura") value = FTWCoreUnits.GetPartyWithAura(aura); else if (action == "PartyWithHealth") value = FTWCoreUnits.GetPartyWithHealth(aura); else if (action == "StackCount") value = (theunit != null) ? theunit.StackCount(aura) : 0; else if (action == "NumItems") value = (theunit != null) ? FTWCoreItems.NumItems(aura) : 0; else throw new Exception(string.Format("Unknown action {0}!", action)); d.Add(match.Value, 0); s = s.Replace(match.Value, value.ToString()); } match = match.NextMatch(); } // Replace simple properties for (int i = 0; i < FTWProps.PropertyNames.Count(); i++) { string propname = FTWProps.PropertyNames[i].Trim(); if (propname.Length > 0) { string search = prefix + "." + propname; if (s.Contains(search)) s = s.Replace(search, GetProperty(theunit, propname).ToString()); } } // Stop the timer MyTimer.Stop(fnname); return s; }