This commit is contained in:
Justin Overton 2017-07-31 23:49:10 -05:00
parent 06b9fc4d51
commit 4f49861eb5
4 changed files with 52451 additions and 2 deletions

View File

@ -1,2 +1,4 @@
# plottoriffic
Generate story plots based on Plotto
# Plottoriffic
Generate plots based on [Plotto](http://garykac.github.io/plotto/plotto-mf.html).

52348
data/plotto.json Normal file

File diff suppressed because it is too large Load Diff

74
index.js Normal file
View File

@ -0,0 +1,74 @@
'use strict'
const seedrandom = require('seedrandom');
const plotto = require("./data/plotto.json");
function pick(rng, arr) {
let min = 0;
let max = arr.length;
return arr[Math.floor(this.fn() * (max - min)) + min];
}
function resolveConflict(id) {
var ids = id.split(',');
var mainId = ids[0].match(/^\d+/);
for(let i of ids) {
let conflictid = i;
if(conflictid.indexOf(maniId) != 0)
conflictid = mainId + i;
let ch = /\s+ch (?:([a-zA-Z0-9-]+|“[^”]+”) to ([a-zA-Z0-9-]+|“[^”]+”))(?: & ([a-zA-Z0-9-]+|“[^”]+”) to ([a-zA-Z0-9-]+|“[^”]+”))*/;
}
}
class PlotGenerator {
constructor({ seed=null, flipGenders=undefined, names=plotto.characters } = {}) {
this._rng = seedrandom(seed);
this._names = names;
if(flipGenders === undefined) {
this._flipGenders = this._rng() < 0.5; //50% chance true/false
} else {
this._flipGenders = flipGenders;
}
}
get flipGenders() { return this._flipGenders; }
set flipGenders(flip) { this._flipGenders = flip; }
get names() { return this._names; }
set names(names) { this._names = Object.assign({}, plotto.characters, names); }
generate() {
let a = pick(this._rng, plotto.masterClauseA);
let b = pick(this._rng, plotto.masterClauseB);
let c = pick(this._rng, plotto.masterClauseA);
return [
a + ' ' + b.description,
this._expand(b),
c
].join(' ');
}
_expand(b) {
let initial = plotto.conflicts[pick(this._rng, b.nodes)];
let leadIn = pick(this._rng, initial.leadIns);
let carryOn = pick(this._rng, initial.carryOns);
}
}
exports.PlotGenerator = PlotGenerator;

25
package.json Normal file
View File

@ -0,0 +1,25 @@
{
"name": "plottoriffic",
"version": "1.0.0",
"description": "Generate plots based on Plotto",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/justinoverton/plottoriffic.git"
},
"author": "Justin Overton",
"license": "GPL-3.0",
"bugs": {
"url": "https://github.com/justinoverton/plottoriffic/issues"
},
"homepage": "https://github.com/justinoverton/plottoriffic#readme",
"engines": {
"node": ">=6.9.5"
},
"dependencies": {
"seedrandom": "^2.4.3"
}
}