コード例 #1
0
ファイル: BotController.cs プロジェクト: shinykody/SysBot.NET
        public void SendCommand(BotControlCommand cmd, bool echo = true)
        {
            if (Runner?.Hub.Config.SkipConsoleBotCreation != false)
            {
                return;
            }
            var bot = GetBot();

            switch (cmd)
            {
            case BotControlCommand.Idle: bot.Pause(); break;

            case BotControlCommand.Start: bot.Start(); break;

            case BotControlCommand.Stop: bot.Stop(); break;

            case BotControlCommand.Resume: bot.Resume(); break;

            default:
                WinFormsUtil.Alert($"{cmd} is not a command that can be sent to the Bot.");
                return;
            }
            if (echo)
            {
                EchoUtil.Echo($"{bot.Bot.Connection.Name} has been issued a command to {cmd}.");
            }
        }
コード例 #2
0
        private async Task <bool> HostRaidAsync(SAV8SWSH sav, int code, CancellationToken token)
        {
            // Connect to Y-Comm
            await EnsureConnectedToYComm(Hub.Config, token).ConfigureAwait(false);

            // Press A and stall out a bit for the loading
            await Click(A, 5_000, token).ConfigureAwait(false);

            if (code >= 0)
            {
                // Set Link code
                await Click(PLUS, 1_000, token).ConfigureAwait(false);
                await EnterTradeCode(code, token).ConfigureAwait(false);

                EchoUtil.Echo($"Raid code is {code}.");

                // Raid barrier here maybe?
                await Click(PLUS, 2_000, token).ConfigureAwait(false);
                await Click(A, 1_000, token).ConfigureAwait(false);
            }

            // Invite others, confirm Pokémon and wait
            await Click(A, 7_000, token).ConfigureAwait(false);
            await Click(DUP, 1_000, token).ConfigureAwait(false);
            await Click(A, 1_000, token).ConfigureAwait(false);

            var timetowait     = Hub.Config.Raid.MinTimeToWait * 1_000;
            var timetojoinraid = 175_000 - timetowait;

            Log("Waiting on raid party...");
            // Wait the minimum timer or until raid party fills up.
            while (timetowait > 0 && !await GetRaidPartyIsFullAsync(token).ConfigureAwait(false))
            {
                await Task.Delay(1_000, token).ConfigureAwait(false);

                timetowait -= 1_000;
            }

            var msg = code < 0 ? "no Link Code." : $"code: {code:0000}.";

            Log("Attempting to start the raid with " + msg);

            // Wait a few seconds for people to lock in.
            await Task.Delay(5_000, token).ConfigureAwait(false);

            /* Press A and check if we entered a raid.  If other users don't lock in,
            *  it will automatically start once the timer runs out. If we don't make it into
            *  a raid by the end, something has gone wrong and we should quit trying. */
            while (timetojoinraid > 0 && !await IsInBattle(token).ConfigureAwait(false))
            {
                await Click(A, 0_500, token).ConfigureAwait(false);

                timetojoinraid -= 0_500;
            }

            Log("Finishing raid routine.");
            await Task.Delay(5_500 + Hub.Config.Raid.ExtraTimeEndRaid, token).ConfigureAwait(false);

            return(false);
        }
コード例 #3
0
ファイル: RaidBot.cs プロジェクト: goofwear/SysBot.NET
        private async Task <bool> HostRaidAsync(SAV8SWSH sav, int code, CancellationToken token)
        {
            // Connect to Y-Comm
            await EnsureConnectedToYComm(token).ConfigureAwait(false);

            // Press A and stall out a bit for the loading
            await Click(A, 5000, token).ConfigureAwait(false);

            if (code >= 0)
            {
                // Set Link code
                await Click(PLUS, 1000, token).ConfigureAwait(false);
                await EnterTradeCode(code, token).ConfigureAwait(false);

                EchoUtil.Echo($"Raid code is {code}.");

                // Raid barrier here maybe?
                await Click(PLUS, 2_000, token).ConfigureAwait(false);
                await Click(A, 1000, token).ConfigureAwait(false);
            }

            // Invite others, confirm Pokémon and wait
            await Click(A, 5000, token).ConfigureAwait(false);
            await Click(DUP, 1000, token).ConfigureAwait(false);
            await Click(A, 1000, token).ConfigureAwait(false);

            // Use Offset to actually calculate this value and press A
            var timetowait = 3 * 60 * 1000;

            while (timetowait > 0)
            {
                bool result = await GetIsRaidPartyIsFullAsync().ConfigureAwait(false);

                if (result)
                {
                    break;
                }

                await Task.Delay(1000, token).ConfigureAwait(false);

                timetowait -= 1000;
            }

            if (timetowait > 0)
            {
                Log("All participants have joined.");
                await Click(A, 3000, token).ConfigureAwait(false);
            }
            else
            {
                Log("Not all participants have joined. Continuing anyway!");
                await Click(A, 3000, token).ConfigureAwait(false);
            }

            Log($"Hosting raid as {sav.OT} with code: {code:0000}.");
            await Task.Delay(10_000, token).ConfigureAwait(false);

            return(false);
        }
