示例#1
0
        public IActionResult Attack([FromRoute, Required] Guid id, [Required] AttackRequest request)
        {
            var game = _gameRegistry.GetGame(id);

            if (game == null)
            {
                return(NotFound("Game not found"));
            }

            var attackResult = game.ProcessAttack(request.XCoordinate, request.YCoordinate);

            // FOR HOSTING REASON: delete the game as soon as the player has won
            // to avoid the number of games from increasing
            if (attackResult == AttackResult.Win)
            {
                _gameRegistry.DeleteGame(id);
            }

            return(Ok(attackResult));
        }