big steppy
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 

488 строки
12 KiB

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