コード例 #4
0
ファイル: Main.cs プロジェクト: Splice-X/SpliceBot.NET
        private void SendAll(BotControlCommand cmd)
        {
            foreach (var c in FLP_Bots.Controls.OfType <BotController>())
            {
                c.SendCommand(cmd, false);
            }

            EchoUtil.Echo($"All bots have been issued a command to {cmd}.");
        }
コード例 #5
0
 public static async Task EchoAndReply(this ISocketMessageChannel channel, string msg)
 {
     // Announce it in the channel the command was entered only if it's not already an echo channel.
     EchoUtil.Echo(msg);
     if (!EchoModule.IsEchoChannel(channel))
     {
         await channel.SendMessageAsync(msg).ConfigureAwait(false);
     }
 }
コード例 #6
0
        private async Task DeleteAddFriends(CancellationToken token)
        {
            // Get to the profile.
            await Click(DUP, 0_600, token).ConfigureAwait(false);

            for (int i = 1; i < Settings.ProfileNumber; i++)
            {
                await Click(DRIGHT, 0_600, token).ConfigureAwait(false);
            }
            await Click(A, 2_000, token).ConfigureAwait(false);

            // Delete before adding to avoid deleting new friends.
            if (deleteFriends)
            {
                Log("Deleting friends.");
                await NavigateFriendsMenu(true, token).ConfigureAwait(false);

                for (int i = 0; i < Settings.NumberFriendsToDelete; i++)
                {
                    await DeleteFriend(token).ConfigureAwait(false);
                }
                EchoUtil.Echo($"Deleted up to {Settings.NumberFriendsToDelete} friends!");
            }

            // If we're deleting friends and need to add friends, it's cleaner to back out
            // to Home and re-open the profile in case we ran out of friends to delete.
            if (deleteFriends && addFriends)
            {
                Log("Navigating back to add friends.");
                await Click(HOME, 2_000, token).ConfigureAwait(false);
                await Click(DUP, 0_600, token).ConfigureAwait(false);

                for (int i = 1; i < Settings.ProfileNumber; i++)
                {
                    await Click(DRIGHT, 0_600, token).ConfigureAwait(false);
                }
                await Click(A, 2_000, token).ConfigureAwait(false);
            }

            if (addFriends)
            {
                Log("Adding friends.");
                await NavigateFriendsMenu(false, token).ConfigureAwait(false);

                for (int i = 0; i < Settings.NumberFriendsToAdd; i++)
                {
                    await AddFriend(token).ConfigureAwait(false);
                }
                EchoUtil.Echo($"Added up to {Settings.NumberFriendsToAdd} new friends!");
            }

            addFriends    = false;
            deleteFriends = false;
            await Click(HOME, 1_000, token).ConfigureAwait(false);
        }
コード例 #7
0
        public async Task ToggleQueueTradeAsync()
        {
            var state = Info.ToggleQueue();
            var msg   = state
                ? "Users are now able to join the trade queue."
                : "Changed queue settings: **Users CANNOT join the queue until it is turned back on.**";

            // Announce it in the channel the command was entered only if it's not already an echo channel.
            if (!EchoModule.IsEchoChannel(Context.Channel))
            {
                await ReplyAsync(msg).ConfigureAwait(false);
            }
            EchoUtil.Echo(msg);
        }
コード例 #8
0
        public static void RestoreChannels(DiscordSocketClient discord)
        {
            var cfg      = SysCordInstance.Settings;
            var channels = ReusableActions.GetListFromString(cfg.EchoChannels);

            foreach (var ch in channels)
            {
                if (!ulong.TryParse(ch, out var cid))
                {
                    continue;
                }
                var c = (ISocketMessageChannel)discord.GetChannel(cid);
                AddEchoChannel(c, cid);
            }

            EchoUtil.Echo("Added echo notification to Discord channel(s) on Bot startup.");
        }
