Пример #1
0
        public static async Task <bool> StartupOpenGates(this AdvancedViewState s, Bot b, CancellationToken token)
        {
            if (!s.Config.AllowTeleportation)
            {
                b.Log($"{nameof(ViewStateConfig.AllowTeleportation)} has to be enabled to automatically retrieve Dodo code.");
                return(false);
            }

            await s.Initialize(token).ConfigureAwait(false);

            // Open gates and retrieve Dodo code in airport.
            b.Log("Opening gates and obtaining Dodo code.");
            await s.WarpToAirportFromIsland(token).ConfigureAwait(false);

            await s.WarpToDodoCounter(token).ConfigureAwait(false);

            await s.OpenGates(token).ConfigureAwait(false);

            await s.WarpToIslandFromAirport(token).ConfigureAwait(false);

            await s.WaitEnterIsland(token).ConfigureAwait(false);

            // Reset player position to initial position.
            await s.ResetToStartPosition(token).ConfigureAwait(false);

            return(true);
        }
Пример #2
0
        public static async Task <bool> StartupGetDodoCode(this AdvancedViewState s, Bot b, CancellationToken token, bool allowNoFetch = false)
        {
            if (!s.Config.DodoCodeRetrieval)
            {
                b.Log($"{nameof(ViewStateConfig.DodoCodeRetrieval)} has to be enabled to automatically retrieve Dodo code. Please set the Dodo code via command.");
                return(allowNoFetch);
            }

            const string dodoFile = "dodo.txt";
            var          code     = await s.GetDodoCode(token).ConfigureAwait(false);

            if (code == null)
            {
                b.Log("Unable to detect Dodo code.");
                if (File.Exists(dodoFile))
                {
                    File.Delete(dodoFile);
                }
                return(false);
            }

            b.Island.DodoCode = code;
            File.WriteAllText(dodoFile, code);
            return(true);
        }