var
Player = require('./Player'),
SocketPlayer = function(options, player) {
var socket = options.socket,
    filterPlayerObject = function(fullPlayer) {
        var filteredPlayer = {}
            ;
            
        filteredPlayer.name = fullPlayer.name;
        
        return filteredPlayer;
    },
    
    filterCardObject = function(fullCard) {
        var filteredCard = {}
            ;
            
        filteredCard.color = fullCard.color;
        filteredCard.value = fullCard.value;
        
        if (fullCard.pickedColor) {
            filteredCard.pickedColor = fullCard.pickedColor;
        }
        
        return filteredCard;
    }
    ;
    
    player = player || {};
    Player(options, player);
    
    player.on('playerJoined', function(data) {
        var event = {};
        event.player = filterPlayerObject(data.player);
        
        socket.emit('playerJoined', event);
    });
    
    player.on('gameStarted', function(data) {
        var event = {};
        event.firstCard = filterCardObject(data.firstCard);
        
        socket.emit('gameStarted', event); 
    });
    
    player.on('gameEnded', function(data) {
        var event = {};
        event.winner = filterPlayerObject(data.winner);
        
        socket.emit('gameEnded', event); 
    });    
    
    player.on('cardAdded', function(data) {
        var event = {};
        event.card = filterCardObject(data.card);
        
        socket.emit('cardAdded', event);
    });
    
    player.on('cardPlayed', function(data) {
        var event = {};
        event.card = filterCardObject(data.card);
        event.player = filterPlayerObject(data.player);
        
        socket.emit('cardPlayed', event);
    });
    
    player.on('playerGotCard', function(data) {
        var event = {};
        event.player = filterPlayerObject(data.player);
        event.cardCount = data.cardCount;
        
        socket.emit('playerGotCard', event);
    });
    
    player.on('playerTurn', function(data) {
        var event = {};
        event.player = filterPlayerObject(data.player);
        
        socket.emit('playerTurn', event);
    });   
    
    return player; 
}

module.exports = SocketPlayer;

@@ -2154,24 +2154,1223 @@
 %7D);   %0A    %0A
+    socket.on('playCard', function(data) %7B%0A        var card = data.card,%0A            pickedCard,%0A            successfulPlay = false,%0A            i%0A            ;%0A            %0A        // remove card from hand%0A        for (i = 0; i %3C player.hand.length; i++) %7B%0A            if (player.hand%5Bi%5D.color === card.color%0A            &&  player.hand%5Bi%5D.value === card.value) %7B%0A                // the card object sent through the socket%0A                // is only a partial copy of the original card%0A                pickedCard = player.hand.splice(i,1)%5B0%5D;%0A                %0A                if (card.pickedColor) %7B%0A                    pickedCard.pickedColor = card.pickedColor;%0A                %7D%0A                %0A                // we want remove one card only%0A                // there may be same cards in hand%0A                break;%0A            %7D%0A        %7D            %0A            %0A        successfulPlay = player.game.playCard(player, pickedCard);%0A        if (!successfulPlay) %7B%0A            player.hand.push(pickedCard);%0A        %7D%0A    %7D);%0A    %0A    socket.on('playDraw', function() %7B%0A        player.game.playDraw(player);%0A    %7D);%0A    %0A    socket.on('sayUno', function() %7B%0A        player.uno(true);%0A    %7D);%0A    %0A
     return p

handle playCard event