コード例 #9
0
        private async Task <bool> ConfirmPlayerReady(uint player, CancellationToken token)
        {
            if (PlayerReady[player])
            {
                return(true);
            }

            var ofs = RaidP0PokemonOffset + (0x30 * player);

            // Check if the player has locked in.
            var data = await Connection.ReadBytesAsync(ofs + RaidLockedInIncr, 1, token).ConfigureAwait(false);

            if (data[0] == 0)
            {
                return(false);
            }

            PlayerReady[player] = true;

            // If we get to here, they're locked in and should have a Pokémon selected.
            if (Settings.EchoPartyReady)
            {
                data = await Connection.ReadBytesAsync(ofs, 2, token).ConfigureAwait(false);

                var dexno = BitConverter.ToUInt16(data, 0);

                data = await Connection.ReadBytesAsync(ofs + RaidAltFormInc, 1, token).ConfigureAwait(false);

                var altformstr = data[0] == 0 ? "" : "-" + data[0];

                data = await Connection.ReadBytesAsync(ofs + RaidShinyIncr, 1, token).ConfigureAwait(false);

                var shiny = data[0] == 1 ? "★ " : "";

                data = await Connection.ReadBytesAsync(ofs + RaidGenderIncr, 1, token).ConfigureAwait(false);

                var gender = data[0] == 0 ? " (M)" : (data[0] == 1 ? " (F)" : "");

                EchoUtil.Echo($"Player {player + 1} is ready with {shiny}{(Species)dexno}{altformstr}{gender}!");
            }

            return(true);
        }
コード例 #10
0
ファイル: BotController.cs プロジェクト: tomvita/SysBot.NET
        public void SendCommand(BotControlCommand cmd, bool echo = true)
        {
            if (Runner?.Hub.Config.SkipConsoleBotCreation != false)
            {
                return;
            }
            var bot = GetBot();

            switch (cmd)
            {
            case BotControlCommand.Idle: bot.Pause(); break;

            case BotControlCommand.Start: bot.Start(); break;

            case BotControlCommand.Stop: bot.Stop(); break;

            case BotControlCommand.Resume: bot.Resume(); break;

            case BotControlCommand.Restart:
            {
                var prompt = WinFormsUtil.Prompt(MessageBoxButtons.YesNo, "Are you sure you want to restart the connection?");
                if (prompt != DialogResult.Yes)
                {
                    return;
                }

                bot.Bot.Connection.Reset(bot.Bot.Config.IP);
                bot.Start();
                break;
            }

            default:
                WinFormsUtil.Alert($"{cmd} is not a command that can be sent to the Bot.");
                return;
            }
            if (echo)
            {
                EchoUtil.Echo($"{bot.Bot.Connection.Name} has been issued a command to {cmd}.");
            }
        }
コード例 #11
0
        private Tuple <ulong, ulong> PerformSeedSearch()
        {
            Log("Searching for a matching seed... Search may take a while.");
            SeedSearchUtil.SpecificSeedSearch(RaidInfo, out long frames, out ulong seed, out ulong threeDay, out string ivSpread);
            if (ivSpread == string.Empty)
            {
                Log($"No results found within the specified search range.");
                return(new Tuple <ulong, ulong>(0, 0));
            }

            var species  = RaidInfo.Den.IsEvent ? RaidInfo.RaidDistributionEncounter.Species : RaidInfo.RaidEncounter.Species;
            var specName = SpeciesName.GetSpeciesNameGeneration((int)species, 2, 8);
            var form     = TradeExtensions.FormOutput((int)(RaidInfo.Den.IsEvent ? RaidInfo.RaidDistributionEncounter.Species : RaidInfo.RaidEncounter.Species), (int)(RaidInfo.Den.IsEvent ? RaidInfo.RaidDistributionEncounter.AltForm : RaidInfo.RaidEncounter.AltForm), out _);
            var results  = $"\n\nDesired species: {(uint)RaidInfo.Den.Stars + 1}★ - {specName}{form}\n" +
                           $"\n{ivSpread}\n" +
                           $"\nStarting seed: {RaidInfo.Den.Seed:X16}\n" +
                           $"Target frame seed: {seed:X16}\n" +
                           $"Three day roll: {threeDay:X16}\n" +
                           $"Skips to target frame: {frames:N0}\n";

            EchoUtil.Echo(results);
            return(new Tuple <ulong, ulong>(seed, threeDay));
        }
コード例 #12
0
        private async Task PerformDaySkip(int skips, CancellationToken token)
        {
            var timeRemaining   = TimeSpan.FromMilliseconds((0_360 + Settings.SkipDelay) * skips);
            var firstQuarterLog = Math.Round(skips * 0.25, 0, MidpointRounding.ToEven);
            var halfLog         = Math.Round(skips * 0.5, 0, MidpointRounding.ToEven);
            var lastQuarterLog  = Math.Round(skips * 0.75, 0, MidpointRounding.ToEven);
            int reset           = Settings.TimeReset == TimeReset.Reset ? skips : 0;
            int resetNTP        = Settings.TimeReset == TimeReset.ResetNTP ? 1 : 0;

            EchoUtil.Echo($"Beginning to skip {(skips > 1 ? $"{skips} frames" : "1 frame")}. Skipping should take around {(timeRemaining.Hours == 0 ? "" : timeRemaining.Hours + "h:")}{(timeRemaining.Minutes == 0 ? "" : timeRemaining.Minutes + "m:")}{(timeRemaining.Seconds < 1 ? "1s" : timeRemaining.Seconds + "s")}.");

            for (int i = 0; i < skips; i++)
            {
                if (i == firstQuarterLog | i == halfLog | i == lastQuarterLog)
                {
                    timeRemaining = TimeSpan.FromMilliseconds((0_360 + Settings.SkipDelay) * (skips - i));
                    Log($"{(skips - i > 1 ? $"{skips - i} skips" : "1 skip")} and around {(timeRemaining.Hours == 0 ? "" : timeRemaining.Hours + "h:")}{(timeRemaining.Minutes == 0 ? "" : timeRemaining.Minutes + "m:")}{(timeRemaining.Seconds < 1 ? "1s" : timeRemaining.Seconds + "s")} left.");
                }

                await DaySkip(reset, 0, token).ConfigureAwait(false);

                await Task.Delay(0_360 + Settings.SkipDelay).ConfigureAwait(false);

                if (i == lastQuarterLog || i + 2 == skips)
                {
                    skips = await SkipCheck(skips, i, token).ConfigureAwait(false);
                }
            }

            if (resetNTP == 1)
            {
                Log("Syncing time via NTP requires internet connection. Connecting to YComm in order to ensure we do.");
                await EnsureConnectedToYComm(Hub.Config, token).ConfigureAwait(false);
                await ResetNTP(token).ConfigureAwait(false);
            }
        }
