<commit_before>var red = '0xff8888';
var yellow = '0xffff88';
var blue = '0x8888ff';
var green = '0x88ff88';


function addCardsToPlayer(gameId, ownerId, color, handCardsNumber, manaPoolCardsNumber) {
    let deck = MeteorApp.Decks.findOne(ownerId);
    var allCards = deck.cards.map(
        (cardId) => MeteorApp.Cards.findOne(cardId)
    );
    
    allCards = lodash.shuffle(allCards);
    
    // Те каты которые мы добавляем как изначальные(герои и арии)
    var initialHandCards = deck.handCards.map(
        (cardId) => MeteorApp.Cards.findOne(cardId)
    );
    

    var handCards = lodash.take(allCards, handCardsNumber);
    var deckCards = lodash.drop(allCards, handCardsNumber);
    var manaPoolCards = [];
    
    // Переносим карты из деки в манапул
    for(var i = 0; i < manaPoolCardsNumber; i++) {
        manaPoolCards.push(deckCards.pop());
    }
    
    //initial cards from handCards
    initialHandCards.forEach(
        (card) => Meteor.call('createCardFromData', gameId, card, ownerId, 'hand', color)
    );

    //hand creatures
    handCards.forEach(
        (card) => Meteor.call('createCardFromData', gameId, card, ownerId, 'hand', color)
    );

    //deck
    deckCards.forEach(
        (card) => Meteor.call('createCardFromData', gameId, card, ownerId, 'deck', color)
    );
    
    //deck
    manaPoolCards.forEach(
        (card) => Meteor.call('createCardFromData', gameId, card, ownerId, 'manaPool', color)
    );
}


Meteor.methods({
    removeGameById: function(gameId) {
        MeteorApp.Games.remove(gameId);
        MeteorApp.CardsInGame.remove({gameId: gameId});
        MeteorApp.Actions.remove({});
    },


    startGame: function(game) {
        addCardsToPlayer(game._id, game.playerId1, red, 8, 0);
        addCardsToPlayer(game._id, game.playerId2, blue, 8, 1);

        if (game.type == 'ogre') {
            addCardsToPlayer(game._id, game.playerId3, yellow, 8, 0);
            addCardsToPlayer(game._id, game.playerId4, green, 8, 1);
        }
    },


    createCardFromData: function(gameId, cardData, ownerId, cardGroup, color) {
        delete cardData._id;
        cardData.gameId = gameId;
        cardData.ownerId = ownerId;
        cardData.cardGroup = cardGroup;
        cardData.color = color;

        cardData.counter = cardData.counter || 0;
        cardData.attachable = _.contains(['spell', 'area'], cardData.type);<commit_msg>Move color of filters to client<commit_after>function addCardsToPlayer(gameId, ownerId, color, handCardsNumber, manaPoolCardsNumber) {
    let deck = MeteorApp.Decks.findOne(ownerId);
    var allCards = deck.cards.map(
        (cardId) => MeteorApp.Cards.findOne(cardId)
    );
    
    allCards = lodash.shuffle(allCards);
    
    // Те каты которые мы добавляем как изначальные(герои и арии)
    var initialHandCards = deck.handCards.map(
        (cardId) => MeteorApp.Cards.findOne(cardId)
    );
    

    var handCards = lodash.take(allCards, handCardsNumber);
    var deckCards = lodash.drop(allCards, handCardsNumber);
    var manaPoolCards = [];
    
    // Переносим карты из деки в манапул
    for(var i = 0; i < manaPoolCardsNumber; i++) {
        manaPoolCards.push(deckCards.pop());
    }
    
    //initial cards from handCards
    initialHandCards.forEach(
        (card) => Meteor.call('createCardFromData', gameId, card, ownerId, 'hand', color)
    );

    //hand creatures
    handCards.forEach(
        (card) => Meteor.call('createCardFromData', gameId, card, ownerId, 'hand', color)
    );

    //deck
    deckCards.forEach(
        (card) => Meteor.call('createCardFromData', gameId, card, ownerId, 'deck', color)
    );
    
    //deck
    manaPoolCards.forEach(
        (card) => Meteor.call('createCardFromData', gameId, card, ownerId, 'manaPool', color)
    );
}


Meteor.methods({
    removeGameById: function(gameId) {
        MeteorApp.Games.remove(gameId);
        MeteorApp.CardsInGame.remove({gameId: gameId});
        MeteorApp.Actions.remove({});
    },


    startGame: function(game) {
        addCardsToPlayer(game._id, game.playerId1, '1', 8, 0);
        addCardsToPlayer(game._id, game.playerId2, '2', 8, 1);

        if (game.type == 'ogre') {
            addCardsToPlayer(game._id, game.playerId3, '3', 8, 0);
            addCardsToPlayer(game._id, game.playerId4, '4', 8, 1);
        }
    },


    createCardFromData: function(gameId, cardData, ownerId, cardGroup, color) {
        delete cardData._id;
        cardData.gameId = gameId;
        cardData.ownerId = ownerId;
        cardData.cardGroup = cardGroup;
        cardData.color = color;

        cardData.counter = cardData.counter || 0;
        cardData.attachable = _.contains(['spell', 'area'], cardData.type);
{'fraction_non_alphanumeric': 0.13237165888841748, 'fraction_numerical': 0.010606703436571913, 'mean_word_length': 2.8271103896103895, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 15, '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': '6111003', 'n_tokens_mistral': 1684, 'n_tokens_neox': 1637, 'n_words': 312}