Beispiel #1
0
        public IActionResult PostPlay([FromBody] PlayDto play)
        {
            if (!ModelState.IsValid || play == null)
            {
                return(BadRequest(ModelState));
            }

            if (_gameLogic.CheckLosePlay(play.Text))
            {
                return(Ok(new PlayResultDto()
                {
                    Text = play.Text,
                    Win = false,
                    Lose = true
                }));
            }

            string text = _ghostPlayer.Play(play.Text);

            return(Ok(new PlayResultDto()
            {
                Text = text,
                Win = _gameLogic.CheckLosePlay(text),
                Lose = false
            }));
        }