コード例 #13
0
        private async Task <bool> HostRaidAsync(SAV8SWSH sav, int code, CancellationToken token)
        {
            if (Roll || (Roll && FRBoth) || (Roll && FRAdd))
            {
                Log("Initializing the rolling auto-host routine.");
                await AutoRollDen(token).ConfigureAwait(false);
            }
            else if (!Roll && (FRBoth || FRAdd) && (encounterCount > 0 && encounterCount % 3 == 0))
            {
                if ((FRBoth == FRAdd) == true)
                {
                    Log("Enable one or the other, not both. Running FriendAdd instead.");
                    Settings.FriendCombined = false;
                    await FriendAdd(token).ConfigureAwait(false);
                }

                if (FRBoth && !FRAdd)
                {
                    await FRAddRemove(token).ConfigureAwait(false);
                }

                if (FRAdd && !FRBoth)
                {
                    await FriendAdd(token).ConfigureAwait(false);
                }
            }
            else if (!Roll && FriendRemoveCount != 0)
            {
                await FriendRemove(token).ConfigureAwait(false);
            }

            // Connect to Y-Comm
            await EnsureConnectedToYComm(Hub.Config, token).ConfigureAwait(false);

            // Press A and stall out a bit for the loading
            await Click(A, 5_000, token).ConfigureAwait(false);

            if (code >= 0)
            {
                // Set Link code
                await Click(PLUS, 1_000, token).ConfigureAwait(false);
                await EnterTradeCode(code, token).ConfigureAwait(false);

                if (RaidLog == true)
                {
                    RaidLogCount++;
                    System.IO.File.WriteAllText("RaidCode.txt", $"Raid #{RaidLogCount}\n{FriendCode}\nHosting raid as: {sav.OT}\nRaid code is: {code}\n------------------------");
                }
                EchoUtil.Echo($"Raid code is {code}.");

                // Raid barrier here maybe?
                await Click(PLUS, 2_000, token).ConfigureAwait(false);
                await Click(A, 1_000, token).ConfigureAwait(false);
            }

            if (code < 0 && RaidLog == true)
            {
                RaidLogCount++;
                System.IO.File.WriteAllText("RaidCode.txt", $"Raid #{RaidLogCount}{Environment.NewLine}\nHosting raid as: {sav.OT}\nRaid is Free For All\n------------------------");
                EchoUtil.Echo($"Raid is Free For All.");
            }

            // Invite others, confirm Pokémon and wait
            await Click(A, 7_000, token).ConfigureAwait(false);
            await Click(DUP, 1_000, token).ConfigureAwait(false);
            await Click(A, 1_000, token).ConfigureAwait(false);

            // Use Offset to actually calculate this value and press A
            var timetowait     = Hub.Config.Raid.MinTimeToWait * 1_000;
            var timetojoinraid = 175_000 - timetowait;

            Log("Waiting on raid party...");
            // Wait the minimum timer or until raid party fills up.
            while (timetowait > 0 && !await GetRaidPartyIsFullAsync(token).ConfigureAwait(false))
            {
                await Task.Delay(1_000, token).ConfigureAwait(false);

                timetowait -= 1_000;
            }

            var msg = code < 0 ? "no Link Code." : $"code: {code:0000}.";

            Log("Attempting to start the raid with " + msg);

            // Wait a few seconds for people to lock in.
            await Task.Delay(5_000, token).ConfigureAwait(false);

            /* Press A and check if we entered a raid.  If other users don't lock in,
            *  it will automatically start once the timer runs out. If we don't make it into
            *  a raid by the end, something has gone wrong and we should quit trying. */
            while (timetojoinraid > 0 && !await IsInBattle(token).ConfigureAwait(false))
            {
                await Click(A, 0_500, token).ConfigureAwait(false);

                timetojoinraid -= 0_500;
            }

            Log("Finishing raid routine.");
            await Task.Delay(5_500, token).ConfigureAwait(false);

            return(false);
        }
