Exemplo n.º 1
0
 public string NewGame(string hashedPlayerId)
 {
     try
     {
         CustomCrypto hashing       = new CustomCrypto();
         int          playerId      = Convert.ToInt32(hashing.Decrypt(hashedPlayerId));
         GameDAL      gdal          = new GameDAL();
         int          gameId        = gdal.AddGame(playerId);
         var          hashed_gameId = hashing.Encrypt(gameId.ToString());
         // Wait for other players to join
         WaitForPlayers(30, gameId);
         var game = gdal.GetGame(gameId);
         // check if game room is full
         if (game.Player1 != null && game.Player2 != null && game.Player3 != null && game.Player4 != null)
         {
             return(hashed_gameId.ToString());
         }
         AbortGame(hashed_gameId);
         throw new CustomException("Timeout. Players insufficient.");
     }
     catch (CustomException e)
     {
         throw new CustomException(e.Message);
     }
     catch (Exception e)
     {
         logger.Error(e);
         throw new Exception("Oops! Some error occured.");
     }
 }
Exemplo n.º 2
0
 public bool AddGame(GameVM vm)
 {
     return(GameDAL.AddGame(vm));
 }