diff --git a/game.js b/game.js index 7427b62..3215aa2 100644 --- a/game.js +++ b/game.js @@ -4358,7 +4358,7 @@ function magic_shrink() prey = getPrey(biome, macro.height * macro.height * 100, true); macro.shrunkPrey = prey; - macro.shrunkPrey.mass /= 1000000; + macro.shrunkPrey.mod_property("mass", x => x/1e2) let line = describe("magic-shrink", prey, macro, false, flat); let linesummary = summarize(prey.sum(), false); diff --git a/recursive-macro.js b/recursive-macro.js index 8c2b960..a92fdb4 100644 --- a/recursive-macro.js +++ b/recursive-macro.js @@ -780,6 +780,18 @@ function defaultSumProperty(thing) { }; } +function defaultModProperty(thing) { + return function(prop, func) { + thing[prop] = func(thing[prop]); + + for (var key in thing.contents) { + if (thing.contents.hasOwnProperty(key)) { + thing.contents[key].mod_property(prop, func); + } + } + }; +} + function defaultAddContent(thing) { return function(name, min, max, count) { if (min == max) { @@ -797,6 +809,7 @@ function DefaultEntity() { this.area = defaultArea; this.mass = defaultMass; this.sum_property = defaultSumProperty; + this.mod_property = defaultModProperty; this.merge = defaultMerge; this.multiply = defaultMultiply; this.describeSimple = defaultDescribeSimple;