Exemple #1
0
        public static bool ReadKey(ILogger logger, KeyAction key)
        {
            if (string.IsNullOrEmpty(key.Key))
            {
                logger.LogError($"You must specify either 'Key' (ConsoleKey value) or 'KeyName' (ConsoleKey enum name) for { key.Name}");
                return(false);
            }

            if (KeyMapping.ContainsKey(key.Key))
            {
                key.ConsoleKey = KeyMapping[key.Key];
            }
            else
            {
                var consoleKey = consoleKeys.FirstOrDefault(k => k.ToString() == key.Key);
                if (consoleKey == 0)
                {
                    logger.LogError($"You must specify a valid 'KeyName' (ConsoleKey enum name) for { key.Name}");
                    return(false);
                }

                key.ConsoleKey = consoleKey;
            }

            return(true);
        }
Exemple #2
0
        private static void CreateConsumableRequirement(string name, KeyAction item)
        {
            if (item.Name == name)
            {
                item.StopBeforeCast    = true;
                item.WhenUsable        = true;
                item.AfterCastWaitBuff = true;

                item.Requirements.Add("not Swimming");
                item.Requirements.Add("not Falling");
            }
        }
Exemple #3
0
        public void InitialiseRequirements(KeyAction item)
        {
            CreateConsumableRequirement("Water", item);
            CreateConsumableRequirement("Food", item);

            item.RequirementObjects.Clear();
            foreach (string requirement in item.Requirements)
            {
                if (requirement.Contains("||"))
                {
                    Requirement orCombinedRequirement = new Requirement
                    {
                        LogMessage = () => ""
                    };
                    foreach (string part in requirement.Split("||"))
                    {
                        var sub = GetRequirement(item.Name, part);
                        orCombinedRequirement = orCombinedRequirement.Or(sub);
                    }

                    item.RequirementObjects.Add(orCombinedRequirement);
                }
                else if (requirement.Contains("&&"))
                {
                    Requirement andCombinedRequirement = new Requirement
                    {
                        LogMessage = () => ""
                    };
                    foreach (string part in requirement.Split("&&"))
                    {
                        var sub = GetRequirement(item.Name, part);
                        andCombinedRequirement = andCombinedRequirement.And(sub);
                    }

                    item.RequirementObjects.Add(andCombinedRequirement);
                }
                else
                {
                    item.RequirementObjects.Add(GetRequirement(item.Name, requirement));
                }
            }

            CreateMinRequirement(item.RequirementObjects, PowerType.Mana, item.MinMana);
            CreateMinRequirement(item.RequirementObjects, PowerType.Rage, item.MinRage);
            CreateMinRequirement(item.RequirementObjects, PowerType.Energy, item.MinEnergy);

            CreateMinComboPointsRequirement(item.RequirementObjects, item);
            CreateTargetIsCastingRequirement(item.RequirementObjects, item);
            CreateActionUsableRequirement(item.RequirementObjects, item);

            CreateCooldownRequirement(item.RequirementObjects, item);
            CreateChargeRequirement(item.RequirementObjects, item);
        }
Exemple #4
0
        public void InitialiseRequirements(KeyAction item)
        {
            item.RequirementObjects.Clear();
            foreach (string requirement in item.Requirements)
            {
                item.RequirementObjects.Add(GetRequirement(item.Name, requirement));
            }

            CreateMinRequirement(item.RequirementObjects, "Mana", item.MinMana);
            CreateMinRequirement(item.RequirementObjects, "Rage", item.MinRage);
            CreateMinRequirement(item.RequirementObjects, "Energy", item.MinEnergy);
            CreateMinComboPointsRequirement(item.RequirementObjects, item);
            item.CreateCooldownRequirement();
            item.CreateChargeRequirement();
        }
Exemple #5
0
        private void AddUnique(KeyAction a)
        {
            if (!KeyReader.KeyMapping.ContainsKey(a.Key))
            {
                return;
            }
            if (sources.Any(i => i.Key == a.Key))
            {
                return;
            }

            var source = new ActionBarSource
            {
                Name        = a.Name,
                Key         = a.Key,
                Item        = false,
                Requirement = a.Requirement
            };

            sources.Add(source);
        }
        private void AddUnique(KeyAction a)
        {
            if (!KeyReader.KeyMapping.ContainsKey(a.Key))
            {
                return;
            }
            if (sources.Any(i => i.KeyAction.ConsoleKeyFormHash == a.ConsoleKeyFormHash))
            {
                return;
            }

            var source = new ActionBarSource
            {
                Name      = a.Name,
                Key       = a.Key,
                Item      = false,
                KeyAction = a
            };

            sources.Add(source);
        }
