Ejemplo n.º 1
0
        public ChatRivenBot(string launcherFullPath, IMouse mouseMover, IScreenStateHandler screenStateHandler,
                            IGameCapture gameCapture,
                            ObsSettings obsSettings,
                            string password,
                            IKeyboard keyboard,
                            IChatParser chatParser,
                            IDataSender dataSender,
                            IRivenCleaner rivenCleaner,
                            IRivenParserFactory rivenParserFactory,
                            RedTextParser redTextParser)
        {
            _launcherPath       = launcherFullPath;
            _mouse              = mouseMover;
            _screenStateHandler = screenStateHandler;
            _gameCapture        = gameCapture;
            _obsSettings        = obsSettings;
            _password           = password;
            _keyboard           = keyboard;
            _chatParser         = chatParser;
            _dataSender         = dataSender;
            _rivenCleaner       = rivenCleaner;
            _rivenParserFactory = rivenParserFactory;
            _redTextParser      = redTextParser;

            if (_obsSettings != null)
            {
                ConnectToObs();
            }
        }
Ejemplo n.º 2
0
        public ChatWatcher(IDataSender dataSender, IChatParser chatParser, IGameCapture gameCapture, IMouseMover mouseMover, IRivenCleaner rivenCleaner, IRivenParser rivenParser,
                           IScreenStateHandler screenStateHandler)
        {
            this._dataSender         = dataSender;
            this._chatParser         = chatParser;
            this._gameCapture        = gameCapture;
            this._mouseMover         = mouseMover;
            this._rivenCleaner       = rivenCleaner;
            this._rivenParser        = rivenParser;
            this._screenStateHandler = screenStateHandler;

            Console.SetWindowSize(1, 1);
            Console.SetBufferSize(147, 10);
            Console.SetWindowSize(147, 9);
            Console.CursorVisible = false;
            Console.Clear();
            UpdateUI();
        }
Ejemplo n.º 3
0
        public static void ProcessRivenQueue(CancellationToken c, IRivenParserFactory factory, IDataSender dataSender, ConcurrentQueue <RivenParseTaskWorkItem> queue, IRivenCleaner cleaner)
        {
            var parser = factory.CreateRivenParser();

            while (true)
            {
                if (c.IsCancellationRequested)
                {
                    break;
                }
                RivenParseTaskWorkItem item = null;
                if (!queue.TryDequeue(out item) || item == null)
                {
                    Thread.Sleep(250);
                    continue;
                }
                foreach (var r in item.RivenWorkDetails)
                {
                    using (var croppedCopy = new Bitmap(r.CroppedRivenBitmap))
                    {
                        using (var cleaned = cleaner.CleanRiven(croppedCopy))
                        {
                            using (var cleanedCopy = new Bitmap(cleaned))
                            {
                                var riven = parser.ParseRivenTextFromImage(cleanedCopy, null);
                                riven.Polarity = parser.ParseRivenPolarityFromColorImage(croppedCopy);
                                riven.Rank     = parser.ParseRivenRankFromColorImage(croppedCopy);

                                riven.MessagePlacementId = r.RivenIndex;
                                riven.Name = r.RivenName;
                                dataSender.AsyncSendRivenImage(riven.ImageID, croppedCopy);
                                r.CroppedRivenBitmap.Dispose();
                                item.Model.Rivens.Add(riven);
                            }
                        }
                    }
                    dataSender.AsyncSendChatMessage(item.Model);
                }
            }

            if (parser is IDisposable)
            {
                ((IDisposable)parser).Dispose();
            }
        }