big steppy
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 

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