Exemple #7
0
 private void CreateActionUsableRequirement(List <Requirement> RequirementObjects, KeyAction item)
 {
     if (!string.IsNullOrEmpty(item.Key))
     {
         RequirementObjects.Add(new Requirement
         {
             HasRequirement = () => playerReader.ActionBarUsable.ActionUsable(item.Key),
             LogMessage     = () => $"Usable"
         });
     }
 }
Exemple #8
0
 private void CreateMinComboPointsRequirement(List <Requirement> RequirementObjects, KeyAction item)
 {
     if (item.MinComboPoints > 0)
     {
         RequirementObjects.Add(new Requirement
         {
             HasRequirement = () => playerReader.ComboPoints >= item.MinComboPoints,
             LogMessage     = () => $"Combo point {playerReader.ComboPoints} >= {item.MinComboPoints}"
         });
     }
 }
Exemple #9
0
        public Tuple <PowerType, int> GetCostByActionBarSlot(PlayerReader playerReader, KeyAction keyAction)
        {
            if (KeyReader.ActionBarSlotMap.TryGetValue(keyAction.Key, out int slot))
            {
                if (slot <= 12)
                {
                    slot += Stance.RuntimeSlotToActionBar(keyAction, playerReader, slot);
                }

                if (dict.TryGetValue(slot, out var tuple))
                {
                    return(tuple);
                }
            }

            return(empty);
        }
Exemple #10
0
 private static void CreateChargeRequirement(List <Requirement> RequirementObjects, KeyAction item)
 {
     if (item.Charge > 1)
     {
         RequirementObjects.Add(new Requirement
         {
             HasRequirement          = () => item.GetChargeRemaining() != 0,
             LogMessage              = () => $"Charge {item.GetChargeRemaining()}",
             VisibleIfHasRequirement = true
         });
     }
 }
Exemple #11
0
 private static void CreateCooldownRequirement(List <Requirement> RequirementObjects, KeyAction item)
 {
     if (item.Cooldown > 0)
     {
         RequirementObjects.Add(new Requirement
         {
             HasRequirement          = () => item.GetCooldownRemaining() == 0,
             LogMessage              = () => $"Cooldown {item.GetCooldownRemaining() / 1000:F1}",
             VisibleIfHasRequirement = false
         });
     }
 }
Exemple #12
0
        private void CreateActionUsableRequirement(List <Requirement> RequirementObjects, KeyAction item)
        {
            if (item.WhenUsable && !string.IsNullOrEmpty(item.Key))
            {
                RequirementObjects.Add(new Requirement
                {
                    HasRequirement = () =>
                                     !item.HasFormRequirement() ? addonReader.UsableAction.Is(item) :
                                     (playerReader.Form == item.FormEnum && addonReader.UsableAction.Is(item)) ||
                                     (playerReader.Form != item.FormEnum && item.CanDoFormChangeAndHaveMinimumMana()),

                    LogMessage = () =>
                                 !item.HasFormRequirement() ? $"Usable" :                                                                                        // {playerReader.UsableAction.Num(item)}
                                 (playerReader.Form != item.FormEnum && item.CanDoFormChangeAndHaveMinimumMana()) ? $"Usable after Form change" :                // {playerReader.UsableAction.Num(item)}
                                 (playerReader.Form == item.FormEnum && addonReader.UsableAction.Is(item)) ? $"Usable current Form" : $"not Usable current Form" // {playerReader.UsableAction.Num(item)}
                });
            }
        }
Exemple #13
0
 private void CreateTargetIsCastingRequirement(List <Requirement> itemRequirementObjects, KeyAction item)
 {
     if (item.UseWhenTargetIsCasting != null)
     {
         itemRequirementObjects.Add(new Requirement
         {
             HasRequirement = () => playerReader.IsTargetCasting == item.UseWhenTargetIsCasting.Value,
             LogMessage     = () => "Target casting"
         });
     }
 }