예제 #1
0
        /// <summary>
        /// Updates all the match stats with data from the browser window.
        /// </summary>
        /// <param name="dataExtractor"></param>
        public void Update(DataExtractor dataExtractor)
        {
            // Set call's stats to the Last
            LastPlayer1     = Player1;
            LastPlayer2     = Player2;
            LastPotPlayer1  = PotPlayer1;
            LastPotPlayer2  = PotPlayer2;
            LastOddsPlayer1 = OddsPlayer1;
            LastOddsPlayer2 = OddsPlayer2;

            // Check if a winner was announced.
            StatusMessage = dataExtractor.GetStatusText();
            if (StatusMessage.Contains(LastPlayer1))
            {
                LastWinner = LastPlayer1;
            }
            if (StatusMessage.Contains(LastPlayer2))
            {
                LastWinner = LastPlayer2;
            }

            // Get new player names, if applicable.
            Player1 = dataExtractor.GetRedName();
            Player2 = dataExtractor.GetBlueName();
            // Get new pots
            PotPlayer1 = dataExtractor.GetRedPotNum();
            PotPlayer2 = dataExtractor.GetBluePotNum();
            // Get new odds
            OddsPlayer1 = dataExtractor.GetRedOdds();
            OddsPlayer2 = dataExtractor.GetBlueOdds();
        }
예제 #2
0
        /// <summary>
        /// Updates the textboxes with new data from saltybet site.
        /// </summary>
        private void refresh()
        {
            // Don't update if browser is on the wrong page. Or the browser isn't initialized.
            if (!browser.IsBrowserInitialized || browser.Address != "http://www.saltybet.com/" || browser.IsLoading)
            {
                return;
            }

            // Update match tracker with new info, if new info is available.
            matchTracker.Update(dataExtractor);

            // Update database
            if (matchTracker.IsNewMatch())
            {
                // If last match wasn't a team match update add a new row
                if (!matchTracker.WasTeamMatch())
                {
                    // row layout
                    // TimeStamp | RedName | RedPot | Red Odds | BlueName | BluePot | BlueOdds | Winner | Match Time
                    dgwMatchHistory.Rows.Add(
                        Util.GetTimeStamp(DateTime.Now),
                        matchTracker.LastPlayer1, matchTracker.LastPotPlayer1, matchTracker.LastOddsPlayer1,
                        matchTracker.LastPlayer2, matchTracker.LastPotPlayer2, matchTracker.LastOddsPlayer2,
                        matchTracker.LastWinner, "n/a"
                        );
                    // Add match data to database
                    dbConn.InsertMatchData(
                        Util.GetTimeStamp(DateTime.Now),
                        matchTracker.LastPlayer1, matchTracker.LastPotPlayer1, matchTracker.LastOddsPlayer1,
                        matchTracker.LastPlayer2, matchTracker.LastPotPlayer2, matchTracker.LastOddsPlayer2,
                        matchTracker.LastWinner, "n/a"
                        );
                    // Update datagridview order after adding a new entry
                    if (dgwMatchHistory.SortOrder == SortOrder.Ascending)
                    {
                        dgwMatchHistory.Sort(dgwMatchHistory.SortedColumn, ListSortDirection.Ascending);
                    }
                    if (dgwMatchHistory.SortOrder == SortOrder.Descending)
                    {
                        dgwMatchHistory.Sort(dgwMatchHistory.SortedColumn, ListSortDirection.Descending);
                    }
                }
            }

            // Update Red Side
            this.tbRedName.Text = matchTracker.Player1;
            this.tbRedPot.Text  = matchTracker.PotPlayer1.ToString();
            this.tbRedOdds.Text = matchTracker.OddsPlayer1.ToString();

            // Update Blue Side
            this.tbBlueName.Text = matchTracker.Player2;
            this.tbBluePot.Text  = matchTracker.PotPlayer2.ToString();
            this.tbBlueOdds.Text = matchTracker.OddsPlayer2.ToString();

            // Update other general info
            this.tbSaltBalance.Text = dataExtractor.GetSaltBalanceNum().ToString();
            this.tbBetStatus.Text   = dataExtractor.GetStatusText();
        }