big steppy
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

1187 lines
32 KiB

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