| @@ -114,9 +114,12 @@ function nothingLarger(container, thing) { | |||||
| return true; | return true; | ||||
| } | } | ||||
| function describe(action, container, macro, verbose=true) { | |||||
| function describe(action, container, macro, verbose=true, flat=false) { | |||||
| var options = []; | var options = []; | ||||
| if (flat) { | |||||
| container = flatten(container); | |||||
| } | |||||
| for (var i = 0; i < rules[action].length; i++) { | for (var i = 0; i < rules[action].length; i++) { | ||||
| if(rules[action][i].test(container,macro)) { | if(rules[action][i].test(container,macro)) { | ||||
| options.push(rules[action][i].desc); | options.push(rules[action][i].desc); | ||||
| @@ -486,6 +486,28 @@ function listSum(sum) { | |||||
| return merge_things(result); | 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) { | function defaultSum(thing) { | ||||
| return function() { | return function() { | ||||
| var counts = {}; | var counts = {}; | ||||