Bladeren bron

Added some more custom descriptions

tags/v0.7.0
Fen Dweller 7 jaren geleden
bovenliggende
commit
337d948eb6
3 gewijzigde bestanden met toevoegingen van 56 en 7 verwijderingen
  1. +1
    -1
      game.js
  2. +49
    -3
      recursive-desc.js
  3. +6
    -3
      recursive-macro.js

+ 1
- 1
game.js Bestand weergeven

@@ -553,7 +553,7 @@ function getPrey(region, area)
}; break;
}
}
return fill_area2(area,weights);
return fill_area(area,weights);
}




+ 49
- 3
recursive-desc.js Bestand weergeven

@@ -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<things.length; i++) {
if (!container.contents.hasOwnProperty(things[i]))
return false;
}

return true;

}
function describe(action, container, macro, verbose=true) {
options = [];

@@ -76,9 +98,33 @@ rules["eat"].push({

rules["eat"].push({
"test": function(container, macro) {
return hasExactly(container, "Person", 1);
return hasOnly(container, ["Person"])
&& hasLessThan(container, "Person", 6)
&& macro.height >= 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();
}
})

+ 6
- 3
recursive-macro.js Bestand weergeven

@@ -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;
}



Laden…
Annuleren
Opslaan