Auto-generated Story

by Sam Fereday

HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/chance/1.0.16/chance.min.js"></script>

JavaScript

const c = new Chance();

const Expositions = [
	"There was a man named Steve who wanted to climb a mountain,"
];

const RisingActions = [
	""
];

const Climax = [

];

const FallingAction = [

];

const Middles = [
	"he purchased a collection of {a}'s that turned in to cake,",
  "he found some {b}'s' that were highly edible and magical,"
];
const Ends = [
	"he sold what he did not eat, and lived happily for the rest of his days.",
  "then the {a} turned in to a pair of {b}, he thought that was cool, and lived forever."
];

const PickSegment = (min, max, alg) => {
	return min + max > 0 ? c.integer({ min, max }) : 0;
};

const UseBeginning = Beginnings[PickSegment(0, Beginnings.length - 1)];
const UseMiddle = Middles[PickSegment(0, Middles.length - 1)];
const UseEnd = Ends[PickSegment(0, Ends.length - 1)];

console.log(UseBeginning);
console.log(UseMiddle);
console.log(UseEnd);