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.
 
 
 

1089 line
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. if (!humanMode)
  344. species = random_desc(["wolf","cat","dog","squirrel","horse","hyena","fox","jackal","crux","sergal"]);
  345. else
  346. species = random_desc(["jogger","police officer","road worker","pastor","dog-walker","clerk","accountant","CEO","millionaire","mailman"]);
  347. return "a " + merge_desc([body,sex,species]);
  348. };
  349. this.describe = function(verbose=true) {
  350. if (verbose) {
  351. if (count <= 3) {
  352. var list = [];
  353. for (var i = 0; i < count; i++) {
  354. list.push(this.describeOne(this.count <= 2));
  355. }
  356. return merge_things(list);
  357. } else {
  358. return this.count + " people";
  359. }
  360. } else {
  361. return (this.count > 1 ? this.count + " people" : "a person");
  362. }
  363. };
  364. return this;
  365. }
  366. function Cow(count = 1) {
  367. this.name = "Cow";
  368. copy_defaults(this,new DefaultEntity());
  369. this.count = count;
  370. this.contents = {};
  371. this.describeOne = function (verbose=true) {
  372. var body = random_desc(["skinny","fat","tall","short","stocky","spindly"], (verbose ? 0.6 : 0));
  373. var sex = random_desc(["male", "female"], (verbose ? 1 : 0));
  374. return "a " + merge_desc([body,sex,"cow"]);
  375. };
  376. this.describe = function(verbose=true) {
  377. if (verbose) {
  378. if (count <= 3) {
  379. var list = [];
  380. for (var i = 0; i < count; i++) {
  381. list.push(this.describeOne(this.count <= 2));
  382. }
  383. return merge_things(list);
  384. } else {
  385. return this.count + " cattle";
  386. }
  387. } else {
  388. return (this.count > 1 ? this.count + " cattle" : "a cow");
  389. }
  390. };
  391. return this;
  392. }
  393. function EmptyCar(count = 1) {
  394. this.name = "Car";
  395. copy_defaults(this,new DefaultEntity());
  396. this.count = count;
  397. this.contents = {};
  398. this.describeOne = function(verbose=true) {
  399. var color = random_desc(["black","black","gray","gray","blue","red","tan","white","white"]);
  400. var adjective = random_desc(["rusty","brand-new"],0.3);
  401. var type = random_desc(["SUV","coupe","sedan","truck","van","convertible"]);
  402. return "a parked " + merge_desc([adjective,color,type]);
  403. };
  404. this.describe = function(verbose = true) {
  405. if (verbose) {
  406. if (this.count <= 3) {
  407. var list = [];
  408. for (var i = 0; i < this.count; i++) {
  409. list.push(this.describeOne());
  410. }
  411. return merge_things(list);
  412. } else {
  413. return this.count + " parked cars";
  414. }
  415. } else {
  416. return (this.count > 1 ? this.count + " parked cars" : "a parked car");
  417. }
  418. };
  419. }
  420. function Car(count = 1) {
  421. this.name = "Car";
  422. copy_defaults(this,new DefaultEntity());
  423. this.count = count;
  424. this.contents = {};
  425. this.addContent("Person", 1, 4, count);
  426. this.describeOne = function(verbose=true) {
  427. var color = random_desc(["black","black","gray","gray","blue","red","tan","white","white"], (verbose ? 1 : 0));
  428. var adjective = random_desc(["rusty","brand-new"], (verbose ? 0.3 : 0));
  429. var type = random_desc(["SUV","coupe","sedan","truck","van","convertible"]);
  430. return "a " + merge_desc([adjective,color,type]);
  431. };
  432. this.describe = function(verbose = true) {
  433. if (verbose) {
  434. if (this.count <= 3) {
  435. var list = [];
  436. for (var i = 0; i < this.count; i++) {
  437. list.push(this.describeOne(this.count < 2));
  438. }
  439. return merge_things(list) + " with " + describe_all(this.contents,verbose) + " inside";
  440. } else {
  441. return this.count + " cars with " + describe_all(this.contents,verbose) + " inside";
  442. }
  443. } else {
  444. return (this.count > 1 ? this.count + " cars" : "a car");
  445. }
  446. };
  447. }
  448. function Bus(count = 1) {
  449. this.name = "Bus";
  450. copy_defaults(this,new DefaultEntity());
  451. this.count = count;
  452. this.contents = {};
  453. this.addContent("Person",2,30,count);
  454. this.describeOne = function(verbose=true) {
  455. var adjective = random_desc(["rusty","brand-new"], (verbose ? 0.3 : 0));
  456. var color = random_desc(["black","tan","gray"], (verbose ? 1 : 0));
  457. var type = random_desc(["bus","double-decker bus","articulating bus"]);
  458. return "a " + merge_desc([adjective,color,type]);
  459. };
  460. this.describe = function(verbose = true) {
  461. if (verbose) {
  462. if (this.count <= 3) {
  463. var list = [];
  464. for (var i = 0; i < this.count; i++) {
  465. list.push(this.describeOne(this.count < 2));
  466. }
  467. return merge_things(list) + " with " + describe_all(this.contents,verbose) + " inside";
  468. } else {
  469. return this.count + " buses with " + describe_all(this.contents,verbose) + " inside";
  470. }
  471. } else {
  472. return (this.count > 1 ? this.count + " buses" : "a bus");
  473. }
  474. };
  475. }
  476. function Tram(count = 1) {
  477. this.name = "Tram";
  478. copy_defaults(this,new DefaultEntity());
  479. this.count = count;
  480. this.contents = {};
  481. this.addContent("Person",10,50,count);
  482. this.describeOne = function(verbose=true) {
  483. var adjective = random_desc(["rusty","weathered"], (verbose ? 0.3 : 0));
  484. var color = random_desc(["blue","brown","gray"], (verbose ? 1 : 0));
  485. var type = random_desc(["tram"]);
  486. return "a " + merge_desc([adjective,color,type]);
  487. };
  488. this.describe = function(verbose = true) {
  489. if (verbose) {
  490. if (this.count == 1) {
  491. var list = [];
  492. for (var i = 0; i < this.count; i++) {
  493. list.push(this.describeOne(verbose));
  494. }
  495. return merge_things(list) + " with " + describe_all(this.contents,verbose) + " inside";
  496. } else {
  497. return this.count + " trams with " + describe_all(this.contents,verbose) + " inside";
  498. }
  499. } else {
  500. return (this.count > 1 ? this.count + " trams" : "a tram");
  501. }
  502. };
  503. this.anal_vore = function() {
  504. return "You slide " + this.describe() + " up your tight ass";
  505. };
  506. }
  507. function Train(count = 1) {
  508. this.name = "Train";
  509. copy_defaults(this,new DefaultEntity());
  510. this.count = count;
  511. this.contents = {};
  512. this.addContent("Person", 1, 4, count);
  513. this.addContent("Train Car", 2, 10, count);
  514. this.describeOne = function(verbose=true) {
  515. var adjective = random_desc(["rusty","brand-new"], (verbose ? 0.3 : 0));
  516. var color = random_desc(["black","tan","gray"], (verbose ? 1 : 0));
  517. var type = random_desc(["train","passenger train","freight train"]);
  518. return "a " + merge_desc([adjective,color,type]);
  519. };
  520. this.describe = function(verbose = true) {
  521. if (verbose) {
  522. if (this.count == 1) {
  523. var list = [];
  524. for (var i = 0; i < this.count; i++) {
  525. list.push(this.describeOne(verbose));
  526. }
  527. return merge_things(list) + " with " + this.contents["Person"].describe(false) + " in the engine and " + this.contents["Train Car"].describe() + " attached";
  528. } else {
  529. return this.count + " trains with " + this.contents["Person"].describe(false) + " in the engine and " + this.contents["Train Car"].describe() + " attached";
  530. }
  531. } else {
  532. return (this.count > 1 ? this.count + " trains" : "a train");
  533. }
  534. };
  535. this.anal_vore = function() {
  536. 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");
  537. return "You snatch up " + this.describeOne() + " and stuff it into your pucker, moaning as " + cars;
  538. };
  539. }
  540. function TrainCar(count = 1) {
  541. this.name = "Train Car";
  542. copy_defaults(this,new DefaultEntity());
  543. this.count = count;
  544. this.contents = {};
  545. this.addContent("Person",10,40,count);
  546. this.describeOne = function(verbose=true) {
  547. var adjective = random_desc(["rusty","brand-new"], (verbose ? 0.3 : 0));
  548. var color = random_desc(["black","tan","gray"], (verbose ? 1 : 0));
  549. var type = random_desc(["train car","passenger train car","freight train car"]);
  550. return "a " + merge_desc([adjective,color,type]);
  551. };
  552. this.describe = function(verbose = true) {
  553. if (verbose) {
  554. return (this.count > 1 ? this.count + " train cars" : "a train car") + " with " + describe_all(this.contents) + " inside";
  555. } else {
  556. return (this.count > 1 ? this.count + " train cars" : "a train car");
  557. }
  558. };
  559. }
  560. function House(count = 1) {
  561. this.name = "House";
  562. copy_defaults(this,new DefaultEntity());
  563. this.count = count;
  564. this.contents = {};
  565. this.addContent("Person",0,8,count);
  566. this.addContent("Empty Car",0,2,count);
  567. this.describeOne = function(verbose=true) {
  568. var size = random_desc(["little","two-story","large"], (verbose ? 0.5 : 0));
  569. var color = random_desc(["blue","white","gray","tan","green"], (verbose ? 0.5 : 0));
  570. var name = random_desc(["house","house","house","house","house","trailer"], 1);
  571. return "a " + merge_desc([size,color,name]);
  572. };
  573. this.describe = function(verbose = true) {
  574. if (verbose) {
  575. if (this.count <= 3) {
  576. var list = [];
  577. for (var i = 0; i < this.count; i++) {
  578. list.push(this.describeOne(this.count < 2));
  579. }
  580. return merge_things(list) + " with " + describe_all(this.contents,verbose) + " inside";
  581. } else {
  582. return this.count + " homes with " + describe_all(this.contents,verbose) + " inside";
  583. }
  584. } else {
  585. return (this.count > 1 ? this.count + " houses" : "a house");
  586. }
  587. };
  588. }
  589. function Barn(count = 1) {
  590. this.name = "Barn";
  591. copy_defaults(this,new DefaultEntity());
  592. this.count = count;
  593. this.contents = {};
  594. this.addContent("Person",0,2,count);
  595. this.addContent("Cow",30,70,count);
  596. this.describeOne = function(verbose=true) {
  597. var size = random_desc(["little","big","large"], (verbose ? 0.5 : 0));
  598. var color = random_desc(["blue","white","gray","tan","green"], (verbose ? 0.5 : 0));
  599. var name = random_desc(["barn","barn","barn","barn","barn","farmhouse"], 1);
  600. return "a " + merge_desc([size,color,name]);
  601. };
  602. this.describe = function(verbose = true) {
  603. if (verbose) {
  604. if (this.count <= 3) {
  605. var list = [];
  606. for (var i = 0; i < this.count; i++) {
  607. list.push(this.describeOne(this.count < 2));
  608. }
  609. return merge_things(list) + " with " + describe_all(this.contents,verbose) + " inside";
  610. } else {
  611. return this.count + " barns with " + describe_all(this.contents,verbose) + " inside";
  612. }
  613. } else {
  614. return (this.count > 1 ? this.count + " barns" : "a barn");
  615. }
  616. };
  617. }
  618. function SmallSkyscraper(count = 1) {
  619. this.name = "Small Skyscraper";
  620. copy_defaults(this,new DefaultEntity());
  621. this.count = count;
  622. this.contents = {};
  623. this.addContent("Person",150,750,count);
  624. this.addContent("Empty Car",10,50,count);
  625. this.describeOne = function(verbose=true) {
  626. var color = random_desc(["blue","white","gray","tan","green"], (verbose ? 0.5 : 0));
  627. var name = random_desc(["skyscraper","office tower","office building"], 1);
  628. return "a " + merge_desc([color,name]);
  629. };
  630. this.describe = function(verbose = true) {
  631. if (verbose) {
  632. if (this.count <= 3) {
  633. var list = [];
  634. for (var i = 0; i < this.count; i++) {
  635. list.push(this.describeOne(this.count < 2));
  636. }
  637. return merge_things(list) + " with " + describe_all(this.contents,verbose) + " inside";
  638. } else {
  639. return this.count + " small skyscrapers with " + describe_all(this.contents,verbose) + " inside";
  640. }
  641. } else {
  642. return (this.count > 1 ? this.count + " small skyscrapers" : "a small skyscraper");
  643. }
  644. };
  645. }
  646. function LargeSkyscraper(count = 1) {
  647. this.name = "Large Skyscraper";
  648. copy_defaults(this,new DefaultEntity());
  649. this.count = count;
  650. this.contents = {};
  651. this.addContent("Person",500,1500,count);
  652. this.addContent("Empty Car",20,100,count);
  653. this.describeOne = function(verbose=true) {
  654. var color = random_desc(["blue","white","gray","tan","green"], (verbose ? 0.5 : 0));
  655. var name = random_desc(["skyscraper","office tower","office building"], 1);
  656. return "a " + merge_desc(["towering",color,name]);
  657. };
  658. this.describe = function(verbose = true) {
  659. if (verbose) {
  660. if (this.count <= 3) {
  661. var list = [];
  662. for (var i = 0; i < this.count; i++) {
  663. list.push(this.describeOne(this.count < 2));
  664. }
  665. return merge_things(list) + " with " + describe_all(this.contents,verbose) + " inside";
  666. } else {
  667. return this.count + " large skyscrapers with " + describe_all(this.contents,verbose) + " inside";
  668. }
  669. } else {
  670. return (this.count > 1 ? this.count + " large skyscrapers" : "a large skyscraper");
  671. }
  672. };
  673. }
  674. function ParkingGarage(count = 1) {
  675. this.name = "Parking Garage";
  676. copy_defaults(this,new DefaultEntity());
  677. this.count = count;
  678. this.contents = {};
  679. this.addContent("Person",10,200,count);
  680. this.addContent("Empty Car",100,300,count);
  681. this.addContent("Car",5,30,count);
  682. this.describeOne = function(verbose=true) {
  683. return "a parking garage";
  684. };
  685. this.describe = function(verbose = true) {
  686. if (verbose) {
  687. return (this.count == 1 ? "a parking garage" : this.count + " parking garages") + " with " + describe_all(this.contents, verbose) + " inside";
  688. } else {
  689. return (this.count == 1 ? "a parking garage" : this.count + " parking garages");
  690. }
  691. };
  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",10000,100000,count);
  699. this.addContent("House",5000,50000,count);
  700. this.addContent("Empty Car",200,800,count);
  701. this.addContent("Car",500,80000,count);
  702. this.addContent("Bus",5,25,count);
  703. this.addContent("Train",5,25,count);
  704. this.describe = function(verbose = true) {
  705. if (verbose) {
  706. return (this.count == 1 ? "a town" : this.count + " towns") + " with " + describe_all(this.contents, verbose) + " in " + (this.count == 1 ? "it" : "them");
  707. } else {
  708. return (this.count == 1 ? "a town" : this.count + " towns");
  709. }
  710. };
  711. }
  712. function City(count = 1) {
  713. this.name = "City";
  714. copy_defaults(this,new DefaultEntity());
  715. this.count = count;
  716. this.contents = {};
  717. this.addContent("Person",100000,1500000,count);
  718. this.addContent("House",20000,200000,count);
  719. this.addContent("Empty Car",10000,100000,count);
  720. this.addContent("Car",7500,125000,count);
  721. this.addContent("Bus",200,400,count);
  722. this.addContent("Train",10,50,count);
  723. this.addContent("Tram",25,100,count);
  724. this.addContent("Small Skyscraper",50,300,count);
  725. this.addContent("Large Skyscraper",10,75,count);
  726. this.addContent("Parking Garage",5,10,count);
  727. this.describe = function(verbose = true) {
  728. if (verbose) {
  729. return (this.count == 1 ? "a city" : this.count + " cities") + " with " + describe_all(this.contents, verbose) + " in " + (this.count == 1 ? "it" : "them");
  730. } else {
  731. return (this.count == 1 ? "a city" : this.count + " cities");
  732. }
  733. };
  734. }
  735. function Continent(count = 1) {
  736. this.name = "Continent";
  737. copy_defaults(this,new DefaultEntity());
  738. this.count = count;
  739. this.contents = {};
  740. this.addContent("Person",1000000,15000000,count);
  741. this.addContent("House",2500,10000,count);
  742. this.addContent("Car",25000,375000,count);
  743. this.addContent("Train",50,500,count);
  744. this.addContent("Town",500,1000,count);
  745. this.addContent("City",50,250,count);
  746. this.describe = function(verbose = true) {
  747. if (verbose) {
  748. return (this.count == 1 ? "a continent" : this.count + " continents") + " with " + describe_all(this.contents, verbose) + " on " + (this.count == 1 ? "it" : "them");
  749. } else {
  750. return (this.count == 1 ? "a continent" : this.count + " continents");
  751. }
  752. };
  753. }
  754. function Planet(count = 1) {
  755. this.name = "Planet";
  756. copy_defaults(this,new DefaultEntity());
  757. this.count = count;
  758. this.contents = {};
  759. this.addContent("Continent",4,9,count);
  760. this.describe = function(verbose = true) {
  761. if (verbose) {
  762. return (this.count == 1 ? "a planet" : this.count + " planets") + " with " + describe_all(this.contents, verbose) + " on " + (this.count == 1 ? "it" : "them");
  763. } else {
  764. return (this.count == 1 ? "a planet" : this.count + " planets");
  765. }
  766. };
  767. }
  768. function Star(count = 1) {
  769. this.name = "Star";
  770. copy_defaults(this,new DefaultEntity());
  771. this.count = count;
  772. this.contents = {};
  773. this.describe = function(verbose = true) {
  774. return (this.count == 1 ? "a star" : this.count + " stars");
  775. };
  776. }
  777. function SolarSystem(count = 1) {
  778. this.name = "Solar System";
  779. copy_defaults(this,new DefaultEntity());
  780. this.count = count;
  781. this.contents = {};
  782. this.addContent("Star",1,1,count);
  783. this.addContent("Planet",5,15,count);
  784. this.describe = function(verbose = true) {
  785. if (verbose) {
  786. return (this.count == 1 ? "a solar system" : this.count + " solar systems") + " made up of " + describe_all(this.contents, verbose);
  787. } else {
  788. return (this.count == 1 ? "a solar system" : this.count + " solar systems");
  789. }
  790. };
  791. }
  792. function Galaxy(count = 1) {
  793. this.name = "Galaxy";
  794. copy_defaults(this,new DefaultEntity());
  795. this.count = count;
  796. this.contents = {};
  797. this.addContent("Star",1e9,500e9,count);
  798. this.addContent("Solar System",1e8,500e8,count);
  799. this.describe = function(verbose = true) {
  800. if (verbose) {
  801. return (this.count == 1 ? "a galaxy" : this.count + " galaxies") + " made up of " + describe_all(this.contents, verbose);
  802. } else {
  803. return (this.count == 1 ? "a galaxy" : this.count + " galaxies");
  804. }
  805. };
  806. }
  807. function Soldier(count = 1) {
  808. this.name = "Soldier";
  809. copy_defaults(this,new DefaultEntity());
  810. this.count = count;
  811. this.contents = {};
  812. this.describe = function(verbose = true) {
  813. return (this.count == 1 ? "a soldier" : this.count + " soldiers");
  814. };
  815. }
  816. function Tank(count = 1) {
  817. this.name = "Tank";
  818. copy_defaults(this,new DefaultEntity());
  819. this.count = count;
  820. this.contents = {};
  821. this.addContent("Soldier",3,5,count);
  822. this.describe = function(verbose = true) {
  823. if (verbose) {
  824. return (this.count == 1 ? "a tank" : this.count + " tanks") + " with " + describe_all(this.contents, verbose) + " trapped inside.";
  825. } else {
  826. return (this.count == 1 ? "a tank" : this.count + " tanks");
  827. }
  828. };
  829. }
  830. function Artillery(count = 1) {
  831. this.name = "Artillery";
  832. copy_defaults(this,new DefaultEntity());
  833. this.count = count;
  834. this.contents = {};
  835. this.addContent("Soldier",4,6,count);
  836. this.describe = function(verbose = true) {
  837. if (verbose) {
  838. return (this.count == 1 ? "an artillery unit" : this.count + " artillery units") + " with " + describe_all(this.contents, verbose) + " trapped inside.";
  839. } else {
  840. return (this.count == 1 ? "an artillery unit" : this.count + " artillery units");
  841. }
  842. };
  843. }
  844. function Helicopter(count = 1) {
  845. this.name = "Helicopter";
  846. copy_defaults(this,new DefaultEntity());
  847. this.count = count;
  848. this.contents = {};
  849. this.addContent("Soldier",4,16,count);
  850. this.describe = function(verbose = true) {
  851. if (verbose) {
  852. return (this.count == 1 ? "a helicopter" : this.count + " helicopters") + " with " + describe_all(this.contents, verbose) + " riding inside.";
  853. } else {
  854. return (this.count == 1 ? "a helicopter" : this.count + " helicopters");
  855. }
  856. };
  857. }
  858. function Micro(count = 1) {
  859. this.name = "Micro";
  860. copy_defaults(this,new DefaultEntity());
  861. this.count = count;
  862. this.contents = {};
  863. this.describe = function(verbose = true) {
  864. return (this.count == 1 ? "a micro" : this.count + " micros");
  865. };
  866. }
  867. function Macro(count = 1) {
  868. this.name = "Macro";
  869. copy_defaults(this,new DefaultEntity());
  870. this.count = count;
  871. this.contents = {};
  872. this.describe = function(verbose = true) {
  873. return (this.count == 1 ? "a smaller macro" : this.count + " smaller macros");
  874. };
  875. }