Exemplo n.º 1
0
        public void LookForStats(IntPtr mainWindowHandle)
        {
            Bitmap screen = (Bitmap)_screenshotter.CaptureWindow(mainWindowHandle);

            if (CurrentState == GameState.Scorescreen)
            {
                LookforSR(screen, _currentGame);
                return;
            }

            var result = StatScrapper.DetermineGameResult(screen);

            if (result == GameResult.Uncertain)
            {
                return;
            }

            Directory.CreateDirectory("./games/" + _currentGame.Id);
            _sw.Start();
            CurrentState = GameState.Scorescreen;
            Console.WriteLine("Current state: " + CurrentState);
            _currentGame             = StatScrapper.MapAndTime(_currentGame, screen, result);
            _currentGame.Result      = result;
            _currentGame.CompletedAt = DateTime.Now;
        }
Exemplo n.º 2
0
        private void LookforSR(Bitmap screenshot, Game game)
        {
            var sr = StatScrapper.SR(screenshot, game);

            // If same measurement twice in a row, that wasn't 0 - means we found a valid SR
            // Or if we didnt find one after 60 seconds we just give up
            if (sr == _tmpSr && sr != 0 || _sw.Elapsed.TotalSeconds > 60)
            {
                OnGameCompleted(new MatchResult {
                    Game = _currentGame, Sr = sr
                });

                _currentGame = new Game();
                CurrentState = GameState.Menus;
                _sw.Reset();
                Console.WriteLine("Current state: " + CurrentState);
                return;
            }

            _tmpSr = sr;
        }