From 59cccc8ed599e2d35496372c1cd5f697e34d374f Mon Sep 17 00:00:00 2001 From: Fen Dweller Date: Tue, 20 Feb 2018 18:55:21 -0500 Subject: [PATCH] Moved all the description logic over. --- game.js | 28 ++++----- recursive-desc.js | 137 ++++++++++++++++++++------------------------- recursive-macro.js | 65 +-------------------- 3 files changed, 78 insertions(+), 152 deletions(-) diff --git a/game.js b/game.js index 5944031..e0594e2 100644 --- a/game.js +++ b/game.js @@ -573,12 +573,14 @@ function feed() var area = macro.handArea; var prey = getPrey(biome, area); - var line = prey.eat(verbose) + var line = describe("eat", prey, macro, verbose) var linesummary = summarize(prey.sum(), false); var people = get_living_prey(prey.sum()); - var sound = "Ulp"; - if (people < 3) { + var sound = ""; + if (people == 0) { + sound = ""; + } else if (people < 3) { sound = "Ulp."; } else if (people < 10) { sound = "Gulp."; @@ -608,7 +610,7 @@ function stomp() { var area = macro.pawArea; var prey = getPrey(biome, area); - var line = prey.stomp(verbose) + var line = describe("stomp", prey, macro, verbose) var linesummary = summarize(prey.sum(), true); var people = get_living_prey(prey.sum()); @@ -646,10 +648,10 @@ function anal_vore() area = macro.assArea; var crushed = getPrey(biome,area); - var line1 = prey.anal_vore(verbose, macro.height); + var line1 = describe("anal-vore", prey, macro, verbose); var line1summary = summarize(prey.sum(), false); - var line2 = crushed.buttcrush(verbose); + var line2 = describe("ass-crush", crushed, macro, verbose); var line2summary = summarize(crushed.sum(), true); var people = get_living_prey(prey.sum()); @@ -705,7 +707,7 @@ function breast_crush() { var area = macro.breastArea; var prey = getPrey(biome, area); - var line = prey.breast_crush(verbose); + var line = describe("breast-crush", prey, macro, verbose); var linesummary = summarize(prey.sum(), true); var people = get_living_prey(prey.sum()); @@ -739,7 +741,7 @@ function unbirth() { var area = macro.vaginaArea; var prey = getPrey(biome, area); - var line = prey.unbirth(verbose) + var line = describe("unbirth", prey, macro, verbose) var linesummary = summarize(prey.sum(), false); var people = get_living_prey(prey.sum()); @@ -776,7 +778,7 @@ function cockslap() { var area = macro.dickArea; var prey = getPrey(biome, area); - var line = prey.cockslap(verbose) + var line = describe("cockslap", prey, macro, verbose) var linesummary = summarize(prey.sum(), true); var people = get_living_prey(prey.sum()); @@ -811,7 +813,7 @@ function cock_vore() { var area = macro.dickGirth; var prey = getPrey(biome, area); - var line = prey.cock_vore(verbose) + var line = describe("cock-vore", prey, macro, verbose) var linesummary = summarize(prey.sum(), false); var people = get_living_prey(prey.sum()); @@ -847,7 +849,7 @@ function ball_smother() { var area = macro.ballArea * 2; var prey = getPrey(biome, area); - var line = prey.ball_smother(verbose) + var line = describe("ball-smother", prey, macro, verbose) var linesummary = summarize(prey.sum(), true); var people = get_living_prey(prey.sum()); @@ -882,7 +884,7 @@ function male_orgasm(vol) var area = Math.pow(vol, 2/3); var prey = getPrey(biome, area); - var line = prey.male_orgasm(verbose).replace("$VOLUME",volume(vol,unit,false)) + var line = describe("male-orgasm", prey, macro, verbose).replace("$VOLUME",volume(vol,unit,false)) var linesummary = summarize(prey.sum(), true); var people = get_living_prey(prey.sum()); @@ -915,7 +917,7 @@ function female_orgasm(vol) var area = Math.pow(vol, 2/3); var prey = getPrey(biome, area); - var line = prey.female_orgasm(verbose).replace("$VOLUME",volume(vol,unit,false)); + var line = describe("female-orgasm", prey, macro, verbose).replace("$VOLUME",volume(vol,unit,false)); var linesummary = summarize(prey.sum(), true); var people = get_living_prey(prey.sum()); diff --git a/recursive-desc.js b/recursive-desc.js index dd0a6a2..dbda108 100644 --- a/recursive-desc.js +++ b/recursive-desc.js @@ -1,97 +1,84 @@ -function configure(dict) { - foot = dict.foot; +rules = {}; -} +rules["eat"] = []; +rules["stomp"] = []; +rules["kick"] = []; +rules["anal-vore"] = []; +rules["ass-crush"] = []; +rules["breast-crush"] = []; +rules["unbirth"] = []; +rules["cock-vore"] = []; +rules["cockslap"] = []; +rules["ball-smother"] = []; +rules["male-orgasm"] = []; +rules["female-orgasm"] = []; -function subset(list1,list2) { - for (var i = 0; i < list1.length; i++) { - if (!list2.includes(list1[i])){ +function hasNothing(container, thing, amount) { + for (var key in container.contents) { + if (container.contents.hasOwnProperty(key)) return false; - } } + return true; } -function seteq(list1,list2) { - return list1.length == list2.length && subset(list1,list2); +function hasExactly(container, thing, amount) { + if (!container.contents.hasOwnProperty(thing) && amount == 0) + return true; + if (container.contents.hasOwnProperty(thing) && container.contents[thing].count == amount) + return true; + return false; } -function getPreyNames(contents) { - prey = []; +function describe(action, container, macro, verbose=true) { + options = []; - for (var key in contents) { - if (contents.hasOwnProperty(key)) { - prey.push(contents[key].name); + for (var i = 0; i < rules[action].length; i++) { + if(rules[action][i].test(container,macro)) { + options.push(rules[action][i].desc); } } - return prey; -} - -function getPreyCounts(contents) { - prey = {}; - for (var key in contents) { - if (contents.hasOwnProperty(key)) { - prey[contents[key].name] = contents[key].count; - } + if (options.length > 0) + return options[0](container, macro); + else { + return describeDefault(action, container, macro, verbose); } - - return prey; -} - -function containerEat(container,verbose=true) { - var preyNames = getPreyNames(container.contents); - var preyCounts = getPreyCounts(container.contents); - return ""; } -function personEat(person) { - if (person.count == 1) { - if (Math.random() > 0.5) - return "You hoist " + person.describe() + " into the air and stuff them down your gullet. Delicious!"; +function describeDefault(action, container, macro, verbose=true) { + switch(action) { + case "eat": return "You scoop up " + container.describe(verbose) + " and swallow " + (container.count > 1 ? "them" : "it") + " whole."; + case "stomp": return "You crush " + container.describe(verbose) + " underfoot."; + case "kick": return "You punt " + container.describe(verbose) + ", destroying " + (container.count > 1 ? "them" : "it") + "."; + case "anal-vore": return "You sit yourself down on " + container.describe(verbose) + ". " + (container.count > 1 ? "They slide" : "It slides") + " inside with ease."; + case "ass-crush": return "Your heavy ass obliterates " + container.describe(verbose) + ". "; + case "breast-crush": return "Your heavy breasts obliterate " + container.describe(verbose) + ". "; + case "unbirth": return "You gasp as you slide " + container.describe(verbose) + " up your slit. "; + case "cock-vore": return "You stuff " + container.describe(verbose) + " into your throbbing shaft, forcing them down to your heavy balls."; + case "cockslap": return "Your swaying shaft crushes " + container.describe(verbose) + ". "; + case "ball-smother": return "Your weighty balls spread over " + container.describe(verbose) + ", smothering them in musk."; + case "male-orgasm": return "You're cumming! Your thick cock spurts out $VOLUME of seed, splooging " + container.describe(verbose) + "."; + case "female-orgasm": return "You're cumming! Your moist slit sprays $VOLUME of slick femcum, splooging " + container.describe(verbose) + "."; } - else if (person.count <= 3) { - if (Math.random() > 0.5) - return "You reach down with both hands, snagging " + (person.count == 2 ? "two" : "three") + " meals. You savor their taste, " + person.describe() + " slipping past your lips and down your throat, one-by-one."; - } - else if (person.count < 5) { - if (Math.random() > 0.5) - return "You reach down and snatch up a fistful of snacks, stuffing " + person.count + " people into your maw and swallowing deeply."; - } - - return ""; } -function personStomp(person) { - if (person.count == 1) { - var choice = Math.random(); - if (choice < 0.2) - return "Your heavy paw smashes a " + person.describe() + " like a bug. Splat."; - else if (choice < 0.4) - return "A wayward step obliterates a " + person.describe(); - else if (choice < 0.6) - return "You lunge at a " + person.describe() + " with your toes outstretched, squashing them flat."; - } - else if (person.count <= 3) { - if (Math.random() > 0.5) - return "Your paw comes down on " + person.describe() + ". " + (person.count == 2 ? "Both" : "All three") + " crunch beneath your heavy toes."; - } +// EATING - return ""; -} - -function skyscraperAnalVore(skyscraper,verbose=true,height = 10) { - if (height < 5000) { - if (verbose) - return "You ease yourself down over the skyscraper, spreading your ass wide as you take it to the ground - then, with a powerful clench, snap it from its base. " + describe_all(skyscraper.contents) + " are sealed away in your ass."; - else - return "You ease yourself down over the skyscraper, spreading your ass wide as you take it to the ground - then, with a powerful clench, snap it from its base. "; - } else { - if (verbose) - return "You stuff the skyscraper up your ass with ease. Bad luck for " + describe_all(skyscraper.contents) + " inside."; - else - return "You stuff the skyscraper up your ass with ease."; +rules["eat"].push({ + "test": function(container, macro) { + return hasNothing(container); + }, + "desc": function(container, macro) { + return "You scoop up...nothing. Oh well."; } +}); - return ""; -} +rules["eat"].push({ + "test": function(container, macro) { + return hasExactly(container, "Person", 1); + }, + "desc": function(conatiner, macro) { + return "you eat them lol"; + } +}); diff --git a/recursive-macro.js b/recursive-macro.js index b6c54a1..305a6ee 100644 --- a/recursive-macro.js +++ b/recursive-macro.js @@ -236,56 +236,6 @@ function distribution(min, max, samples) { return result; } -/* default actions */ - -function defaultStomp(thing) { - return function (verbose=true,height=10) { return "You crush " + thing.describe(verbose) + " underfoot."}; -} - -function defaultKick(thing) { - return function(verbose=true,height=10) { return "You punt " + thing.describe(verbose) + ", destroying " + (thing.count > 1 ? "them" : "it") + "."; } -} - -function defaultEat(thing) { - return function(verbose=true,height=10) { return "You scoop up " + thing.describe(verbose) + " and swallow " + (thing.count > 1 ? "them" : "it") + " whole."; } -} - -function defaultAnalVore(thing) { - return function(verbose=true,height=10) { return "You sit yourself down on " + thing.describe(verbose) + ". " + (thing.count > 1 ? "They slide" : "It slides") + " inside with ease."; } -} - -function defaultButtcrush(thing) { - return function(verbose=true,height=10) { return "Your heavy ass obliterates " + thing.describe(verbose) + ". "; } -} - -function defaultBreastCrush(thing) { - return function(verbose=true,height=10) { return "Your heavy breasts obliterate " + thing.describe(verbose) + ". "; } -} - -function defaultUnbirth(thing) { - return function(verbose=true,height=10) { return "You gasp as you slide " + thing.describe(verbose) + " up your slit. "; } -} - -function defaultCockslap(thing) { - return function(verbose=true,height=10) { return "Your swaying shaft crushes " + thing.describe(verbose) + ". "; } -} - -function defaultCockVore(thing) { - return function(verbose=true,height=10) { return "You stuff " + thing.describe(verbose) + " into your throbbing shaft, forcing them down to your heavy balls."; } -} - -function defaultBallSmother(thing) { - return function(verbose=true,height=10) { return "Your weighty balls spread over " + thing.describe(verbose) + ", smothering them in musk."; } -} - -function defaultMaleOrgasm(thing) { - return function(verbose=true,height=10) { return "You're cumming! Your thick cock spurts out $VOLUME of seed, splooging " + thing.describe(verbose) + "."; } -} - -function defaultFemaleOrgasm(thing) { - return function(verbose=true,height=10) { return "You're cumming! Your moist slit sprays $VOLUME of slick femcum, splooging " + thing.describe(verbose) + "."; } -} - function defaultArea(thing) { return areas[thing.name]; } @@ -422,20 +372,7 @@ function Container(contents = []) { else return line; }; - - this.stomp = defaultStomp(this); - this.eat = defaultEat(this); - this.kick = defaultKick(this); - this.anal_vore = defaultAnalVore(this); - this.buttcrush = defaultButtcrush(this); - this.breast_crush = defaultBreastCrush(this); - this.unbirth = defaultUnbirth(this); - this.cockslap = defaultCockslap(this); - this.cock_vore = defaultCockVore(this); - this.ball_smother = defaultBallSmother(this); - this.male_orgasm = defaultMaleOrgasm(this); - this.female_orgasm = defaultFemaleOrgasm(this); - + return this; }