From 0003c072cb83f48386c5e264d86b0aa3a9eaa20d Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Fri, 2 Aug 2013 17:21:32 -0400 Subject: app --- js/course.js | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 js/course.js (limited to 'js/course.js') diff --git a/js/course.js b/js/course.js new file mode 100644 index 0000000..2924eb6 --- /dev/null +++ b/js/course.js @@ -0,0 +1,46 @@ +var courses = [ + ["Amuse Bouche", 1], + ["First Pair", 1,1], + ["Second Pair", 2], + ["Three Of A Kind", 1,1,1], + ["Third Pair", 1,2,1], + ["Full House", 2,2,1], + ["Four Of A Kind", 1,1,1,1] +] + +function course(n) { + console.log(n); + n = n || 1; + var ds = [ dish() ]; + return ds.join(", "); +} +function dish(){ + var pcount = rand(3) + 1; + var ps = []; + while (pcount-- > 0) ps.push(product()); + if (rand(100) > 60) { + var d = ps.join(" and ") + " " + choice(preparations); + } + else { + var d = ps.join(", "); + } + return d; +} +function product(){ + var result; + if (rand(100) > 90) { + var technique = choice(techniques); + if (technique[0] == '-') { + result = choice(products) + technique + " " + choice(products); + } else { + result = technique + " " + choice(products) + } + } + else if (rand(100) > 0) { + result = choice(products) + " " + choice(products) + } + else { + result = choice(products) + } + return result; +} -- cgit v1.2.3-70-g09d2