From 3b351b5259e04d24d1711b599d7a9778ac8de824 Mon Sep 17 00:00:00 2001 From: Fen Dweller Date: Tue, 20 Feb 2018 20:26:12 -0500 Subject: [PATCH] Fixed a silly area fill bug. Some more eating stuff --- recursive-desc.js | 46 +++++++++++++++++++++++++++++++++++++++++----- recursive-macro.js | 17 +++++++++-------- stroll.html | 6 +++--- 3 files changed, 53 insertions(+), 16 deletions(-) diff --git a/recursive-desc.js b/recursive-desc.js index c54da54..f5cc050 100644 --- a/recursive-desc.js +++ b/recursive-desc.js @@ -50,7 +50,15 @@ function hasOnly(container, things) { } return true; +} +function nothingLarger(container, thing) { + for (var key in container.contents) + if (container.contents.hasOwnProperty(key)) + if (areas[key] > areas[thing]) + return false; + + return true; } function describe(action, container, macro, verbose=true) { options = []; @@ -62,7 +70,7 @@ function describe(action, container, macro, verbose=true) { } if (options.length > 0) - return options[0](container, macro); + return options[0](container, macro, verbose); else { return describeDefault(action, container, macro, verbose); } @@ -91,7 +99,7 @@ rules["eat"].push({ "test": function(container, macro) { return hasNothing(container); }, - "desc": function(container, macro) { + "desc": function(container, macro, verbose) { return "You scoop up...nothing. Oh well."; } }); @@ -102,7 +110,7 @@ rules["eat"].push({ && hasLessThan(container, "Person", 6) && macro.height >= 10; }, - "desc": function(container, macro) { + "desc": function(container, macro, verbose) { return "You pluck up the " + container.describe() + " and stuff them into your mouth, swallowing lightly to drag them down to your bubbling guts."; } }); @@ -113,7 +121,7 @@ rules["eat"].push({ && hasExactly(container, "Person", 1) && macro.height < 10; }, - "desc": function(container, macro) { + "desc": function(container, macro, verbose) { 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."; } }) @@ -124,7 +132,35 @@ rules["eat"].push({ && hasExactly(container, "Car", 1) && hasLessThan(container, "Person", 5); }, - "desc": function(container, macro) { + "desc": function(container, macro, verbose) { return "You crush the " + container.contents["Car"].describe() + " with your tight throat, washing it down with " + container.contents["Person"].describe(); } }) + +rules["eat"].push({ + "test": function(container, macro) { + return hasExactly(container, "Small Skyscraper", 1) + && nothingLarger(container, "Small Skyscraper") + && macro.height < 500; + }, + "desc": function(container, macro, verbose) { + return "You drop onto your hands and knees, jaws opening wide to envelop the skyscraper. It glides into your throat as your snout touches the ground,\ + and you suckle on it for a long moment before twisting your head to snap it loose. The entire building and the " + describe_all(container.contents["Small Skyscraper"].contents, verbose) + "\ + within plunge into your roiling guts, along with some delicious treats you slurped up along with it - " + describe_all(container.contents, verbose, ["Small Skyscraper"]) + "."; + } +}) + +rules["eat"].push({ + "test": function(container, macro) { + return hasExactly(container, "Small Skyscraper", 2) + && nothingLarger(container, "Small Skyscraper") + && macro.height < 750; + }, + "desc": function(container, macro, verbose) { + return "You drop onto your hands and knees, jaws opening wide to envelop the skyscraper. It glides into your throat as your snout touches the ground,\ + and you suckle on it for a long moment before twisting your head to snap it loose. Without missing a beat, you rise back up, sloppy tongue slathering over the side \ + of the remaining tower, sucking on its tip and roughly shoving it into your maw. It breaks from its foundation, vanishing past your lips as you use two fingers to shove it \ + down your sultry throat. Your gut bubbles as " + describe_all(container.contents["Small Skyscraper"].contents, verbose) + " are crunched and crushed within, along with the \ + " + describe_all(container.contents, verbose, ["Small Skyscraper"]) + " that were unfortunate enough to be caught up by your slimy tongue."; + } +}) diff --git a/recursive-macro.js b/recursive-macro.js index b9a45cb..f3ca6d4 100644 --- a/recursive-macro.js +++ b/recursive-macro.js @@ -35,7 +35,7 @@ var areas = "Motorcycle": 2, "House": 1000, "Barn": 750, - "Small Skyscraper": 10000, + "Small Skyscraper": 2500, "Train": 500, "TrainCar": 500, "Parking Garage": 5000, @@ -60,7 +60,7 @@ var masses = "Motorcycle": 200, "House": 10000, "Barn": 5000, - "Small Skyscraper": 100000, + "Small Skyscraper": 10000000, "Train": 5000, "Train Car": 5000, "Parking Garage": 100000, @@ -88,7 +88,7 @@ var clusters = "Small Skyscraper": 5, "Train": 2, "Train Car": 1, - "Parking Garage": 1, + "Parking Garage": 0, "Overpass": 1, "Town": 1, "City": 1, @@ -125,16 +125,17 @@ function fill_area(area, weights) var limit = Math.min(max, 100); var count = 0; + var loopvar = limit; // for small amounts, actually do the randomness // the first few ones get a much better shot - while (limit > 0) { - if (limit <= clusters[candidate.name]) + while (loopvar > 0) { + if (loopvar <= clusters[candidate.name]) count += 1; else count += Math.random() < candidate.weight ? 1 : 0; - --limit; + --loopvar; } if (limit < max) { @@ -154,10 +155,10 @@ function fill_area(area, weights) } // describes everything in the container -function describe_all(contents,verbose=true) { +function describe_all(contents,verbose=true,except=[]) { var things = []; for (var key in contents) { - if (contents.hasOwnProperty(key)) { + if (contents.hasOwnProperty(key) && !except.includes(key)) { things.push(contents[key].describe(verbose)); } } diff --git a/stroll.html b/stroll.html index 56c7b70..c16fcc8 100644 --- a/stroll.html +++ b/stroll.html @@ -5,8 +5,8 @@ Stroll - + @@ -34,7 +34,7 @@
-
Welcome to Stroll 0.3.0
+
Welcome to Stroll 0.3.1
This game features 18+ content
Changelog
It's a nice day for a walk
@@ -61,7 +61,7 @@
-

Welcome to Stroll 0.3.0

+

Welcome to Stroll 0.3.1

This game features 18+ content

Changelog