コード例 #1
0
        public UnovaBattle StartWildBattle(int pokeId, int level, int mapId, int type, int x = 20, int y = 20)
        {
            var nvc = new NameValueCollection {
                { "token_pokemon", Convert.ToBase64String(Encoding.UTF8.GetBytes($"{pokeId}|{(type == 0 ? string.Empty : (type).ToString())}|{level}|{mapId}")) },
                { "id_pokemon", pokeId.ToString() },
                { "level", level.ToString() },
                { "id_map", mapId.ToString() },
                { "x", x.ToString() },
                { "y", y.ToString() }
            };

            if (type != 0)
            {
                nvc.Add("shiny", type.ToString());
            }

            byte[] resp = Web.UploadValues(Urls.UrlBattleWild, nvc);

            return(UnovaBattle.FromHtml(this, Encoding.UTF8.GetString(resp), pokeId, level, mapId));
        }
コード例 #2
0
        internal static UnovaBattle FromHtml(UnovaSession sess, string html, int?pokeId = null, int?level = null, int?mapId = null, long?tid = null)
        {
            var ub = new UnovaBattle();

            ub._sess  = sess;
            ub.PokeId = pokeId;
            ub.Level  = level;
            ub._mapId = mapId;

            if (tid != null)
            {
                ub._tid = tid;
            }

            //get tokens
            string fParams = RegexToken.Match(html).Groups[1].Value;

            ub._type     = fParams.Split(',')[2].Trim('\'', ' ');
            ub._token    = fParams.Split(',').Last().Trim('\'', ' ');
            ub._runToken = RegexRunToken.Match(html).Groups[1].Value;

            return(ub);
        }
コード例 #3
0
        public UnovaBattle StartTrainerBattle(long tid)
        {
            string resp = Web.DownloadString(Urls.UrlBattleTrainer + "&tid=" + tid);

            return(UnovaBattle.FromHtml(this, resp, tid: tid));
        }