public void Initialise(PlayerReader playerReader, RequirementFactory requirementFactory, ILogger logger)
        {
            this.playerReader = playerReader;
            this.logger       = logger;

            ResetChanges();

            if (!string.IsNullOrEmpty(this.Requirement))
            {
                Requirements.Add(this.Requirement);
            }

            requirementFactory.InitialiseRequirements(this);

            if (!string.IsNullOrEmpty(ShapeShiftForm))
            {
                if (Enum.TryParse(typeof(ShapeshiftForm), ShapeShiftForm, out var desiredForm))
                {
                    this.ShapeShiftFormEnum = (ShapeshiftForm)desiredForm;
                }
                else
                {
                    logger.LogInformation($"Unknown shapeshift form: {ShapeShiftForm}");
                }
            }

            KeyReader.ReadKey(logger, this);
        }
Exemple #2
0
        public void Initialise(string prefix, AddonReader addonReader, RequirementFactory requirementFactory, ILogger logger)
        {
            if (Sequence.Count > 0)
            {
                logger.LogInformation($"[{prefix}] Initialise KeyActions.");
            }

            Sequence.ForEach(i => i.Initialise(addonReader, requirementFactory, logger));
        }
        public void InitialiseForm(AddonReader addonReader, RequirementFactory requirementFactory, ILogger logger)
        {
            Initialise(addonReader, requirementFactory, logger);

            if (HasFormRequirement())
            {
                if (addonReader.PlayerReader.FormCost.ContainsKey(FormEnum))
                {
                    addonReader.PlayerReader.FormCost.Remove(FormEnum);
                }

                addonReader.PlayerReader.FormCost.Add(FormEnum, MinMana);
                logger.LogInformation($"[{Name}] Added {FormEnum} to FormCost with {MinMana}");
            }
        }
        public void Initialise(AddonReader addonReader, RequirementFactory requirementFactory, ILogger logger)
        {
            this.playerReader = addonReader.PlayerReader;
            this.logger       = logger;

            ResetCharges();

            KeyReader.ReadKey(logger, this);

            if (!string.IsNullOrEmpty(this.Requirement))
            {
                Requirements.Add(this.Requirement);
            }

            if (HasFormRequirement())
            {
                if (Enum.TryParse(typeof(Form), Form, out var desiredForm))
                {
                    this.FormEnum = (Form)desiredForm;
                    this.logger.LogInformation($"[{Name}] Required Form: {FormEnum}");

                    if (KeyReader.ActionBarSlotMap.TryGetValue(Key, out int slot))
                    {
                        int offset = Stance.RuntimeSlotToActionBar(this, playerReader, slot);
                        this.logger.LogInformation($"[{Name}] Actionbar Form key map: Key:{Key} -> Actionbar:{slot} -> Form Map:{slot + offset}");
                    }
                }
                else
                {
                    logger.LogInformation($"Unknown form: {Form}");
                }
            }

            ConsoleKeyFormHash = ((int)FormEnum * 1000) + (int)ConsoleKey;

            UpdateMinResourceRequirement(playerReader, addonReader.ActionBarCostReader);

            requirementFactory.InitialiseRequirements(this);
        }
        private ClassConfiguration ReadClassConfiguration(string classFilename, string?pathFilename)
        {
            if (!classFilename.ToLower().Contains(AddonReader.PlayerReader.PlayerClass.ToString().ToLower()))
            {
                throw new Exception("Not allowed to load other class profile!");
            }

            var requirementFactory = new RequirementFactory(AddonReader.PlayerReader, AddonReader.BagReader, AddonReader.equipmentReader, logger);

            ClassConfiguration classConfig;
            var classFilePath = Path.Join(DataConfig.Class, classFilename);

            if (File.Exists(classFilePath))
            {
                classConfig = JsonConvert.DeserializeObject <ClassConfiguration>(File.ReadAllText(classFilePath));
                classConfig.Initialise(DataConfig, AddonReader, requirementFactory, logger, pathFilename);

                logger.LogDebug($"Loaded `{classFilename}` with Path Profile `{classConfig.PathFilename}`.");

                return(classConfig);
            }

            throw new ArgumentOutOfRangeException($"Class config file not found {classFilename}");
        }
 public void Initialise(PlayerReader playerReader, RequirementFactory requirementFactory, ILogger logger)
 {
     Sequence.ForEach(i => i.Initialise(playerReader, requirementFactory, logger));
 }
        public void Initialise(DataConfig dataConfig, AddonReader addonReader, RequirementFactory requirementFactory, ILogger logger, string?overridePathProfileFile)
        {
            SpiritPathFilename = string.Empty;

            Interact.Key            = InteractKey;
            Interact.Name           = "Interact";
            Interact.WaitForGCD     = false;
            Interact.DelayAfterCast = 0;
            Interact.PressDuration  = 30;
            Interact.Initialise(addonReader, requirementFactory, logger);

            Approach.Key            = InteractKey;
            Approach.Name           = "Approach";
            Approach.WaitForGCD     = false;
            Approach.DelayAfterCast = 0;
            Approach.PressDuration  = 10;
            Approach.Cooldown       = 150;
            Approach.Initialise(addonReader, requirementFactory, logger);

            AutoAttack.Key            = InteractKey;
            AutoAttack.Name           = "AutoAttack";
            AutoAttack.WaitForGCD     = false;
            AutoAttack.DelayAfterCast = 0;
            AutoAttack.Initialise(addonReader, requirementFactory, logger);

            StopAttack.PressDuration = 10;

            InitializeKeyActions(Pull, Interact, Approach, AutoAttack);
            InitializeKeyActions(Combat, Interact, Approach, AutoAttack);

            logger.LogInformation("[Form] Initialise KeyActions.");
            Form.ForEach(i => i.InitialiseForm(addonReader, requirementFactory, logger));

            Pull.Initialise("Pull", addonReader, requirementFactory, logger);
            Combat.Initialise("Combat", addonReader, requirementFactory, logger);
            Adhoc.Initialise("Adhoc", addonReader, requirementFactory, logger);
            NPC.Initialise("AdhocNpc", addonReader, requirementFactory, logger);
            Parallel.Initialise("Parallel", addonReader, requirementFactory, logger);

            Jump.Key = JumpKey;
            Jump.Initialise(addonReader, requirementFactory, logger);

            TargetLastTarget.Key = TargetLastTargetKey;
            TargetLastTarget.Initialise(addonReader, requirementFactory, logger);

            StandUp.Key = StandUpKey;
            StandUp.Initialise(addonReader, requirementFactory, logger);

            ClearTarget.Key = ClearTargetKey;
            ClearTarget.Initialise(addonReader, requirementFactory, logger);

            StopAttack.Key = StopAttackKey;
            StopAttack.Initialise(addonReader, requirementFactory, logger);

            TargetNearestTarget.Key = TargetNearestTargetKey;
            TargetNearestTarget.Initialise(addonReader, requirementFactory, logger);

            TargetPet.Key = TargetPetKey;
            TargetPet.Initialise(addonReader, requirementFactory, logger);

            TargetTargetOfTarget.Key = TargetTargetOfTargetKey;
            TargetTargetOfTarget.Initialise(addonReader, requirementFactory, logger);

            PetAttack.Key           = PetAttackKey;
            PetAttack.PressDuration = 10;
            PetAttack.Initialise(addonReader, requirementFactory, logger);

            Mount.Key = MountKey;
            Mount.Initialise(addonReader, requirementFactory, logger);

            GatherFindKeys.ForEach(key =>
            {
                GatherFindKeyConfig.Add(new KeyAction {
                    Key = key
                });
                GatherFindKeyConfig.Last().Initialise(addonReader, requirementFactory, logger);
            });

            OverridePathFilename = overridePathProfileFile;
            if (!string.IsNullOrEmpty(OverridePathFilename))
            {
                PathFilename = OverridePathFilename;
            }

            if (!File.Exists(Path.Join(dataConfig.Path, PathFilename)))
            {
                if (!string.IsNullOrEmpty(OverridePathFilename))
                {
                    throw new Exception($"The `{OverridePathFilename}` path file does not exists!");
                }
                else
                {
                    throw new Exception($"The loaded class config contains not existing `{PathFilename}` path file!");
                }
            }

            CheckConfigConsistency(logger);
        }
