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.
 
 
 

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