Example #1
0
 public ActionResult <GameFullStateModel> CreateGame([FromBody] CreateGameModel createParameters)
 {
     return(_gameCreationService.CreateGame(createParameters));
     // return new GameFullStateModel
     // {
     //     CurrentPlayer = "red",
     //     HasScrolled = false,
     //     PlayerState = new List<PlayerState>
     //     {
     //         new PlayerState {
     //             Coordinates = new Models.Coordinates {
     //                 Row = 0,
     //                 Column = 0
     //             },
     //             Name = "red",
     //             Type = "red"
     //         }
     //     },
     //     ID = Guid.NewGuid().ToString(),
     //     IsMoving = false,
     //     Tiles = Enumerable.Range(0, 10)
     //         .SelectMany(row => Enumerable.Range(0, 10)
     //             .Select(column => new GameFullStateModel.Tile
     //             {
     //                 Directions = GenerateDirections(),
     //                 Coordinates = new Models.Coordinates { Row = row, Column = column }
     //             })
     //         ).ToList()
     // };
 }
Example #2
0
        private async Task Seed()
        {
            foreach (var player in new[] { "gio", "fra" })
            {
                await _playerService.CreatePlayer(new PlayerInVM
                {
                    Username = player,
                    Password = "******"
                });
            }

            await _gameCreationService.CreateGame(new[] { "gio", "fra" }, 5);
        }
Example #3
0
        public async Task <FullGameStateOutVM> NewGame(NewGameInVM newGame)
        {
            var currentUser = User.Identity.Name;

            if (currentUser == newGame.OtherPlayer)
            {
                throw new ValidationException("Cannot play with yourself");
            }
            var game = await _gameCreationService.CreateGame(new[] {
                currentUser,
                newGame.OtherPlayer
            }, newGame.CardLimit);

            return(game);
        }