コード例 #1
0
        public async Task <GuessLetter> CreateGuessLetter(GuessWord guessWord, string guessLetter)
        {
            var newGuessLetter = new GuessLetter()
            {
                GuessWord   = guessWord,
                GuessWordId = guessWord.Id,
                Letter      = guessLetter
            };

            await _repositoryGuessLetter.Save(newGuessLetter);

            return(newGuessLetter);
        }
コード例 #2
0
        public Word(string word)
        {
            FindedLetters = 0;

            if (String.IsNullOrWhiteSpace(word))
            {
                throw new Exception("Wrong Word!");
            }

            for (int i = 0; i < word.Length; i++)
            {
                GuessWord.Add(word[i]);
            }
        }
コード例 #3
0
        public void guessWord(GuessWord command)
        {
            if (this.GameOver)
            {
                throw new DomainException(
                          $"[{this.gameId.ToString()}] Failed to apply GuessWord command! {this.gameEndReason}");
            }

            if (command.Word == this.word)
            {
                this.Record(new WordGuessed(command.Word));
                this.Record(new GameWon("Word guessed"));
            }
            else
            {
                this.Record(new WordNotGuessed(command.Word));
                this.Record(new GameLost("Word not guessed"));
            }
        }
コード例 #4
0
        public IEnumerable <string> GetGuessWordStateSoFar(GuessWord guessWord)
        {
            var allGuessedLetters = guessWord.GuessLetters.Select(letter => letter.Letter);

            return(_gameLogic.GetGuessWordSoFar(allGuessedLetters, guessWord.Word));
        }