big steppy
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

375 line
8.8 KiB

  1. var baseHeight = 3.65;
  2. var baseMass = 1360;
  3. var scale = 1;
  4. var strolling = false;
  5. var maxStomachDigest = 10;
  6. var maxBowelsDigest = 10;
  7. var metric = true;
  8. var verbose = true;
  9. var newline = " ";
  10. victims = {};
  11. function toggle_auto()
  12. {
  13. strolling = !strolling;
  14. document.getElementById("strolling-indicator").innerHTML = strolling ? "Strolling" : "Standing";
  15. if (strolling)
  16. update(["You start walking."]);
  17. else
  18. update(["You stop walking."]);
  19. }
  20. function toggle_units()
  21. {
  22. metric = !metric;
  23. document.getElementById("button-units").innerHTML = metric ? "Metric" : "Customary";
  24. update();
  25. }
  26. function toggle_verbose()
  27. {
  28. verbose = !verbose;
  29. document.getElementById("button-verbose").innerHTML = verbose ? "Verbose" : "Simple";
  30. }
  31. function initVictims()
  32. {
  33. return {
  34. "Person": 0,
  35. "Car": 0,
  36. "Bus": 0,
  37. "Tram": 0,
  38. "Motorcycle": 0,
  39. "House": 0,
  40. "Small Skyscraper": 0,
  41. "Train": 0,
  42. "Train Car": 0,
  43. "Parking Garage": 0,
  44. "Overpass": 0,
  45. };
  46. };
  47. // lists out total people
  48. function summarize(sum, fatal = true)
  49. {
  50. return "<b>(" + sum["Person"] + " " + (fatal ? (sum["Person"] > 1 ? "kills" : "kill") : (sum["Person"] > 1 ? "people" : "person")) + ")</b>";
  51. }
  52. var stomach = []
  53. var bowels = []
  54. function getOnePrey(area)
  55. {
  56. var potential = ["Person", "Car", "Bus", "Tram", "House", "Train", "Parking Garage", "Small Skyscraper"];
  57. var potAreas = []
  58. potential.forEach(function (x) {
  59. potAreas.push([x,areas[x]]);
  60. });
  61. potAreas = potAreas.sort(function (x,y) {
  62. return y[1] - x[1];
  63. });
  64. for (var i=0; i<potAreas.length; i++) {
  65. x = potAreas[i];
  66. if (x[1] < area) {
  67. return new things[x[0]](1);
  68. }
  69. };
  70. return new Person(1);
  71. }
  72. function getPrey(region, area)
  73. {
  74. switch(region)
  75. {
  76. case "suburb": return suburbPrey(area);
  77. }
  78. }
  79. function suburbPrey(area)
  80. {
  81. 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});
  82. }
  83. function updateVictims(type,prey)
  84. {
  85. var sums = prey.sum();
  86. for (var key in sums) {
  87. if (sums.hasOwnProperty(key)) {
  88. victims[type][key] += sums[key];
  89. }
  90. }
  91. }
  92. function scaleAddMass(scale, baseMass, mass)
  93. {
  94. var startMass = Math.pow(scale, 3) * baseMass;
  95. var newMass = startMass + mass;
  96. return Math.pow(newMass / baseMass, 1/3) ;
  97. }
  98. function feed()
  99. {
  100. var prey = getPrey("suburb", 0.5*scale*scale);
  101. var line = prey.eat(verbose)
  102. var linesummary = summarize(prey.sum(), false);
  103. var people = prey.sum()["Person"];
  104. var sound = "Ulp";
  105. if (people < 3) {
  106. sound = "Ulp.";
  107. } else if (people < 10) {
  108. sound = "Gulp.";
  109. } else if (people < 50) {
  110. sound = "Glrrp.";
  111. } else if (people < 500) {
  112. sound = "Glrrrpkh!";
  113. } else if (people < 5000) {
  114. sound = "GLRRKPKH!";
  115. } else {
  116. sound = "Oh the humanity!";
  117. }
  118. var preyMass = prey.sum_property("mass");
  119. scale = scaleAddMass(scale, baseMass, preyMass);
  120. stomach.push(prey);
  121. if (stomach.length == 1)
  122. setTimeout(function() { doDigest("stomach"); }, 15000);
  123. updateVictims("stomach",prey);
  124. update([sound,line,linesummary,newline]);
  125. }
  126. function stomp()
  127. {
  128. var prey = getPrey("suburb", 1.5*scale*scale);
  129. var line = prey.stomp(verbose)
  130. var linesummary = summarize(prey.sum(), true);
  131. var people = prey.sum()["Person"];
  132. var sound = "Thump";
  133. if (people < 3) {
  134. sound = "Thump!";
  135. } else if (people < 10) {
  136. sound = "Squish!";
  137. } else if (people < 50) {
  138. sound = "Crunch!";
  139. } else if (people < 500) {
  140. sound = "CRUNCH!";
  141. } else if (people < 5000) {
  142. sound = "CRRUUUNCH!!";
  143. } else {
  144. sound = "Oh the humanity!";
  145. }
  146. var preyMass = prey.sum_property("mass");
  147. scale = scaleAddMass(scale, baseMass, preyMass);
  148. updateVictims("stomped",prey);
  149. update([sound,line,linesummary,newline]);
  150. }
  151. function anal_vore()
  152. {
  153. var prey = getOnePrey(0.25*scale*scale);
  154. var crushed = getPrey("suburb",3*scale*scale);
  155. var line1 = prey.anal_vore(verbose, baseHeight*scale);
  156. var line1summary = summarize(prey.sum(), false);
  157. var line2 = crushed.buttcrush(verbose);
  158. var line2summary = summarize(crushed.sum(), true);
  159. var people = prey.sum()["Person"];
  160. var sound = "Shlp";
  161. if (people < 3) {
  162. sound = "Shlp.";
  163. } else if (people < 10) {
  164. sound = "Squelch.";
  165. } else if (people < 50) {
  166. sound = "Shlurrp.";
  167. } else if (people < 500) {
  168. sound = "SHLRP!";
  169. } else if (people < 5000) {
  170. sound = "SQLCH!!";
  171. } else {
  172. sound = "Oh the humanity!";
  173. }
  174. people = crushed.sum()["Person"];
  175. var sound2 = "Thump";
  176. if (people < 3) {
  177. sound2 = "Thump!";
  178. } else if (people < 10) {
  179. sound2 = "Squish!";
  180. } else if (people < 50) {
  181. sound2 = "Crunch!";
  182. } else if (people < 500) {
  183. sound2 = "CRUNCH!";
  184. } else if (people < 5000) {
  185. sound2 = "CRRUUUNCH!!";
  186. } else {
  187. sound2 = "Oh the humanity!";
  188. }
  189. var preyMass = prey.sum_property("mass");
  190. var crushedMass = prey.sum_property("mass");
  191. scale = scaleAddMass(scale, baseMass, preyMass);
  192. scale = scaleAddMass(scale, baseMass, crushedMass);
  193. bowels.push(prey);
  194. if (bowels.length == 1)
  195. setTimeout(function() { doDigest("bowels"); }, 15000);
  196. updateVictims("bowels",prey);
  197. updateVictims("stomped",crushed);
  198. update([sound,line1,line1summary,newline,sound2,line2,line2summary,newline]);
  199. }
  200. function update(lines = [])
  201. {
  202. var log = document.getElementById("log");
  203. lines.forEach(function (x) {
  204. var line = document.createElement('div');
  205. line.innerHTML = x;
  206. log.appendChild(line);
  207. });
  208. log.scrollTop = log.scrollHeight;
  209. var height = baseHeight * scale;
  210. var mass = baseMass * Math.pow(scale, 3);
  211. document.getElementById("height").innerHTML = "Height: " + (metric ? metricLength(height) : customaryLength(height));
  212. document.getElementById("mass").innerHTML = "Mass: " + (metric ? metricMass(mass) : customaryMass(mass));
  213. for (var type in victims) {
  214. if (victims.hasOwnProperty(type)) {
  215. for (var key in victims[type]){
  216. if (victims[type].hasOwnProperty(key)) {
  217. if (document.getElementById("stats-" + type + "-" + key) == null) {
  218. if (victims[type][key] == 0)
  219. continue;
  220. child = document.createElement('div');
  221. child.id = "stats-" + type + "-" + key;
  222. child.classList.add("stat-line");
  223. document.getElementById("stats-" + type).appendChild(child);
  224. }
  225. document.getElementById("stats-" + type + "-" + key).innerHTML = key + ": " + victims[type][key];
  226. }
  227. }
  228. }
  229. }
  230. }
  231. function pick_move()
  232. {
  233. if (!strolling) {
  234. setTimeout(pick_move, 1500 * Math.sqrt(scale));
  235. return;
  236. }
  237. var choice = Math.random();
  238. if (choice < 0.2) {
  239. anal_vore();
  240. } else if (choice < 0.6) {
  241. stomp();
  242. } else {
  243. feed();
  244. }
  245. setTimeout(pick_move, 1500 * Math.sqrt(scale));
  246. }
  247. function grow()
  248. {
  249. scale *= 1.2;
  250. update();
  251. }
  252. // pop the list and digest that object
  253. function doDigest(containerName)
  254. {
  255. var digestType = containerName == "stomach" ? stomach : bowels;
  256. var count = 0
  257. if (containerName == "stomach") {
  258. count = stomach.length;
  259. count = Math.min(count,maxStomachDigest);
  260. } else if (containerName == "bowels") {
  261. count = bowels.length;
  262. count = Math.min(count,maxBowelsDigest);
  263. }
  264. var container = new Container();
  265. while (count > 0) {
  266. --count;
  267. var toDigest = digestType.shift();
  268. if (toDigest.name != "Container")
  269. toDigest = new Container([toDigest]);
  270. container = container.merge(toDigest);
  271. }
  272. var digested = container.sum();
  273. for (var key in victims[containerName]) {
  274. if (victims[containerName].hasOwnProperty(key) && digested.hasOwnProperty(key) ) {
  275. victims["digested"][key] += digested[key];
  276. victims[containerName][key] -= digested[key];
  277. }
  278. }
  279. if (containerName == "stomach")
  280. update(["Your stomach gurgles as it digests " + container.describe(false),summarize(container.sum()),newline]);
  281. else if (containerName == "bowels")
  282. update(["Your bowels churn as they absorb " + container.describe(false),summarize(container.sum()),newline]);
  283. if (digestType.length > 0) {
  284. setTimeout(function() {
  285. doDigest(containerName);
  286. }, 15000);
  287. }
  288. }
  289. window.addEventListener('load', function(event) {
  290. victims["stomped"] = initVictims();
  291. victims["digested"] = initVictims();
  292. victims["stomach"] = initVictims();
  293. victims["bowels"] = initVictims();
  294. document.getElementById("button-grow").addEventListener("click",grow);
  295. document.getElementById("button-feed").addEventListener("click",feed);
  296. document.getElementById("button-stomp").addEventListener("click",stomp);
  297. document.getElementById("button-anal_vore").addEventListener("click",anal_vore);
  298. document.getElementById("button-stroll").addEventListener("click",toggle_auto);
  299. document.getElementById("button-units").addEventListener("click",toggle_units);
  300. document.getElementById("button-verbose").addEventListener("click",toggle_verbose);
  301. setTimeout(pick_move, 2000);
  302. update();
  303. });