big steppy
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 

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