Ejemplo n.º 1
0
        public IHttpActionResult Create()
        {
            var userId = this.userIdProvider.GetUserId();
            var game = new Game
            {
                PlayerOneId = userId,
                Field = InitializeField(11)
            };

            this.Data.Games.Add(game);
            this.Data.SaveChanges();

            return this.Ok(game.Id);
        }
        public IHttpActionResult CreateGame()
        {
            var userId = this.userIdProvider.GetUserId();
            var game = new Game
            {
                PlayerOneId = userId,

                // TODO: Generate ships
            };

            this.Data.Games.Add(game);
            this.Data.SaveChanges();

            return this.Ok(game.Id);
        }
Ejemplo n.º 3
0
        public IHttpActionResult CreateGame()
        {
            var userId = this.userIdProvider.GetUserId();
            var game = new Game
            {
                PlayerOneId = userId,
            };
            game.Ships.Add(new Ship()
            {
                PositionX = new Random().Next(0, 20),
                PositionY = new Random().Next(0, 20),
                Game = game,
                GameId = game.Id
            });

            this.Data.Games.Add(game);
            this.Data.SaveChanges();

            return this.Ok(game.Id);
        }
Ejemplo n.º 4
0
        public IHttpActionResult CreateGame()
        {
            var userId = this.userIdProvider.GetUserId();            
            var game = new Game
            {
                PlayerOneId = userId
            };

            this.Data.Games.Add(game);
            var ships = new List<Ship>()
                {
                    new Ship()
                    {
                        PositionX = 1,
                        PositionY = 2
                    },
                    new Ship()
                    {
                        PositionX = 3,
                        PositionY = 4
                    },
                    new Ship()
                    {
                        PositionX = 5,
                        PositionY = 6
                    },
                    new Ship()
                    {
                        PositionX = 7,
                        PositionY = 8
                    }
                };

            game.Ships = ships;
                
            this.Data.SaveChanges();

            return this.Ok(game.Id);
        }