<commit_before>#! /usr/bin/env node

var nomnom = require("nomnom");
var fs = require("fs");

nomnom.options({
  inputFile: {
    abbr: "i",
    full: "input",
    help: "Name of the JSON input file. If you don't specify a file, data will be read from stdin",
    metavar : "FILE"
  },
  outputFile:{
    abbr: "o",
    full: "output",
    help: "name of the output file",
    default : "powers.html",
    metavar: "FILE"
  },
  format: {
    abbr: "f",
    full: "format",
    default: "html",
    help: "Format to output the power cards in, either \'html\' or \'pdf\'"
  }
});

function PowerPlant(format, input, output){
  this.data = input;
  this.format = format;
  this.outputFile = output;
}

PowerPlant.prototype = {
  outputFile: null,
  format:null,
  html: "<!DOCTYPE html><html>",
  data: null,
  typeToClass : { "At-Will" : "atWill", "Encounter" : "encounter", "Daily" : "daily", "Utility" : "utility" },
  buildCss : function buildCss(){
    var css = "";
    css += "body { font-family: Helvetica, sans-serif; font-size: 14px;}";
    css += ".card { width: 350px; height: 400px; display: inline-block; float: left; margin: 1px;}";
    css += ".header { color: #FFFFFF; padding-left: 5px; padding-right: 5px; font-size: 16px;}";
    css += ".atWill { background-color: #407040; }";
    css += ".encounter { background-color: #892a2a; }";
    css += ".daily { background-color: #1d1070; }";
    css += ".utility { background-color: #2e2e2e; }";
    css += ".left { float: left; }";
    css += ".right { float: right; }";
    css += ".clear {clear: both; }";

    return css;
  },

  addHeader: function addHeader(){

  },

  addDocumentHead: function addDocumentHead(){
    this.html += "<head>";
    this.html += "<title>Power Cards</title>";
    this.html += "</head>";
  },

  addStyle : function addStyle(){
    this.html += "<style type=\"text/css\">";
    this.html += this.buildCss();
    this.html += "</style>";
  },

  finishDocument : function finishDocument(){
    this.html += "</html>";
  },

  slug: function slug(text){
    return text.replace(/s+/g, "-");
  },

  addCards: function addCards(){
    var power;
    for(var i = 0; i < this.data.powers.length; i++){
      power = this.data.powers[i];
      this.html += "<div class=\'card\' id=\'" + this.slug(power.name) + "\'>";
      this.html += "<div class=\'header " + this.typeToClass[power.type] + "\'><span class=\'left\'><strong>" + power.name + "</strong></span><span class=\'right\'>" + power.level + "</span><div class=\'clear\'></div></div>";
      this.html += "<div class=\'clear\'><em>" + power.description + "</em></div>";
      this.html += "<div><strong>" + power.type + "</strong></div>";
      this.html += "<div>" + power.action_type + " | <strong>" + power.weapon_type + "</strong></div>";
      this.html += "<div><strong>" + power.attack + "</strong> | " + power.targets + "</div><br />";
      this.html += "<div><strong>Requirement</strong>: " + power.requirstrongent + "</div>";
      this.html += "<div><strong>Trigger</strong>: " + power.trigger + "</div>";
      this.html += "<div><strong>Effect</strong>: " + power.effect + "</div>";
      this.html += "<div><strong>Hit</strong>: " + power.hit + "</div><br /><br />";
      this.html += "<div><em>" + power.note + "</em></div>";
      this.html += "</div>";
    }
  },

  start: function start(){
    this.addDocumentHead();
    this.addStyle();
    this.addHeader();
    this.addCards();
    this.finishDocument();
    this.writeOut();<commit_msg>more style tweaks add feats and check for power items before showing<commit_after>#! /usr/bin/env node

var nomnom = require("nomnom");
var fs = require("fs");

nomnom.options({
  inputFile: {
    abbr: "i",
    full: "input",
    help: "Name of the JSON input file. If you don't specify a file, data will be read from stdin",
    metavar : "FILE"
  },
  outputFile:{
    abbr: "o",
    full: "output",
    help: "name of the output file",
    default : "powers.html",
    metavar: "FILE"
  },
  format: {
    abbr: "f",
    full: "format",
    default: "html",
    help: "Format to output the power cards in, either \'html\' or \'pdf\'"
  }
});

function PowerPlant(format, input, output){
  this.data = input;
  this.format = format;
  this.outputFile = output;
}

PowerPlant.prototype = {
  outputFile: null,
  format:null,
  html: "<!DOCTYPE html><html>",
  data: null,
  typeToClass : { "At-Will" : "atWill", "Encounter" : "encounter", "Daily" : "daily", "Utility" : "utility" },
  buildCss : function buildCss(){
    var css = "";
    css += "body { font-family: Helvetica, sans-serif; font-size: 14px;}";
    css += ".card { width: 300px; height: 350px; display: inline-block; float: left; margin: 1px; page-break-inside: avoid;}";
    css += ".cardHeader { color: #FFFFFF; padding-left: 5px; padding-right: 5px; font-size: 16px;}";
    css += ".atWill { background-color: #407040; }";
    css += ".encounter { background-color: #892a2a; }";
    css += ".daily { background-color: #1d1070; }";
    css += ".utility { background-color: #2e2e2e; }";
    css += ".left { float: left; }";
    css += ".right { float: right; }";
    css += ".clear { clear: both; }";
    css += ".header { font-size: 18px; clear: both;}";
    css += ".featTitle { font-size: 16px;}";
    css += "h1 { font-size: 18px; float: left;}";
    css += "h2 {font-size: 16px; float: right;}";
    css += ".featHeader { font-size: 18px;}";
    css += ".feat { padding: 5px; }";
    return css;
  },

  addHeader: function addHeader(){

  },

  addDocumentHead: function addDocumentHead(){
    this.html += "<head>";
    this.html += "<title>Power Cards</title>";
    this.html += "</head>";
  },

  addStyle : function addStyle(){
    this.html += "<style type=\"text/css\">";
    this.html += this.buildCss();
    this.html += "</style>";
  },

  finishDocument : function finishDocument(){
    this.html += "</html>";
  },

  slug: function slug(text){
    return text.replace(/s+/g, "-");
  },

  addCards: function addCards(){
    var power;
    if(!this.data.powers){ return; }
    for(var i = 0; i < this.data.powers.length; i++){
      power = this.data.powers[i];
      this.html += "<div class=\'card\' id=\'" + this.slug(power.name) + "\'>";
      this.html += "<div class=\'cardHeader " + this.typeToClass[power.type] + "\'><span class=\'left\'><strong>" + power.name + "</strong></span><span class=\'right\'>" + power.level + "</span><div class=\'clear\'></div></div>";
      this.html += "<div class=\'clear\'><em>" + power.description + "</em></div>";
      this.html += "<div><strong>" + power.type + "</strong></div>";
      this.html += "<div>" + power.action_type + " | <strong>" + power.weapon_type + "</strong></div>";
      if(power.attack && power.targets){
        this.html += "<div><strong>" + power.attack + "</strong> | " + power.targets + "</div><br />";
      }
      if(power.requirement){
        this.html += "<div><strong>Requirement</strong>: " + power.requiremrent + "</strong></div>";
      }
      if(power.trigger){
        this.html += "<div><strong>Trigger</strong>: " + power.trigger + "</div>";
      }
      if(power.effect){
        this.html += "<div><strong>Effect</strong>: " + power.effect + "</div>";
      }
      if(power.hit){
        this.html += "<div><strong>Hit</strong>: " + power.hit + "</div><br /><br />";
      }
      if(power.note){
        this.html += "<div><em>" + power.note + "</em></div>";
      }
      this.html += "</div>";
    }
  },

  addFeats: function addFeats(){
    var feat;
    this.html += "<div class=\'clear\'></div>";
    this.html += "<div class=\'featHeader\'><strong>Feats</strong></div>";
    if(!this.data.feats){ return; }
    for(var i = 0; i < this.data.feats.length; i++){
      feat = this.data.feats[i];
      this.html += "<div class=\'feat\'>";
      this.html += "<div class=\'featTitle\'><strong>" + feat.name + "</strong></div>";
      this.html += "<div><em>" + feat.prerequisite + "</em></div>";
      this.html += "<div>" + feat.benefit + "</div>";
      this.html += "</div>";
    }
  },

  start: function start(){
    this.addDocumentHead();
    this.addStyle();
    this.addHeader();
    this.addCards();
    this.addFeats();
    this.finishDocument();
    this.writeOut();
{'fraction_non_alphanumeric': 0.22414418773436556, 'fraction_numerical': 0.009435103423249063, 'mean_word_length': 2.9730898606439213, 'pattern_counts': {'":': 0, '<': 145, '<?xml version=': 0, '>': 142, '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': '2074112', 'n_tokens_mistral': 2897, 'n_tokens_neox': 2787, 'n_words': 647}