Exemplo n.º 1
0
        public async Task <IActionResult> ConfigurePlayer()//[FromBody]PlayerSetup setup)
        {
            var setup = new PlayerSetup();

            await TryUpdateModelAsync(setup);

            var player = _ctx.Players
                         .Include(p => p.Game)
                         .SingleOrDefault(p => p.PlayerId == setup.PlayerId);

            if (player == null)
            {
                return(NotFound());
            }

            player.Name = setup.Name;

            var game = new BattleshipGame(player.Game);

            game.PlaceShip(player, setup.IsShipHorizontal, setup.ShipX, setup.ShipY);

            _ctx.SaveChanges();

            return(RedirectToAction(nameof(Player), new { playerId = player.PlayerId }));
        }
Exemplo n.º 2
0
 public Ship PlaceShip(ShipPlacementParams args)
 {
     return(gameObj.PlaceShip(args.player, args.ship, args.location));
 }