Exemple #8
0
 public void Initialise(AddonReader addonReader, RequirementFactory requirementFactory, ILogger logger)
 {
     Sequence.ForEach(i => i.Initialise(addonReader, requirementFactory, logger));
 }
Exemple #9
0
        public void Initialise(DataConfig dataConfig, PlayerReader playerReader, RequirementFactory requirementFactory, ILogger logger, string?overridePathProfileFile)
        {
            SpiritPathFilename = string.Empty;

            Interact.Key  = InteractKey;
            Interact.Name = "Interact";
            Interact.Initialise(playerReader, requirementFactory, logger);

            Approach.Key  = InteractKey;
            Approach.Name = "Approach";
            Approach.Initialise(playerReader, requirementFactory, logger);

            AutoAttack.Key            = InteractKey;
            AutoAttack.Name           = "AutoAttack";
            AutoAttack.DelayAfterCast = 0;
            AutoAttack.Initialise(playerReader, requirementFactory, logger);

            InitializeKeyActions(Pull, Interact, Approach, AutoAttack);
            InitializeKeyActions(Combat, Interact, Approach, AutoAttack);

            Pull.Initialise(playerReader, requirementFactory, logger);
            Combat.Initialise(playerReader, requirementFactory, logger);
            Adhoc.Initialise(playerReader, requirementFactory, logger);
            NPC.Initialise(playerReader, requirementFactory, logger);
            Parallel.Initialise(playerReader, requirementFactory, logger);
            ShapeshiftForm.ForEach(i => i.Initialise(playerReader, requirementFactory, logger));

            Jump.Key = JumpKey;
            Jump.Initialise(playerReader, requirementFactory, logger);

            TargetLastTarget.Key = TargetLastTargetKey;
            TargetLastTarget.Initialise(playerReader, requirementFactory, logger);

            StandUp.Key = StandUpKey;
            StandUp.Initialise(playerReader, requirementFactory, logger);

            ClearTarget.Key = ClearTargetKey;
            ClearTarget.Initialise(playerReader, requirementFactory, logger);

            StopAttack.Key = StopAttackKey;
            StopAttack.Initialise(playerReader, requirementFactory, logger);

            TargetNearestTarget.Key = TargetNearestTargetKey;
            TargetNearestTarget.Initialise(playerReader, requirementFactory, logger);

            TargetPet.Key = TargetPetKey;
            TargetPet.Initialise(playerReader, requirementFactory, logger);

            TargetTargetOfTarget.Key = TargetTargetOfTargetKey;
            TargetTargetOfTarget.Initialise(playerReader, requirementFactory, logger);

            PetAttack.Key = PetAttackKey;
            PetAttack.Initialise(playerReader, requirementFactory, logger);

            GatherFindKeys.ForEach(key =>
            {
                GatherFindKeyConfig.Add(new KeyAction {
                    Key = key
                });
                GatherFindKeyConfig.Last().Initialise(playerReader, requirementFactory, logger);
            });

            OverridePathFilename = overridePathProfileFile;
            if (!string.IsNullOrEmpty(OverridePathFilename))
            {
                PathFilename = OverridePathFilename;
            }

            if (!File.Exists(Path.Join(dataConfig.Path, PathFilename)))
            {
                if (!string.IsNullOrEmpty(OverridePathFilename))
                {
                    throw new Exception($"The `{OverridePathFilename}` path file does not exists!");
                }
                else
                {
                    throw new Exception($"The loaded class config contains not existing `{PathFilename}` path file!");
                }
            }
        }