コード例 #14
0
        private async Task HostRaidAsync(int code, CancellationToken token)
        {
            if (Hub.Config.Raid.AutoRoll && !softLock)
            {
                await AutoRollDen(token).ConfigureAwait(false);
            }

            // Connect to Y-Comm
            await EnsureConnectedToYComm(Hub.Config, token).ConfigureAwait(false);

            // Press A and stall out a bit for the loading
            await Click(A, 5_000 + Hub.Config.Timings.ExtraTimeLoadRaid, token).ConfigureAwait(false);

            if (raidBossSpecies == -1)
            {
                var data = await Connection.ReadBytesAsync(RaidBossOffset, 2, Config.ConnectionType, token).ConfigureAwait(false);

                raidBossSpecies = BitConverter.ToUInt16(data, 0);
            }
            Log($"Initializing raid for {(Species)raidBossSpecies}.");

            if (code >= 0)
            {
                // Set Link code
                await Click(PLUS, 1_000, token).ConfigureAwait(false);
                await EnterTradeCode(code, Hub.Config, token).ConfigureAwait(false);
                await Click(PLUS, 2_000, token).ConfigureAwait(false);
                await Click(A, 2_000, token).ConfigureAwait(false);
            }

            if (addFriends && !string.IsNullOrEmpty(Settings.FriendCode))
            {
                EchoUtil.Echo($"Send a friend request to Friend Code **{Settings.FriendCode}** to join in! Friends will be added after this raid.");
            }

            // Invite others, confirm Pokémon and wait
            await Click(A, 7_000 + Hub.Config.Timings.ExtraTimeOpenRaid, token).ConfigureAwait(false);

            if (!softLock)
            {
                await Click(DUP, 1_000, token).ConfigureAwait(false);
                await Click(A, 1_000, token).ConfigureAwait(false);
            }

            var linkcodemsg = code < 0 ? "no Link Code" : $"code **{code:0000 0000}**";

            string raiddescmsg = string.IsNullOrEmpty(Hub.Config.Raid.RaidDescription) ? ((Species)raidBossSpecies).ToString() : Hub.Config.Raid.RaidDescription;

            RaidLog(linkcodemsg, raiddescmsg);

            if (Hub.Config.Raid.EchoRaidNotifications)
            {
                EchoUtil.Echo($"Raid lobby for {raiddescmsg} is open with {linkcodemsg}.");
            }

            var timetowait     = Hub.Config.Raid.MinTimeToWait * 1_000;
            var timetojoinraid = 175_000 - timetowait;

            Log("Waiting on raid party...");
            // Wait the minimum timer or until raid party fills up.
            while (timetowait > 0 && !await GetRaidPartyReady(token).ConfigureAwait(false))
            {
                await Task.Delay(1_000, token).ConfigureAwait(false);

                timetowait -= 1_000;

                if ((PlayerReady[1] || PlayerReady[2] || PlayerReady[3]) && Config.ConnectionType == ConnectionType.USB && Settings.AirplaneQuitout) // Need at least one player to be ready
                {
                    airplaneUsable = true;
                }
            }

            await Task.Delay(1_000, token).ConfigureAwait(false);

            if (Hub.Config.Raid.EchoRaidNotifications)
            {
                EchoUtil.Echo($"Raid is starting now with {linkcodemsg}.");
            }

            if (airplaneUsable && softLock) // Because we didn't ready up earlier if we're soft locked
            {
                await Click(DUP, 1_000, token).ConfigureAwait(false);
                await Click(A, 1_000, token).ConfigureAwait(false);
            }
            else if (!airplaneUsable && softLock) // Don't waste time and don't risk losing soft lock; re-host.
            {
                await AirplaneLobbyExit(code, token).ConfigureAwait(false);
            }

            /* Press A and check if we entered a raid.  If other users don't lock in,
            *  it will automatically start once the timer runs out. If we don't make it into
            *  a raid by the end, something has gone wrong and we should quit trying. */
            while (timetojoinraid > 0 && !await IsInBattle(token).ConfigureAwait(false))
            {
                await Click(A, 0_500, token).ConfigureAwait(false);

                timetojoinraid -= 0_500;

                if (await IsOnOverworld(Hub.Config, token).ConfigureAwait(false) && softLock) // If overworld, lobby disbanded.
                {
                    await AirplaneLobbyRecover(code, token).ConfigureAwait(false);
                }
            }

            for (int i = 0; i < 4; i++)
            {
                PlayerReady[i] = false;
            }

            Log("Finishing raid routine.");
            await Task.Delay(1_000 + Hub.Config.Timings.ExtraTimeEndRaid, token).ConfigureAwait(false);
        }
