<commit_before>var _ = require('underscore')
  , Cards = require('../cards/cards')
  , Sets  = require('../cards/sets')
  , rarity =
    { mythic: 1
    , rare: 2
    , uncommon: 3
    , common: 4
    }
  ;

function rand(arr, num) {
  if (num)
    return _.shuffle(arr).slice(0, num);
  return arr[_.random(arr.length - 1)];
}

function getCardInfo(card) {
  card = Cards[card];

  return {
    cmc: card.cmc,
    color: card.color,
    name: card.name,
    rarity: rarity[card.rarity],
    url: card.url
  };
}

function genPack(setName) {
  var pack = { id: _.random(1e8) };

  if (typeof setName === 'object') {
    pack.cards = _.map(setName.splice(-15, 15), getCardInfo);
    return pack;
  }

  set = Sets[setName];
  var commons = set.common
    , uncommons = set.uncommon
    , rares = set.rare
    , mythics = set.mythic
    , special = set.special
    , cards = []
    ;
  mythics.length || (mythics = rares);
  cards.push.apply(cards, rand(commons, 10));
  cards.push.apply(cards, rand(uncommons, 3));
  if (_.random(7))
    cards.push(rand(rares));
  else
    cards.push(rand(mythics));

  switch (setName) {
    case "Dragon's Maze":
      if (_.random(21))
        cards.push(rand(special.gate));
      else
        cards.push(rand(special.shock));
      break;
    case 'Time Spiral':
      cards.push(rand(special));
  }

  pack.cards = _.map(cards, getCardInfo);

  return pack;
}

module.exports = genPack;<commit_msg>break<commit_after>var _ = require('underscore')
  , Cards = require('../cards/cards')
  , Sets  = require('../cards/sets')
  , rarity =
    { mythic: 1
    , rare: 2
    , uncommon: 3
    , common: 4
    }
  ;

function rand(arr, num) {
  if (num)
    return _.shuffle(arr).slice(0, num);
  return arr[_.random(arr.length - 1)];
}

function getCardInfo(card) {
  card = Cards[card];

  return {
    cmc: card.cmc,
    color: card.color,
    name: card.name,
    rarity: rarity[card.rarity],
    url: card.url
  };
}

function genPack(setName) {
  var pack = { id: _.random(1e8) };

  if (typeof setName === 'object') {
    pack.cards = _.map(setName.splice(-15, 15), getCardInfo);
    return pack;
  }

  set = Sets[setName];
  var commons = set.common
    , uncommons = set.uncommon
    , rares = set.rare
    , mythics = set.mythic
    , special = set.special
    , cards = []
    ;
  mythics.length || (mythics = rares);
  cards.push.apply(cards, rand(commons, 10));
  cards.push.apply(cards, rand(uncommons, 3));
  if (_.random(7))
    cards.push(rand(rares));
  else
    cards.push(rand(mythics));

  switch (setName) {
    case "Dragon's Maze":
      if (_.random(21))
        cards.push(rand(special.gate));
      else
        cards.push(rand(special.shock));
      break;
    case 'Time Spiral':
      cards.push(rand(special));
      break;
  }

  pack.cards = _.map(cards, getCardInfo);

  return pack;
}

module.exports = genPack;
{'fraction_non_alphanumeric': 0.16498784300104202, 'fraction_numerical': 0.012504341785342132, 'mean_word_length': 2.6455696202531644, 'pattern_counts': {'":': 2, '<': 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': '6836192', 'n_tokens_mistral': 1107, 'n_tokens_neox': 1057, 'n_words': 214}