Ejemplo n.º 1
0
        public async void Check()
        {
            var currentWord = _gameRepository.Word;

            if (!currentWord.IsCompleted())
            {
                if (_gameRepository.LastGuess.IsCorrect)
                {
                    return;
                }
                _gameRepository.RemainingLives -= 1;
                if (_gameRepository.RemainingLives == 0)
                {
                    _eventDispatcherService.Dispatch(new GameOverSignal());
                }

                return;
            }

            var(word, token) = await _gameService.GetSolution();

            _gameRepository.Word      = word;
            _gameRepository.GameToken = token;
            if (word.Equals(currentWord))
            {
                _eventDispatcherService.Dispatch(new WordCompletedSignal());
            }
        }
Ejemplo n.º 2
0
        public async Task Start()
        {
            _eventDispatcherService.Dispatch(new UpdateLoadingScreenSignal(true));
            var(word, token) = await _gameService.StartNewGame();

            _gameRepository.RemainingLives = _configurationGameRepository.StartLives;
            _gameRepository.Word           = word;
            _gameRepository.GameToken      = token;
            _eventDispatcherService.Dispatch(new NewWordSignal(word.Value));
            _eventDispatcherService.Dispatch(new UpdateLoadingScreenSignal(false));
        }
        public async Task Guess(char letter)
        {
            _eventDispatcherService.Dispatch(new UpdateLoadingScreenSignal(true));
            var(guess, token) = await _gameService.GuessLetter(letter);

            _gameRepository.Word      = guess.UpdatedWord;
            _gameRepository.GameToken = token;
            _gameRepository.LastGuess = guess;

            _eventDispatcherService.Dispatch(
                new GuessResultSignal
                (
                    letter.ToString(),
                    guess.UpdatedWord.Value,
                    guess.IsCorrect
                )
                );

            _checkSolution.Check();
            _eventDispatcherService.Dispatch(new UpdateLoadingScreenSignal(false));
        }
        public async void Restart()
        {
            await _startGame.Start();

            _eventDispatcherService.Dispatch(new RestartGameSignal());
        }