コード例 #15
0
        private async Task HostRaidAsync(int code, CancellationToken token)
        {
            // Connect to Y-Comm
            await EnsureConnectedToYComm(Hub.Config, token).ConfigureAwait(false);

            // Press A and stall out a bit for the loading
            await Click(A, 5_000 + Hub.Config.Timings.ExtraTimeLoadRaid, token).ConfigureAwait(false);

            if (raidBossSpecies == -1)
            {
                var data = await Connection.ReadBytesAsync(RaidBossOffset, 2, token).ConfigureAwait(false);

                raidBossSpecies = BitConverter.ToUInt16(data, 0);
            }
            Log($"Initializing raid for {(Species)raidBossSpecies}.");

            if (code >= 0)
            {
                // Set Link code
                await Click(PLUS, 1_000, token).ConfigureAwait(false);
                await EnterLinkCode(code, Hub.Config, token).ConfigureAwait(false);
                await Click(PLUS, 2_000, token).ConfigureAwait(false);
                await Click(A, 2_000, token).ConfigureAwait(false);
            }

            if (addFriends && !string.IsNullOrEmpty(Settings.FriendCode))
            {
                EchoUtil.Echo($"Send a friend request to Friend Code **{Settings.FriendCode}** to join in! Friends will be added after this raid.");
            }

            // Invite others, confirm Pokémon and wait
            await Click(A, 7_000 + Hub.Config.Timings.ExtraTimeOpenRaid, token).ConfigureAwait(false);
            await Click(DUP, 1_000, token).ConfigureAwait(false);
            await Click(A, 1_000, token).ConfigureAwait(false);

            var linkcodemsg = code < 0 ? "no Link Code" : $"code **{code:0000 0000}**";

            string raiddescmsg = string.IsNullOrEmpty(Settings.RaidDescription) ? ((Species)raidBossSpecies).ToString() : Settings.RaidDescription;

            EchoUtil.Echo($"Raid lobby for {raiddescmsg} is open with {linkcodemsg}.");

            var timetowait     = Settings.MinTimeToWait * 1_000;
            var timetojoinraid = 175_000 - timetowait;

            Log("Waiting on raid party...");
            // Wait the minimum timer or until raid party fills up.
            while (timetowait > 0 && !await GetRaidPartyReady(token).ConfigureAwait(false))
            {
                await Task.Delay(1_000, token).ConfigureAwait(false);

                timetowait -= 1_000;
            }

            await Task.Delay(1_000, token).ConfigureAwait(false);

            EchoUtil.Echo($"Raid is starting now with {linkcodemsg}.");

            /* Press A and check if we entered a raid.  If other users don't lock in,
            *  it will automatically start once the timer runs out. If we don't make it into
            *  a raid by the end, something has gone wrong and we should quit trying. */
            while (timetojoinraid > 0 && !await IsInBattle(token).ConfigureAwait(false))
            {
                await Click(A, 0_500, token).ConfigureAwait(false);

                timetojoinraid -= 0_500;
            }

            for (int i = 0; i < 4; i++)
            {
                PlayerReady[i] = false;
            }

            Log("Finishing raid routine.");
            await Task.Delay(1_000 + Hub.Config.Timings.ExtraTimeEndRaid, token).ConfigureAwait(false);
        }
コード例 #16
0
        private async Task AutoRollDen(CancellationToken token)
        {
            DateSkipClicks();
            for (int day = 0; day < 3; day++)
            {
                if (ResetCount == 0 || ResetCount >= 40)
                {
                    await Click(B, 0_500, token).ConfigureAwait(false);
                    await TimeMenu(token).ConfigureAwait(false);
                    await ResetTime(token).ConfigureAwait(false);

                    day = 0;
                }

                if (day == 0) // Enters den and invites others on day 1
                {
                    Log("Initializing the rolling auto-host routine.");
                    await Click(A, 5_000 + Hub.Config.Timings.ExtraTimeLoadLobbyAR, token).ConfigureAwait(false);
                    await Click(A, 7_000 + Hub.Config.Timings.ExtraTimeInviteOthersAR, token).ConfigureAwait(false);
                }

                await TimeMenu(token).ConfigureAwait(false);                                                  // Goes to system time screen
                await TimeSkip(token).ConfigureAwait(false);                                                  // Skips a year
                await Click(B, 2_000, token).ConfigureAwait(false);
                await Click(A, 5_000 + Hub.Config.Timings.ExtraTimeLobbyQuitAR, token).ConfigureAwait(false); // Cancel lobby

                if (day == 2)                                                                                 // We're on the fourth frame. Collect watts, exit lobby, return to main loop
                {
                    for (int i = 0; i < 2; i++)
                    {
                        await Click(A, 1_000 + Hub.Config.Timings.ExtraTimeAButtonClickAR, token).ConfigureAwait(false);
                    }
                    await Click(A, 5_000 + Hub.Config.Timings.ExtraTimeLoadLobbyAR, token).ConfigureAwait(false);

                    var data = await Connection.ReadBytesAsync(RaidBossOffset, 2, Config.ConnectionType, token).ConfigureAwait(false);

                    raidBossSpecies = BitConverter.ToUInt16(data, 0);
                    EchoUtil.Echo($"Rolling complete. Raid for {(Species)raidBossSpecies} will be going up shortly!");

                    if ((Species)raidBossSpecies == Settings.AutoRollSpecies && Config.ConnectionType == ConnectionType.USB && Settings.AirplaneQuitout)
                    {
                        softLock = true;
                        EchoUtil.Echo($"Soft locking on {(Species)raidBossSpecies}.");
                    }

                    for (int i = 0; i < 2; i++)
                    {
                        await Click(B, 0_500, token).ConfigureAwait(false);
                    }
                    Log("Completed the rolling auto-host routine.");
                    return;
                }

                for (int i = 0; i < 2; i++)
                {
                    await Click(A, 1_000 + Hub.Config.Timings.ExtraTimeAButtonClickAR, token).ConfigureAwait(false);
                }
                await Click(A, 5_000 + Hub.Config.Timings.ExtraTimeLoadLobbyAR, token).ConfigureAwait(false);
                await Click(A, 7_000 + Hub.Config.Timings.ExtraTimeInviteOthersAR, token).ConfigureAwait(false); // Collect watts, invite others
            }
        }
