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 })); }
public Ship PlaceShip(ShipPlacementParams args) { return(gameObj.PlaceShip(args.player, args.ship, args.location)); }