Beispiel #1
0
        private static void SetGameModeFromString(string GameMode)
        {
            switch (GameMode)
            {
            default:
                CurrentGameMode = LeagueOfLegends.GameMode.Unknown;
                break;

            case "CLASSIC":
                CurrentGameMode = LeagueOfLegends.GameMode.Classic;
                break;

            case "GAMEMODEX":
                CurrentGameMode = LeagueOfLegends.GameMode.NexusBlitz;
                break;

            case "ARAM":
                CurrentGameMode = LeagueOfLegends.GameMode.ARAM;
                break;
            }

            Debug.WriteLine("Detected as playing " + CurrentGameMode.ToString());
        }
Beispiel #2
0
        private static async void OnWebsocketMessage(object sender, MessageEventArgs e)
        {
            var Messages = JArray.Parse(e.Data);

            int MessageType = 0;

            if (!int.TryParse(Messages[0].ToString(), out MessageType) || MessageType != 8)
            {
                return;
            }

            var EventName = Messages[1].ToString();

#if DEBUG_EVENTS
            Debug.WriteLine("Received an event: " + EventName);
#endif

            switch (EventName)
            {
            case LoggedInEvent:
                while (!IsLoggedIn)
                {
                    try
                    {
                        CurrentSummoner = await Summoner.GetCurrent();

                        var Lobby = await LobbyRequest.Get();

                        SetGameModeFromString(Lobby != null ? Lobby.gameConfig.gameMode : "UNKNOWN");

                        LoggedIn?.Invoke(null, EventArgs.Empty);
                        IconChanged?.Invoke(null, EventArgs.Empty);
                        break;
                    }

                    // We aren't logged in!
                    catch (System.Net.Http.HttpRequestException)
                    {
                        await Task.Delay(TimeSpan.FromSeconds(5));
                    }
                }
                break;

            case SummonerIconChangedEvent:
                CurrentSummoner = await Summoner.GetCurrent();

                if (CurrentSummoner.profileIconId != ForcedPoroIcon)
                {
                    IconChanged?.Invoke(null, EventArgs.Empty);
                }
                else if (ForcedPoroIcon != -1 && CurrentSummoner.profileIconId != ForcedPoroIcon)
                {
                    Icon.Set(ForcedPoroIcon);
                }
                break;

            case QueueUpEvent:
                var QueueEvent = Messages[2];
                var QueueURI   = QueueEvent["uri"].ToString();

                if (QueueURI == "/lol-lobby-team-builder/v1/lobby/countdown" && QueueEvent["data"]["phaseName"].ToString() == "MATCHMAKING")
                {
                    Debug.WriteLine("Noticed start of matchmaking, setting poro icon.");
                    Icon.SetToPoro(CurrentGameMode, out ForcedPoroIcon);
                    break;
                }

                if (QueueURI != "/lol-lobby-team-builder/v1/lobby")
                {
                    break;
                }

                var QueueEventType = QueueEvent["eventType"].ToString();
                Debug.WriteLine($"QueueUpEvent: {QueueEventType}");
                if (QueueEventType == "Delete")
                {
                    Icon.ResetToDefault();
                    ForcedPoroIcon = -1;
                }
                else if (ForcedPoroIcon == -1)
                {
                    Icon.SetToPoro(CurrentGameMode, out ForcedPoroIcon);
                }
                break;

            case GameModeChangedEvent:
                var EventContainer = Messages[2];
                if (EventContainer["uri"].ToString() != "/lol-lobby/v2/lobby")
                {
                    break;
                }
                var EventType = EventContainer["eventType"].ToString();
                Debug.WriteLine("GameModeChangedEvent: " + EventType);
                switch (EventType)
                {
                case "Create":
                    var LobbyCreatedEvent = JsonConvert.DeserializeObject <LobbyCreateEvent>(Messages[2].ToString());
                    SetGameModeFromString(LobbyCreatedEvent.data.gameConfig.gameMode);
                    break;

                case "Delete":
                    CurrentGameMode = LeagueOfLegends.GameMode.Unknown;
                    break;

                case "Update":
                    var LobbyUpdatedEvent = JsonConvert.DeserializeObject <LobbyCreateEvent>(Messages[2].ToString());
                    SetGameModeFromString(LobbyUpdatedEvent.data.gameConfig.gameMode);
                    break;
                }
                GameModeUpdated?.Invoke(null, EventArgs.Empty);
                break;

            case GameEvent:
                var GameEventData = Messages[2];
                var GameURI       = GameEventData["uri"].ToString();
                if (GameURI != "/lol-gameflow/v1/session")
                {
                    break;
                }

                if (GameEventData["data"] == null)
                {
                    break;
                }

                var Phase = GameEventData["data"]["phase"].ToString();
                Debug.WriteLine("Current GameFlow phase: " + Phase);
                if (Phase == "InProgress")
                {
                    Icon.ResetToDefault();
                }
                break;
            }
        }
Beispiel #3
0
        internal static void SetToPoro(LeagueOfLegends.GameMode Mode, out int IconID)
        {
            string ID = Config.Current.GetEntryIDForCurrentSummonerSync();

            int[] IconSet;
            int   Index;

            switch (Mode)
            {
            default:
                IconID = -1;
                return;

            case LeagueOfLegends.GameMode.ARAM:
                IconSet = Config.Current.Entries[ID].EnabledForARAM.ToArray();
                Index   = Config.Current.Entries[ID].ARAMIterator;
                break;

            case LeagueOfLegends.GameMode.NexusBlitz:
                IconSet = Config.Current.Entries[ID].EnabledForBlitz.ToArray();
                Index   = Config.Current.Entries[ID].BlitzIterator;
                break;

            case LeagueOfLegends.GameMode.URF:
                IconSet = Config.Current.Entries[ID].EnabledForURF.ToArray();
                Index   = Config.Current.Entries[ID].URFIterator;
                break;
            }

            if (Index >= IconSet.Length)
            {
                Index = 0;
            }

            if (IconSet.Length == 0 || IconSet[Index] == LeagueOfLegends.CurrentSummoner.profileIconId)
            {
                IconID = -1;
                return;
            }

            IconID = IconSet[Index];
            Debug.WriteLine("Setting Poro Icon " + IconID);
            Set(IconID);

            switch (Mode)
            {
            default:
                return;

            case LeagueOfLegends.GameMode.ARAM:
                Config.Current.Entries[ID].ARAMIterator++;
                break;

            case LeagueOfLegends.GameMode.NexusBlitz:
                Config.Current.Entries[ID].BlitzIterator++;
                break;

            case LeagueOfLegends.GameMode.URF:
                Config.Current.Entries[ID].URFIterator++;
                break;
            }
        }