コード例 #17
0
ファイル: EncounterBot.cs プロジェクト: Koi-3088/ForkBot.NET
        // return true if breaking loop
        protected async Task <bool> HandleEncounter(PK8 pk, CancellationToken token)
        {
            encounterCount++;
            var print = Hub.Config.StopConditions.GetPrintName(pk);

            Log($"Encounter: {encounterCount}{Environment.NewLine}{print}{Environment.NewLine}");

            var legendary = Legal.Legends.Contains(pk.Species) || Legal.SubLegends.Contains(pk.Species);

            if (legendary)
            {
                Settings.AddCompletedLegends();
            }
            else
            {
                Settings.AddCompletedEncounters();
            }

            if (DumpSetting.Dump && !string.IsNullOrEmpty(DumpSetting.DumpFolder))
            {
                DumpPokemon(DumpSetting.DumpFolder, legendary ? "legends" : "encounters", pk);
            }

            if (!StopConditionSettings.EncounterFound(pk, DesiredMinIVs, DesiredMaxIVs, Hub.Config.StopConditions, UnwantedMarks))
            {
                return(false);
            }

            if (Hub.Config.StopConditions.CaptureVideoClip)
            {
                await Task.Delay(Hub.Config.StopConditions.ExtraTimeWaitCaptureVideo, token).ConfigureAwait(false);
                await PressAndHold(CAPTURE, 2_000, 0, token).ConfigureAwait(false);
            }

            var mode = Settings.ContinueAfterMatch;
            var msg  = $"Result found!\n{print}\n" + mode switch
            {
                ContinueAfterMatch.Continue => "Continuing...",
                ContinueAfterMatch.PauseWaitAcknowledge => "Waiting for instructions to continue.",
                ContinueAfterMatch.StopExit => "Stopping routine execution; restart the bot to search again.",
                _ => throw new ArgumentOutOfRangeException(),
            };

            if (!string.IsNullOrWhiteSpace(Hub.Config.StopConditions.MatchFoundEchoMention))
            {
                msg = $"{Hub.Config.StopConditions.MatchFoundEchoMention} {msg}";
            }
            EchoUtil.Echo(msg);
            Log(msg);

            if (mode == ContinueAfterMatch.StopExit)
            {
                return(true);
            }
            if (mode == ContinueAfterMatch.Continue)
            {
                return(false);
            }

            IsWaiting = true;
            while (IsWaiting)
            {
                await Task.Delay(1_000, token).ConfigureAwait(false);
            }
            return(false);
        }
