Пример #1
0
        public void RefreshState()
        {
            STATE lastState = currentState;
            var   lockState = DataExtractor.GetBetState() == "open" ? STATE.OPEN : STATE.CLOSED;

            var footerText      = DataExtractor.GetFooterText();
            var footerPopulated = !string.IsNullOrWhiteSpace(footerText);

            //If closed but information is now available
            if (lockState == STATE.CLOSED && currentState == STATE.CLOSED && footerPopulated)
            {
                currentState = STATE.ClOSED_INFORMATION;
                OnStateClosedInformation();
                return;
            }

            //If state changed from last measured state
            if (lastState != lockState)
            {
                if (lockState == STATE.OPEN)
                {
                    OnOpenState();
                    currentState = STATE.OPEN;
                }
                if (lockState == STATE.CLOSED && lastState != STATE.ClOSED_INFORMATION)
                {
                    OnClosedState();
                    currentState = STATE.CLOSED;
                }
            }
        }
Пример #2
0
        public static bool IsBetStateOpen()
        {
            //if bet has already been placed
            if (HasPlacedBet)
            {
                return(false);
            }

            string betState = DataExtractor.GetBetState();

            //Check if betstate is open
            if (betState == "open")
            {
                return(true);
            }

            return(false);
        }
Пример #3
0
        private void Refresh()
        {
            saltyStateMachine.RefreshState();
            MatchInformation.UpdateFighterData();

            if (!MatchInformation.HasOfferedBet)
            {
                MatchInformation.UpdateData();
                MatchInformation.MatchStart = DateTime.Now;


                var matchStartEventArgs = new MatchStartEventArgs
                {
                    Salt       = DataExtractor.GetSaltBalanceNum(),
                    BluePlayer = MatchInformation.currentBluePlayer,
                    RedPlayer  = MatchInformation.currentRedPlayer,

                    Tournament = _lastMatchType == MatchType.Tournament,
                    TournamentPlayersRemaining = _bracketCount,
                };

                if (_lastMatchType == MatchType.Tournament && _nextMatchType != MatchType.Tournament)
                {
                    OnTournamentEnded(new EventArgs());
                }

                switch (_nextMatchType)
                {
                case MatchType.Tournament:
                    OnTournamentMatchStart(matchStartEventArgs);
                    break;

                case MatchType.Exhibition:
                    OnExhibitionMatchStart(matchStartEventArgs);
                    break;

                case MatchType.Matchmaking:
                    OnMatchStart(matchStartEventArgs);
                    break;
                }

                MatchInformation.HasOfferedBet = true;
            }
        }
Пример #4
0
 public static void UpdateData()
 {
     currentRedPlayer  = DataExtractor.GetRedName();
     currentBluePlayer = DataExtractor.GetBlueName();
 }
Пример #5
0
        private void MatchFinished()
        {
            Players winningPlayer;
            var     winningPlayerName = MatchInformation.winningplayer;
            string  losingPlayerName;

            int winnerSalt;
            int loserSalt;

            int balanceChange;
            int salt = MatchInformation.SaltBeforeMatch;

            if (winningPlayerName == MatchInformation.currentBluePlayer)
            {
                winningPlayer    = Players.BluePlayer;
                winnerSalt       = MatchInformation.BlueSalt;
                losingPlayerName = MatchInformation.currentRedPlayer;
                loserSalt        = MatchInformation.RedSalt;
            }
            else
            {
                winningPlayer    = Players.RedPlayer;
                winnerSalt       = MatchInformation.RedSalt;
                losingPlayerName = MatchInformation.currentBluePlayer;
                loserSalt        = MatchInformation.BlueSalt;
            }

            if (winningPlayerName == MatchInformation.currentBettedPlayer)
            {
                balanceChange = DataExtractor.GetPayout();
            }
            else
            {
                balanceChange = MatchInformation.SaltBettedOnMatch * -1;
            }

            var matchEndEventArgs = new MatchEndEventArgs
            {
                BluePlayer = MatchInformation.currentBluePlayer,
                RedPlayer  = MatchInformation.currentRedPlayer,

                Tournament = _lastMatchType == MatchType.Tournament,
                TournamentPlayersRemaining = _bracketCount,

                WinningPlayer     = winningPlayer,
                WinningPlayerName = winningPlayerName,
                LoosingPlayerName = losingPlayerName,

                PickedPlayerName = MatchInformation.currentBettedPlayer,

                Tier = MatchInformation.Tier,

                WinnerSalt = winnerSalt,
                LoserSalt  = loserSalt,

                MatchStart  = MatchInformation.MatchStart,
                MatchLength = DateTime.Now - MatchInformation.MatchStart,

                SaltBalanceChange = balanceChange,
                Salt = salt + balanceChange,
            };

            switch (_lastMatchType)
            {
            case MatchType.Tournament:
                OnTournamentMatchEnd(matchEndEventArgs);
                break;

            case MatchType.Exhibition:
                OnExhibitionMatchEnded(matchEndEventArgs);
                break;

            case MatchType.Matchmaking:
                OnMatchEnd(matchEndEventArgs);
                break;
            }
        }
Пример #6
0
        private void SaltyStateMachine_StateClosedInformation(object sender, EventArgs e)
        {
            _lastMatchType = _nextMatchType;

            var footerText = DataExtractor.GetFooterText();

            if (footerText == "Tournament mode will be activated after the next match!")
            {
                _nextMatchType = MatchType.Tournament;
                _bracketCount  = 16;
                return;
            }

            if (footerText == "FINAL ROUND! Stay tuned for exhibitions after the tournament")
            {
                _nextMatchType = MatchType.Exhibition;
                _bracketCount  = 2;
                return;
            }

            if (footerText == "Tournament mode start!")
            {
                _nextMatchType = MatchType.Tournament;
                return;
            }

            if (footerText == "Exhibition mode start!")
            {
                _nextMatchType = MatchType.Exhibition;
                return;
            }

            if (footerText == "Matchmaking mode will be activated after the next exhibition match!")
            {
                _nextMatchType = MatchType.Matchmaking;
                return;
            }

            var tournamentRegex = @"(\d+) characters are left in the bracket!";
            var tournamentMatch = Regex.Match(footerText, tournamentRegex);

            if (tournamentMatch.Success)
            {
                var particpantsString = tournamentMatch.Groups[1].ToString();

                int.TryParse(particpantsString, out var count);

                _bracketCount  = count;
                _nextMatchType = MatchType.Tournament;
                return;
            }

            var exhibitionRegex = @"\d+ exhibition matches left!";
            var exhibitionMatch = Regex.Match(footerText, exhibitionRegex);

            if (exhibitionMatch.Success)
            {
                _nextMatchType = MatchType.Exhibition;
                return;
            }

            var matchMakingRegex = @"\d+ more matches until the next tournament!";
            var matchMakingMatch = Regex.Match(footerText, matchMakingRegex);

            if (matchMakingMatch.Success)
            {
                _nextMatchType = MatchType.Matchmaking;
                return;
            }

            _nextMatchType = MatchType.Matchmaking;
        }