<commit_before>var User = S.extendClass(require('events').EventEmitter);
module.exports = User;


User.extendPrototype({
    construct(application, socket, data) {
        console.log('new User', data);
        this.application = application;
        this.socket = socket;
        this.name = data.name;
        this.user = application.createUser(this, data.name);
        // TODO parent / common Mainboard + User
        socket.on('disconnect', this._onDisconnect.bind(this));
        socket.on('ready', this._onReady.bind(this));
        socket.on('playCard', this._onPlayCard.bind(this));
    },

    _onDisconnect() {
        this.application.removeUser(this);
    },
    _onReady() {
        logger.log('user ready:' + this.name);
        this.user.markAsReady();
        this.emitServer('ready');
    },
    _onPlayCard() {
        var card = this.application.app.playCard(this.user);
        var data = { userName: this.name, cardId: card.id };
        this.application.emitToMainBoards('player:cardPlayed', data);
        this.emitClient('cardPlayed', data);
    },
    isReady() {
        return this.user.ready();
    },
    markAsIdle() {
        return this.user.markAsIdle();
    },
    emitServer: function(event, data) {
        console.log('User.emitServer', event, data);
        this.emit(event, data);
        this.application.userEvent(this, event, data);
    },
    emitClient: function(event, data) {
        console.log('User.emitClient', event, data);
        this.emit(event, data);
        this.socket.emit(event, data);
    }
});<commit_msg>cheat<commit_after>var User = S.extendClass(require('events').EventEmitter);
module.exports = User;


User.extendPrototype({
    construct(application, socket, data) {
        console.log('new User', data);
        this.application = application;
        this.socket = socket;
        this.name = data.name;
        this.user = application.createUser(this, data.name);
        // TODO parent / common Mainboard + User
        socket.on('disconnect', this._onDisconnect.bind(this));
        socket.on('ready', this._onReady.bind(this));
        socket.on('playCard', this._onPlayCard.bind(this));
    },

    _onDisconnect() {
        this.application.removeUser(this);
    },
    _onReady() {
        logger.log('user ready:' + this.name);
        this.user.markAsReady();
        this.emitServer('ready');
    },
    _onPlayCard(data) {
        if (data && data.cheat) {
            this.application.app.cheat(this.user);
        }
        var card = this.application.app.playCard(this.user);
        var emitData = { userName: this.name, cardId: card.id };
        this.application.emitToMainBoards('player:cardPlayed', emitData);
        this.emitClient('cardPlayed', emitData);
    },
    isReady() {
        return this.user.ready();
    },
    markAsIdle() {
        return this.user.markAsIdle();
    },
    emitServer: function(event, data) {
        console.log('User.emitServer', event, data);
        this.emit(event, data);
        this.application.userEvent(this, event, data);
    },
    emitClient: function(event, data) {
        console.log('User.emitClient', event, data);
        this.emit(event, data);
        this.socket.emit(event, data);
    }
});
{'fraction_non_alphanumeric': 0.1512812596480395, 'fraction_numerical': 0.0, 'mean_word_length': 2.5801104972375692, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7200731', 'n_tokens_mistral': 977, 'n_tokens_neox': 973, 'n_words': 166}