Ejemplo n.º 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;
                }
            }
        }
Ejemplo n.º 2
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;
        }