public async Task <GameSession> InitializeGame(Guid gameDefinitionId, int numberOfPlayers)
        {
            var gameDefinitions = await gameDefinitionAccess.FindGameDefinitions(i => i.Id == gameDefinitionId);

            var gameDefinition = gameDefinitions.FirstOrDefault();

            gameDefinition.NotNull();

            var createdPlayers = await CreatePlayers(numberOfPlayers, gameDefinition);

            var gameSession = GameSessionFactory.Create(gameDefinitionId, createdPlayers.Select(i => i.Id).ToArray());
            await gameSessionAccess.ProvisionGameSession(gameSession);

            var tiles = TicTacToeBoardFactory.Create(gameSession.Id, new[] { "A1", "A2", "A3", "B1", "B2", "B3", "C1", "C2", "C3" });
            await tileAccess.ProvisionTiles(tiles.ToArray());

            return(gameSession);
        }
Exemple #2
0
        public async Task <GameDefinition[]> GetGames()
        {
            var gameDefinitions = await gameDefinitionAccess.FindGameDefinitions(null);

            return(gameDefinitions);
        }