示例#1
0
#pragma warning restore CS1591
        #endregion

        private Map(Gamemode gamemode, string mapName, OWEvent gameEvent)
        {
            GameEvent = gameEvent;
            GameMode  = gamemode;
            MapName   = mapName;
            ShortName = mapName.Substring(mapName.IndexOf('_') + 1);
        }
示例#2
0
        /// <summary>
        /// Gets the modes enabled in the Overwatch custom game.
        /// </summary>
        /// <param name="currentOverwatchEvent">The current Overwatch event.</param>
        /// <returns></returns>
        public Gamemode GetModesEnabled(OWEvent currentOverwatchEvent)
        {
            using (LockHandler.Interactive)
            {
                NavigateToModesMenu();

                ResetMouse();

                Thread.Sleep(100);

                UpdateScreen();

                Gamemode modesEnabled = new Gamemode();

                foreach (Gamemode gamemode in Enum.GetValues(typeof(Gamemode)))
                {
                    Point gamemodeIconLocation = GetModeLocation(gamemode, currentOverwatchEvent);
                    if (gamemodeIconLocation != Point.Empty && Capture.CompareColor(gamemodeIconLocation, Colors.SETTINGS_MODES_ENABLED, Fades.SETTINGS_MODES_ENABLED))
                    {
                        modesEnabled |= gamemode;
                    }
                }

                GoBack(2);

                return(modesEnabled);
            }
        }
