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.
 
 
 

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