From fe8ace67344fdecc097b04aa0efa2c514fae95ca Mon Sep 17 00:00:00 2001 From: Fen Dweller Date: Wed, 28 Feb 2018 17:55:09 -0500 Subject: [PATCH] Added military/micros/macros --- game.js | 72 ++++++++++----------------- recursive-macro.js | 120 +++++++++++++++++++++++++++++++++++++++++++-- stroll.html | 1 - 3 files changed, 144 insertions(+), 49 deletions(-) diff --git a/game.js b/game.js index d32f6c7..1a9d3b5 100644 --- a/game.js +++ b/game.js @@ -952,7 +952,7 @@ function get_living_prey(sum) { let total = 0; for (let key in sum) { if (sum.hasOwnProperty(key)) { - if (key == "Person" || key == "Cow") + if (key == "Micro" || key == "Macro" || key == "Person" || key == "Cow") total += sum[key]; } } @@ -1123,50 +1123,32 @@ function getPrey(region, area, sameSize = false) }; } else { - switch(region) - { - case "rural": weights = { - "Person": 0.005, - "House": 0.001, - "Barn": 0.001, - "Cow": 0.02, - }; break; - case "suburb": weights = { - "Person": 0.03, - "House": 0.15, - "Car": 0.05, - "Bus": 0.02, - "Train": 0.02, - "Town": 0.00001, - "City": 0.00005, - "Continent": 0.0005, - "Planet": 0.0001 - }; break; - case "city": weights = { - "Person": 0.05, - "House": 0.1, - "Car": 0.07, - "Bus": 0.02, - "Parking Garage": 0.003, - "Small Skyscraper": 0.05, - "Town": 0.00001, - "City": 0.00005, - "Continent": 0.0005, - "Planet": 0.0001 - }; break; - case "downtown": weights = { - "Person": 0.1, - "Car": 0.1, - "Bus": 0.05, - "Tram": 0.01, - "Parking Garage": 0.005, - "Small Skyscraper": 0.4, - "Large Skyscraper": 0.1, - "Town": 0.00001, - "City": 0.00005, - "Continent": 0.0005, - "Planet": 0.0001 - }; break; + weights = { + "Person": 0.05, + "House": 0.1, + "Car": 0.07, + "Bus": 0.02, + "Parking Garage": 0.003, + "Small Skyscraper": 0.05, + "Town": 0.00001, + "City": 0.00005, + "Continent": 0.0005, + "Planet": 0.0001 + }; + + if (macro.victimsMilitary) { + weights["Soldier"] = 0.01; + weights["Tank"] = 0.0005; + weights["Artillery"] = 0.0001; + weights["Helicopter"] = 0.00005; + } + + if (macro.victimsMicros) { + weights["Micro"] = 1; + } + + if (macro.victimsMacros) { + weights["Macro"] = 0.0001; } } var prey = fill_area(area,weights); diff --git a/recursive-macro.js b/recursive-macro.js index 1321a97..2222d38 100644 --- a/recursive-macro.js +++ b/recursive-macro.js @@ -22,7 +22,13 @@ var things = "Planet": Planet, "Star": Star, "Solar System": SolarSystem, - "Galaxy": Galaxy + "Galaxy": Galaxy, + "Soldier": Soldier, + "Tank": Tank, + "Artillery": Artillery, + "Helicopter": Helicopter, + "Micro": Micro, + "Macro": Macro, }; var areas = @@ -47,6 +53,12 @@ var areas = "Star": 3e18, "Solar System": 3e21, "Galaxy": 2e42, + "Soldier": 1, + "Tank": 10, + "Artillery": 12, + "Helicopter": 8, + "Micro": 0.05, + "Macro": 100, }; var masses = @@ -70,7 +82,13 @@ var masses = "Planet": 5.972e24, "Star": 1e40, "Solar System": 1, - "Galaxy": 1 + "Galaxy": 1, + "Soldier": 80, + "Tank": 5000, + "Artillery": 7000, + "Helicopter": 1500, + "Micro": 0.01, + "Macro": 80000, }; var clusters = @@ -94,7 +112,13 @@ var clusters = "Planet": 1, "Star": 1, "Solar System": 1, - "Galaxy": 1 + "Galaxy": 1, + "Soldier": 0, + "Tank": 0, + "Artillery": 0, + "Helicopter": 0, + "Micro": 10, + "Macro": 0, }; // general logic: each step fills in a fraction of the remaining space @@ -971,3 +995,93 @@ function Galaxy(count = 1) { } }; } + +function Soldier(count = 1) { + this.name = "Soldier"; + + copy_defaults(this,new DefaultEntity()); + this.count = count; + this.contents = {}; + + this.describe = function(verbose = true) { + return (this.count == 1 ? "a soldier" : this.count + " soldiers"); + }; +} + +function Tank(count = 1) { + this.name = "Tank"; + + copy_defaults(this,new DefaultEntity()); + this.count = count; + this.contents = {}; + + this.addContent("Soldier",3,5,count); + + this.describe = function(verbose = true) { + if (verbose) { + return (this.count == 1 ? "a tank" : this.count + " tanks") + " with " + describe_all(this.contents, verbose) + " trapped inside."; + } else { + return (this.count == 1 ? "a tank" : this.count + " tanks"); + } + }; +} + +function Artillery(count = 1) { + this.name = "Artillery"; + + copy_defaults(this,new DefaultEntity()); + this.count = count; + this.contents = {}; + + this.addContent("Soldier",4,6,count); + + this.describe = function(verbose = true) { + if (verbose) { + return (this.count == 1 ? "an artillery unit" : this.count + " artillery units") + " with " + describe_all(this.contents, verbose) + " trapped inside."; + } else { + return (this.count == 1 ? "an artillery unit" : this.count + " artillery units"); + } + }; +} + +function Helicopter(count = 1) { + this.name = "Helicopter"; + + copy_defaults(this,new DefaultEntity()); + this.count = count; + this.contents = {}; + + this.addContent("Soldier",4,16,count); + + this.describe = function(verbose = true) { + if (verbose) { + return (this.count == 1 ? "a helicopter" : this.count + " helicopters") + " with " + describe_all(this.contents, verbose) + " riding inside."; + } else { + return (this.count == 1 ? "a helicopter" : this.count + " helicopters"); + } + }; +} + +function Micro(count = 1) { + this.name = "Micro"; + + copy_defaults(this,new DefaultEntity()); + this.count = count; + this.contents = {}; + + this.describe = function(verbose = true) { + return (this.count == 1 ? "a micro" : this.count + " micros"); + }; +} + +function Macro(count = 1) { + this.name = "Macro"; + + copy_defaults(this,new DefaultEntity()); + this.count = count; + this.contents = {}; + + this.describe = function(verbose = true) { + return (this.count == 1 ? "a smaller macro" : this.count + " smaller macros"); + }; +} diff --git a/stroll.html b/stroll.html index a32f84b..248e869 100644 --- a/stroll.html +++ b/stroll.html @@ -63,7 +63,6 @@ -