Ejemplo n.º 1
0
        private void persistantBattle()
        {
            String result = String.Empty;
            String points = String.Empty;
            CookieAwareWebClient client = new CookieAwareWebClient(this.cookie);

            points = SourceParser.ParseArenaPoints(client.DownloadString(CoinBrawl.ARENA_RANK));
            setBattleResultText("Battle Start:" + DateTime.Now.ToString("HH:mm:ss tt")
                                + NEW_LINE + "Your current Arena Points: " + points + NEW_LINE, Color.Black);
            while (autoBattle)
            {
                client.clickFight = false;
                points            = SourceParser.ParseArenaPoints(client.DownloadString(CoinBrawl.ARENA_RANK));
                List <String> enemyList = SourceParser.BattleInfo(client.DownloadString(CoinBrawl.ARENA));
                String        postData  = String.Format("battle%5Bdefender_id%5D={0}&token={1}", enemyList[1], enemyList[0]);
                client.Method     = CookieAwareWebClient.POST;
                client.clickFight = true;
                client.CSRF_Token = SourceParser.ParseCSRFToken(client.DownloadString(CoinBrawl.ARENA));
                client.UploadString(CoinBrawl.BATTELS, postData);
                client.clickFight = false;
                if (points.Equals(SourceParser.ParseArenaPoints(client.DownloadString(CoinBrawl.ARENA_RANK))))
                {
                    result += CoinBrawl.LOSE_BATTLE + NEW_LINE;
                    setBattleResultText(result, Color.Red);
                }
                else
                {
                    result += CoinBrawl.WIN_BATTLE + NEW_LINE;
                    setBattleResultText(result, Color.Green);
                }
            }
            setBattleResultText("Battle Stop:" + DateTime.Now.ToString("HH:mm:ss tt"), Color.Black);
            battleThread.Join();
        }
Ejemplo n.º 2
0
        private void updateMainForm()
        {
            CookieAwareWebClient client = new CookieAwareWebClient(this.cookie);
            List <String>        info   = SourceParser.PlayerStateInfo(client.DownloadString(CoinBrawl.CHARACTER));

            info.Add(SourceParser.ParseArenaPoints(client.DownloadString(CoinBrawl.ARENA_RANK)));
            Player.updatePlayer(info);
        }
Ejemplo n.º 3
0
 private static void ParallelParsingStateThread2(List <String> playerInfo, String sourceInfo)
 {
     playerInfo[Player.UPGRADE_STAMINA_GOLD] = SourceParser.ParseUpdateStamina(sourceInfo);
     playerInfo[Player.UPGRADE_TOKENS_GOLD]  = SourceParser.ParseUpdateTokens(sourceInfo);
     playerInfo[Player.UPGRADE_ATK_GOLD]     = SourceParser.ParseUpdateATK(sourceInfo);
     playerInfo[Player.UPGRADE_DEF_GOLD]     = SourceParser.ParseUpdateDEF(sourceInfo);
     playerInfo[Player.BITCOIN_ADDR]         = SourceParser.ParseBitcoinAddress(sourceInfo);
     playerInfo[Player.USER_ID] = SourceParser.ParseUserID(sourceInfo);
 }
Ejemplo n.º 4
0
        public static String ParseCSRFToken(String sourceInfo)
        {
            String pattern = "(<meta content=\"authenticity_token\" name=\"csrf-param\"\\/><meta content=\")(.*)(\" name=\"csrf-token\"\\/>)";

            sourceInfo = sourceInfo.Replace("\n", SourceParser.EMPTY);
            sourceInfo = sourceInfo.Replace("\r", SourceParser.EMPTY);
            Match match = Regex.Match(SourceParser.FilterBlanlAndNewLine(sourceInfo), pattern);

            return(match.Groups[2].Value);
        }
Ejemplo n.º 5
0
 private static void ParallelParsingStateThread1(List <String> playerInfo, String sourceInfo)
 {
     playerInfo[Player.LEVEL]   = SourceParser.ParseLevel(sourceInfo);
     playerInfo[Player.GOLDS]   = SourceParser.ParseGold(sourceInfo);
     playerInfo[Player.ATTACK]  = SourceParser.ParseAttack(sourceInfo);
     playerInfo[Player.DEFENSE] = SourceParser.ParseDefense(sourceInfo);
     playerInfo[Player.STAMINA] = SourceParser.ParseStamina(sourceInfo);
     playerInfo[Player.TOKENS]  = SourceParser.ParseTokens(sourceInfo);
     playerInfo[Player.SATOSHI] = SourceParser.ParseSatoshi(sourceInfo);
 }
Ejemplo n.º 6
0
 private void checkToken()
 {
     while (autoBattle)
     {
         updateMainForm();
         if (SourceParser.ParseAvailableTokens(Player.getPlayer().getTokens()).Equals(Player.EMPTY))
         {
             autoBattle = false;
         }
     }
     tokenThread.Join();
 }
Ejemplo n.º 7
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (userName.TextLength == 0 || userPassword.TextLength == 0)
            {
                MessageBox.Show("Must input user account/password");
                return;
            }

            var cookieJar = new CookieContainer();
            CookieAwareWebClient client = new CookieAwareWebClient(cookieJar);

            System.Net.ServicePointManager.Expect100Continue = false;
            client.Method = CookieAwareWebClient.POST;

            String response = String.Empty;
            String token    = SourceParser.ParseAuthenticationToken(client.DownloadString(CoinBrawl.SIGN_IN));
            String postData = String.Format("utf8={0}&authenticity_token={1}&user%5Bemail%5D={2}&user%5Bpassword%5D={3}&commit={4}",
                                            CoinBrawl.UTF8, token, userName.Text, userPassword.Text, CoinBrawl.COMMIT_SIGN_IN);

            try
            {
                response = client.UploadString(CoinBrawl.SIGN_IN, postData);
            }
            catch (WebException ex)
            {
                MessageBox.Show("A ntework error occurred\nPlease try again later or reopen the program");
            }

            if (response.Contains(CoinBrawl.LOGIN_SUCCESS))
            {
                MessageBox.Show("Login successfully");
                Player player = Player.getPlayer();
                player.setAuthenticityToken(token);
                mainForm mForm = new mainForm();
                mForm.cookie  = client.CookieContainer;
                this.Visible  = false;
                mForm.Visible = true;
            }
            else
            {
                MessageBox.Show("Invalid email or passowrd");
            }
        }
Ejemplo n.º 8
0
        private void button1_Click(object sender, EventArgs e)
        {
            Player player = Player.getPlayer();

            player.setBitCoinAddress(bitconAddressTextBox.Text);
            CookieAwareWebClient client = new CookieAwareWebClient(this.cookie);
            String postData             = String.Format("utf8={0}&_method={1}&authenticity_token={2}&user%5Bbitcoin_address%5D={3}&commit={4}",
                                                        CoinBrawl.UTF8, CoinBrawl.METHOD_PATCH, SourceParser.ParseCSRFToken(client.DownloadString(CoinBrawl.CHARACTER)), player.getBitCoinAddress(), CoinBrawl.COMMIT_SAVE);

            client.Method    = CookieAwareWebClient.POST;
            client.clickSave = true;
            try
            {
                client.UploadString(CoinBrawl.USER + player.getUserID(), postData);
                MessageBox.Show("You have successfully updated your bitcoin address");
            }
            catch (WebException ex)
            {
                //
                MessageBox.Show("Fail to updat your bitcoin address");
                //
            }
            updateMainForm();
            loadStateInfo();
        }