예제 #1
0
        //public async Task<EmptyResponse> IncrementPlayer(IncrementPlayerRequest request)
        //{

        //	var response = ServiceMessageFactory<EmptyResponse>.CreateFrom(request);
        //	var gameSessionRequest = ServiceMessageFactory<GetGameSessionRequest>.CreateFrom(request);
        //	gameSessionRequest.GameSessionId = request.gameSessionId;

        //	var gameSessionResponse = await gameSessionAccess.GetGameSessionAsync(gameSessionRequest);
        //	if (gameSessionResponse.HasErrors)
        //	{
        //		response.Errors += "Unable to get the game session.";
        //		return response;
        //	}

        //	IncrementPlayer(gameSessionResponse.GameSession.Convert());
        //	var updateGameSessionRequest = ServiceMessageFactory<UpdateGameSessionRequest>.CreateFrom(request);
        //	updateGameSessionRequest.GameSession = gameSessionResponse.GameSession;
        //	var updateGameSessionResponse = await gameSessionAccess.UpdateGameSessionAsync(updateGameSessionRequest);
        //	if (updateGameSessionResponse.HasErrors)
        //	{
        //		response.Errors += "Unable to update the game session";
        //	}
        //	return response;

        //}

        private void IncrementPlayer(GameSession gameSession)
        {
            var playerIds    = gameSession.PlayerIds.ToList();
            var idx          = playerIds.IndexOf(gameSession.CurrentPlayerId) + 1;
            var nextPlayerId = idx < playerIds.Count()
                                ? playerIds[idx]
                                : playerIds[0];

            gameSession.CurrentPlayerId = nextPlayerId;
        }
예제 #2
0
        public async Task IncrementPlayer(GameSession gameSession)
        {
            var playerIds    = gameSession.PlayerIds.ToList();
            var idx          = playerIds.IndexOf(gameSession.CurrentPlayerId) + 1;
            var nextPlayerId = idx < playerIds.Count()
                                ? playerIds[idx]
                                : playerIds[0];

            gameSession.CurrentPlayerId = nextPlayerId;
            await gameSessionAccess.UpdateGameSession(gameSession.Convert());
        }
예제 #3
0
 private async Task CreateTicTacToeBoard(GameSession gameSession)
 {
     // Create Game Tiles
     var tiles = TicTacToeBoardFactory.Create(gameSession.Id, new [] { "A1", "A2", "A3", "B1", "B2", "B3", "C1", "C2", "C3" });
     await tileAccess.CreateTiles(tiles.Convert());
 }