示例#3
0
        internal Point GetModeLocation(Gamemode mode, OWEvent owevent) // Gets the location of a gamemode in Settings/Modes
        {
            // Ordered by how the gamemodes are listed in Overwatch at Settings/Modes
            var gamemodes = new Tuple <Gamemode, OWEvent>[]
            {
                // Default modes are listed first in alphabetical order.
                new Tuple <Gamemode, OWEvent>(Gamemode.Assault, OWEvent.None),
                new Tuple <Gamemode, OWEvent>(Gamemode.AssaultEscort, OWEvent.None),
                new Tuple <Gamemode, OWEvent>(Gamemode.Control, OWEvent.None),
                new Tuple <Gamemode, OWEvent>(Gamemode.Escort, OWEvent.None),

                // Followed by Mei's Snowball Offensive, which goes against the normal order for some reason.
                new Tuple <Gamemode, OWEvent>(Gamemode.MeisSnowballOffensive, OWEvent.WinterWonderland),

                // Then the rest in alphabetical order, except for skirmish.
                new Tuple <Gamemode, OWEvent>(Gamemode.CaptureTheFlag, OWEvent.None),
                new Tuple <Gamemode, OWEvent>(Gamemode.Deathmatch, OWEvent.None),
                new Tuple <Gamemode, OWEvent>(Gamemode.Elimination, OWEvent.None),
                new Tuple <Gamemode, OWEvent>(Gamemode.JunkensteinsRevenge, OWEvent.HalloweenTerror),
                new Tuple <Gamemode, OWEvent>(Gamemode.Lucioball, OWEvent.SummerGames),
                new Tuple <Gamemode, OWEvent>(Gamemode.TeamDeathmatch, OWEvent.None),
                new Tuple <Gamemode, OWEvent>(Gamemode.YetiHunter, OWEvent.WinterWonderland),

                // Skirmish is always last.
                new Tuple <Gamemode, OWEvent>(Gamemode.Skirmish, OWEvent.None)
            };

            int modeIndex = Array.IndexOf(gamemodes
                                          .Where(m => m.Item2 == OWEvent.None || m.Item2 == owevent)
                                          .Select(m => m.Item1)
                                          .ToArray()
                                          , mode) + 1;

            if (modeIndex == 0)
            {
                return(Point.Empty);
            }

            int[] columns = new int[] { 83, 227, 370, 515 };

            return(new Point(columns[modeIndex % 4], 129 + modeIndex / 4 * 107));
        }
    static void Main()
    {
        CustomGame cg = new CustomGame();

        Map[] voteForMaps = new Map[]
        {
            Map.AE_BlizzardWorld,
            Map.AE_Eichenwalde,
            Map.AE_Hollywood,
            Map.AE_KingsRow,
            Map.AE_Numbani
        };
        OWEvent  currentEvent     = CustomGame.GetCurrentEvent();
        Gamemode enabledGamemodes = cg.GetModesEnabled(currentEvent);

        VoteForMap(cg, voteForMaps, enabledGamemodes, currentEvent, true);

        Console.WriteLine("Done.");
        Console.ReadLine();
    }
    public static Map VoteForMap(CustomGame cg, Map[] maps, Gamemode enabledGamemodes, OWEvent currentEvent, bool logResults)
    {
        if (maps.Length < 3)
        {
            throw new ArgumentException($"{nameof(maps)} must have at least 3 maps.", nameof(maps));
        }

        Map[] voteForMaps = Get3RandomMaps(maps);

        List <Vote> voteResults = new List <Vote>();
        ListenTo    voteCommand = new ListenTo("$VOTE", true, false, false, (cd) => OnVote(cd, voteResults, voteForMaps, logResults));

        cg.Commands.Listen = true;

        // Send the maps to vote for to the chat.
        cg.Chat.SwapChannel(Channel.Match); // Join the match channel
        cg.Chat.SendChatMessage(FormatMessage(
                                    "Vote for map! (15 seconds)",
                                    voteForMaps[0].ShortName + " - $VOTE 1",
                                    voteForMaps[1].ShortName + " - $VOTE 2",
                                    voteForMaps[2].ShortName + " - $VOTE 3"));

        // Listen to the "$VOTE" command for 15 seconds.
        cg.Commands.ListenTo.Add(voteCommand);
        Thread.Sleep(15000);
        cg.Commands.ListenTo.Remove(voteCommand);
        // Get results
        int[] results = new int[3]
        {
            voteResults.Count(vr => vr.VotingFor == 1),
            voteResults.Count(vr => vr.VotingFor == 2),
            voteResults.Count(vr => vr.VotingFor == 3)
        };

        Map winningmap = voteForMaps[Array.IndexOf(results, results.Max())];

        // Dispose all chat identities.
        foreach (Vote voteResult in voteResults)
        {
            voteResult.ChatIdentity.Dispose();
        }
        voteResults = new List <Vote>();

        // Print the results to the chat
        string mapResults = String.Format("{0}: {1} votes, {2}: {3} votes, {4}: {5} votes",
                                          voteForMaps[0].ShortName, results[0],
                                          voteForMaps[1].ShortName, results[1],
                                          voteForMaps[2].ShortName, results[2]);

        cg.Chat.SendChatMessage(mapResults);

        if (logResults)
        {
            Console.WriteLine(mapResults);
            Console.WriteLine("Next map: " + winningmap.ShortName);
        }
        cg.Chat.SendChatMessage("Next map: " + winningmap.ShortName);
        cg.ToggleMap(enabledGamemodes, currentEvent, ToggleAction.DisableAll, winningmap);

        return(winningmap);
    }
