big steppy
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 

1214 行
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. function get_living_prey(sum) {
  219. let total = 0;
  220. for (let key in sum) {
  221. if (sum.hasOwnProperty(key)) {
  222. if (key == "Micro" || key == "Macro" || key == "Person" || key == "Cow" || key == 'Soldier')
  223. total += sum[key];
  224. }
  225. }
  226. return total;
  227. }
  228. // general logic: each step fills in a fraction of the remaining space
  229. function fill_area(area, weights, variance=0.15)
  230. {
  231. area = area + Math.random() * variance * 2 * area - variance * area;
  232. var result = [];
  233. var candidates = [];
  234. for (var key in weights) {
  235. if (weights.hasOwnProperty(key)) {
  236. candidates.push({"name": key, "area": areas[key], "weight": weights[key]});
  237. }
  238. }
  239. candidates = candidates.sort(function (x,y) {
  240. return x.area - y.area;
  241. });
  242. while(candidates.length > 0) {
  243. var candidate = candidates.pop();
  244. if (candidate.area > area)
  245. continue;
  246. var max = Math.floor(area / candidate.area);
  247. var limit = Math.min(max, 100);
  248. var count = 0;
  249. var loopvar = limit;
  250. // for small amounts, actually do the randomness
  251. // the first few ones get a much better shot
  252. while (loopvar > 0) {
  253. if (loopvar <= clusters[candidate.name] && loopvar == 1)
  254. count += 1;
  255. else if (loopvar <= clusters[candidate.name]) {
  256. if (Math.random() < candidate.weight ? 1 : 0 || Math.random() < 0.75) {
  257. count += 1;
  258. }
  259. }
  260. else
  261. count += Math.random() < candidate.weight ? 1 : 0;
  262. --loopvar;
  263. }
  264. if (limit < max) {
  265. count += Math.round((max-limit) * candidate.weight);
  266. }
  267. area -= count * candidate.area;
  268. if (count > 0)
  269. result.push(new things[candidate.name](count));
  270. }
  271. return new Container(result);
  272. }
  273. // describes everything in the container
  274. function describe_all(contents,verbose=true,except=[]) {
  275. var things = [];
  276. for (var key in contents) {
  277. if (contents.hasOwnProperty(key) && !except.includes(key)) {
  278. things.push(contents[key].describe(verbose));
  279. }
  280. }
  281. return merge_things(things);
  282. }
  283. function random_desc(list, odds=1) {
  284. if (Math.random() < odds)
  285. return list[Math.floor(Math.random() * list.length)];
  286. else
  287. return "";
  288. }
  289. // combine strings into a list with proper grammar
  290. function merge_things(list,semicolons=false) {
  291. if (list.length == 0) {
  292. return "";
  293. } else if (list.length == 1) {
  294. return list[0];
  295. } else if (list.length == 2) {
  296. return list[0] + " and " + list[1];
  297. } else {
  298. var result = "";
  299. list.slice(0,list.length-1).forEach(function(term) {
  300. result += term + ", ";
  301. });
  302. result += "and " + list[list.length-1];
  303. return result;
  304. }
  305. }
  306. // combine the adjectives for something into a single string
  307. function merge_desc(list) {
  308. var result = "";
  309. list.forEach(function(term) {
  310. if (term != "")
  311. result += term + " ";
  312. });
  313. // knock off the last space
  314. if (result.length > 0) {
  315. result = result.substring(0, result.length - 1);
  316. }
  317. return result;
  318. }
  319. // maybe make this something that approximates a
  320. // normal distribution; doing this 15,000,000 times is bad...
  321. // solution: only a few are random lul
  322. // improvement: take up to 100 samples, then use that to scale the final result
  323. function distribution(min, max, samples) {
  324. var result = 0;
  325. var limit = Math.min(100,samples);
  326. if (limit < samples) {
  327. let dist = 0;
  328. for (let i = 0; i < limit; i++) {
  329. dist += Math.random();
  330. }
  331. dist /= 100;
  332. return Math.floor(dist * samples * (max - min + 1) + samples * min);
  333. } else {
  334. for (let i = 0; i < limit; i++) {
  335. result += Math.floor(Math.random() * (max - min + 1) + min);
  336. }
  337. }
  338. return result;
  339. }
  340. function defaultMultiply(thing) {
  341. return function(amount) {
  342. thing.count *= amount;
  343. for (var key in thing.contents) {
  344. if (thing.contents.hasOwnProperty(key)) {
  345. thing.contents[key].multiply(amount);
  346. }
  347. }
  348. };
  349. }
  350. function defaultArea(thing) {
  351. return areas[thing.name];
  352. }
  353. function defaultMass(thing) {
  354. return masses[thing.name];
  355. }
  356. function defaultMerge(thing) {
  357. return function(container) {
  358. var newCount = this.count + container.count;
  359. var newThing = new things[thing.name](newCount);
  360. newThing.contents = {};
  361. for (var key in this.contents) {
  362. if (this.contents.hasOwnProperty(key)) {
  363. newThing.contents[key] = this.contents[key];
  364. }
  365. }
  366. for (key in container.contents) {
  367. if (container.contents.hasOwnProperty(key)) {
  368. if (this.contents.hasOwnProperty(key)) {
  369. newThing.contents[key] = this.contents[key].merge(container.contents[key]);
  370. } else {
  371. newThing.contents[key] = container.contents[key];
  372. }
  373. }
  374. }
  375. return newThing;
  376. };
  377. }
  378. function listSum(sum) {
  379. let result = [];
  380. for (let key in sum) {
  381. if (sum.hasOwnProperty(key)) {
  382. result.push(new things[key](sum[key]).describe(false));
  383. }
  384. }
  385. return merge_things(result);
  386. }
  387. function defaultSum(thing) {
  388. return function() {
  389. var counts = {};
  390. if (thing.name != "Container")
  391. counts[thing.name] = thing.count;
  392. for (var key in thing.contents) {
  393. if (thing.contents.hasOwnProperty(key)) {
  394. var subcount = thing.contents[key].sum();
  395. for (var subkey in subcount) {
  396. if (!counts.hasOwnProperty(subkey)) {
  397. counts[subkey] = 0;
  398. }
  399. counts[subkey] += subcount[subkey];
  400. }
  401. }
  402. }
  403. return counts;
  404. };
  405. }
  406. function defaultSumProperty(thing) {
  407. return function(prop) {
  408. var total = 0;
  409. total += thing[prop] * thing.count;
  410. for (var key in thing.contents) {
  411. if (thing.contents.hasOwnProperty(key)) {
  412. total += thing.contents[key].sum_property(prop);
  413. }
  414. }
  415. return total;
  416. };
  417. }
  418. function defaultAddContent(thing) {
  419. return function(name, min, max, count) {
  420. if (min == max) {
  421. let object = new things[name](min*count);
  422. thing.contents[object.name] = object;
  423. } else {
  424. let object = new things[name](distribution(min, max, count));
  425. thing.contents[object.name] = object;
  426. }
  427. };
  428. }
  429. function DefaultEntity() {
  430. this.sum = defaultSum;
  431. this.area = defaultArea;
  432. this.mass = defaultMass;
  433. this.sum_property = defaultSumProperty;
  434. this.merge = defaultMerge;
  435. this.multiply = defaultMultiply;
  436. return this;
  437. }
  438. // god I love reinventing the wheel
  439. function copy_defaults(self,proto) {
  440. for (var key in proto) {
  441. if (proto.hasOwnProperty(key)) {
  442. self[key] = proto[key](self);
  443. }
  444. }
  445. }
  446. function Container(contents = []) {
  447. this.name = "Container";
  448. copy_defaults(this,new DefaultEntity());
  449. if (Number.isInteger(contents))
  450. this.count = contents;
  451. else
  452. this.count = 0;
  453. this.contents = {};
  454. for (var i=0; i < contents.length; i++) {
  455. this.contents[contents[i].name] = contents[i];
  456. }
  457. for (var key in this.contents) {
  458. if (this.contents.hasOwnProperty(key)) {
  459. this.count += this.contents[key].count;
  460. }
  461. }
  462. this.describe = function(verbose = true) {
  463. return describe_all(this.contents,verbose);
  464. };
  465. return this;
  466. }
  467. function Person(count = 1) {
  468. this.name = "Person";
  469. copy_defaults(this,new DefaultEntity());
  470. this.count = count;
  471. this.contents = initContents(this.name,this.count);
  472. this.describeOne = function (verbose=true) {
  473. var body = random_desc(["skinny","fat","tall","short","stocky","spindly"], (verbose ? 0.6 : 0));
  474. var sex = random_desc(["male", "female"], (verbose ? 1 : 0));
  475. var species = "";
  476. species = random_desc(["wolf","cat","dog","squirrel","horse","hyena","fox","jackal","crux","sergal"]);
  477. return "a " + merge_desc([body,sex,species]);
  478. };
  479. this.describe = function(verbose=true) {
  480. if (verbose) {
  481. if (count <= 3) {
  482. var list = [];
  483. for (var i = 0; i < count; i++) {
  484. list.push(this.describeOne(this.count <= 2));
  485. }
  486. return merge_things(list);
  487. } else {
  488. return this.count + " people";
  489. }
  490. } else {
  491. return (this.count > 1 ? this.count + " people" : "a person");
  492. }
  493. };
  494. return this;
  495. }
  496. function Human(count = 1) {
  497. this.name = "Person";
  498. copy_defaults(this,new DefaultEntity());
  499. this.count = count;
  500. this.contents = initContents(this.name,this.count);
  501. this.describeOne = function (verbose=true) {
  502. var body = random_desc(["skinny","fat","tall","short","stocky","spindly"], (verbose ? 0.6 : 0));
  503. var sex = random_desc(["man", "woman"], 1);
  504. return "a " + merge_desc([body,sex]);
  505. };
  506. this.describe = function(verbose=true) {
  507. if (verbose) {
  508. if (count <= 3) {
  509. var list = [];
  510. for (var i = 0; i < count; i++) {
  511. list.push(this.describeOne(this.count <= 2));
  512. }
  513. return merge_things(list);
  514. } else {
  515. return this.count + " people";
  516. }
  517. } else {
  518. return (this.count > 1 ? this.count + " people" : "a person");
  519. }
  520. };
  521. return this;
  522. }
  523. function Cow(count = 1) {
  524. this.name = "Cow";
  525. copy_defaults(this,new DefaultEntity());
  526. this.count = count;
  527. this.contents = initContents(this.name,this.count);
  528. this.describeOne = function (verbose=true) {
  529. var body = random_desc(["skinny","fat","tall","short","stocky","spindly"], (verbose ? 0.6 : 0));
  530. var sex = random_desc(["male", "female"], (verbose ? 1 : 0));
  531. return "a " + merge_desc([body,sex,"cow"]);
  532. };
  533. this.describe = function(verbose=true) {
  534. if (verbose) {
  535. if (count <= 3) {
  536. var list = [];
  537. for (var i = 0; i < count; i++) {
  538. list.push(this.describeOne(this.count <= 2));
  539. }
  540. return merge_things(list);
  541. } else {
  542. return this.count + " cattle";
  543. }
  544. } else {
  545. return (this.count > 1 ? this.count + " cattle" : "a cow");
  546. }
  547. };
  548. return this;
  549. }
  550. function EmptyCar(count = 1) {
  551. this.name = "Car";
  552. copy_defaults(this,new DefaultEntity());
  553. this.count = count;
  554. this.contents = initContents(this.name,this.count);
  555. this.describeOne = function(verbose=true) {
  556. var color = random_desc(["black","black","gray","gray","blue","red","tan","white","white"]);
  557. var adjective = random_desc(["rusty","brand-new"],0.3);
  558. var type = random_desc(["SUV","coupe","sedan","truck","van","convertible"]);
  559. return "a parked " + merge_desc([adjective,color,type]);
  560. };
  561. this.describe = function(verbose = true) {
  562. if (verbose) {
  563. if (this.count <= 3) {
  564. var list = [];
  565. for (var i = 0; i < this.count; i++) {
  566. list.push(this.describeOne());
  567. }
  568. return merge_things(list);
  569. } else {
  570. return this.count + " parked cars";
  571. }
  572. } else {
  573. return (this.count > 1 ? this.count + " parked cars" : "a parked car");
  574. }
  575. };
  576. }
  577. function Car(count = 1) {
  578. this.name = "Car";
  579. copy_defaults(this,new DefaultEntity());
  580. this.count = count;
  581. this.contents = initContents(this.name,this.count);
  582. this.describeOne = function(verbose=true) {
  583. var color = random_desc(["black","black","gray","gray","blue","red","tan","white","white"], (verbose ? 1 : 0));
  584. var adjective = random_desc(["rusty","brand-new"], (verbose ? 0.3 : 0));
  585. var type = random_desc(["SUV","coupe","sedan","truck","van","convertible"]);
  586. return "a " + merge_desc([adjective,color,type]);
  587. };
  588. this.describe = function(verbose = true) {
  589. if (verbose) {
  590. if (this.count <= 3) {
  591. var list = [];
  592. for (var i = 0; i < this.count; i++) {
  593. list.push(this.describeOne(this.count < 2));
  594. }
  595. return merge_things(list) + " with " + describe_all(this.contents,verbose) + " inside";
  596. } else {
  597. return this.count + " cars with " + describe_all(this.contents,verbose) + " inside";
  598. }
  599. } else {
  600. return (this.count > 1 ? this.count + " cars" : "a car");
  601. }
  602. };
  603. }
  604. function Bus(count = 1) {
  605. this.name = "Bus";
  606. copy_defaults(this,new DefaultEntity());
  607. this.count = count;
  608. this.contents = initContents(this.name,this.count);
  609. this.describeOne = function(verbose=true) {
  610. var adjective = random_desc(["rusty","brand-new"], (verbose ? 0.3 : 0));
  611. var color = random_desc(["black","tan","gray"], (verbose ? 1 : 0));
  612. var type = random_desc(["bus","double-decker bus","articulating bus"]);
  613. return "a " + merge_desc([adjective,color,type]);
  614. };
  615. this.describe = function(verbose = true) {
  616. if (verbose) {
  617. if (this.count <= 3) {
  618. var list = [];
  619. for (var i = 0; i < this.count; i++) {
  620. list.push(this.describeOne(this.count < 2));
  621. }
  622. return merge_things(list) + " with " + describe_all(this.contents,verbose) + " inside";
  623. } else {
  624. return this.count + " buses with " + describe_all(this.contents,verbose) + " inside";
  625. }
  626. } else {
  627. return (this.count > 1 ? this.count + " buses" : "a bus");
  628. }
  629. };
  630. }
  631. function Tram(count = 1) {
  632. this.name = "Tram";
  633. copy_defaults(this,new DefaultEntity());
  634. this.count = count;
  635. this.contents = initContents(this.name,this.count);
  636. this.describeOne = function(verbose=true) {
  637. var adjective = random_desc(["rusty","weathered"], (verbose ? 0.3 : 0));
  638. var color = random_desc(["blue","brown","gray"], (verbose ? 1 : 0));
  639. var type = random_desc(["tram"]);
  640. return "a " + merge_desc([adjective,color,type]);
  641. };
  642. this.describe = function(verbose = true) {
  643. if (verbose) {
  644. if (this.count == 1) {
  645. var list = [];
  646. for (var i = 0; i < this.count; i++) {
  647. list.push(this.describeOne(verbose));
  648. }
  649. return merge_things(list) + " with " + describe_all(this.contents,verbose) + " inside";
  650. } else {
  651. return this.count + " trams with " + describe_all(this.contents,verbose) + " inside";
  652. }
  653. } else {
  654. return (this.count > 1 ? this.count + " trams" : "a tram");
  655. }
  656. };
  657. this.anal_vore = function() {
  658. return "You slide " + this.describe() + " up your tight ass";
  659. };
  660. }
  661. function Train(count = 1) {
  662. this.name = "Train";
  663. copy_defaults(this,new DefaultEntity());
  664. this.count = count;
  665. this.contents = initContents(this.name,this.count);
  666. this.describeOne = function(verbose=true) {
  667. var adjective = random_desc(["rusty","brand-new"], (verbose ? 0.3 : 0));
  668. var color = random_desc(["black","tan","gray"], (verbose ? 1 : 0));
  669. var type = random_desc(["train","passenger train","freight train"]);
  670. return "a " + merge_desc([adjective,color,type]);
  671. };
  672. this.describe = function(verbose = true) {
  673. if (verbose) {
  674. if (this.count == 1) {
  675. var list = [];
  676. for (var i = 0; i < this.count; i++) {
  677. list.push(this.describeOne(verbose));
  678. }
  679. return merge_things(list) + " with " + this.contents["engine"].describe(false) + " in the engine and " + this.contents["Train Car"].describe() + " attached";
  680. } else {
  681. return this.count + " trains with " + this.contents["engine"].describe(false) + " in the engine and " + this.contents["Train Car"].describe() + " attached";
  682. }
  683. } else {
  684. return (this.count > 1 ? this.count + " trains" : "a train");
  685. }
  686. };
  687. this.anal_vore = function() {
  688. 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");
  689. return "You snatch up " + this.describeOne() + " and stuff it into your pucker, moaning as " + cars;
  690. };
  691. }
  692. function TrainCar(count = 1) {
  693. this.name = "Train Car";
  694. copy_defaults(this,new DefaultEntity());
  695. this.count = count;
  696. this.contents = initContents(this.name,this.count);
  697. this.describeOne = function(verbose=true) {
  698. var adjective = random_desc(["rusty","brand-new"], (verbose ? 0.3 : 0));
  699. var color = random_desc(["black","tan","gray"], (verbose ? 1 : 0));
  700. var type = random_desc(["train car","passenger train car","freight train car"]);
  701. return "a " + merge_desc([adjective,color,type]);
  702. };
  703. this.describe = function(verbose = true) {
  704. if (verbose) {
  705. return (this.count > 1 ? this.count + " train cars" : "a train car") + " with " + describe_all(this.contents) + " inside";
  706. } else {
  707. return (this.count > 1 ? this.count + " train cars" : "a train car");
  708. }
  709. };
  710. }
  711. function House(count = 1) {
  712. this.name = "House";
  713. copy_defaults(this,new DefaultEntity());
  714. this.count = count;
  715. this.contents = initContents(this.name,this.count);
  716. this.describeOne = function(verbose=true) {
  717. var size = random_desc(["little","two-story","large"], (verbose ? 0.5 : 0));
  718. var color = random_desc(["blue","white","gray","tan","green"], (verbose ? 0.5 : 0));
  719. var name = random_desc(["house","house","house","house","house","trailer"], 1);
  720. return "a " + merge_desc([size,color,name]);
  721. };
  722. this.describe = function(verbose = true) {
  723. if (verbose) {
  724. if (this.count <= 3) {
  725. var list = [];
  726. for (var i = 0; i < this.count; i++) {
  727. list.push(this.describeOne(this.count < 2));
  728. }
  729. return merge_things(list) + " with " + describe_all(this.contents,verbose) + " inside";
  730. } else {
  731. return this.count + " homes with " + describe_all(this.contents,verbose) + " inside";
  732. }
  733. } else {
  734. return (this.count > 1 ? this.count + " houses" : "a house");
  735. }
  736. };
  737. }
  738. function Barn(count = 1) {
  739. this.name = "Barn";
  740. copy_defaults(this,new DefaultEntity());
  741. this.count = count;
  742. this.contents = initContents(this.name,this.count);
  743. this.describeOne = function(verbose=true) {
  744. var size = random_desc(["little","big","large"], (verbose ? 0.5 : 0));
  745. var color = random_desc(["blue","white","gray","tan","green"], (verbose ? 0.5 : 0));
  746. var name = random_desc(["barn","barn","barn","barn","barn","farmhouse"], 1);
  747. return "a " + merge_desc([size,color,name]);
  748. };
  749. this.describe = function(verbose = true) {
  750. if (verbose) {
  751. if (this.count <= 3) {
  752. var list = [];
  753. for (var i = 0; i < this.count; i++) {
  754. list.push(this.describeOne(this.count < 2));
  755. }
  756. return merge_things(list) + " with " + describe_all(this.contents,verbose) + " inside";
  757. } else {
  758. return this.count + " barns with " + describe_all(this.contents,verbose) + " inside";
  759. }
  760. } else {
  761. return (this.count > 1 ? this.count + " barns" : "a barn");
  762. }
  763. };
  764. }
  765. function SmallSkyscraper(count = 1) {
  766. this.name = "Small Skyscraper";
  767. copy_defaults(this,new DefaultEntity());
  768. this.count = count;
  769. this.contents = initContents(this.name,this.count);
  770. this.describeOne = function(verbose=true) {
  771. var color = random_desc(["blue","white","gray","tan","green"], (verbose ? 0.5 : 0));
  772. var name = random_desc(["skyscraper","office tower","office building"], 1);
  773. return "a " + merge_desc([color,name]);
  774. };
  775. this.describe = function(verbose = true) {
  776. if (verbose) {
  777. if (this.count <= 3) {
  778. var list = [];
  779. for (var i = 0; i < this.count; i++) {
  780. list.push(this.describeOne(this.count < 2));
  781. }
  782. return merge_things(list) + " with " + describe_all(this.contents,verbose) + " inside";
  783. } else {
  784. return this.count + " small skyscrapers with " + describe_all(this.contents,verbose) + " inside";
  785. }
  786. } else {
  787. return (this.count > 1 ? this.count + " small skyscrapers" : "a small skyscraper");
  788. }
  789. };
  790. }
  791. function LargeSkyscraper(count = 1) {
  792. this.name = "Large Skyscraper";
  793. copy_defaults(this,new DefaultEntity());
  794. this.count = count;
  795. this.contents = initContents(this.name,this.count);
  796. this.describeOne = function(verbose=true) {
  797. var color = random_desc(["blue","white","gray","tan","green"], (verbose ? 0.5 : 0));
  798. var name = random_desc(["skyscraper","office tower","office building"], 1);
  799. return "a " + merge_desc(["towering",color,name]);
  800. };
  801. this.describe = function(verbose = true) {
  802. if (verbose) {
  803. if (this.count <= 3) {
  804. var list = [];
  805. for (var i = 0; i < this.count; i++) {
  806. list.push(this.describeOne(this.count < 2));
  807. }
  808. return merge_things(list) + " with " + describe_all(this.contents,verbose) + " inside";
  809. } else {
  810. return this.count + " large skyscrapers with " + describe_all(this.contents,verbose) + " inside";
  811. }
  812. } else {
  813. return (this.count > 1 ? this.count + " large skyscrapers" : "a large skyscraper");
  814. }
  815. };
  816. }
  817. function ParkingGarage(count = 1) {
  818. this.name = "Parking Garage";
  819. copy_defaults(this,new DefaultEntity());
  820. this.count = count;
  821. this.contents = initContents(this.name,this.count);
  822. this.describeOne = function(verbose=true) {
  823. return "a parking garage";
  824. };
  825. this.describe = function(verbose = true) {
  826. if (verbose) {
  827. return (this.count == 1 ? "a parking garage" : this.count + " parking garages") + " with " + describe_all(this.contents, verbose) + " inside";
  828. } else {
  829. return (this.count == 1 ? "a parking garage" : this.count + " parking garages");
  830. }
  831. };
  832. }
  833. function Town(count = 1) {
  834. this.name = "Town";
  835. copy_defaults(this,new DefaultEntity());
  836. this.count = count;
  837. this.contents = initContents(this.name,this.count);
  838. this.describe = function(verbose = true) {
  839. if (verbose) {
  840. return (this.count == 1 ? "a town" : this.count + " towns") + " with " + describe_all(this.contents, verbose) + " in " + (this.count == 1 ? "it" : "them");
  841. } else {
  842. return (this.count == 1 ? "a town" : this.count + " towns");
  843. }
  844. };
  845. }
  846. function City(count = 1) {
  847. this.name = "City";
  848. copy_defaults(this,new DefaultEntity());
  849. this.count = count;
  850. this.contents = initContents(this.name,this.count);
  851. this.describe = function(verbose = true) {
  852. if (verbose) {
  853. return (this.count == 1 ? "a city" : this.count + " cities") + " with " + describe_all(this.contents, verbose) + " in " + (this.count == 1 ? "it" : "them");
  854. } else {
  855. return (this.count == 1 ? "a city" : this.count + " cities");
  856. }
  857. };
  858. }
  859. function Continent(count = 1) {
  860. this.name = "Continent";
  861. copy_defaults(this,new DefaultEntity());
  862. this.count = count;
  863. this.contents = initContents(this.name,this.count);
  864. this.describe = function(verbose = true) {
  865. if (verbose) {
  866. return (this.count == 1 ? "a continent" : this.count + " continents") + " with " + describe_all(this.contents, verbose) + " on " + (this.count == 1 ? "it" : "them");
  867. } else {
  868. return (this.count == 1 ? "a continent" : this.count + " continents");
  869. }
  870. };
  871. }
  872. function Planet(count = 1) {
  873. this.name = "Planet";
  874. copy_defaults(this,new DefaultEntity());
  875. this.count = count;
  876. this.contents = initContents(this.name,this.count);
  877. this.describe = function(verbose = true) {
  878. if (verbose) {
  879. return (this.count == 1 ? "a planet" : this.count + " planets") + " with " + describe_all(this.contents, verbose) + " on " + (this.count == 1 ? "it" : "them");
  880. } else {
  881. return (this.count == 1 ? "a planet" : this.count + " planets");
  882. }
  883. };
  884. }
  885. function Star(count = 1) {
  886. this.name = "Star";
  887. copy_defaults(this,new DefaultEntity());
  888. this.count = count;
  889. this.contents = initContents(this.name,this.count);
  890. this.describe = function(verbose = true) {
  891. return (this.count == 1 ? "a star" : this.count + " stars");
  892. };
  893. }
  894. function SolarSystem(count = 1) {
  895. this.name = "Solar System";
  896. copy_defaults(this,new DefaultEntity());
  897. this.count = count;
  898. this.contents = initContents(this.name,this.count);
  899. this.describe = function(verbose = true) {
  900. if (verbose) {
  901. return (this.count == 1 ? "a solar system" : this.count + " solar systems") + " made up of " + describe_all(this.contents, verbose);
  902. } else {
  903. return (this.count == 1 ? "a solar system" : this.count + " solar systems");
  904. }
  905. };
  906. }
  907. function Galaxy(count = 1) {
  908. this.name = "Galaxy";
  909. copy_defaults(this,new DefaultEntity());
  910. this.count = count;
  911. this.contents = initContents(this.name,this.count);
  912. this.describe = function(verbose = true) {
  913. if (verbose) {
  914. return (this.count == 1 ? "a galaxy" : this.count + " galaxies") + " made up of " + describe_all(this.contents, verbose);
  915. } else {
  916. return (this.count == 1 ? "a galaxy" : this.count + " galaxies");
  917. }
  918. };
  919. }
  920. function Cluster(count = 1) {
  921. this.name = "Cluster";
  922. copy_defaults(this,new DefaultEntity());
  923. this.count = count;
  924. this.contents = initContents(this.name,this.count);
  925. this.describe = function(verbose = true) {
  926. if (verbose) {
  927. return (this.count == 1 ? "a cluster" : this.count + " clusters") + " made up of " + describe_all(this.contents, verbose);
  928. } else {
  929. return (this.count == 1 ? "a cluster" : this.count + " clusters");
  930. }
  931. };
  932. }
  933. function Universe(count = 1) {
  934. this.name = "Universe";
  935. copy_defaults(this,new DefaultEntity());
  936. this.count = count;
  937. this.contents = initContents(this.name,this.count);
  938. this.describe = function(verbose = true) {
  939. if (verbose) {
  940. return (this.count == 1 ? "a universe" : this.count + " universes") + " made up of " + describe_all(this.contents, verbose);
  941. } else {
  942. return (this.count == 1 ? "a universe" : this.count + " universes");
  943. }
  944. };
  945. }
  946. function Multiverse(count = 1) {
  947. this.name = "Multiverse";
  948. copy_defaults(this,new DefaultEntity());
  949. this.count = count;
  950. this.contents = initContents(this.name,this.count);
  951. this.describe = function(verbose = true) {
  952. if (verbose) {
  953. return (this.count == 1 ? "a multiverse" : this.count + " multiverses") + " made up of " + describe_all(this.contents, verbose);
  954. } else {
  955. return (this.count == 1 ? "a multiverse" : this.count + " multiverses");
  956. }
  957. };
  958. }
  959. function Soldier(count = 1) {
  960. this.name = "Soldier";
  961. copy_defaults(this,new DefaultEntity());
  962. this.count = count;
  963. this.contents = initContents(this.name,this.count);
  964. this.describe = function(verbose = true) {
  965. return (this.count == 1 ? "a soldier" : this.count + " soldiers");
  966. };
  967. }
  968. function Tank(count = 1) {
  969. this.name = "Tank";
  970. copy_defaults(this,new DefaultEntity());
  971. this.count = count;
  972. this.contents = initContents(this.name,this.count);
  973. this.describe = function(verbose = true) {
  974. if (verbose) {
  975. return (this.count == 1 ? "a tank" : this.count + " tanks") + " with " + describe_all(this.contents, verbose) + " trapped inside.";
  976. } else {
  977. return (this.count == 1 ? "a tank" : this.count + " tanks");
  978. }
  979. };
  980. }
  981. function Artillery(count = 1) {
  982. this.name = "Artillery";
  983. copy_defaults(this,new DefaultEntity());
  984. this.count = count;
  985. this.contents = initContents(this.name,this.count);
  986. this.describe = function(verbose = true) {
  987. if (verbose) {
  988. return (this.count == 1 ? "an artillery unit" : this.count + " artillery units") + " with " + describe_all(this.contents, verbose) + " trapped inside.";
  989. } else {
  990. return (this.count == 1 ? "an artillery unit" : this.count + " artillery units");
  991. }
  992. };
  993. }
  994. function Helicopter(count = 1) {
  995. this.name = "Helicopter";
  996. copy_defaults(this,new DefaultEntity());
  997. this.count = count;
  998. this.contents = initContents(this.name,this.count);
  999. this.describe = function(verbose = true) {
  1000. if (verbose) {
  1001. return (this.count == 1 ? "a helicopter" : this.count + " helicopters") + " with " + describe_all(this.contents, verbose) + " riding inside.";
  1002. } else {
  1003. return (this.count == 1 ? "a helicopter" : this.count + " helicopters");
  1004. }
  1005. };
  1006. }
  1007. function Micro(count = 1) {
  1008. this.name = "Micro";
  1009. copy_defaults(this,new DefaultEntity());
  1010. this.count = count;
  1011. this.contents = initContents(this.name,this.count);
  1012. this.describe = function(verbose = true) {
  1013. return (this.count == 1 ? "a micro" : this.count + " micros");
  1014. };
  1015. }
  1016. function Macro(count = 1) {
  1017. this.name = "Macro";
  1018. copy_defaults(this,new DefaultEntity());
  1019. this.count = count;
  1020. this.contents = initContents(this.name,this.count);
  1021. this.describe = function(verbose = true) {
  1022. return (this.count == 1 ? "a smaller macro" : this.count + " smaller macros");
  1023. };
  1024. }