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

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