Example #1
0
    public static IList <Unforgiven.Champion> GetPlayableChamps()
    {
        var json = Request("GET",
                           "/lol-champions/v1/owned-champions-minimal");

        return(Unforgiven.Parse <IList <Unforgiven.Champion> >(json));
    }
Example #2
0
    private static void OnInitialized()
    {
        // First request :D
        var json = Request("GET", "/riotclient/get_region_locale");

        if (json != null)
        {
            var region = Unforgiven.Parse <Unforgiven.Region>(json);
            WashingPole.SetLanguage(region.webLanguage);
        }
        else
        {
            connected = false;
        }
    }
Example #3
0
    private static void OnMessage(object sender, MessageEventArgs meArgs)
    {
        if (!connected)
        {
            return;
        }
        if (!meArgs.IsText)
        {
            return;
        }
        var data = meArgs.Data;

        if (Int32.Parse(data.Substring(1, 1)) != 8)
        {
            return;
        }
        if (!data.Substring(4, listener.Length).Equals(listener))
        {
            return;
        }

        var json = data.Substring((4 + 2) + listener.Length,
                                  data.Length - listener.Length - (4 + 2 + 1));

        Match match;

        if ((match = CHAT_REGEX.Match(json)).Success)
        {
            prevChatId = match.Groups[1].Value;
            var body = Unforgiven.Parse <Unforgiven.Root <Unforgiven.Message> >(json).data.body;

            if (CMD_REGEX.IsMatch(body))
            {
                var tokens = body.ToLower().Split(' ');
                var cmd    = tokens[0].Remove(0, 1);
                var args   = tokens.Skip(1).ToArray();

                WashingPole.OnCommand(cmd, args);
            }
        }
        else if (CHSLCT_REGEX.IsMatch(json))
        {
            var session  = Unforgiven.Parse <Unforgiven.Root <Unforgiven.ChampSelectSession> >(json).data;
            var myCellId = session.localPlayerCellId;

            session.actions[0].Where((v) => {
                if (myCellId == v.actorCellId)
                {
                    actionId = v.id;
                }
                return(true);
            }).ToArray();   // Without calling ToArray, this code is not executed.

            WashingPole.OnChampSelect(actionId);
        }
        else if (MCHFND_REGEX.IsMatch(json))
        {
            WashingPole.OnMatchFound();
        }
        else if (SLCTED_REGEX.IsMatch(json))
        {
            // We had actionId when Champ Select is created.
            WashingPole.OnAfterPicked(actionId);
        }
    }