big steppy
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 

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