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.
 
 
 

1290 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 defaultDescribeSimple(thing) {
  484. return function(flat) {
  485. if (flat) {
  486. return flatten(thing).describe(false)
  487. } else {
  488. return thing.describe(false);
  489. }
  490. }
  491. }
  492. function DefaultEntity() {
  493. this.sum = defaultSum;
  494. this.area = defaultArea;
  495. this.mass = defaultMass;
  496. this.sum_property = defaultSumProperty;
  497. this.merge = defaultMerge;
  498. this.multiply = defaultMultiply;
  499. this.describeSimple = defaultDescribeSimple;
  500. return this;
  501. }
  502. // god I love reinventing the wheel
  503. function copy_defaults(self,proto) {
  504. for (var key in proto) {
  505. if (proto.hasOwnProperty(key)) {
  506. self[key] = proto[key](self);
  507. }
  508. }
  509. }
  510. function Container(contents = []) {
  511. this.name = "Container";
  512. copy_defaults(this,new DefaultEntity());
  513. if (Number.isInteger(contents))
  514. this.count = contents;
  515. else
  516. this.count = 0;
  517. this.contents = {};
  518. for (var i=0; i < contents.length; i++) {
  519. this.contents[contents[i].name] = contents[i];
  520. }
  521. for (var key in this.contents) {
  522. if (this.contents.hasOwnProperty(key)) {
  523. this.count += this.contents[key].count;
  524. }
  525. }
  526. this.describe = function(verbose = true) {
  527. return describe_all(this.contents,verbose);
  528. };
  529. return this;
  530. }
  531. function Person(count = 1) {
  532. this.name = "Person";
  533. copy_defaults(this,new DefaultEntity());
  534. this.count = count;
  535. this.contents = initContents(this.name,this.count);
  536. this.describeOne = function (verbose=true) {
  537. var body = random_desc(["skinny","fat","tall","short","stocky","spindly"], (verbose ? 0.6 : 0));
  538. var sex = random_desc(["male", "female"], (verbose ? 1 : 0));
  539. var species = "";
  540. species = random_desc(["wolf","cat","dog","squirrel","horse","hyena","fox","jackal","crux","sergal"]);
  541. return "a " + merge_desc([body,sex,species]);
  542. };
  543. this.describe = function(verbose=true) {
  544. if (verbose) {
  545. if (count <= 3) {
  546. var list = [];
  547. for (var i = 0; i < count; i++) {
  548. list.push(this.describeOne(this.count <= 2));
  549. }
  550. return merge_things(list);
  551. } else {
  552. return this.count + " people";
  553. }
  554. } else {
  555. return (this.count > 1 ? this.count + " people" : "a person");
  556. }
  557. };
  558. return this;
  559. }
  560. function Human(count = 1) {
  561. this.name = "Person";
  562. copy_defaults(this,new DefaultEntity());
  563. this.count = count;
  564. this.contents = initContents(this.name,this.count);
  565. this.describeOne = function (verbose=true) {
  566. var body = random_desc(["skinny","fat","tall","short","stocky","spindly"], (verbose ? 0.6 : 0));
  567. var sex = random_desc(["man", "woman"], 1);
  568. return "a " + merge_desc([body,sex]);
  569. };
  570. this.describe = function(verbose=true) {
  571. if (verbose) {
  572. if (count <= 3) {
  573. var list = [];
  574. for (var i = 0; i < count; i++) {
  575. list.push(this.describeOne(this.count <= 2));
  576. }
  577. return merge_things(list);
  578. } else {
  579. return this.count + " people";
  580. }
  581. } else {
  582. return (this.count > 1 ? this.count + " people" : "a person");
  583. }
  584. };
  585. return this;
  586. }
  587. function Cow(count = 1) {
  588. this.name = "Cow";
  589. copy_defaults(this,new DefaultEntity());
  590. this.count = count;
  591. this.contents = initContents(this.name,this.count);
  592. this.describeOne = function (verbose=true) {
  593. var body = random_desc(["skinny","fat","tall","short","stocky","spindly"], (verbose ? 0.6 : 0));
  594. var sex = random_desc(["male", "female"], (verbose ? 1 : 0));
  595. return "a " + merge_desc([body,sex,"cow"]);
  596. };
  597. this.describe = function(verbose=true) {
  598. if (verbose) {
  599. if (count <= 3) {
  600. var list = [];
  601. for (var i = 0; i < count; i++) {
  602. list.push(this.describeOne(this.count <= 2));
  603. }
  604. return merge_things(list);
  605. } else {
  606. return this.count + " cattle";
  607. }
  608. } else {
  609. return (this.count > 1 ? this.count + " cattle" : "a cow");
  610. }
  611. };
  612. return this;
  613. }
  614. function EmptyCar(count = 1) {
  615. this.name = "Car";
  616. copy_defaults(this,new DefaultEntity());
  617. this.count = count;
  618. this.contents = initContents(this.name,this.count);
  619. this.describeOne = function(verbose=true) {
  620. var color = random_desc(["black","black","gray","gray","blue","red","tan","white","white"]);
  621. var adjective = random_desc(["rusty","brand-new"],0.3);
  622. var type = random_desc(["SUV","coupe","sedan","truck","van","convertible"]);
  623. return "a parked " + merge_desc([adjective,color,type]);
  624. };
  625. this.describe = function(verbose = true) {
  626. if (verbose) {
  627. if (this.count <= 3) {
  628. var list = [];
  629. for (var i = 0; i < this.count; i++) {
  630. list.push(this.describeOne());
  631. }
  632. return merge_things(list);
  633. } else {
  634. return this.count + " parked cars";
  635. }
  636. } else {
  637. return (this.count > 1 ? this.count + " parked cars" : "a parked car");
  638. }
  639. };
  640. }
  641. function Car(count = 1) {
  642. this.name = "Car";
  643. copy_defaults(this,new DefaultEntity());
  644. this.count = count;
  645. this.contents = initContents(this.name,this.count);
  646. this.describeOne = function(verbose=true) {
  647. var color = random_desc(["black","black","gray","gray","blue","red","tan","white","white"], (verbose ? 1 : 0));
  648. var adjective = random_desc(["rusty","brand-new"], (verbose ? 0.3 : 0));
  649. var type = random_desc(["SUV","coupe","sedan","truck","van","convertible"]);
  650. return "a " + merge_desc([adjective,color,type]);
  651. };
  652. this.describe = function(verbose = true) {
  653. if (verbose) {
  654. if (this.count <= 3) {
  655. var list = [];
  656. for (var i = 0; i < this.count; i++) {
  657. list.push(this.describeOne(this.count < 2));
  658. }
  659. return merge_things(list) + " with " + describe_all(this.contents,verbose) + " inside";
  660. } else {
  661. return this.count + " cars with " + describe_all(this.contents,verbose) + " inside";
  662. }
  663. } else {
  664. return (this.count > 1 ? this.count + " cars" : "a car");
  665. }
  666. };
  667. }
  668. function Bus(count = 1) {
  669. this.name = "Bus";
  670. copy_defaults(this,new DefaultEntity());
  671. this.count = count;
  672. this.contents = initContents(this.name,this.count);
  673. this.describeOne = function(verbose=true) {
  674. var adjective = random_desc(["rusty","brand-new"], (verbose ? 0.3 : 0));
  675. var color = random_desc(["black","tan","gray"], (verbose ? 1 : 0));
  676. var type = random_desc(["bus","double-decker bus","articulating bus"]);
  677. return "a " + merge_desc([adjective,color,type]);
  678. };
  679. this.describe = function(verbose = true) {
  680. if (verbose) {
  681. if (this.count <= 3) {
  682. var list = [];
  683. for (var i = 0; i < this.count; i++) {
  684. list.push(this.describeOne(this.count < 2));
  685. }
  686. return merge_things(list) + " with " + describe_all(this.contents,verbose) + " inside";
  687. } else {
  688. return this.count + " buses with " + describe_all(this.contents,verbose) + " inside";
  689. }
  690. } else {
  691. return (this.count > 1 ? this.count + " buses" : "a bus");
  692. }
  693. };
  694. }
  695. function Tram(count = 1) {
  696. this.name = "Tram";
  697. copy_defaults(this,new DefaultEntity());
  698. this.count = count;
  699. this.contents = initContents(this.name,this.count);
  700. this.describeOne = function(verbose=true) {
  701. var adjective = random_desc(["rusty","weathered"], (verbose ? 0.3 : 0));
  702. var color = random_desc(["blue","brown","gray"], (verbose ? 1 : 0));
  703. var type = random_desc(["tram"]);
  704. return "a " + merge_desc([adjective,color,type]);
  705. };
  706. this.describe = function(verbose = true) {
  707. if (verbose) {
  708. if (this.count == 1) {
  709. var list = [];
  710. for (var i = 0; i < this.count; i++) {
  711. list.push(this.describeOne(verbose));
  712. }
  713. return merge_things(list) + " with " + describe_all(this.contents,verbose) + " inside";
  714. } else {
  715. return this.count + " trams with " + describe_all(this.contents,verbose) + " inside";
  716. }
  717. } else {
  718. return (this.count > 1 ? this.count + " trams" : "a tram");
  719. }
  720. };
  721. this.anal_vore = function() {
  722. return "You slide " + this.describe() + " up your tight ass";
  723. };
  724. }
  725. function Train(count = 1) {
  726. this.name = "Train";
  727. copy_defaults(this,new DefaultEntity());
  728. this.count = count;
  729. this.contents = initContents(this.name,this.count);
  730. this.describeOne = function(verbose=true) {
  731. var adjective = random_desc(["rusty","brand-new"], (verbose ? 0.3 : 0));
  732. var color = random_desc(["black","tan","gray"], (verbose ? 1 : 0));
  733. var type = random_desc(["train","passenger train","freight train"]);
  734. return "a " + merge_desc([adjective,color,type]);
  735. };
  736. this.describe = function(verbose = true) {
  737. if (verbose) {
  738. if (this.count == 1) {
  739. var list = [];
  740. for (var i = 0; i < this.count; i++) {
  741. list.push(this.describeOne(verbose));
  742. }
  743. return merge_things(list) + " with " + this.contents["engine"].describe(false) + " in the engine and " + this.contents["Train Car"].describe() + " attached";
  744. } else {
  745. return this.count + " trains with " + this.contents["engine"].describe(false) + " in the engine and " + this.contents["Train Car"].describe() + " attached";
  746. }
  747. } else {
  748. return (this.count > 1 ? this.count + " trains" : "a train");
  749. }
  750. };
  751. this.anal_vore = function() {
  752. 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");
  753. return "You snatch up " + this.describeOne() + " and stuff it into your pucker, moaning as " + cars;
  754. };
  755. }
  756. function TrainCar(count = 1) {
  757. this.name = "Train Car";
  758. copy_defaults(this,new DefaultEntity());
  759. this.count = count;
  760. this.contents = initContents(this.name,this.count);
  761. this.describeOne = function(verbose=true) {
  762. var adjective = random_desc(["rusty","brand-new"], (verbose ? 0.3 : 0));
  763. var color = random_desc(["black","tan","gray"], (verbose ? 1 : 0));
  764. var type = random_desc(["train car","passenger train car","freight train car"]);
  765. return "a " + merge_desc([adjective,color,type]);
  766. };
  767. this.describe = function(verbose = true) {
  768. if (verbose) {
  769. return (this.count > 1 ? this.count + " train cars" : "a train car") + " with " + describe_all(this.contents) + " inside";
  770. } else {
  771. return (this.count > 1 ? this.count + " train cars" : "a train car");
  772. }
  773. };
  774. }
  775. function House(count = 1) {
  776. this.name = "House";
  777. copy_defaults(this,new DefaultEntity());
  778. this.count = count;
  779. this.contents = initContents(this.name,this.count);
  780. this.describeOne = function(verbose=true) {
  781. var size = random_desc(["little","two-story","large"], (verbose ? 0.5 : 0));
  782. var color = random_desc(["blue","white","gray","tan","green"], (verbose ? 0.5 : 0));
  783. var name = random_desc(["house","house","house","house","house","trailer"], 1);
  784. return "a " + merge_desc([size,color,name]);
  785. };
  786. this.describe = function(verbose = true) {
  787. if (verbose) {
  788. if (this.count <= 3) {
  789. var list = [];
  790. for (var i = 0; i < this.count; i++) {
  791. list.push(this.describeOne(this.count < 2));
  792. }
  793. return merge_things(list) + " with " + describe_all(this.contents,verbose) + " inside";
  794. } else {
  795. return this.count + " homes with " + describe_all(this.contents,verbose) + " inside";
  796. }
  797. } else {
  798. return (this.count > 1 ? this.count + " houses" : "a house");
  799. }
  800. };
  801. }
  802. function Barn(count = 1) {
  803. this.name = "Barn";
  804. copy_defaults(this,new DefaultEntity());
  805. this.count = count;
  806. this.contents = initContents(this.name,this.count);
  807. this.describeOne = function(verbose=true) {
  808. var size = random_desc(["little","big","large"], (verbose ? 0.5 : 0));
  809. var color = random_desc(["blue","white","gray","tan","green"], (verbose ? 0.5 : 0));
  810. var name = random_desc(["barn","barn","barn","barn","barn","farmhouse"], 1);
  811. return "a " + merge_desc([size,color,name]);
  812. };
  813. this.describe = function(verbose = true) {
  814. if (verbose) {
  815. if (this.count <= 3) {
  816. var list = [];
  817. for (var i = 0; i < this.count; i++) {
  818. list.push(this.describeOne(this.count < 2));
  819. }
  820. return merge_things(list) + " with " + describe_all(this.contents,verbose) + " inside";
  821. } else {
  822. return this.count + " barns with " + describe_all(this.contents,verbose) + " inside";
  823. }
  824. } else {
  825. return (this.count > 1 ? this.count + " barns" : "a barn");
  826. }
  827. };
  828. }
  829. function SmallSkyscraper(count = 1) {
  830. this.name = "Small Skyscraper";
  831. copy_defaults(this,new DefaultEntity());
  832. this.count = count;
  833. this.contents = initContents(this.name,this.count);
  834. this.describeOne = function(verbose=true) {
  835. var color = random_desc(["blue","white","gray","tan","green"], (verbose ? 0.5 : 0));
  836. var name = random_desc(["skyscraper","office tower","office building"], 1);
  837. return "a " + merge_desc([color,name]);
  838. };
  839. this.describe = function(verbose = true) {
  840. if (verbose) {
  841. if (this.count <= 3) {
  842. var list = [];
  843. for (var i = 0; i < this.count; i++) {
  844. list.push(this.describeOne(this.count < 2));
  845. }
  846. return merge_things(list) + " with " + describe_all(this.contents,verbose) + " inside";
  847. } else {
  848. return this.count + " small skyscrapers with " + describe_all(this.contents,verbose) + " inside";
  849. }
  850. } else {
  851. return (this.count > 1 ? this.count + " small skyscrapers" : "a small skyscraper");
  852. }
  853. };
  854. }
  855. function LargeSkyscraper(count = 1) {
  856. this.name = "Large Skyscraper";
  857. copy_defaults(this,new DefaultEntity());
  858. this.count = count;
  859. this.contents = initContents(this.name,this.count);
  860. this.describeOne = function(verbose=true) {
  861. var color = random_desc(["blue","white","gray","tan","green"], (verbose ? 0.5 : 0));
  862. var name = random_desc(["skyscraper","office tower","office building"], 1);
  863. return "a " + merge_desc(["towering",color,name]);
  864. };
  865. this.describe = function(verbose = true) {
  866. if (verbose) {
  867. if (this.count <= 3) {
  868. var list = [];
  869. for (var i = 0; i < this.count; i++) {
  870. list.push(this.describeOne(this.count < 2));
  871. }
  872. return merge_things(list) + " with " + describe_all(this.contents,verbose) + " inside";
  873. } else {
  874. return this.count + " large skyscrapers with " + describe_all(this.contents,verbose) + " inside";
  875. }
  876. } else {
  877. return (this.count > 1 ? this.count + " large skyscrapers" : "a large skyscraper");
  878. }
  879. };
  880. }
  881. function ParkingGarage(count = 1) {
  882. this.name = "Parking Garage";
  883. copy_defaults(this,new DefaultEntity());
  884. this.count = count;
  885. this.contents = initContents(this.name,this.count);
  886. this.describeOne = function(verbose=true) {
  887. return "a parking garage";
  888. };
  889. this.describe = function(verbose = true) {
  890. if (verbose) {
  891. return (this.count == 1 ? "a parking garage" : this.count + " parking garages") + " with " + describe_all(this.contents, verbose) + " inside";
  892. } else {
  893. return (this.count == 1 ? "a parking garage" : this.count + " parking garages");
  894. }
  895. };
  896. }
  897. function Town(count = 1) {
  898. this.name = "Town";
  899. copy_defaults(this,new DefaultEntity());
  900. this.count = count;
  901. this.contents = initContents(this.name,this.count);
  902. this.describe = function(verbose = true) {
  903. if (verbose) {
  904. return (this.count == 1 ? "a town" : this.count + " towns") + " with " + describe_all(this.contents, verbose) + " in " + (this.count == 1 ? "it" : "them");
  905. } else {
  906. return (this.count == 1 ? "a town" : this.count + " towns");
  907. }
  908. };
  909. }
  910. function City(count = 1) {
  911. this.name = "City";
  912. copy_defaults(this,new DefaultEntity());
  913. this.count = count;
  914. this.contents = initContents(this.name,this.count);
  915. this.describe = function(verbose = true) {
  916. if (verbose) {
  917. return (this.count == 1 ? "a city" : this.count + " cities") + " with " + describe_all(this.contents, verbose) + " in " + (this.count == 1 ? "it" : "them");
  918. } else {
  919. return (this.count == 1 ? "a city" : this.count + " cities");
  920. }
  921. };
  922. }
  923. function Continent(count = 1) {
  924. this.name = "Continent";
  925. copy_defaults(this,new DefaultEntity());
  926. this.count = count;
  927. this.contents = initContents(this.name,this.count);
  928. this.describe = function(verbose = true) {
  929. if (verbose) {
  930. return (this.count == 1 ? "a continent" : this.count + " continents") + " with " + describe_all(this.contents, verbose) + " on " + (this.count == 1 ? "it" : "them");
  931. } else {
  932. return (this.count == 1 ? "a continent" : this.count + " continents");
  933. }
  934. };
  935. }
  936. function Planet(count = 1) {
  937. this.name = "Planet";
  938. copy_defaults(this,new DefaultEntity());
  939. this.count = count;
  940. this.contents = initContents(this.name,this.count);
  941. this.describe = function(verbose = true) {
  942. if (verbose) {
  943. return (this.count == 1 ? "a planet" : this.count + " planets") + " with " + describe_all(this.contents, verbose) + " on " + (this.count == 1 ? "it" : "them");
  944. } else {
  945. return (this.count == 1 ? "a planet" : this.count + " planets");
  946. }
  947. };
  948. }
  949. function Star(count = 1) {
  950. this.name = "Star";
  951. copy_defaults(this,new DefaultEntity());
  952. this.count = count;
  953. this.contents = initContents(this.name,this.count);
  954. this.describe = function(verbose = true) {
  955. return (this.count == 1 ? "a star" : this.count + " stars");
  956. };
  957. }
  958. function SolarSystem(count = 1) {
  959. this.name = "Solar System";
  960. copy_defaults(this,new DefaultEntity());
  961. this.count = count;
  962. this.contents = initContents(this.name,this.count);
  963. this.describe = function(verbose = true) {
  964. if (verbose) {
  965. return (this.count == 1 ? "a solar system" : this.count + " solar systems") + " made up of " + describe_all(this.contents, verbose);
  966. } else {
  967. return (this.count == 1 ? "a solar system" : this.count + " solar systems");
  968. }
  969. };
  970. }
  971. function Galaxy(count = 1) {
  972. this.name = "Galaxy";
  973. copy_defaults(this,new DefaultEntity());
  974. this.count = count;
  975. this.contents = initContents(this.name,this.count);
  976. this.describe = function(verbose = true) {
  977. if (verbose) {
  978. return (this.count == 1 ? "a galaxy" : this.count + " galaxies") + " made up of " + describe_all(this.contents, verbose);
  979. } else {
  980. return (this.count == 1 ? "a galaxy" : this.count + " galaxies");
  981. }
  982. };
  983. }
  984. function Cluster(count = 1) {
  985. this.name = "Cluster";
  986. copy_defaults(this,new DefaultEntity());
  987. this.count = count;
  988. this.contents = initContents(this.name,this.count);
  989. this.describe = function(verbose = true) {
  990. if (verbose) {
  991. return (this.count == 1 ? "a cluster" : this.count + " clusters") + " made up of " + describe_all(this.contents, verbose);
  992. } else {
  993. return (this.count == 1 ? "a cluster" : this.count + " clusters");
  994. }
  995. };
  996. }
  997. function Universe(count = 1) {
  998. this.name = "Universe";
  999. copy_defaults(this,new DefaultEntity());
  1000. this.count = count;
  1001. this.contents = initContents(this.name,this.count);
  1002. this.describe = function(verbose = true) {
  1003. if (verbose) {
  1004. return (this.count == 1 ? "a universe" : this.count + " universes") + " made up of " + describe_all(this.contents, verbose);
  1005. } else {
  1006. return (this.count == 1 ? "a universe" : this.count + " universes");
  1007. }
  1008. };
  1009. }
  1010. function Multiverse(count = 1) {
  1011. this.name = "Multiverse";
  1012. copy_defaults(this,new DefaultEntity());
  1013. this.count = count;
  1014. this.contents = initContents(this.name,this.count);
  1015. this.describe = function(verbose = true) {
  1016. if (verbose) {
  1017. return (this.count == 1 ? "a multiverse" : this.count + " multiverses") + " made up of " + describe_all(this.contents, verbose);
  1018. } else {
  1019. return (this.count == 1 ? "a multiverse" : this.count + " multiverses");
  1020. }
  1021. };
  1022. }
  1023. function Soldier(count = 1) {
  1024. this.name = "Soldier";
  1025. copy_defaults(this,new DefaultEntity());
  1026. this.count = count;
  1027. this.contents = initContents(this.name,this.count);
  1028. this.describe = function(verbose = true) {
  1029. return (this.count == 1 ? "a soldier" : this.count + " soldiers");
  1030. };
  1031. }
  1032. function Tank(count = 1) {
  1033. this.name = "Tank";
  1034. copy_defaults(this,new DefaultEntity());
  1035. this.count = count;
  1036. this.contents = initContents(this.name,this.count);
  1037. this.describe = function(verbose = true) {
  1038. if (verbose) {
  1039. return (this.count == 1 ? "a tank" : this.count + " tanks") + " with " + describe_all(this.contents, verbose) + " trapped inside.";
  1040. } else {
  1041. return (this.count == 1 ? "a tank" : this.count + " tanks");
  1042. }
  1043. };
  1044. }
  1045. function Artillery(count = 1) {
  1046. this.name = "Artillery";
  1047. copy_defaults(this,new DefaultEntity());
  1048. this.count = count;
  1049. this.contents = initContents(this.name,this.count);
  1050. this.describe = function(verbose = true) {
  1051. if (verbose) {
  1052. return (this.count == 1 ? "an artillery unit" : this.count + " artillery units") + " with " + describe_all(this.contents, verbose) + " trapped inside.";
  1053. } else {
  1054. return (this.count == 1 ? "an artillery unit" : this.count + " artillery units");
  1055. }
  1056. };
  1057. }
  1058. function Helicopter(count = 1) {
  1059. this.name = "Helicopter";
  1060. copy_defaults(this,new DefaultEntity());
  1061. this.count = count;
  1062. this.contents = initContents(this.name,this.count);
  1063. this.describe = function(verbose = true) {
  1064. if (verbose) {
  1065. return (this.count == 1 ? "a helicopter" : this.count + " helicopters") + " with " + describe_all(this.contents, verbose) + " riding inside.";
  1066. } else {
  1067. return (this.count == 1 ? "a helicopter" : this.count + " helicopters");
  1068. }
  1069. };
  1070. }
  1071. function Micro(count = 1) {
  1072. this.name = "Micro";
  1073. copy_defaults(this,new DefaultEntity());
  1074. this.count = count;
  1075. this.contents = initContents(this.name,this.count);
  1076. this.describe = function(verbose = true) {
  1077. return (this.count == 1 ? "a micro" : this.count + " micros");
  1078. };
  1079. }
  1080. function Macro(count = 1) {
  1081. this.name = "Macro";
  1082. copy_defaults(this,new DefaultEntity());
  1083. this.count = count;
  1084. this.contents = initContents(this.name,this.count);
  1085. this.describe = function(verbose = true) {
  1086. return (this.count == 1 ? "a smaller macro" : this.count + " smaller macros");
  1087. };
  1088. }