示例#6
0
        /// <summary>
        /// Toggles maps in Overwatch.
        /// </summary>
        /// <param name="modesEnabled">The modes enabled in the overwatch game.</param>
        /// <param name="currentEvent">The current Overwatch event.</param>
        /// <param name="toggleAction">Determines if all maps should be enabled, disabled or neither before toggling.</param>
        /// <param name="maps">Maps that should be toggled.</param>
        /// <remarks>
        /// <include file="docs.xml" path="doc/getMaps" />
        /// </remarks>
        /// <include file='docs.xml' path='doc/ToggleMap2/example'></include>
        /// <seealso cref="Map"/>
        /// <seealso cref="ToggleMap(ToggleAction, Map[])"/>
        public void ToggleMap(Gamemode modesEnabled, OWEvent currentEvent, ToggleAction toggleAction, params Map[] maps)
        {
            using (LockHandler.Interactive)
            {
                int waitTime = 1;

                GoToSettings();

                LeftClick(Points.SETTINGS_MAPS, 1000); // Clicks "Maps" button (SETTINGS/MAPS/)

                // Click Disable All or Enable All in custom games if ta doesnt equal ToggleAction.None.
                if (toggleAction == ToggleAction.DisableAll)
                {
                    LeftClick(Points.SETTINGS_MAPS_DISABLE_ALL, 250);
                }
                else if (toggleAction == ToggleAction.EnableAll)
                {
                    LeftClick(Points.SETTINGS_MAPS_ENABLE_ALL, 250);
                }

                // Get the modes enabled state in a bool in alphabetical order.
                bool[] enabledModes = new bool[]
                {
                    modesEnabled.HasFlag(Gamemode.Assault),
                    modesEnabled.HasFlag(Gamemode.AssaultEscort),
                    modesEnabled.HasFlag(Gamemode.CaptureTheFlag),
                    modesEnabled.HasFlag(Gamemode.Control),
                    modesEnabled.HasFlag(Gamemode.Deathmatch),
                    modesEnabled.HasFlag(Gamemode.Elimination),
                    modesEnabled.HasFlag(Gamemode.Escort),
                    modesEnabled.HasFlag(Gamemode.JunkensteinsRevenge),
                    modesEnabled.HasFlag(Gamemode.Lucioball),
                    modesEnabled.HasFlag(Gamemode.MeisSnowballOffensive),
                    modesEnabled.HasFlag(Gamemode.Skirmish),
                    modesEnabled.HasFlag(Gamemode.TeamDeathmatch),
                    modesEnabled.HasFlag(Gamemode.YetiHunter),
                };

                if (enabledModes.Length != Enum.GetNames(typeof(Gamemode)).Length)
                {
                    throw new NotImplementedException("The length of enabledModes does not equal the length of the gamemodes in the Gamemode enum.");
                }

                List <int> selectMap = new List <int>();
                int        mapcount  = 0;
                // For each enabled mode...
                for (int i = 0; i < enabledModes.Length; i++)
                {
                    if (enabledModes[i])
                    {
                        Gamemode emi = (Gamemode)Enum.Parse(typeof(Gamemode), Enum.GetNames(typeof(Gamemode))[i]); //enabledmodesindex

                        List <Map> allowedmaps = Map.GetMapsInGamemode(emi, currentEvent).ToList();
                        // ...And for each map...
                        for (int mi = 0; mi < maps.Length; mi++)
                        {
                            // ...Check if the maps mode equals the enabledModes index and check if the map is in allowed maps...
                            if (maps[mi].GameMode == emi && allowedmaps.Contains(maps[mi]))
                            {
                                // ...then add the map index to the selectmap list. 1, 5, 10 will toggle the first map in overwatch, the fifth, then the tenth...
                                selectMap.Add(mapcount + allowedmaps.IndexOf(maps[mi]) + 1);
                            }
                        }
                        // ...then finally add the number of maps in the mode to the mapcount.
                        mapcount += allowedmaps.Count;
                    }
                }
                mapcount++;

                // Toggle maps
                for (int i = 0; i < mapcount; i++)
                {
                    for (int mi = 0; mi < selectMap.Count; mi++)
                    {
                        if (selectMap[mi] == i)
                        {
                            KeyPress(Keys.Space);
                            Thread.Sleep(waitTime);
                        }
                    }
                    KeyPress(Keys.Down);
                    Thread.Sleep(waitTime);
                }

                GoBack(2, 0);
            }
        }
示例#7
0
 /// <summary>
 /// Gets all maps in a gamemode.
 /// </summary>
 /// <param name="gamemode">The gamemode to get the maps from.</param>
 /// <param name="owEvent">Filter by Overwatch event.</param>
 /// <returns>An array of maps in the <paramref name="gamemode"/>.</returns>
 public static Map[] GetMapsInGamemode(Gamemode gamemode, OWEvent owEvent = OWEvent.None)
 {
     return(GetMaps().Where(v => (v.GameEvent == OWEvent.None || v.GameEvent == owEvent) && gamemode.HasFlag(v.GameMode)).ToArray());
 }