diff --git a/game.js b/game.js index a6c6746..4c2aa51 100644 --- a/game.js +++ b/game.js @@ -11,25 +11,51 @@ var metric = true; var verbose = true; +var biome = "suburb"; + var newline = " "; victims = {}; +function get_living_prey(sum) { + var total = 0; + for (var key in sum) { + if (sum.hasOwnProperty(key)) { + if (key == "Person" || key == "Cow") + total += sum[key]; + } + } + + return total; +} + function toggle_auto() { strolling = !strolling; - document.getElementById("strolling-indicator").innerHTML = strolling ? "Strolling" : "Standing"; + document.getElementById("button-stroll").innerHTML = "Status: " + (strolling ? "Strolling" : "Standing"); if (strolling) - update(["You start walking."]); + update(["You start walking.",newline]); else - update(["You stop walking."]); + update(["You stop walking.",newline]); +} + +function change_location() +{ + switch(biome) { + case "suburb": biome = "city"; break; + case "city": biome = "downtown"; break; + case "downtown": biome = "rural"; break; + case "rural": biome = "suburb"; break; + } + + document.getElementById("button-location").innerHTML = "Location: " + biome.charAt(0).toUpperCase() + biome.slice(1); } function toggle_units() { metric = !metric; - document.getElementById("button-units").innerHTML = metric ? "Metric" : "Customary"; + document.getElementById("button-units").innerHTML = "Units: " + (metric ? "Metric" : "Customary"); update(); } @@ -38,18 +64,20 @@ function toggle_verbose() { verbose = !verbose; - document.getElementById("button-verbose").innerHTML = verbose ? "Verbose" : "Simple"; + document.getElementById("button-verbose").innerHTML = "Descriptions: " + (verbose ? "Verbose" : "Simple"); } function initVictims() { return { "Person": 0, + "Cow": 0, "Car": 0, "Bus": 0, "Tram": 0, "Motorcycle": 0, "House": 0, + "Barn": 0, "Small Skyscraper": 0, "Train": 0, "Train Car": 0, @@ -61,15 +89,23 @@ function initVictims() // lists out total people function summarize(sum, fatal = true) { - return "(" + sum["Person"] + " " + (fatal ? (sum["Person"] > 1 ? "kills" : "kill") : (sum["Person"] > 1 ? "people" : "person")) + ")"; + var count = get_living_prey(sum); + return "(" + count + " " + (fatal ? (count > 1 ? "kills" : "kill") : (count > 1 ? "prey" : "prey")) + ")"; } var stomach = [] var bowels = [] -function getOnePrey(area) +function getOnePrey(biome,area) { - var potential = ["Person", "Car", "Bus", "Tram", "House", "Train", "Parking Garage", "Small Skyscraper"]; + var potential = ["Person"]; + + switch(biome) { + case "suburb": potential = ["Person", "Car", "Bus", "Train", "House"]; break; + case "city": potential = ["Person", "Car", "Bus", "Train", "Tram", "House", "Parking Garage"]; break; + case "downtown": potential = ["Person", "Car", "Bus", "Tram", "Small Skyscraper", "Parking Garage"]; break; + case "rural": potential = ["Person", "Barn", "House", "Cow"]; break; + } var potAreas = [] @@ -92,16 +128,44 @@ function getOnePrey(area) } function getPrey(region, area) { + var weights = {"Person": 1}; + switch(region) { - case "suburb": return suburbPrey(area); + case "rural": weights = { + "Person": 0.05, + "House": 0.01, + "Barn": 0.01, + "Cow": 0.2 + }; break; + case "suburb": weights = { + "Person": 0.5, + "House": 0.5, + "Car": 0.2, + "Train": 0.1, + "Bus": 0.1 + }; break; + case "city": weights = { + "Person": 0.5, + "House": 0.2, + "Car": 0.2, + "Train": 0.1, + "Bus": 0.1, + "Tram": 0.1, + "Parking Garage": 0.02 + }; break; + case "downtown": weights = { + "Person": 0.5, + "Car": 0.3, + "Bus": 0.15, + "Tram": 0.1, + "Parking Garage": 0.02, + "Small Skyscraper": 0.4 + }; break; } + return fill_area2(area,weights); } -function suburbPrey(area) -{ - return fill_area2(area, {"Person": 0.5, "House": 0.5, "Car": 0.2, "Tram": 0.1, "Bus": 0.1, "Small Skyscraper": 0.05, "Parking Garage": 0.02, "Train": 0.05}); -} function updateVictims(type,prey) { @@ -123,12 +187,13 @@ function scaleAddMass(scale, baseMass, mass) function feed() { - var prey = getPrey("suburb", 0.5*scale*scale); + var area = baseHeight / 30 * scale * scale; + var prey = getPrey(biome, area); var line = prey.eat(verbose) var linesummary = summarize(prey.sum(), false); - var people = prey.sum()["Person"]; + var people = get_living_prey(prey.sum()); var sound = "Ulp"; if (people < 3) { @@ -160,11 +225,12 @@ function feed() function stomp() { - var prey = getPrey("suburb", 1.5*scale*scale); + var area = baseHeight / 15 * scale * scale; + var prey = getPrey(biome, area); var line = prey.stomp(verbose) var linesummary = summarize(prey.sum(), true); - var people = prey.sum()["Person"]; + var people = get_living_prey(prey.sum()); var sound = "Thump"; @@ -191,14 +257,17 @@ function stomp() function anal_vore() { - var prey = getOnePrey(0.25*scale*scale); - var crushed = getPrey("suburb",3*scale*scale); + var area = baseHeight / 30 * scale * scale; + var prey = getOnePrey(biome,area); + + area = baseHeight * scale * scale / 5; + var crushed = getPrey(biome,3*scale*scale); var line1 = prey.anal_vore(verbose, baseHeight*scale); var line1summary = summarize(prey.sum(), false); var line2 = crushed.buttcrush(verbose); var line2summary = summarize(crushed.sum(), true); - var people = prey.sum()["Person"]; + var people = get_living_prey(prey.sum()); var sound = "Shlp"; if (people < 3) { @@ -215,7 +284,7 @@ function anal_vore() sound = "Oh the humanity!"; } - people = crushed.sum()["Person"]; + var people = get_living_prey(crushed.sum()); var sound2 = "Thump"; if (people < 3) { @@ -305,8 +374,21 @@ function pick_move() function grow() { + var oldHeight = baseHeight * scale; + var oldMass = baseMass * Math.pow(scale,3); + scale *= 1.2; - update(); + + var newHeight = baseHeight * scale; + var newMass = baseMass * Math.pow(scale,3); + + var heightDelta = newHeight - oldHeight; + var massDelta = newMass - oldMass; + + var heightStr = metric ? metricLength(heightDelta) : customaryLength(heightDelta); + var massStr = metric ? metricMass(massDelta) : customaryMass(massDelta); + + update(["Power surges through you as you grow " + heightStr + " and gain " + massStr,newline]); } // pop the list and digest that object @@ -368,6 +450,7 @@ window.addEventListener('load', function(event) { document.getElementById("button-stroll").addEventListener("click",toggle_auto); document.getElementById("button-units").addEventListener("click",toggle_units); document.getElementById("button-verbose").addEventListener("click",toggle_verbose); + document.getElementById("button-location").addEventListener("click",change_location); setTimeout(pick_move, 2000); update(); diff --git a/recursive-macro.js b/recursive-macro.js index 60a8c15..ba4e070 100644 --- a/recursive-macro.js +++ b/recursive-macro.js @@ -2,12 +2,14 @@ var things = { "Container": Container, "Person": Person, + "Cow": Cow, "Empty Car": EmptyCar, "Car": Car, "Bus": Bus, "Tram": Tram, "Motorcycle": Motorcycle, "House": House, + "Barn": Barn, "Small Skyscraper": SmallSkyscraper, "Train": Train, "Train Car": TrainCar, @@ -19,11 +21,13 @@ var areas = { "Container": 0, "Person": 1, + "Cow": 2, "Car": 4, "Bus": 12, "Tram": 20, "Motorcycle": 2, "House": 1000, + "Barn": 750, "Small Skyscraper": 10000, "Train": 500, "TrainCar": 500, @@ -35,11 +39,13 @@ var masses = { "Container": 0, "Person": 80, + "Cow": 300, "Car": 1000, "Bus": 5000, "Tram": 10000, "Motorcycle": 200, "House": 10000, + "Barn": 5000, "Small Skyscraper": 100000, "Train": 5000, "Train Car": 5000, @@ -49,7 +55,7 @@ var masses = // general logic: each step fills in a fraction of the remaining space -function fill_area2(area, weights = {"Person": 0.1, "Car": 0.05, "House": 0.1}) +function fill_area2(area, weights) { result = []; candidates = []; @@ -76,10 +82,10 @@ function fill_area2(area, weights = {"Person": 0.1, "Car": 0.05, "House": 0.1}) // for small amounts, actually do the randomness - // the first few ones get a better shot + // the first few ones get a much better shot while (limit > 0) { if (limit <= 3) - count += Math.random() < (1 - Math.pow((1 - candidate.weight),2)) ? 1 : 0; + count += Math.random() < (1 - Math.pow((1 - candidate.weight),limit*3)) ? 1 : 0; else count += Math.random() < candidate.weight ? 1 : 0; --limit; @@ -406,7 +412,6 @@ function Person(count = 1) { } else { return (this.count > 1 ? this.count + " people" : "a person"); } - } this.stomp = function(verbose=true) { @@ -427,6 +432,40 @@ function Person(count = 1) { return this; } +function Cow(count = 1) { + this.name = "Cow"; + + copy_defaults(this,new DefaultEntity()); + + this.count = count; + this.contents = {}; + + + this.describeOne = function (verbose=true) { + body = random_desc(["skinny","fat","tall","short","stocky","spindly"], (verbose ? 0.6 : 0)); + sex = random_desc(["male", "female"], (verbose ? 1 : 0)); + return "a " + merge_desc([body,sex,"cow"]); + } + + this.describe = function(verbose=true) { + if (verbose) { + if (count <= 3) { + list = []; + for (var i = 0; i < count; i++) { + list.push(this.describeOne(this.count <= 2)); + } + return merge_things(list); + } else { + return this.count + " cattle" + } + } else { + return (this.count > 1 ? this.count + " cattle" : "a cow"); + } + } + + return this; +} + function EmptyCar(count = 1) { this.name = "Car"; @@ -694,6 +733,41 @@ function House(count = 1) { } } +function Barn(count = 1) { + this.name = "Barn"; + copy_defaults(this,new DefaultEntity()); + this.count = count; + this.contents = {}; + + var amount = distribution(0,2,count); + this.contents.person = new Person(amount); + amount = distribution(30,70,count); + this.contents.cow = new Cow(amount); + + this.describeOne = function(verbose=true) { + size = random_desc(["little","big","large"], (verbose ? 0.5 : 0)); + color = random_desc(["blue","white","gray","tan","green"], (verbose ? 0.5 : 0)); + name = random_desc(["barn","barn","barn","barn","barn","farmhouse"], 1); + return "a " + merge_desc([size,color,name]); + } + + this.describe = function(verbose = true) { + if (verbose) { + if (this.count <= 3) { + list = []; + for (var i = 0; i < this.count; i++) { + list.push(this.describeOne(this.count < 2)); + } + return merge_things(list) + " with " + describe_all(this.contents,verbose) + " inside"; + } else { + return this.count + " barns with " + describe_all(this.contents,verbose) + " inside"; + } + } else { + return (this.count > 1 ? this.count + " barns" : "a barn"); + } + } +} + function SmallSkyscraper(count = 1) { this.name = "Small Skyscraper"; copy_defaults(this,new DefaultEntity()); diff --git a/stroll.html b/stroll.html index cbf4dac..e816aae 100644 --- a/stroll.html +++ b/stroll.html @@ -32,7 +32,7 @@