Browse Source

Added a concise text option, which flattens victim lists.

tags/v1.0.0
Fen Dweller 6 years ago
parent
commit
ad061fb575
3 changed files with 179 additions and 134 deletions
  1. +153
    -133
      game.js
  2. +4
    -1
      recursive-desc.js
  3. +22
    -0
      recursive-macro.js

+ 153
- 133
game.js
File diff suppressed because it is too large
View File


+ 4
- 1
recursive-desc.js View File

@@ -114,9 +114,12 @@ function nothingLarger(container, thing) {
return true;
}

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

if (flat) {
container = flatten(container);
}
for (var i = 0; i < rules[action].length; i++) {
if(rules[action][i].test(container,macro)) {
options.push(rules[action][i].desc);


+ 22
- 0
recursive-macro.js View File

@@ -486,6 +486,28 @@ function listSum(sum) {
return merge_things(result);
}

// turn a nested object into a container with everything on one level

function flatten(thing) {
let dict = defaultSum(thing)();

let list = [];

Object.entries(dict).forEach(function([key, val]) {
console.log(key);
console.log(things[key])
let obj = new things[key](val);

obj.contents = [];
list.push(obj);
});

console.log(list);

return new Container(list);
}

function defaultSum(thing) {
return function() {
var counts = {};


Loading…
Cancel
Save