Exemple #1
0
 public SkillPresentModeDeterminer(
     int skillId,
     EncounterMode skillPresentMode    = EncounterMode.Challenge,
     EncounterMode skillNotPresentMode = EncounterMode.Normal)
 {
     this.skillId             = skillId;
     this.skillPresentMode    = skillPresentMode;
     this.skillNotPresentMode = skillNotPresentMode;
 }
Exemple #2
0
 private uint GetResetOffset(EncounterMode mode)
 {
     return(mode switch
     {
         EncounterMode.Gift => BoxStartOffset,
         EncounterMode.Regigigas or EncounterMode.Eternatus => RaidPokemonOffset,
         EncounterMode.MotostokeGym => LegendaryPokemonOffset,
         _ => WildPokemonOffset,
     });
Exemple #3
0
 public Statistics(DateTimeOffset fightStart, Player logAuthor, EncounterResult encounterResult, EncounterMode encounterMode, Encounter encounter,
                   string logVersion, TimeSpan encounterDuration)
 {
     Encounter         = encounter;
     LogVersion        = logVersion;
     EncounterResult   = encounterResult;
     EncounterMode     = encounterMode;
     FightStart        = fightStart;
     LogAuthor         = logAuthor;
     EncounterDuration = encounterDuration;
 }
 public AgentHealthModeDeterminer(
     Agent agent,
     ulong maxHealth,
     EncounterMode enoughHealthMode = EncounterMode.Challenge,
     EncounterMode lessHealthMode   = EncounterMode.Normal)
 {
     this.agent            = agent;
     this.maxHealth        = maxHealth;
     this.enoughHealthMode = enoughHealthMode;
     this.lessHealthMode   = lessHealthMode;
 }
 // Setters
 internal void SetEncounterMode(CombatData combatData, AgentData agentData)
 {
     if (_encounterStatus == EncounterMode.NotSet)
     {
         _encounterStatus = Logic.GetEncounterMode(combatData, agentData, this);
         if (_encounterStatus == EncounterMode.Story)
         {
             Logic.InvalidateEncounterID();
         }
     }
 }
Exemple #6
0
        private async Task DoRestartingEncounter(CancellationToken token)
        {
            EncounterMode type            = Hub.Config.SWSH_Encounter.EncounteringType;
            uint          encounterOffset = (type == EncounterMode.Regigigas || type == EncounterMode.Eternatus) ? RaidPokemonOffset : WildPokemonOffset;
            bool          skipRoutine     = (type == EncounterMode.Spiritomb || type == EncounterMode.SwordsJustice);

            while (!token.IsCancellationRequested)
            {
                if (!skipRoutine)
                {
                    Log($"Looking for {type}...");

                    if (type == EncounterMode.Eternatus)
                    {
                        await SetStick(LEFT, 0, 20_000, 1_000, token).ConfigureAwait(false);
                        await ResetStick(token).ConfigureAwait(false);
                    }

                    //Click through all the menus until the encounter.
                    while (!await IsInBattle(token).ConfigureAwait(false) && !await SWSHIsGiftFound(token).ConfigureAwait(false))
                    {
                        await Click(A, 0_300, token).ConfigureAwait(false);
                    }

                    Log("An encounter found! Checking details...");

                    PK8?pk;
                    if (type == EncounterMode.Gifts)
                    {
                        pk = await ReadUntilPresent(await ParsePointer(PokeGift, token), 2_000, 0_200, token).ConfigureAwait(false);
                    }
                    else
                    {
                        pk = await ReadUntilPresent(encounterOffset, 2_000, 0_200, token).ConfigureAwait(false);
                    }

                    if (pk != null)
                    {
                        if (await HandleEncounter(pk, IsPKLegendary(pk.Species), token).ConfigureAwait(false))
                        {
                            return;
                        }
                    }

                    Log($"Resetting {type} by restarting the game");
                }

                skipRoutine = false;
                await CloseGame(Hub.Config, token).ConfigureAwait(false);
                await StartGame(Hub.Config, token).ConfigureAwait(false);
            }
        }
 public GroupedSpawnModeDeterminer(
     Func <Agent, bool> agentCounted,
     int count,
     long timeSpan,
     EncounterMode spawnOccuredMode    = EncounterMode.Challenge,
     EncounterMode spawnNotOccuredMode = EncounterMode.Normal)
 {
     this.agentCounted        = agentCounted ?? throw new ArgumentNullException(nameof(agentCounted));
     this.count               = count;
     this.timeSpan            = timeSpan;
     this.spawnOccuredMode    = spawnOccuredMode;
     this.spawnNotOccuredMode = spawnNotOccuredMode;
 }
        private async Task DoExtraCommands(CancellationToken token, EncounterMode mode)
        {
            switch (mode)
            {
            case EncounterMode.Eternatus or EncounterMode.MotostokeGym:
                await SetStick(LEFT, 0, 20_000, 0_500, token).ConfigureAwait(false);
                await ResetStick(token).ConfigureAwait(false);

                break;

            default:
                await Click(A, 0_050, token).ConfigureAwait(false);

                break;
            }
        }
Exemple #9
0
        public LogStatistics(DateTimeOffset fightStart, Player logAuthor, IEnumerable <PlayerData> playerData,
                             SquadDamageData fullFightSquadDamageData,
                             IEnumerable <TargetSquadDamageData> fullFightTargetDamageData, BuffData buffData,
                             EncounterResult encounterResult, EncounterMode encounterMode, string encounterName, string logVersion,
                             IReadOnlyDictionary <string, int> eventCounts, IEnumerable <Agent> agents, IEnumerable <Skill> skills)
        {
            EncounterName            = encounterName;
            LogVersion               = logVersion;
            EncounterResult          = encounterResult;
            EventCounts              = eventCounts;
            EncounterMode            = encounterMode;
            FightStart               = fightStart;
            LogAuthor                = logAuthor;
            PlayerData               = playerData.ToArray();
            FullFightSquadDamageData = fullFightSquadDamageData;
            BuffData = buffData;
            FullFightBossDamageData = fullFightTargetDamageData.ToArray();

            FightTimeMs = fullFightSquadDamageData.TimeMs;
            Agents      = agents as Agent[] ?? agents.ToArray();
            Skills      = skills as Skill[] ?? skills.ToArray();
        }
Exemple #10
0
        public EncounterBot(PokeBotConfig cfg, EncounterSettings encounter, IDumper dump, BotCompleteCounts count) : base(cfg)
        {
            Counts        = count;
            DumpSetting   = dump;
            StopOnSpecies = encounter.StopOnSpecies;
            Mode          = encounter.EncounteringType;
            DesiredNature = encounter.DesiredNature;

            /* Populate DesiredIVs array.  Bot matches 0 and 31 IVs.
             * Any other nonzero IV is treated as a minimum accepted value.
             * If they put "x", this is a wild card so we can leave -1. */
            string[] splitIVs = encounter.DesiredIVs.Split(new [] { '/' }, StringSplitOptions.RemoveEmptyEntries);

            // Only accept up to 6 values in case people can't count.
            for (int i = 0; i < 6 && i < splitIVs.Length; i++)
            {
                if (splitIVs[i] == "x" || splitIVs[i] == "X")
                {
                    continue;
                }
                DesiredIVs[i] = Convert.ToInt32(splitIVs[i]);
            }
        }
Exemple #11
0
 /// <summary>
 /// Creates a determiner that identifies the encounter mode according to whether a buff was removed with a specific remaining time.
 /// </summary>
 /// <param name="buffId">The skill id of the tracked buff.</param>
 /// <param name="mode1">First encounter mode option.</param>
 /// <param name="remaining1">The remaining time of the buff in order to identify the encounter as <paramref name="mode1"/>.</param>
 /// <param name="mode2">Second encounter mode option.</param>
 /// <param name="remaining2">The remaining time of the buff in order to identify the encounter as <paramref name="mode2"/>.</param>
 /// <param name="defaultMode">The default mode to fall to in case neither <paramref name="mode1"/> or <paramref name="mode2"/> is identified.</param>
 /// <exception cref="ArgumentException">Thrown if <paramref name="remaining1"/> and <paramref name="remaining2"/> are within
 /// 2*<see cref="RemainingTimePrecision"/>, which would result in ambiguous mode detection as a remaining buff duration would be too close to both.</exception>
 public RemovedBuffStackRemainingTimeModeDeterminer(
     int buffId,
     EncounterMode mode1,
     int remaining1,
     EncounterMode mode2,
     int remaining2,
     EncounterMode defaultMode
     )
 {
     this.buffId      = buffId;
     this.mode1       = mode1;
     this.remaining1  = remaining1;
     this.mode2       = mode2;
     this.remaining2  = remaining2;
     this.defaultMode = defaultMode;
     if (Math.Abs(this.remaining1 - this.remaining2) < RemainingTimePrecision * 2)
     {
         throw new ArgumentException("Ambiguous buff remaining times." +
                                     "For some values both modes would be a possible result." +
                                     $"Make sure {nameof(remaining1)} and {nameof(remaining2)} are not " +
                                     $"within {2*RemainingTimePrecision} of each other",
                                     nameof(this.remaining1));
     }
 }
Exemple #12
0
 private static uint GetResetOffset(EncounterMode mode) => mode switch
 {
        private List <string> GetAlgorithmsByEncounterMode(List <Type> implementations, EncounterMode encounterMode)
        {
            List <string> types = new List <string>();

            foreach (Type type in implementations)
            {
                if (type.GetProperty("EncounterMode").Equals(encounterMode))
                {
                    types.Add(type.Name);
                }
            }

            return(types);
        }
Exemple #14
0
 public ConstantModeDeterminer(EncounterMode mode)
 {
     this.mode = mode;
 }