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

1086 строки
28 KiB

  1. 'use strict';
  2. var things =
  3. {
  4. "Container": Container,
  5. "Person": Person,
  6. "Cow": Cow,
  7. "Empty Car": EmptyCar,
  8. "Car": Car,
  9. "Bus": Bus,
  10. "Tram": Tram,
  11. "House": House,
  12. "Barn": Barn,
  13. "Small Skyscraper": SmallSkyscraper,
  14. "Large Skyscraper": LargeSkyscraper,
  15. "Train": Train,
  16. "Train Car": TrainCar,
  17. "Parking Garage": ParkingGarage,
  18. "Town": Town,
  19. "City": City,
  20. "Continent": Continent,
  21. "Planet": Planet,
  22. "Star": Star,
  23. "Solar System": SolarSystem,
  24. "Galaxy": Galaxy,
  25. "Soldier": Soldier,
  26. "Tank": Tank,
  27. "Artillery": Artillery,
  28. "Helicopter": Helicopter,
  29. "Micro": Micro,
  30. "Macro": Macro,
  31. };
  32. var areas =
  33. {
  34. "Container": 0,
  35. "Person": 1,
  36. "Cow": 2,
  37. "Car": 4,
  38. "Bus": 12,
  39. "Tram": 20,
  40. "House": 150,
  41. "Barn": 300,
  42. "Small Skyscraper": 1000,
  43. "Large Skyscraper": 2000,
  44. "Train": 40,
  45. "TrainCar": 20,
  46. "Parking Garage": 750,
  47. "Town": 1e7,
  48. "City": 1e9,
  49. "Continent": 1.5e13,
  50. "Planet": 2.5e14,
  51. "Star": 3e18,
  52. "Solar System": 3e21,
  53. "Galaxy": 2e42,
  54. "Soldier": 1,
  55. "Tank": 10,
  56. "Artillery": 12,
  57. "Helicopter": 8,
  58. "Micro": 0.05,
  59. "Macro": 100,
  60. };
  61. var masses =
  62. {
  63. "Container": 0,
  64. "Person": 80,
  65. "Cow": 300,
  66. "Car": 1000,
  67. "Bus": 5000,
  68. "Tram": 10000,
  69. "House": 10000,
  70. "Barn": 5000,
  71. "Small Skyscraper": 10000000,
  72. "Large Skyscraper": 80000000,
  73. "Train": 50000,
  74. "Train Car": 7500,
  75. "Parking Garage": 10000000,
  76. "Town": 1,
  77. "City": 1,
  78. "Continent": 1e21,
  79. "Planet": 5.972e24,
  80. "Star": 1e40,
  81. "Solar System": 1,
  82. "Galaxy": 1,
  83. "Soldier": 80,
  84. "Tank": 5000,
  85. "Artillery": 7000,
  86. "Helicopter": 1500,
  87. "Micro": 0.01,
  88. "Macro": 80000,
  89. };
  90. var clusters =
  91. {
  92. "Container": 0,
  93. "Person": 5,
  94. "Cow": 15,
  95. "Car": 3,
  96. "Bus": 1,
  97. "Tram": 1,
  98. "House": 5,
  99. "Barn": 1,
  100. "Small Skyscraper": 2,
  101. "Large Skyscraper": 1,
  102. "Train": 2,
  103. "Train Car": 1,
  104. "Parking Garage": 1,
  105. "Town": 1,
  106. "City": 1,
  107. "Continent": 5,
  108. "Planet": 1,
  109. "Star": 1,
  110. "Solar System": 1,
  111. "Galaxy": 1,
  112. "Soldier": 0,
  113. "Tank": 0,
  114. "Artillery": 0,
  115. "Helicopter": 0,
  116. "Micro": 10,
  117. "Macro": 0,
  118. };
  119. // general logic: each step fills in a fraction of the remaining space
  120. function fill_area(area, weights, variance=0.15)
  121. {
  122. area = area + Math.random() * variance * 2 - variance;
  123. var result = [];
  124. var candidates = [];
  125. for (var key in weights) {
  126. if (weights.hasOwnProperty(key)) {
  127. candidates.push({"name": key, "area": areas[key], "weight": weights[key]});
  128. }
  129. }
  130. candidates = candidates.sort(function (x,y) {
  131. return x.area - y.area;
  132. });
  133. while(candidates.length > 0) {
  134. var candidate = candidates.pop();
  135. if (candidate.area > area)
  136. continue;
  137. var max = Math.floor(area / candidate.area);
  138. var limit = Math.min(max, 100);
  139. var count = 0;
  140. var loopvar = limit;
  141. // for small amounts, actually do the randomness
  142. // the first few ones get a much better shot
  143. while (loopvar > 0) {
  144. if (loopvar <= clusters[candidate.name])
  145. count += 1;
  146. else
  147. count += Math.random() < candidate.weight ? 1 : 0;
  148. --loopvar;
  149. }
  150. if (limit < max) {
  151. count += Math.round((max-limit) * candidate.weight);
  152. }
  153. area -= count * candidate.area;
  154. if (count > 0)
  155. result.push(new things[candidate.name](count));
  156. }
  157. return new Container(result);
  158. }
  159. // describes everything in the container
  160. function describe_all(contents,verbose=true,except=[]) {
  161. var things = [];
  162. for (var key in contents) {
  163. if (contents.hasOwnProperty(key) && !except.includes(key)) {
  164. things.push(contents[key].describe(verbose));
  165. }
  166. }
  167. return merge_things(things);
  168. }
  169. function random_desc(list, odds=1) {
  170. if (Math.random() < odds)
  171. return list[Math.floor(Math.random() * list.length)];
  172. else
  173. return "";
  174. }
  175. // combine strings into a list with proper grammar
  176. function merge_things(list,semicolons=false) {
  177. if (list.length == 0) {
  178. return "";
  179. } else if (list.length == 1) {
  180. return list[0];
  181. } else if (list.length == 2) {
  182. return list[0] + " and " + list[1];
  183. } else {
  184. var result = "";
  185. list.slice(0,list.length-1).forEach(function(term) {
  186. result += term + ", ";
  187. });
  188. result += "and " + list[list.length-1];
  189. return result;
  190. }
  191. }
  192. // combine the adjectives for something into a single string
  193. function merge_desc(list) {
  194. var result = "";
  195. list.forEach(function(term) {
  196. if (term != "")
  197. result += term + " ";
  198. });
  199. // knock off the last space
  200. if (result.length > 0) {
  201. result = result.substring(0, result.length - 1);
  202. }
  203. return result;
  204. }
  205. // maybe make this something that approximates a
  206. // normal distribution; doing this 15,000,000 times is bad...
  207. // solution: only a few are random lul
  208. // improvement: take up to 100 samples, then use that to scale the final result
  209. function distribution(min, max, samples) {
  210. var result = 0;
  211. var limit = Math.min(100,samples);
  212. if (limit < samples) {
  213. let dist = 0;
  214. for (let i = 0; i < limit; i++) {
  215. dist += Math.random();
  216. }
  217. dist /= 100;
  218. return Math.floor(dist * samples * (max - min + 1) + samples * min);
  219. } else {
  220. for (let i = 0; i < limit; i++) {
  221. result += Math.floor(Math.random() * (max - min + 1) + min);
  222. }
  223. }
  224. return result;
  225. }
  226. function defaultArea(thing) {
  227. return areas[thing.name];
  228. }
  229. function defaultMass(thing) {
  230. return masses[thing.name];
  231. }
  232. function defaultMerge(thing) {
  233. return function(container) {
  234. var newCount = this.count + container.count;
  235. var newThing = new things[thing.name](newCount);
  236. newThing.contents = {};
  237. for (var key in this.contents) {
  238. if (this.contents.hasOwnProperty(key)) {
  239. newThing.contents[key] = this.contents[key];
  240. }
  241. }
  242. for (key in container.contents) {
  243. if (container.contents.hasOwnProperty(key)) {
  244. if (this.contents.hasOwnProperty(key)) {
  245. newThing.contents[key] = this.contents[key].merge(container.contents[key]);
  246. } else {
  247. newThing.contents[key] = container.contents[key];
  248. }
  249. }
  250. }
  251. return newThing;
  252. };
  253. }
  254. function defaultSum(thing) {
  255. return function() {
  256. var counts = {};
  257. if (thing.name != "Container")
  258. counts[thing.name] = thing.count;
  259. for (var key in thing.contents) {
  260. if (thing.contents.hasOwnProperty(key)) {
  261. var subcount = thing.contents[key].sum();
  262. for (var subkey in subcount) {
  263. if (!counts.hasOwnProperty(subkey)) {
  264. counts[subkey] = 0;
  265. }
  266. counts[subkey] += subcount[subkey];
  267. }
  268. }
  269. }
  270. return counts;
  271. };
  272. }
  273. function defaultSumProperty(thing) {
  274. return function(prop) {
  275. var total = 0;
  276. total += thing[prop] * thing.count;
  277. for (var key in thing.contents) {
  278. if (thing.contents.hasOwnProperty(key)) {
  279. total += thing.contents[key].sum_property(prop);
  280. }
  281. }
  282. return total;
  283. };
  284. }
  285. function defaultAddContent(thing) {
  286. return function(name, min, max, count) {
  287. if (min == max) {
  288. let object = new things[name](min*count);
  289. thing.contents[object.name] = object;
  290. } else {
  291. let object = new things[name](distribution(min, max, count));
  292. thing.contents[object.name] = object;
  293. }
  294. };
  295. }
  296. function DefaultEntity() {
  297. this.sum = defaultSum;
  298. this.area = defaultArea;
  299. this.mass = defaultMass;
  300. this.sum_property = defaultSumProperty;
  301. this.merge = defaultMerge;
  302. this.addContent = defaultAddContent;
  303. return this;
  304. }
  305. // god I love reinventing the wheel
  306. function copy_defaults(self,proto) {
  307. for (var key in proto) {
  308. if (proto.hasOwnProperty(key)) {
  309. self[key] = proto[key](self);
  310. }
  311. }
  312. }
  313. function Container(contents = []) {
  314. this.name = "Container";
  315. copy_defaults(this,new DefaultEntity());
  316. if (Number.isInteger(contents))
  317. this.count = contents;
  318. else
  319. this.count = 0;
  320. this.contents = {};
  321. for (var i=0; i < contents.length; i++) {
  322. this.contents[contents[i].name] = contents[i];
  323. }
  324. for (var key in this.contents) {
  325. if (this.contents.hasOwnProperty(key)) {
  326. this.count += this.contents[key].count;
  327. }
  328. }
  329. this.describe = function(verbose = true) {
  330. return describe_all(this.contents,verbose);
  331. };
  332. return this;
  333. }
  334. function Person(count = 1) {
  335. this.name = "Person";
  336. copy_defaults(this,new DefaultEntity());
  337. this.count = count;
  338. this.contents = {};
  339. this.describeOne = function (verbose=true) {
  340. var body = random_desc(["skinny","fat","tall","short","stocky","spindly"], (verbose ? 0.6 : 0));
  341. var sex = random_desc(["male", "female"], (verbose ? 1 : 0));
  342. var species = "";
  343. species = random_desc(["wolf","cat","dog","squirrel","horse","hyena","fox","jackal","crux","sergal"]);
  344. return "a " + merge_desc([body,sex,species]);
  345. };
  346. this.describe = function(verbose=true) {
  347. if (verbose) {
  348. if (count <= 3) {
  349. var list = [];
  350. for (var i = 0; i < count; i++) {
  351. list.push(this.describeOne(this.count <= 2));
  352. }
  353. return merge_things(list);
  354. } else {
  355. return this.count + " people";
  356. }
  357. } else {
  358. return (this.count > 1 ? this.count + " people" : "a person");
  359. }
  360. };
  361. return this;
  362. }
  363. function Cow(count = 1) {
  364. this.name = "Cow";
  365. copy_defaults(this,new DefaultEntity());
  366. this.count = count;
  367. this.contents = {};
  368. this.describeOne = function (verbose=true) {
  369. var body = random_desc(["skinny","fat","tall","short","stocky","spindly"], (verbose ? 0.6 : 0));
  370. var sex = random_desc(["male", "female"], (verbose ? 1 : 0));
  371. return "a " + merge_desc([body,sex,"cow"]);
  372. };
  373. this.describe = function(verbose=true) {
  374. if (verbose) {
  375. if (count <= 3) {
  376. var list = [];
  377. for (var i = 0; i < count; i++) {
  378. list.push(this.describeOne(this.count <= 2));
  379. }
  380. return merge_things(list);
  381. } else {
  382. return this.count + " cattle";
  383. }
  384. } else {
  385. return (this.count > 1 ? this.count + " cattle" : "a cow");
  386. }
  387. };
  388. return this;
  389. }
  390. function EmptyCar(count = 1) {
  391. this.name = "Car";
  392. copy_defaults(this,new DefaultEntity());
  393. this.count = count;
  394. this.contents = {};
  395. this.describeOne = function(verbose=true) {
  396. var color = random_desc(["black","black","gray","gray","blue","red","tan","white","white"]);
  397. var adjective = random_desc(["rusty","brand-new"],0.3);
  398. var type = random_desc(["SUV","coupe","sedan","truck","van","convertible"]);
  399. return "a parked " + merge_desc([adjective,color,type]);
  400. };
  401. this.describe = function(verbose = true) {
  402. if (verbose) {
  403. if (this.count <= 3) {
  404. var list = [];
  405. for (var i = 0; i < this.count; i++) {
  406. list.push(this.describeOne());
  407. }
  408. return merge_things(list);
  409. } else {
  410. return this.count + " parked cars";
  411. }
  412. } else {
  413. return (this.count > 1 ? this.count + " parked cars" : "a parked car");
  414. }
  415. };
  416. }
  417. function Car(count = 1) {
  418. this.name = "Car";
  419. copy_defaults(this,new DefaultEntity());
  420. this.count = count;
  421. this.contents = {};
  422. this.addContent("Person", 1, 4, count);
  423. this.describeOne = function(verbose=true) {
  424. var color = random_desc(["black","black","gray","gray","blue","red","tan","white","white"], (verbose ? 1 : 0));
  425. var adjective = random_desc(["rusty","brand-new"], (verbose ? 0.3 : 0));
  426. var type = random_desc(["SUV","coupe","sedan","truck","van","convertible"]);
  427. return "a " + merge_desc([adjective,color,type]);
  428. };
  429. this.describe = function(verbose = true) {
  430. if (verbose) {
  431. if (this.count <= 3) {
  432. var list = [];
  433. for (var i = 0; i < this.count; i++) {
  434. list.push(this.describeOne(this.count < 2));
  435. }
  436. return merge_things(list) + " with " + describe_all(this.contents,verbose) + " inside";
  437. } else {
  438. return this.count + " cars with " + describe_all(this.contents,verbose) + " inside";
  439. }
  440. } else {
  441. return (this.count > 1 ? this.count + " cars" : "a car");
  442. }
  443. };
  444. }
  445. function Bus(count = 1) {
  446. this.name = "Bus";
  447. copy_defaults(this,new DefaultEntity());
  448. this.count = count;
  449. this.contents = {};
  450. this.addContent("Person",2,30,count);
  451. this.describeOne = function(verbose=true) {
  452. var adjective = random_desc(["rusty","brand-new"], (verbose ? 0.3 : 0));
  453. var color = random_desc(["black","tan","gray"], (verbose ? 1 : 0));
  454. var type = random_desc(["bus","double-decker bus","articulating bus"]);
  455. return "a " + merge_desc([adjective,color,type]);
  456. };
  457. this.describe = function(verbose = true) {
  458. if (verbose) {
  459. if (this.count <= 3) {
  460. var list = [];
  461. for (var i = 0; i < this.count; i++) {
  462. list.push(this.describeOne(this.count < 2));
  463. }
  464. return merge_things(list) + " with " + describe_all(this.contents,verbose) + " inside";
  465. } else {
  466. return this.count + " buses with " + describe_all(this.contents,verbose) + " inside";
  467. }
  468. } else {
  469. return (this.count > 1 ? this.count + " buses" : "a bus");
  470. }
  471. };
  472. }
  473. function Tram(count = 1) {
  474. this.name = "Tram";
  475. copy_defaults(this,new DefaultEntity());
  476. this.count = count;
  477. this.contents = {};
  478. this.addContent("Person",10,50,count);
  479. this.describeOne = function(verbose=true) {
  480. var adjective = random_desc(["rusty","weathered"], (verbose ? 0.3 : 0));
  481. var color = random_desc(["blue","brown","gray"], (verbose ? 1 : 0));
  482. var type = random_desc(["tram"]);
  483. return "a " + merge_desc([adjective,color,type]);
  484. };
  485. this.describe = function(verbose = true) {
  486. if (verbose) {
  487. if (this.count == 1) {
  488. var list = [];
  489. for (var i = 0; i < this.count; i++) {
  490. list.push(this.describeOne(verbose));
  491. }
  492. return merge_things(list) + " with " + describe_all(this.contents,verbose) + " inside";
  493. } else {
  494. return this.count + " trams with " + describe_all(this.contents,verbose) + " inside";
  495. }
  496. } else {
  497. return (this.count > 1 ? this.count + " trams" : "a tram");
  498. }
  499. };
  500. this.anal_vore = function() {
  501. return "You slide " + this.describe() + " up your tight ass";
  502. };
  503. }
  504. function Train(count = 1) {
  505. this.name = "Train";
  506. copy_defaults(this,new DefaultEntity());
  507. this.count = count;
  508. this.contents = {};
  509. this.addContent("Person", 1, 4, count);
  510. this.addContent("Train Car", 2, 10, count);
  511. this.describeOne = function(verbose=true) {
  512. var adjective = random_desc(["rusty","brand-new"], (verbose ? 0.3 : 0));
  513. var color = random_desc(["black","tan","gray"], (verbose ? 1 : 0));
  514. var type = random_desc(["train","passenger train","freight train"]);
  515. return "a " + merge_desc([adjective,color,type]);
  516. };
  517. this.describe = function(verbose = true) {
  518. if (verbose) {
  519. if (this.count == 1) {
  520. var list = [];
  521. for (var i = 0; i < this.count; i++) {
  522. list.push(this.describeOne(verbose));
  523. }
  524. return merge_things(list) + " with " + this.contents["Person"].describe(false) + " in the engine and " + this.contents["Train Car"].describe() + " attached";
  525. } else {
  526. return this.count + " trains with " + this.contents["Person"].describe(false) + " in the engine and " + this.contents["Train Car"].describe() + " attached";
  527. }
  528. } else {
  529. return (this.count > 1 ? this.count + " trains" : "a train");
  530. }
  531. };
  532. this.anal_vore = function() {
  533. var cars = (this.contents["Train Car"].count == 1 ? this.contents["Train Car"].describe() + " follows it inside" : this.contents["Train Car"].describe() + " are pulled slowly inside");
  534. return "You snatch up " + this.describeOne() + " and stuff it into your pucker, moaning as " + cars;
  535. };
  536. }
  537. function TrainCar(count = 1) {
  538. this.name = "Train Car";
  539. copy_defaults(this,new DefaultEntity());
  540. this.count = count;
  541. this.contents = {};
  542. this.addContent("Person",10,40,count);
  543. this.describeOne = function(verbose=true) {
  544. var adjective = random_desc(["rusty","brand-new"], (verbose ? 0.3 : 0));
  545. var color = random_desc(["black","tan","gray"], (verbose ? 1 : 0));
  546. var type = random_desc(["train car","passenger train car","freight train car"]);
  547. return "a " + merge_desc([adjective,color,type]);
  548. };
  549. this.describe = function(verbose = true) {
  550. if (verbose) {
  551. return (this.count > 1 ? this.count + " train cars" : "a train car") + " with " + describe_all(this.contents) + " inside";
  552. } else {
  553. return (this.count > 1 ? this.count + " train cars" : "a train car");
  554. }
  555. };
  556. }
  557. function House(count = 1) {
  558. this.name = "House";
  559. copy_defaults(this,new DefaultEntity());
  560. this.count = count;
  561. this.contents = {};
  562. this.addContent("Person",0,8,count);
  563. this.addContent("Empty Car",0,2,count);
  564. this.describeOne = function(verbose=true) {
  565. var size = random_desc(["little","two-story","large"], (verbose ? 0.5 : 0));
  566. var color = random_desc(["blue","white","gray","tan","green"], (verbose ? 0.5 : 0));
  567. var name = random_desc(["house","house","house","house","house","trailer"], 1);
  568. return "a " + merge_desc([size,color,name]);
  569. };
  570. this.describe = function(verbose = true) {
  571. if (verbose) {
  572. if (this.count <= 3) {
  573. var list = [];
  574. for (var i = 0; i < this.count; i++) {
  575. list.push(this.describeOne(this.count < 2));
  576. }
  577. return merge_things(list) + " with " + describe_all(this.contents,verbose) + " inside";
  578. } else {
  579. return this.count + " homes with " + describe_all(this.contents,verbose) + " inside";
  580. }
  581. } else {
  582. return (this.count > 1 ? this.count + " houses" : "a house");
  583. }
  584. };
  585. }
  586. function Barn(count = 1) {
  587. this.name = "Barn";
  588. copy_defaults(this,new DefaultEntity());
  589. this.count = count;
  590. this.contents = {};
  591. this.addContent("Person",0,2,count);
  592. this.addContent("Cow",30,70,count);
  593. this.describeOne = function(verbose=true) {
  594. var size = random_desc(["little","big","large"], (verbose ? 0.5 : 0));
  595. var color = random_desc(["blue","white","gray","tan","green"], (verbose ? 0.5 : 0));
  596. var name = random_desc(["barn","barn","barn","barn","barn","farmhouse"], 1);
  597. return "a " + merge_desc([size,color,name]);
  598. };
  599. this.describe = function(verbose = true) {
  600. if (verbose) {
  601. if (this.count <= 3) {
  602. var list = [];
  603. for (var i = 0; i < this.count; i++) {
  604. list.push(this.describeOne(this.count < 2));
  605. }
  606. return merge_things(list) + " with " + describe_all(this.contents,verbose) + " inside";
  607. } else {
  608. return this.count + " barns with " + describe_all(this.contents,verbose) + " inside";
  609. }
  610. } else {
  611. return (this.count > 1 ? this.count + " barns" : "a barn");
  612. }
  613. };
  614. }
  615. function SmallSkyscraper(count = 1) {
  616. this.name = "Small Skyscraper";
  617. copy_defaults(this,new DefaultEntity());
  618. this.count = count;
  619. this.contents = {};
  620. this.addContent("Person",150,750,count);
  621. this.addContent("Empty Car",10,50,count);
  622. this.describeOne = function(verbose=true) {
  623. var color = random_desc(["blue","white","gray","tan","green"], (verbose ? 0.5 : 0));
  624. var name = random_desc(["skyscraper","office tower","office building"], 1);
  625. return "a " + merge_desc([color,name]);
  626. };
  627. this.describe = function(verbose = true) {
  628. if (verbose) {
  629. if (this.count <= 3) {
  630. var list = [];
  631. for (var i = 0; i < this.count; i++) {
  632. list.push(this.describeOne(this.count < 2));
  633. }
  634. return merge_things(list) + " with " + describe_all(this.contents,verbose) + " inside";
  635. } else {
  636. return this.count + " small skyscrapers with " + describe_all(this.contents,verbose) + " inside";
  637. }
  638. } else {
  639. return (this.count > 1 ? this.count + " small skyscrapers" : "a small skyscraper");
  640. }
  641. };
  642. }
  643. function LargeSkyscraper(count = 1) {
  644. this.name = "Large Skyscraper";
  645. copy_defaults(this,new DefaultEntity());
  646. this.count = count;
  647. this.contents = {};
  648. this.addContent("Person",500,1500,count);
  649. this.addContent("Empty Car",20,100,count);
  650. this.describeOne = function(verbose=true) {
  651. var color = random_desc(["blue","white","gray","tan","green"], (verbose ? 0.5 : 0));
  652. var name = random_desc(["skyscraper","office tower","office building"], 1);
  653. return "a " + merge_desc(["towering",color,name]);
  654. };
  655. this.describe = function(verbose = true) {
  656. if (verbose) {
  657. if (this.count <= 3) {
  658. var list = [];
  659. for (var i = 0; i < this.count; i++) {
  660. list.push(this.describeOne(this.count < 2));
  661. }
  662. return merge_things(list) + " with " + describe_all(this.contents,verbose) + " inside";
  663. } else {
  664. return this.count + " large skyscrapers with " + describe_all(this.contents,verbose) + " inside";
  665. }
  666. } else {
  667. return (this.count > 1 ? this.count + " large skyscrapers" : "a large skyscraper");
  668. }
  669. };
  670. }
  671. function ParkingGarage(count = 1) {
  672. this.name = "Parking Garage";
  673. copy_defaults(this,new DefaultEntity());
  674. this.count = count;
  675. this.contents = {};
  676. this.addContent("Person",10,200,count);
  677. this.addContent("Empty Car",100,300,count);
  678. this.addContent("Car",5,30,count);
  679. this.describeOne = function(verbose=true) {
  680. return "a parking garage";
  681. };
  682. this.describe = function(verbose = true) {
  683. if (verbose) {
  684. return (this.count == 1 ? "a parking garage" : this.count + " parking garages") + " with " + describe_all(this.contents, verbose) + " inside";
  685. } else {
  686. return (this.count == 1 ? "a parking garage" : this.count + " parking garages");
  687. }
  688. };
  689. }
  690. function Town(count = 1) {
  691. this.name = "Town";
  692. copy_defaults(this,new DefaultEntity());
  693. this.count = count;
  694. this.contents = {};
  695. this.addContent("Person",10000,100000,count);
  696. this.addContent("House",5000,50000,count);
  697. this.addContent("Empty Car",200,800,count);
  698. this.addContent("Car",500,80000,count);
  699. this.addContent("Bus",5,25,count);
  700. this.addContent("Train",5,25,count);
  701. this.describe = function(verbose = true) {
  702. if (verbose) {
  703. return (this.count == 1 ? "a town" : this.count + " towns") + " with " + describe_all(this.contents, verbose) + " in " + (this.count == 1 ? "it" : "them");
  704. } else {
  705. return (this.count == 1 ? "a town" : this.count + " towns");
  706. }
  707. };
  708. }
  709. function City(count = 1) {
  710. this.name = "City";
  711. copy_defaults(this,new DefaultEntity());
  712. this.count = count;
  713. this.contents = {};
  714. this.addContent("Person",100000,1500000,count);
  715. this.addContent("House",20000,200000,count);
  716. this.addContent("Empty Car",10000,100000,count);
  717. this.addContent("Car",7500,125000,count);
  718. this.addContent("Bus",200,400,count);
  719. this.addContent("Train",10,50,count);
  720. this.addContent("Tram",25,100,count);
  721. this.addContent("Small Skyscraper",50,300,count);
  722. this.addContent("Large Skyscraper",10,75,count);
  723. this.addContent("Parking Garage",5,10,count);
  724. this.describe = function(verbose = true) {
  725. if (verbose) {
  726. return (this.count == 1 ? "a city" : this.count + " cities") + " with " + describe_all(this.contents, verbose) + " in " + (this.count == 1 ? "it" : "them");
  727. } else {
  728. return (this.count == 1 ? "a city" : this.count + " cities");
  729. }
  730. };
  731. }
  732. function Continent(count = 1) {
  733. this.name = "Continent";
  734. copy_defaults(this,new DefaultEntity());
  735. this.count = count;
  736. this.contents = {};
  737. this.addContent("Person",1000000,15000000,count);
  738. this.addContent("House",2500,10000,count);
  739. this.addContent("Car",25000,375000,count);
  740. this.addContent("Train",50,500,count);
  741. this.addContent("Town",500,1000,count);
  742. this.addContent("City",50,250,count);
  743. this.describe = function(verbose = true) {
  744. if (verbose) {
  745. return (this.count == 1 ? "a continent" : this.count + " continents") + " with " + describe_all(this.contents, verbose) + " on " + (this.count == 1 ? "it" : "them");
  746. } else {
  747. return (this.count == 1 ? "a continent" : this.count + " continents");
  748. }
  749. };
  750. }
  751. function Planet(count = 1) {
  752. this.name = "Planet";
  753. copy_defaults(this,new DefaultEntity());
  754. this.count = count;
  755. this.contents = {};
  756. this.addContent("Continent",4,9,count);
  757. this.describe = function(verbose = true) {
  758. if (verbose) {
  759. return (this.count == 1 ? "a planet" : this.count + " planets") + " with " + describe_all(this.contents, verbose) + " on " + (this.count == 1 ? "it" : "them");
  760. } else {
  761. return (this.count == 1 ? "a planet" : this.count + " planets");
  762. }
  763. };
  764. }
  765. function Star(count = 1) {
  766. this.name = "Star";
  767. copy_defaults(this,new DefaultEntity());
  768. this.count = count;
  769. this.contents = {};
  770. this.describe = function(verbose = true) {
  771. return (this.count == 1 ? "a star" : this.count + " stars");
  772. };
  773. }
  774. function SolarSystem(count = 1) {
  775. this.name = "Solar System";
  776. copy_defaults(this,new DefaultEntity());
  777. this.count = count;
  778. this.contents = {};
  779. this.addContent("Star",1,1,count);
  780. this.addContent("Planet",5,15,count);
  781. this.describe = function(verbose = true) {
  782. if (verbose) {
  783. return (this.count == 1 ? "a solar system" : this.count + " solar systems") + " made up of " + describe_all(this.contents, verbose);
  784. } else {
  785. return (this.count == 1 ? "a solar system" : this.count + " solar systems");
  786. }
  787. };
  788. }
  789. function Galaxy(count = 1) {
  790. this.name = "Galaxy";
  791. copy_defaults(this,new DefaultEntity());
  792. this.count = count;
  793. this.contents = {};
  794. this.addContent("Star",1e9,500e9,count);
  795. this.addContent("Solar System",1e8,500e8,count);
  796. this.describe = function(verbose = true) {
  797. if (verbose) {
  798. return (this.count == 1 ? "a galaxy" : this.count + " galaxies") + " made up of " + describe_all(this.contents, verbose);
  799. } else {
  800. return (this.count == 1 ? "a galaxy" : this.count + " galaxies");
  801. }
  802. };
  803. }
  804. function Soldier(count = 1) {
  805. this.name = "Soldier";
  806. copy_defaults(this,new DefaultEntity());
  807. this.count = count;
  808. this.contents = {};
  809. this.describe = function(verbose = true) {
  810. return (this.count == 1 ? "a soldier" : this.count + " soldiers");
  811. };
  812. }
  813. function Tank(count = 1) {
  814. this.name = "Tank";
  815. copy_defaults(this,new DefaultEntity());
  816. this.count = count;
  817. this.contents = {};
  818. this.addContent("Soldier",3,5,count);
  819. this.describe = function(verbose = true) {
  820. if (verbose) {
  821. return (this.count == 1 ? "a tank" : this.count + " tanks") + " with " + describe_all(this.contents, verbose) + " trapped inside.";
  822. } else {
  823. return (this.count == 1 ? "a tank" : this.count + " tanks");
  824. }
  825. };
  826. }
  827. function Artillery(count = 1) {
  828. this.name = "Artillery";
  829. copy_defaults(this,new DefaultEntity());
  830. this.count = count;
  831. this.contents = {};
  832. this.addContent("Soldier",4,6,count);
  833. this.describe = function(verbose = true) {
  834. if (verbose) {
  835. return (this.count == 1 ? "an artillery unit" : this.count + " artillery units") + " with " + describe_all(this.contents, verbose) + " trapped inside.";
  836. } else {
  837. return (this.count == 1 ? "an artillery unit" : this.count + " artillery units");
  838. }
  839. };
  840. }
  841. function Helicopter(count = 1) {
  842. this.name = "Helicopter";
  843. copy_defaults(this,new DefaultEntity());
  844. this.count = count;
  845. this.contents = {};
  846. this.addContent("Soldier",4,16,count);
  847. this.describe = function(verbose = true) {
  848. if (verbose) {
  849. return (this.count == 1 ? "a helicopter" : this.count + " helicopters") + " with " + describe_all(this.contents, verbose) + " riding inside.";
  850. } else {
  851. return (this.count == 1 ? "a helicopter" : this.count + " helicopters");
  852. }
  853. };
  854. }
  855. function Micro(count = 1) {
  856. this.name = "Micro";
  857. copy_defaults(this,new DefaultEntity());
  858. this.count = count;
  859. this.contents = {};
  860. this.describe = function(verbose = true) {
  861. return (this.count == 1 ? "a micro" : this.count + " micros");
  862. };
  863. }
  864. function Macro(count = 1) {
  865. this.name = "Macro";
  866. copy_defaults(this,new DefaultEntity());
  867. this.count = count;
  868. this.contents = {};
  869. this.describe = function(verbose = true) {
  870. return (this.count == 1 ? "a smaller macro" : this.count + " smaller macros");
  871. };
  872. }