Exemplo n.º 1
0
        public async void Save()
        {
            foreach (var Entry in Entries)
            {
                Entry.Value.EnabledForURF   = Entry.Value.EnabledForURF.Distinct().ToList();
                Entry.Value.EnabledForARAM  = Entry.Value.EnabledForARAM.Distinct().ToList();
                Entry.Value.EnabledForBlitz = Entry.Value.EnabledForBlitz.Distinct().ToList();

                Entry.Value.EnabledForURF.Sort();
                Entry.Value.EnabledForARAM.Sort();
                Entry.Value.EnabledForBlitz.Sort();
            }

            File.WriteAllText(LocalLocation, JsonConvert.SerializeObject(this));

            if (Summoner != null && Summoner.UnderstandsServerSync)
            {
                var S = LeagueOfLegends.CurrentSummoner;
                if (!Summoner.WantsServerSync)
                {
                    await JSONRequest.Get <bool>($"{DeleteURL}?p={S.puuid}");
                }

                var IconsARAM  = string.Join(",", Summoner.EnabledForARAM);
                var IconsBlitz = string.Join(",", Summoner.EnabledForBlitz);
                var IconsURF   = string.Join(",", Summoner.EnabledForURF);
                await Request.Get($"{WriteURL}?p={S.puuid}" +
                                  $"&a={IconsARAM}&ai={Summoner.ARAMIterator}" +
                                  $"&b={IconsBlitz}&bi={Summoner.BlitzIterator}" +
                                  $"&u={IconsURF}&ui={Summoner.URFIterator}");
            }
        }
Exemplo n.º 2
0
        public static async Task <EffectIcon[]> GetEffectIcons()
        {
            if (AllowedIcons == null)
            {
                AllowedIcons = await JSONRequest.Get <EffectIcon[]>("https://querijn.codes/poro_queue/icons.json");
            }

            return(AllowedIcons);
        }
Exemplo n.º 3
0
 public static async Task <LobbyRequest> Get()
 {
     try
     {
         return(await JSONRequest.Get <LobbyRequest>(LeagueOfLegends.APIDomain + "/lol-lobby/v2/lobby"));
     }
     catch (System.Net.Http.HttpRequestException)
     {
         return(null);
     }
 }
Exemplo n.º 4
0
        public async Task <string> GetEntryIDForCurrentSummoner()
        {
            if (LeagueOfLegends.CurrentSummoner == null)
            {
                return("Default");
            }

            if (LookedUpSummoners.Any(s => s == LeagueOfLegends.CurrentSummoner.puuid) == false)
            {
                SummonerConfig Result;
                try
                {
                    var URL = $"{ReadURL}?p={LeagueOfLegends.CurrentSummoner.puuid}";
                    Result = await JSONRequest.Get <SummonerConfig>(URL);

                    if (Result != null)
                    {
                        if (!Entries.Any(e => e.Key == LeagueOfLegends.CurrentSummoner.puuid))
                        {
                            Entries.Add(LeagueOfLegends.CurrentSummoner.puuid, Result);
                        }
                        else
                        {
                            Entries[LeagueOfLegends.CurrentSummoner.puuid] = Result;
                        }
                    }
                }
                catch (System.Net.Http.HttpRequestException e)
                {
                    int i = 0; i++;
                }

                LookedUpSummoners.Add(LeagueOfLegends.CurrentSummoner.puuid);
            }

            if (!Entries.Any(e => e.Key == LeagueOfLegends.CurrentSummoner.puuid))
            {
                Entries.Add(LeagueOfLegends.CurrentSummoner.puuid, new SummonerConfig());
                Save();
            }

            return(LeagueOfLegends.CurrentSummoner.puuid);
        }
Exemplo n.º 5
0
        private static async void Init()
        {
            IsActive = true;

            var Parts = LockFile.Split(':');

            ushort Port     = ushort.Parse(Parts[2]);
            var    Password = Parts[3];
            var    Protocol = Parts[4];

            APIDomain = String.Format("{0}://127.0.0.1:{1}", Protocol, Port);
            Request.SetUserData("riot", Password);

#if DEBUG_EVENTS
            try
            {
                var AllEventsText = await Request.Get(APIDomain + "/help");

                File.WriteAllText("events.json", AllEventsText);
            }
            catch (System.Net.Http.HttpRequestException)
            {
            }
#endif

            var Versions = await JSONRequest.Get <string[]>("http://ddragon.leagueoflegends.com/api/versions.json");

            LatestVersion = Versions[0];

            Started?.Invoke(null, EventArgs.Empty);

            Connection = new WebSocket("wss://127.0.0.1:" + Port + "/", "wamp");
            Connection.SetCredentials("riot", Password, true);
            Connection.SslConfiguration.EnabledSslProtocols = System.Security.Authentication.SslProtocols.Tls12;
            Connection.OnMessage += OnWebsocketMessage;
            Connection.Connect();

#if !DEBUG_EVENTS
            Connection.Send("[5,\"" + SummonerIconChangedEvent + "\"]");
            Connection.Send("[5,\"" + QueueUpEvent + "\"]");
            Connection.Send("[5,\"" + GameModeChangedEvent + "\"]");
            Connection.Send("[5,\"" + GameEvent + "\"]");
#else
            var HelpDocument = JsonConvert.DeserializeObject <DebugEventHelper>(File.ReadAllText("events.json"));
            foreach (var EventName in HelpDocument.events)
            {
                var Event = EventName.Key;
                if (Event == "OnJsonApiEvent")
                {
                    continue;
                }
                Connection.Send("[5,\"" + Event + "\"]");
            }
#endif

            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);
            }

            // We aren't logged in!
            catch (System.Net.Http.HttpRequestException e)
            {
#if !DEBUG_EVENTS
                Connection.Send("[5,\"" + LoggedInEvent + "\"]");
#endif
            }
        }
Exemplo n.º 6
0
 public static async Task <MissionDataRequest> Get()
 {
     return(await JSONRequest.Get <MissionDataRequest>(LeagueOfLegends.APIDomain + "/lol-missions/v1/data"));
 }
Exemplo n.º 7
0
 public static async Task <Summoner> GetCurrent()
 {
     return(await JSONRequest.Get <Summoner>(LeagueOfLegends.APIDomain + "/lol-summoner/v1/current-summoner"));
 }