From 97d48c5b2b9878ec01cd4939936cdf9b13c64fa4 Mon Sep 17 00:00:00 2001 From: Fen Dweller Date: Sat, 3 Mar 2018 14:49:01 -0500 Subject: [PATCH] Improved clustering a bit - some randomness. Working on shoes and socks --- game.js | 113 ++++++++++++++++++++++++++++++++++++++++++--- recursive-desc.js | 5 +- recursive-macro.js | 9 ++-- 3 files changed, 114 insertions(+), 13 deletions(-) diff --git a/game.js b/game.js index 587bb3d..0827334 100644 --- a/game.js +++ b/game.js @@ -89,9 +89,14 @@ let macro = // part types "footType": "paw", + "footSock": "none", + "footShoe": "none", + "footSockWorn": false, + "footShoeWorn": true, - "footDesc": function(plural=false,capital=false) { + "footOnlyDesc": function(plural=false,capital=false) { let result = ""; + switch(this.footType) { case "paw": result = plural ? "paws" : "paw"; @@ -103,18 +108,51 @@ let macro = case "avian": result = plural ? "feet" : "foot"; break; + } + return capital ? result.charAt(0).toUpperCase() + result.slice(1) : result; + }, + + "footDesc": function(plural=false,capital=false,possessive=true) { + let result = ""; + if (!this.footSockWorn && !this.footShoeWorn) { + return this.footOnlyDesc(plural,capital); + } else if (this.footShoeWorn) { + switch(this.footShoe) { + case "shoe": + result = plural ? "shoes" : "shoe"; + break; + case "boot": + result = plural ? "boots" : "boot"; + break; + case "trainer": + result = plural ? "trainers" : "trainer"; + break; + case "sandal": + result = plural ? "sandals" : "sandal"; + break; + } + } else if (this.footSockWorn) { + switch(this.footSock) { + case "sock": + result = "socked " + this.footOnlyDesc(plural,false); + } + } + + if(possessive) { + result = " your " + result; } return capital ? result.charAt(0).toUpperCase() + result.slice(1) : result; }, - "toeDesc": function(plural=false,capital=false) { + "toeOnlyDesc": function(plural=false,capital=false) { let result = ""; + switch(this.footType) { case "paw": result = plural ? "toes" : "toe"; break; case "hoof": - result = plural ? "hooves" : "hoof"; + result = plural ? "toes" : "toe"; break; case "feet": result = plural ? "toes" : "toe"; @@ -122,9 +160,42 @@ let macro = case "avian": result = plural ? "talons" : "talon"; break; + } + return capital ? result.charAt(0).toUpperCase() + result.slice(1) : result; + }, + + "toeDesc": function(plural=false,capital=false,possessive=false) { + let result = ""; + if (!this.footSockWorn && !this.footShoeWorn) { + return this.toeOnlyDesc(plural,capital); + } else if (this.footShoeWorn) { + switch(this.footShoe) { + case "shoe": + result = plural ? "treads" : "tread"; + break; + case "boot": + result = plural ? "treads" : "tread"; + break; + case "trainer": + result = plural ? "treads" : "tread"; + break; + case "sandal": + result = plural ? "treads" : "tread"; + break; + } + } else if (this.footSockWorn) { + switch(this.footSock) { + case "sock": + result = "socked " + this.toeOnlyDesc(plural,false); + } + } + + if(possessive) { + result = "your " + result; } return capital ? result.charAt(0).toUpperCase() + result.slice(1) : result; }, + "jawType": "jaw", "jawDesc": function(plural=false,capital=false) { @@ -635,6 +706,34 @@ let macro = } }, + "shoe": { + "name": "shoe", + "container": new Container(), + get description() { + if (this.container.count == 0) + return "Your shoes are empty."; + else + return "Your shoes contain " + this.container.describe(false); + }, + "add": function(victims) { + this.container = this.container.merge(victims); + } + }, + + "sock": { + "name": "sock", + "container": new Container(), + get description() { + if (this.container.count == 0) + return "Your shoes are empty."; + else + return "Your shoes contain " + this.container.describe(false); + }, + "add": function(victims) { + this.container = this.container.merge(victims); + } + }, + "init": function() { this.stomach.setup(this); this.bowels.setup(this); @@ -1158,9 +1257,9 @@ function getOnePrey(biome, area, sameSize = true) { let potential = ["Person"]; - if (macro.height > 1e12) + if (area >= areas["Planet"]) potential = ["Planet","Star","Solar System","Galaxy"]; - else if (macro.height > 1e6) + else if (area >= areas["Town"]) potential = ["Town","City","Continent","Planet"]; else switch(biome) { @@ -1197,7 +1296,7 @@ function getPrey(region, area, sameSize = false) { let weights = {"Person": 1}; - if (macro.height > 1e12) { + if (area > areas["Planet"]) { weights = { "Planet": 1.47e-10, "Star": 1.7713746e-12, @@ -1205,7 +1304,7 @@ function getPrey(region, area, sameSize = false) "Galaxy": 0.1, }; } - else if (macro.height > 1e6) { + else if (area > areas["Town"]) { weights = { "Town": 0.00001, "City": 0.00005, diff --git a/recursive-desc.js b/recursive-desc.js index 1433fe8..22cad5b 100644 --- a/recursive-desc.js +++ b/recursive-desc.js @@ -670,10 +670,9 @@ rules["stomp"].push({ rules["stomp"].push({ "test": function(container, macro) { return hasNothingElse(container, ["Person","Cow","Car"]) && - isNonFatal(macro) && - macro.footType == "paw"; + isNonFatal(macro); }, "desc": function(container, macro, verbose) { - return "Your paw smooshes over " + container.describe(verbose) + ". They stick to your toes, carried along for the ride as you take another few steps before finally\ + return "Your " + macro.footDesc() + " smooshes over " + container.describe(verbose) + ". They stick to your " + macro.toeDesc(true) + ", carried along for the ride as you take another few steps before finally\ falling off."; } }); diff --git a/recursive-macro.js b/recursive-macro.js index 6c869aa..dc7644a 100644 --- a/recursive-macro.js +++ b/recursive-macro.js @@ -106,7 +106,7 @@ var clusters = "Train": 2, "Train Car": 1, "Parking Garage": 1, - "Town": 1, + "Town": 5, "City": 1, "Continent": 5, "Planet": 1, @@ -154,8 +154,11 @@ function fill_area(area, weights, variance=0.15) // the first few ones get a much better shot while (loopvar > 0) { - if (loopvar <= clusters[candidate.name]) - count += 1; + if (loopvar <= clusters[candidate.name]) { + if (Math.random() < candidate.weight ? 1 : 0 || Math.random() < 0.75) { + count += 1; + } + } else count += Math.random() < candidate.weight ? 1 : 0; --loopvar;