diff --git a/game.js b/game.js index e0594e2..045cbd7 100644 --- a/game.js +++ b/game.js @@ -553,7 +553,7 @@ function getPrey(region, area) }; break; } } - return fill_area2(area,weights); + return fill_area(area,weights); } diff --git a/recursive-desc.js b/recursive-desc.js index dbda108..c54da54 100644 --- a/recursive-desc.js +++ b/recursive-desc.js @@ -22,6 +22,13 @@ function hasNothing(container, thing, amount) { return true; } +function hasLessThan(container, thing, amount) { + if (container.contents.hasOwnProperty(thing)) + if (container.contents[thing].count < amount && container.contents[thing].count > 0) + return true; + return false; +} + function hasExactly(container, thing, amount) { if (!container.contents.hasOwnProperty(thing) && amount == 0) return true; @@ -30,6 +37,21 @@ function hasExactly(container, thing, amount) { return false; } +function hasOnly(container, things) { + for (var key in container.contents) { + if (container.contents.hasOwnProperty(key)) + if (!things.includes(key)) + return false; + } + + for (var i=0; i= 10; }, - "desc": function(conatiner, macro) { - return "you eat them lol"; + "desc": function(container, macro) { + return "You pluck up the " + container.describe() + " and stuff them into your mouth, swallowing lightly to drag them down to your bubbling guts."; } }); + +rules["eat"].push({ + "test": function(container, macro) { + return hasOnly(container, ["Person"]) + && hasExactly(container, "Person", 1) + && macro.height < 10; + }, + "desc": function(container, macro) { + return "You grasp " + container.describe() + " and greedily wolf them down, swallowing forcefully to cram them into your bulging stomach. A crass belch escapes your lips as they curl up in your slimy gut."; + } +}) + +rules["eat"].push({ + "test": function(container, macro) { + return hasOnly(container, ["Person","Car"]) + && hasExactly(container, "Car", 1) + && hasLessThan(container, "Person", 5); + }, + "desc": function(container, macro) { + return "You crush the " + container.contents["Car"].describe() + " with your tight throat, washing it down with " + container.contents["Person"].describe(); + } +}) diff --git a/recursive-macro.js b/recursive-macro.js index 305a6ee..b9a45cb 100644 --- a/recursive-macro.js +++ b/recursive-macro.js @@ -101,7 +101,7 @@ var clusters = // general logic: each step fills in a fraction of the remaining space -function fill_area2(area, weights) +function fill_area(area, weights) { result = []; candidates = []; @@ -147,7 +147,10 @@ function fill_area2(area, weights) result.push(new things[candidate.name](count)); } - return new Container(result); + if (result.length > 0) + return new Container(result); + else + return new Container([new Person(1)]); } // describes everything in the container @@ -372,7 +375,7 @@ function Container(contents = []) { else return line; }; - + return this; }