瀏覽代碼

Fixed a silly area fill bug. Some more eating stuff

tags/v0.7.0
Fen Dweller 7 年之前
父節點
當前提交
3b351b5259
共有 3 個檔案被更改,包括 53 行新增16 行删除
  1. +41
    -5
      recursive-desc.js
  2. +9
    -8
      recursive-macro.js
  3. +3
    -3
      stroll.html

+ 41
- 5
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.";
}
})

+ 9
- 8
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));
}
}


+ 3
- 3
stroll.html 查看文件

@@ -5,8 +5,8 @@
<title>Stroll</title>
<link rel="stylesheet" href="style.css">
<script src="units.js"></script>
<script src="recursive-desc.js"></script>
<script src="recursive-macro.js"></script>
<script src="recursive-desc.js"></script>
<script src="game.js"></script>
</head>
<body>
@@ -34,7 +34,7 @@
</div>
<div id=log-area>
<div id=log>
<div>Welcome to Stroll 0.3.0</div>
<div>Welcome to Stroll 0.3.1</div>
<div><b>This game features 18+ content</b></div>
<div><a href="https://chemicalcrux.org/stroll">Changelog</a></div>
<div>It's a nice day for a walk</div>
@@ -61,7 +61,7 @@


<div class=option-container id=option-panel>
<p>Welcome to Stroll 0.3.0</p>
<p>Welcome to Stroll 0.3.1</p>
<p><b>This game features 18+ content</b></p>
<a href="https://chemicalcrux.org/stroll">Changelog</a>
<br>


Loading…
取消
儲存