コード例 #18
0
        private async Task AutoRollDen(CancellationToken token)
        {
            for (int day = 0; day < 3; day++)
            {
                if (ResetCount == 0 || ResetCount >= 58)
                {
                    await Click(B, 0_100, token).ConfigureAwait(false);
                    await TimeMenu(token).ConfigureAwait(false);
                    await ResetTime(token).ConfigureAwait(false);

                    day = 0;
                }

                if (Hub.Config.Raid.NumberFriendsToAdd > 0 && Hub.Config.Raid.RaidsBetweenAddFriends > 0)
                {
                    addFriends = (encounterCount - Settings.InitialRaidsToHost) % Hub.Config.Raid.RaidsBetweenAddFriends == 0;
                }
                if (Hub.Config.Raid.NumberFriendsToDelete > 0 && Hub.Config.Raid.RaidsBetweenDeleteFriends > 0)
                {
                    deleteFriends = (encounterCount - Settings.InitialRaidsToHost) % Hub.Config.Raid.RaidsBetweenDeleteFriends == 0;
                }

                if (day == 0) //Enters den and invites others on day 1
                {
                    Log("Initializing the rolling auto-host routine.");
                    await Click(A, 5_000 + Hub.Config.Raid.ExtraTimeLoadLobbyAR, token).ConfigureAwait(false);
                    await Click(A, 7_000 + Hub.Config.Raid.ExtraTimeInviteOthersAR, token).ConfigureAwait(false);
                }

                await TimeMenu(token).ConfigureAwait(false);                                               //Goes to system time screen
                await TimeSkip(token).ConfigureAwait(false);                                               //Skips a year
                await Click(B, 2_000, token).ConfigureAwait(false);
                await Click(A, 5_000 + Hub.Config.Raid.ExtraTimeLobbyQuitAR, token).ConfigureAwait(false); //Cancel lobby

                if (day == 2)                                                                              //We're on the fourth frame. Collect watts, exit lobby, return to main loop
                {
                    for (int i = 0; i < 2; i++)
                    {
                        await Click(A, 1_000 + Hub.Config.Raid.ExtraTimeAButtonClickAR, token).ConfigureAwait(false);
                    }
                    await Click(A, 5_000 + Hub.Config.Raid.ExtraTimeLoadLobbyAR, token).ConfigureAwait(false); //Collect watts, invite others

                    var data = await Connection.ReadBytesAsync(RaidBossOffset, 2, token).ConfigureAwait(false);

                    raidBossSpecies = BitConverter.ToUInt16(data, 0);
                    EchoUtil.Echo($"Rolling complete. Raid for {(Species)raidBossSpecies} will be going up shortly!");

                    for (int i = 0; i < 2; i++)
                    {
                        await Click(B, 0_500, token).ConfigureAwait(false);
                    }
                    Log("Completed the rolling auto-host routine.");
                    return;
                }

                for (int i = 0; i < 2; i++)
                {
                    await Click(A, 1_000 + Hub.Config.Raid.ExtraTimeAButtonClickAR, token).ConfigureAwait(false);
                }
                await Click(A, 5_000 + Hub.Config.Raid.ExtraTimeLoadLobbyAR, token).ConfigureAwait(false);    //Collect watts, invite others
                await Click(A, 7_000 + Hub.Config.Raid.ExtraTimeInviteOthersAR, token).ConfigureAwait(false); //Collect watts, invite others
            }
        }
コード例 #19
0
        private async Task DoDenBot(CancellationToken token)
        {
            if (Settings.Star < 0 || Settings.Star > 4)
            {
                Log("Please enter a valid star count.");
                return;
            }
            else if (Settings.Randroll < 1 || Settings.Randroll > 100)
            {
                Log("Please enter a valid randroll");
                return;
            }
            else if (Settings.SkipCount < 0)
            {
                Log("Please enter a valid skip count.");
                return;
            }

            RaidInfo.Settings = Settings;
            var denData = await DenData(Hub, token).ConfigureAwait(false);

            RaidInfo = DenUtil.GetRaid(RaidInfo, denData);
            Log("Starting main DenBot loop.");

            while (!token.IsCancellationRequested && Config.NextRoutineType == PokeRoutineType.DenBot)
            {
                Config.IterateNextRoutine();
                if (Settings.DenMode == DenMode.Skip)
                {
                    var skips = Settings.SkipCount;
                    InitialSeed     = RaidInfo.Den.Seed;
                    DestinationSeed = DenUtil.GetTargetSeed(RaidInfo.Den.Seed, skips);
                    Log($"\nInitial seed: {InitialSeed:X16}.\nDestination seed: {DestinationSeed:X16}.");
                    await PerformDaySkip(skips, token).ConfigureAwait(false);

                    if (!await SkipCorrection(skips, token).ConfigureAwait(false))
                    {
                        return;
                    }

                    EchoUtil.Echo($"{(!Hub.Config.StopConditions.PingOnMatch.Equals(string.Empty) ? $"<@{Hub.Config.StopConditions.PingOnMatch}> " : "")}Skipping complete\n");
                }
                else
                {
                    PerformSeedSearch();
                    EchoUtil.Echo($"{(!Hub.Config.StopConditions.PingOnMatch.Equals(string.Empty) ? $"<@{Hub.Config.StopConditions.PingOnMatch}> " : "")}Seed search complete, stopping the bot.\n");
                    return;
                }

                if (Settings.HostAfterSkip && Settings.DenMode != DenMode.SeedSearch)
                {
                    Config.Initialize(PokeRoutineType.RaidBot);
                    await SaveGame(Hub.Config, token).ConfigureAwait(false);

                    Log("\nInitializing RaidBot...");
                }
                else
                {
                    return;
                }
            }
        }